Skip to content

Commit

Permalink
Merge pull request #26 from vapor-community/2018-02-28
Browse files Browse the repository at this point in the history
2018 02 28
  • Loading branch information
Andrewangeta authored Mar 22, 2018
2 parents 40873d9 + 9a7b602 commit a4415c4
Show file tree
Hide file tree
Showing 45 changed files with 446 additions and 342 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let package = Package(
.library(name: "Stripe", targets: ["Stripe"])
],
dependencies: [
.package(url: "https://github.com/vapor/vapor.git", from: "3.0.0-beta"),
.package(url: "https://github.com/vapor/vapor.git", from: "3.0.0-rc"),
],
targets: [
.target(name: "Stripe", dependencies: ["Vapor"]),
Expand Down
44 changes: 36 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,53 @@ futureCharge.do({ (charge) in

And you can always check the documentation to see the required paramaters for specific API calls.

## Linux compatibility
Currently the project won't compile for linux.
You can track this issue [here](https://bugs.swift.org/browse/SR-7180) and [here](https://github.com/apple/swift-corelibs-foundation/pull/1347)

## Whats Implemented
* [x] Balance Fetching

### Core Resources
* [x] Balance
* [x] Charges
* [x] Customers
* [x] Coupons
* [x] Plans
* [x] Disputes
* [ ] Events
* [ ] File Uploads
* [ ] Payouts
* [x] Refunds
* [x] Tokens
---
### Payment Methods
* [x] Bank Accounts
* [x] Cards
* [x] Sources
---
### Subscriptions
* [x] Coupons
* [x] Discounts
* [x] Invoices
* [x] Invoice Items
* [x] Plans
* [x] Subscriptions
* [x] Connect account
* [x] Subscription items
---
### Connect
* [x] Account
* [ ] Application Fee Refunds
* [ ] Application Fees
* [ ] Country Specs
* [x] External Accounts
* [ ] Transfers
* [ ] Transfer Reversals
---
### Relay
* [x] Orders
* [x] Order Items
* [x] Products
* [x] Disputes
* [x] Invoices
* [x] Invoice Items
* [x] Returns
* [x] SKUs
* [x] Ephemeral Keys
* [] Events API

[stripe_home]: http://stripe.com "Stripe"
[stripe_api]: https://stripe.com/docs/api "Stripe API Endpoints"
Expand Down
14 changes: 7 additions & 7 deletions Sources/Stripe/API/Routes/AccountRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ public struct StripeConnectAccountRoutes: AccountRoutes {
metadata.forEach { body["metadata[\($0)]"] = $1 }
}

return try request.send(method: .post, path: StripeAPIEndpoint.account.endpoint, body: body.queryParameters)
return try request.send(method: .POST, path: StripeAPIEndpoint.account.endpoint, body: body.queryParameters)
}

/// Retrieve account details
/// [Learn More →](https://stripe.com/docs/api/curl#retrieve_account)
public func retrieve(account accountId: String) throws -> Future<StripeConnectAccount> {
return try request.send(method: .get, path: StripeAPIEndpoint.accounts(accountId).endpoint)
return try request.send(method: .GET, path: StripeAPIEndpoint.accounts(accountId).endpoint)
}

/// Update an account
Expand Down Expand Up @@ -161,20 +161,20 @@ public struct StripeConnectAccountRoutes: AccountRoutes {
try tos.toEncodedDictionary().forEach { body["tos_acceptance[\($0)]"] = $1 }
}

return try request.send(method: .post, path: StripeAPIEndpoint.accounts(accountId).endpoint, body: body.queryParameters)
return try request.send(method: .POST, path: StripeAPIEndpoint.accounts(accountId).endpoint, body: body.queryParameters)
}

/// Delete an account
/// [Learn More →](https://stripe.com/docs/api/curl#delete_account)
public func delete(account accountId: String) throws -> Future<StripeDeletedObject> {
return try request.send(method: .delete, path: StripeAPIEndpoint.accounts(accountId).endpoint)
return try request.send(method: .DELETE, path: StripeAPIEndpoint.accounts(accountId).endpoint)
}

/// Reject an account
/// [Learn More →](https://stripe.com/docs/api/curl#reject_account)
public func reject(account accountId: String, for rejectReason: AccountRejectReason) throws -> Future<StripeConnectAccount> {
let body = ["reason": rejectReason.rawValue].queryParameters
return try request.send(method: .post, path: StripeAPIEndpoint.accountsReject(accountId).endpoint, body: body)
return try request.send(method: .POST, path: StripeAPIEndpoint.accountsReject(accountId).endpoint, body: body)
}

/// List all connected accounts
Expand All @@ -184,12 +184,12 @@ public struct StripeConnectAccountRoutes: AccountRoutes {
if let filter = filter {
queryParams = filter.queryParameters
}
return try request.send(method: .get, path: StripeAPIEndpoint.account.endpoint, query: queryParams)
return try request.send(method: .GET, path: StripeAPIEndpoint.account.endpoint, query: queryParams)
}

/// Create a login link
/// [Learn More →](https://stripe.com/docs/api/curl#create_login_link)
public func createLoginLink(for accountId: String) throws -> Future<StripeConnectLoginLink> {
return try request.send(method: .post, path: StripeAPIEndpoint.accountsLoginLink(accountId).endpoint)
return try request.send(method: .POST, path: StripeAPIEndpoint.accountsLoginLink(accountId).endpoint)
}
}
6 changes: 3 additions & 3 deletions Sources/Stripe/API/Routes/BalanceRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public struct StripeBalanceRoutes: BalanceRoutes {
/// Retrieve balance
/// [Learn More →](https://stripe.com/docs/api/curl#retrieve_balance)
public func retrieve() throws -> Future<StripeBalance> {
return try request.send(method: .get, path: StripeAPIEndpoint.balance.endpoint)
return try request.send(method: .GET, path: StripeAPIEndpoint.balance.endpoint)
}

/// Retrieve a balance transaction
/// [Learn More →](https://stripe.com/docs/api/curl#balance_transaction_retrieve)
public func retrieve(forTransaction transactionId: String) throws -> Future<StripeBalanceTransactionItem> {
return try request.send(method: .get, path: StripeAPIEndpoint.balanceHistoryTransaction(transactionId).endpoint)
return try request.send(method: .GET, path: StripeAPIEndpoint.balanceHistoryTransaction(transactionId).endpoint)
}

/// List all balance history
Expand All @@ -44,6 +44,6 @@ public struct StripeBalanceRoutes: BalanceRoutes {
if let filter = filter {
queryParams = filter.queryParameters
}
return try request.send(method: .get, path: StripeAPIEndpoint.account.endpoint, query: queryParams)
return try request.send(method: .GET, path: StripeAPIEndpoint.account.endpoint, query: queryParams)
}
}
10 changes: 5 additions & 5 deletions Sources/Stripe/API/Routes/ChargeRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ public struct StripeChargeRoutes: ChargeRoutes {
body["statement_descriptor"] = statementDescriptor
}

return try request.send(method: .post, path: StripeAPIEndpoint.charges.endpoint, body: body.queryParameters)
return try request.send(method: .POST, path: StripeAPIEndpoint.charges.endpoint, body: body.queryParameters)
}

/// Retrieve a charge
/// [Learn More →](https://stripe.com/docs/api/curl#retrieve_charge)
public func retrieve(charge: String) throws -> Future<StripeCharge> {
return try request.send(method: .get, path: StripeAPIEndpoint.charge(charge).endpoint)
return try request.send(method: .GET, path: StripeAPIEndpoint.charge(charge).endpoint)
}

/// Update a charge
Expand Down Expand Up @@ -160,7 +160,7 @@ public struct StripeChargeRoutes: ChargeRoutes {
body["transfer_group"] = transferGroup
}

return try request.send(method: .post, path: StripeAPIEndpoint.charge(chargeId).endpoint, body: body.queryParameters)
return try request.send(method: .POST, path: StripeAPIEndpoint.charge(chargeId).endpoint, body: body.queryParameters)
}

/// Capture a charge
Expand Down Expand Up @@ -193,7 +193,7 @@ public struct StripeChargeRoutes: ChargeRoutes {
body["statement_descriptor"] = statementDescriptor
}

return try request.send(method: .post, path: StripeAPIEndpoint.captureCharge(charge).endpoint, body: body.queryParameters)
return try request.send(method: .POST, path: StripeAPIEndpoint.captureCharge(charge).endpoint, body: body.queryParameters)
}

/// List all charges
Expand All @@ -204,6 +204,6 @@ public struct StripeChargeRoutes: ChargeRoutes {
queryParams = filter.queryParameters
}

return try request.send(method: .get, path: StripeAPIEndpoint.account.endpoint, query: queryParams)
return try request.send(method: .GET, path: StripeAPIEndpoint.account.endpoint, query: queryParams)
}
}
10 changes: 5 additions & 5 deletions Sources/Stripe/API/Routes/CouponRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ public struct StripeCouponRoutes: CouponRoutes {
metadata.forEach { body["metadata[\($0)]"] = $1 }
}

return try request.send(method: .post, path: StripeAPIEndpoint.coupons.endpoint, body: body.queryParameters)
return try request.send(method: .POST, path: StripeAPIEndpoint.coupons.endpoint, body: body.queryParameters)
}

/// Retrieve coupon
/// [Learn More →](https://stripe.com/docs/api/curl#retrieve_coupon)
public func retrieve(coupon: String) throws -> Future<StripeCoupon> {
return try request.send(method: .get, path: StripeAPIEndpoint.coupon(coupon).endpoint)
return try request.send(method: .GET, path: StripeAPIEndpoint.coupon(coupon).endpoint)
}

/// Update coupon
Expand All @@ -89,13 +89,13 @@ public struct StripeCouponRoutes: CouponRoutes {
metadata.forEach { body["metadata[\($0)]"] = $1 }
}

return try request.send(method: .post, path: StripeAPIEndpoint.coupon(coupon).endpoint, body: body.queryParameters)
return try request.send(method: .POST, path: StripeAPIEndpoint.coupon(coupon).endpoint, body: body.queryParameters)
}

/// Delete coupon
/// [Learn More →](https://stripe.com/docs/api/curl#delete_coupon)
public func delete(coupon: String) throws -> Future<StripeDeletedObject> {
return try request.send(method: .delete, path: StripeAPIEndpoint.coupon(coupon).endpoint)
return try request.send(method: .DELETE, path: StripeAPIEndpoint.coupon(coupon).endpoint)
}

/// List all coupons
Expand All @@ -106,6 +106,6 @@ public struct StripeCouponRoutes: CouponRoutes {
queryParams = filter.queryParameters
}

return try request.send(method: .get, path: StripeAPIEndpoint.coupons.endpoint, query: queryParams)
return try request.send(method: .GET, path: StripeAPIEndpoint.coupons.endpoint, query: queryParams)
}
}
26 changes: 13 additions & 13 deletions Sources/Stripe/API/Routes/CustomerRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ public struct StripeCustomerRoutes: CustomerRoutes {
cardDictionarySource.forEach { body["source[\($0)]"] = $1 }
}

return try request.send(method: .post, path: StripeAPIEndpoint.customers.endpoint, body: body.queryParameters)
return try request.send(method: .POST, path: StripeAPIEndpoint.customers.endpoint, body: body.queryParameters)
}

/// Retrieve customer
/// [Learn More →](https://stripe.com/docs/api/curl#retrieve_customer)
public func retrieve(customer: String) throws -> Future<StripeCustomer> {
return try request.send(method: .get, path: StripeAPIEndpoint.customer(customer).endpoint)
return try request.send(method: .GET, path: StripeAPIEndpoint.customer(customer).endpoint)
}

/// Update customer
Expand Down Expand Up @@ -152,13 +152,13 @@ public struct StripeCustomerRoutes: CustomerRoutes {
cardDictionarySource.forEach { body["source[\($0)]"] = $1 }
}

return try request.send(method: .post, path: StripeAPIEndpoint.customer(customer).endpoint, body: body.queryParameters)
return try request.send(method: .POST, path: StripeAPIEndpoint.customer(customer).endpoint, body: body.queryParameters)
}

/// Delete a customer
/// [Learn More →](https://stripe.com/docs/api/curl#delete_customer)
public func delete(customer: String) throws -> Future<StripeDeletedObject> {
return try request.send(method: .delete, path: StripeAPIEndpoint.customer(customer).endpoint)
return try request.send(method: .DELETE, path: StripeAPIEndpoint.customer(customer).endpoint)
}

/// List all customers
Expand All @@ -169,7 +169,7 @@ public struct StripeCustomerRoutes: CustomerRoutes {
queryParams = filter.queryParameters
}

return try request.send(method: .get, path: StripeAPIEndpoint.customers.endpoint, query: queryParams)
return try request.send(method: .GET, path: StripeAPIEndpoint.customers.endpoint, query: queryParams)
}

/// Attach a source
Expand All @@ -179,10 +179,10 @@ public struct StripeCustomerRoutes: CustomerRoutes {
var headers: HTTPHeaders = [:]

if let connectedAccount = toConnectedAccount {
headers["Stripe-Account"] = connectedAccount
headers.add(name: .stripeAccount, value: connectedAccount)
}

return try request.send(method: .post, path: StripeAPIEndpoint.customerSources(customer).endpoint, body: body.queryParameters, headers: headers)
return try request.send(method: .POST, path: StripeAPIEndpoint.customerSources(customer).endpoint, body: body.queryParameters, headers: headers)
}

/// Create a bank account
Expand All @@ -192,7 +192,7 @@ public struct StripeCustomerRoutes: CustomerRoutes {
var headers: HTTPHeaders = [:]

if let connectedAccount = toConnectedAccount {
headers["Stripe-Account"] = connectedAccount
headers.add(name: .stripeAccount, value: connectedAccount)
}

if let source = source as? String {
Expand All @@ -207,7 +207,7 @@ public struct StripeCustomerRoutes: CustomerRoutes {
metadata.forEach { body["metadata[\($0)]"] = $1 }
}

return try request.send(method: .post, path: StripeAPIEndpoint.customerSources(customer).endpoint, body: body.queryParameters, headers: headers)
return try request.send(method: .POST, path: StripeAPIEndpoint.customerSources(customer).endpoint, body: body.queryParameters, headers: headers)
}

/// Create a card
Expand All @@ -217,7 +217,7 @@ public struct StripeCustomerRoutes: CustomerRoutes {
var headers: HTTPHeaders = [:]

if let connectedAccount = toConnectedAccount {
headers["Stripe-Account"] = connectedAccount
headers.add(name: .stripeAccount, value: connectedAccount)
}

if let source = source as? String {
Expand All @@ -232,18 +232,18 @@ public struct StripeCustomerRoutes: CustomerRoutes {
metadata.forEach { body["metadata[\($0)]"] = $1 }
}

return try request.send(method: .post, path: StripeAPIEndpoint.customerSources(customer).endpoint, body: body.queryParameters, headers: headers)
return try request.send(method: .POST, path: StripeAPIEndpoint.customerSources(customer).endpoint, body: body.queryParameters, headers: headers)
}

/// Detach a source
/// [Learn More →](https://stripe.com/docs/api/curl#detach_source)
public func deleteSource(customer: String, source: String) throws -> Future<StripeSource> {
return try request.send(method: .delete, path: StripeAPIEndpoint.customerDetachSources(customer, source).endpoint)
return try request.send(method: .DELETE, path: StripeAPIEndpoint.customerDetachSources(customer, source).endpoint)
}

/// Delete a customer discount
/// [Learn More →](https://stripe.com/docs/api/curl#delete_discount)
public func deleteDiscount(customer: String) throws -> Future<StripeDeletedObject> {
return try request.send(method: .delete, path: StripeAPIEndpoint.customerDiscount(customer).endpoint)
return try request.send(method: .DELETE, path: StripeAPIEndpoint.customerDiscount(customer).endpoint)
}
}
8 changes: 4 additions & 4 deletions Sources/Stripe/API/Routes/DisputeRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public struct StripeDisputeRoutes: DisputeRoutes {
/// Retrieve a dispute
/// [Learn More →](https://stripe.com/docs/api/curl#retrieve_dispute)
public func retrieve(dispute: String) throws -> Future<StripeDispute> {
return try request.send(method: .get, path: StripeAPIEndpoint.disputes(dispute).endpoint)
return try request.send(method: .GET, path: StripeAPIEndpoint.disputes(dispute).endpoint)
}

/// Update a dispute
Expand All @@ -49,13 +49,13 @@ public struct StripeDisputeRoutes: DisputeRoutes {
body["submit"] = submit
}

return try request.send(method: .post, path: StripeAPIEndpoint.disputes(dispute).endpoint, body: body.queryParameters)
return try request.send(method: .POST, path: StripeAPIEndpoint.disputes(dispute).endpoint, body: body.queryParameters)
}

/// Close a dispute
/// [Learn More →](https://stripe.com/docs/api/curl#close_dispute)
public func close(dispute: String) throws -> Future<StripeDispute> {
return try request.send(method: .post, path: StripeAPIEndpoint.closeDispute(dispute).endpoint)
return try request.send(method: .POST, path: StripeAPIEndpoint.closeDispute(dispute).endpoint)
}

/// List all disputes
Expand All @@ -66,6 +66,6 @@ public struct StripeDisputeRoutes: DisputeRoutes {
queryParams = filter.queryParameters
}

return try request.send(method: .get, path: StripeAPIEndpoint.dispute.endpoint, query: queryParams)
return try request.send(method: .GET, path: StripeAPIEndpoint.dispute.endpoint, query: queryParams)
}
}
4 changes: 2 additions & 2 deletions Sources/Stripe/API/Routes/EphemeralKeyRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public struct StripeEphemeralKeyRoutes: EphemeralKeyRoutes {

public func create(customer: String) throws -> Future<StripeEphemeralKey> {
let body = ["customer": customer]
return try request.send(method: .post, path: StripeAPIEndpoint.ephemeralKeys.endpoint, body: body.queryParameters)
return try request.send(method: .POST, path: StripeAPIEndpoint.ephemeralKeys.endpoint, body: body.queryParameters)
}

public func delete(ephemeralKey: String) throws -> Future<StripeEphemeralKey> {
return try request.send(method: .delete, path: StripeAPIEndpoint.ephemeralKey(ephemeralKey).endpoint)
return try request.send(method: .DELETE, path: StripeAPIEndpoint.ephemeralKey(ephemeralKey).endpoint)
}
}
Loading

0 comments on commit a4415c4

Please sign in to comment.