Skip to content

Commit

Permalink
Restore defaultForCurrency variable in the Card (#238)
Browse files Browse the repository at this point in the history
* Rollback defaultForCurrency variable in the Card

* Add subscription_details to Invoice

* Make SubscriptionDetails codable

* Add subscription_details to PaymentIntent

* Revert "Add subscription_details to PaymentIntent"

This reverts commit 745c48c.

* Add defaultForCurrency to the initializer

* Add subscriptionDetails to the initializer

* Add a public initializer for SubscriptionDetails

* Add a default nil param for SubscriptionDetails init
  • Loading branch information
Maxim-Inv authored Nov 3, 2023
1 parent 0f6728b commit 23bac40
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Sources/StripeKit/Billing/Invoices/Invoice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public struct Invoice: Codable {
public var status: InvoiceStatus?
/// The subscription that this invoice was prepared for, if any.
@Expandable<Subscription> public var subscription: String?
/// Details about the subscription that created this invoice.
public var subscriptionDetails: SubscriptionDetails?
/// Total after discount.
public var total: Int?
/// String representing the object’s type. Objects of the same type share the same value.
Expand Down Expand Up @@ -178,6 +180,7 @@ public struct Invoice: Codable {
periodStart: Date? = nil,
status: InvoiceStatus? = nil,
subscription: String? = nil,
subscriptionDetails: SubscriptionDetails? = nil,
total: Int? = nil,
object: String,
accountCountry: String? = nil,
Expand Down Expand Up @@ -254,6 +257,7 @@ public struct Invoice: Codable {
self.periodStart = periodStart
self.status = status
self._subscription = Expandable(id: subscription)
self.subscriptionDetails = subscriptionDetails
self.total = total
self.object = object
self.accountCountry = accountCountry
Expand Down Expand Up @@ -318,6 +322,15 @@ public struct Invoice: Codable {
}
}

public struct SubscriptionDetails: Codable {
/// Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
public var metadata: [String: String]?

public init(metadata: [String: String]? = nil) {
self.metadata = metadata
}
}

public enum InvoiceCollectionMethod: String, Codable {
case chargeAutomatically = "charge_automatically"
case sendInvoice = "send_invoice"
Expand Down
4 changes: 4 additions & 0 deletions Sources/StripeKit/Payment Methods/Cards/Card.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public struct Card: Codable {
@Expandable<Customer> public var customer: String?
/// If a CVC was provided, results of the check: `pass`, `fail`, `unavailable`, or `unchecked`.
public var cvcCheck: CardValidationCheck?
/// Whether this card is the default external account for its currency.
public var defaultForCurrency: Bool?
/// Two-digit number representing the card’s expiration month.
public var expMonth: Int?
/// Four-digit number representing the card’s expiration year.
Expand Down Expand Up @@ -87,6 +89,7 @@ public struct Card: Codable {
addressLine1Check: CardValidationCheck? = nil,
availablePayoutMethods: [String]? = nil,
currency: Currency? = nil,
defaultForCurrency: Bool? = nil,
dynamicLast4: String? = nil,
tokenizationMethod: CardTokenizedMethod? = nil,
wallet: CardWallet? = nil) {
Expand Down Expand Up @@ -114,6 +117,7 @@ public struct Card: Codable {
self.addressLine1Check = addressLine1Check
self.availablePayoutMethods = availablePayoutMethods
self.currency = currency
self.defaultForCurrency = defaultForCurrency
self.dynamicLast4 = dynamicLast4
self.tokenizationMethod = tokenizationMethod
self.wallet = wallet
Expand Down

0 comments on commit 23bac40

Please sign in to comment.