Skip to content

Commit

Permalink
Merge pull request #31 from vapor-community/refund-fix
Browse files Browse the repository at this point in the history
Made the charge parameter optional for issuing a refund.
  • Loading branch information
Andrewangeta authored Feb 2, 2020
2 parents e9046e5 + e4fc9ff commit 4d38da4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Sources/StripeKit/Core Resources/Refunds/RefundRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public protocol RefundRoutes {
/// - refundApplicationFee: Boolean indicating whether the application fee should be refunded when refunding this charge. If a full charge refund is given, the full application fee will be refunded. Otherwise, the application fee will be refunded in an amount proportional to the amount of the charge refunded. /n An application fee can be refunded only by the application that created the charge.
/// - reverseTransfer: Boolean indicating whether the transfer should be reversed when refunding this charge. The transfer will be reversed proportionally to the amount being refunded (either the entire or partial amount). /n A transfer can be reversed only by the application that created the charge.
/// - Returns: A `StripeRefund`.
func create(charge: String,
func create(charge: String?,
amount: Int?,
metadata: [String: String]?,
paymentIntent: String?,
Expand Down Expand Up @@ -54,7 +54,7 @@ public protocol RefundRoutes {
}

extension RefundRoutes {
public func create(charge: String,
public func create(charge: String? = nil,
amount: Int? = nil,
metadata: [String: String]? = nil,
paymentIntent: String? = nil,
Expand Down Expand Up @@ -93,7 +93,7 @@ public struct StripeRefundRoutes: RefundRoutes {
self.apiHandler = apiHandler
}

public func create(charge: String,
public func create(charge: String?,
amount: Int?,
metadata: [String: String]?,
paymentIntent: String?,
Expand All @@ -102,7 +102,9 @@ public struct StripeRefundRoutes: RefundRoutes {
reverseTransfer: Bool?) -> EventLoopFuture<StripeRefund> {
var body: [String: Any] = [:]

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

if let amount = amount {
body["amount"] = amount
Expand Down

0 comments on commit 4d38da4

Please sign in to comment.