Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PAY-1900] [PAY-1898] Create Payment Source From Payment Sheet (#1733)
* successfully updating payment methods with new stripe payment sheet card. * added tests to everything except the view model * added tests for new card addition via payment sheet. * test name correction
- Loading branch information
Showing
16 changed files
with
334 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
KsApi/mutations/inputs/CreatePaymentSourceSetupIntentInput.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
public struct CreatePaymentSourceSetupIntentInput: GraphMutationInput { | ||
let intentClientSecret: String | ||
let reuseable: Bool | ||
|
||
public init(intentClientSecret: String, reuseable: Bool) { | ||
self.intentClientSecret = intentClientSecret | ||
self.reuseable = reuseable | ||
} | ||
|
||
public func toInputDictionary() -> [String: Any] { | ||
return [ | ||
"intentClientSecret": self.intentClientSecret, | ||
"reusable": self.reuseable | ||
] | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
KsApi/mutations/inputs/CreatePaymentSourceSetupIntentInputTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@testable import KsApi | ||
import Prelude | ||
import XCTest | ||
|
||
final class CreatePaymentSourceSetupIntentInputTests: XCTestCase { | ||
func testCreatePaymentSourceSetupIntentInputDictionary_WithValue_Success() { | ||
let createSetupIntentInput = | ||
CreatePaymentSourceSetupIntentInput(intentClientSecret: "UHJvamVjdC0yMzEyODc5ODc", reuseable: false) | ||
|
||
let input = createSetupIntentInput.toInputDictionary() | ||
|
||
XCTAssertEqual(input["intentClientSecret"] as? String, "UHJvamVjdC0yMzEyODc5ODc") | ||
XCTAssertEqual(input["reusable"] as? Bool, false) | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
Library/CreatePaymentSourceSetupIntentClientSecret+Constructor.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import KsApi | ||
|
||
extension CreatePaymentSourceSetupIntentInput { | ||
internal static func input( | ||
fromIntentClientSecret token: String, | ||
reuseable: Bool | ||
) -> CreatePaymentSourceSetupIntentInput { | ||
return CreatePaymentSourceSetupIntentInput(intentClientSecret: token, reuseable: reuseable) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Library/CreatePaymentSourceSetupIntentClientSecret+ConstructorTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@testable import KsApi | ||
@testable import Library | ||
import XCTest | ||
|
||
final class CreatePaymentSourceSetupIntentClientSecret_ConstructorTests: TestCase { | ||
func testCreatePaymentSourceSetupIntentInput_Reusable() { | ||
let input = CreatePaymentSourceSetupIntentInput.input(fromIntentClientSecret: "xyz", reuseable: true) | ||
|
||
XCTAssertEqual(input.intentClientSecret, "xyz") | ||
XCTAssertEqual(input.reuseable, true) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
@testable import Stripe | ||
|
||
extension STPPaymentMethod { | ||
static let visaStripePaymentMethod = STPPaymentMethod.decodedObject(fromAPIResponse: [ | ||
"id": "_randomID123", | ||
"card": [ | ||
"brand": "visa", | ||
"last4": "1234" | ||
], | ||
"type": "card" | ||
]) | ||
|
||
static let amexStripePaymentMethod = STPPaymentMethod.decodedObject(fromAPIResponse: [ | ||
"id": "_randomID123", | ||
"card": [ | ||
"brand": "amex", | ||
"last4": "1234" | ||
], | ||
"type": "card" | ||
]) | ||
|
||
static let sampleStringPaymentOption: (STPPaymentMethod) -> PaymentSheet.PaymentOption = { paymentMethod in | ||
PaymentSheet.PaymentOption.saved(paymentMethod: paymentMethod) | ||
} | ||
|
||
static let samplePaymentOptionsDisplayData: (PaymentSheet.PaymentOption) -> PaymentSheet.FlowController | ||
.PaymentOptionDisplayData = { paymentOption in | ||
PaymentSheet.FlowController.PaymentOptionDisplayData(paymentOption: paymentOption) | ||
} | ||
} |
Oops, something went wrong.