Skip to content

Commit

Permalink
Merge pull request #54 from vapor-community/bugfix
Browse files Browse the repository at this point in the history
Fix for nullable client secret. Although stripes documentation sugges…
  • Loading branch information
Andrewangeta authored Aug 9, 2018
2 parents c0465a0 + 1cc8bfa commit 038b0bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Sources/Stripe/Models/Sources/Source.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public struct StripeSource: StripeModel {
public var id: String
public var object: String
public var amount: Int?
public var clientSecret: String
public var clientSecret: String?
public var codeVerification: CodeVerification?
public var created: Date
public var currency: StripeCurrency?
Expand Down Expand Up @@ -50,7 +50,7 @@ public struct StripeSource: StripeModel {
id = try container.decode(String.self, forKey: .id)
object = try container.decode(String.self, forKey: .object)
amount = try container.decodeIfPresent(Int.self, forKey: .amount)
clientSecret = try container.decode(String.self, forKey: .clientSecret)
clientSecret = try container.decodeIfPresent(String.self, forKey: .clientSecret)
codeVerification = try container.decodeIfPresent(CodeVerification.self, forKey: .codeVerification)
created = try container.decode(Date.self, forKey: .created)
currency = try container.decodeIfPresent(StripeCurrency.self, forKey: .currency)
Expand Down
4 changes: 2 additions & 2 deletions Tests/StripeTests/SourceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SourceTests: XCTestCase {
"id": "src_1AhIN74iJb0CbkEwmbRYPsd4",
"object": "source",
"amount": 20,
"client_secret": "src_client_secret_sSPHZ17iQG6j9uKFdAYqPErO",
"client_secret": null,
"created": 1500471469,
"currency": "usd",
"flow": "redirect",
Expand Down Expand Up @@ -102,7 +102,7 @@ class SourceTests: XCTestCase {
XCTAssertEqual(source.id, "src_1AhIN74iJb0CbkEwmbRYPsd4")
XCTAssertEqual(source.object, "source")
XCTAssertEqual(source.amount, 20)
XCTAssertEqual(source.clientSecret, "src_client_secret_sSPHZ17iQG6j9uKFdAYqPErO")
XCTAssertEqual(source.clientSecret, nil)
XCTAssertEqual(source.created, Date(timeIntervalSince1970: 1500471469))
XCTAssertEqual(source.currency, .usd)
XCTAssertEqual(source.flow, Flow.redirect)
Expand Down

0 comments on commit 038b0bc

Please sign in to comment.