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
//class that generates the ephermal key | |
class StripeCustomerSessionManager: NSObject, STPEphemeralKeyProvider { | |
func createCustomerKey(withAPIVersion apiVersion: String, completion: @escaping STPJSONResponseCompletionBlock) { | |
let parameters = [ | |
"api_version": apiVersion | |
] | |
//this runs async, could this be causing an issue? i think the app crashes before it runs though |
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
//function that presents STPPaymentMethodsViewController | |
func handlePaymentMethodsButtonTapped() { | |
// Setup customer context | |
let customerKeyProvider = StripeCustomerSessionManager() | |
let customerContext = STPCustomerContext(keyProvider: customerKeyProvider) | |
// Setup payment methods view controller | |
let paymentMethodsViewController = STPPaymentMethodsViewController(configuration: STPPaymentConfiguration.shared(), theme: STPTheme.default(), customerContext: customerContext, delegate: self) | |
// Present payment methods view controller |