Skip to content

Commit

Permalink
Merge pull request #136 from vapor-community/clone-payment-method
Browse files Browse the repository at this point in the history
Added expand to cloning payment method.
  • Loading branch information
Andrewangeta authored Aug 27, 2021
2 parents 52af608 + c9c2551 commit ce9d91e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 13.2.0 - 2021-08-27
* [#136](https://github.com/vapor-community/stripe-kit/pull/136)
* Added expand parameter for cloning a payment method.

## 13.1.0 - 2021-08-17
* [#134](https://github.com/vapor-community/stripe-kit/pull/134)
* Added support for cloning a payment method.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ public protocol PaymentMethodRoutes {
/// - Parameters:
/// - paymentMethod: The id of the payment method to clone.
/// - customer: The id of trhe customer this payment method beelongs to. You must provide the Customer ID in the request when cloning PaymentMethods that are attached to Customers for security purposes
/// - expand: An array of properties to expand.
/// - Returns: A `StripePaymentMethod`.
func clone(paymentMethod: String, customer: String?) -> EventLoopFuture<StripePaymentMethod>
func clone(paymentMethod: String, customer: String?, expand: [String]?) -> EventLoopFuture<StripePaymentMethod>

/// Retrieves a PaymentMethod object.
///
Expand Down Expand Up @@ -169,8 +170,8 @@ extension PaymentMethodRoutes {
expand: expand)
}

public func clone(paymentMethod: String, customer: String? = nil) -> EventLoopFuture<StripePaymentMethod> {
clone(paymentMethod: paymentMethod, customer: customer)
public func clone(paymentMethod: String, customer: String? = nil, expand: [String]? = nil) -> EventLoopFuture<StripePaymentMethod> {
clone(paymentMethod: paymentMethod, customer: customer, expand: expand)
}

public func retrieve(paymentMethod: String, expand: [String]? = nil) -> EventLoopFuture<StripePaymentMethod> {
Expand Down Expand Up @@ -325,12 +326,16 @@ public struct StripePaymentMethodRoutes: PaymentMethodRoutes {
return apiHandler.send(method: .POST, path: paymentmethods, body: .string(body.queryParameters), headers: headers)
}

public func clone(paymentMethod: String, customer: String?) -> EventLoopFuture<StripePaymentMethod> {
public func clone(paymentMethod: String, customer: String?, expand: [String]?) -> EventLoopFuture<StripePaymentMethod> {
var body: [String: Any] = ["payment_method": paymentMethod]
if let customer = customer {
body["customer"] = customer
}

if let expand = expand {
body["expand"] = expand
}

return apiHandler.send(method: .POST, path: paymentmethods, body: .string(body.queryParameters), headers: headers)
}

Expand Down

0 comments on commit ce9d91e

Please sign in to comment.