Skip to content

Instantly share code, notes, and snippets.

//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
//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