// 👇 Add thisimport PrimerSDK// 👇 Conform to PrimerDelegateclass MyViewController: UIViewController, PrimerDelegate { // ... // 👇 Add this func primerDidCompleteCheckoutWithData(_ data: PrimerCheckoutData) { // Do something with the payment's data }}
This method will be called with the when the payment method has been tokenized, returning the payment method’s tokenization data. Use the token to create a payment on your backend. Make sure that you call the decisionHandler once your operation has been completed.
⚠️ This method will be called only on the manual flow, or when vaulting.
// 👇 Add thisimport PrimerSDK// 👇 Conform to PrimerDelegateclass MyViewController: UIViewController, PrimerDelegate { // ... // 👇 Add this func primerDidTokenizePaymentMethod(_ paymentMethodTokenData: PrimerPaymentMethodTokenData, decisionHandler: @escaping (PrimerResumeDecision) -> Void) { // Create your payment createPayment(with: paymentMethodTokenData.token) { res, err in if let err = err { // 👇 Call the decisionHandler to show the error screen with your custom error message decisionHandler(.fail(withErrorMessage: "Oh no, something went wrong creating the payment...")) } else if let res = res { if let newClientToken = res.requiredAction?.clientToken { // 👇 Call the decisionHandler with the new client token to continue the flow decisionHandler(.continueWithNewClientToken(requiredAction.clientToken)) } else { // 👇 Call the decisionHandler to show the success screen decisionHandler(.succeed()) } } } }}
// 👇 Add thisimport PrimerSDK// 👇 Conform to PrimerDelegateclass MyViewController: UIViewController, PrimerDelegate { // ... // 👇 Add this func primerDidResumeWith(_ resumeToken: String, decisionHandler: @escaping (PrimerResumeDecision) -> Void) // Resume your payment resumePayment(with: resumeToken) { res, err in if let err = err { // 👇 Call the decisionHandler to show the error screen with your custom error message decisionHandler(.fail(withErrorMessage: "Oh no, something went wrong creating the payment...")) } else if let res = res { if let newClientToken = res.requiredAction?.clientToken { // 👇 Call the decisionHandler with the new client token to continue the flow decisionHandler(.continueWithNewClientToken(requiredAction.clientToken)) } else { // 👇 Call the decisionHandler to show the success screen decisionHandler(.succeed()) } } } }}
This method will be called to notify you that the client session will be updated, e.g.
a surcharge needs to be applied when a payment method has been chosen.
This method will be called to notify you that the client session has been updated, e.g.
surcharge has been applied when a payment method has been chosen.
This method will be called when an error occurs. It may return PrimerCheckoutData if the occurs after the payment creation.
Make sure you call the decisionHandler to finalize the flow.