OPPCheckoutProvider

@interface OPPCheckoutProvider : NSObject

Abstract class for displaying an in-App payment page.

  • Factory method to generate an OPPCheckoutProvider used for displaying an in-App payment pages.

    Declaration

    Objective-C

    + (nullable instancetype)
        checkoutProviderWithPaymentProvider:(nonnull OPPPaymentProvider *)provider
                                 checkoutID:(nonnull NSString *)checkoutID
                                   settings:
                                       (nullable OPPCheckoutSettings *)settings;

    Parameters

    provider

    The OPPPaymentProvider which is used for performing the transaction once all the data from the user is collected.

    checkoutID

    The checkout Id of the transaction. Must be not nil or empty.

    settings

    The OPPCheckoutSettings used for these payment pages. These settings are provided to customize the appearance and functionality of the payment pages. If nil, default settings will be created.

    Return Value

    Returns an OPPCheckoutProvider for displaying in-App payment pages. Returns nil if provider or checkoutID are not set.

  • Designated initializer method to generate an OPPCheckoutProvider used for displaying an in-App payment pages.

    Declaration

    Objective-C

    - (nullable instancetype)
        initWithPaymentProvider:(nonnull OPPPaymentProvider *)provider
                     checkoutID:(nonnull NSString *)checkoutID
                       settings:(nullable OPPCheckoutSettings *)settings;

    Swift

    init?(paymentProvider provider: OPPPaymentProvider, checkoutID: String, settings: OPPCheckoutSettings?)

    Parameters

    provider

    The OPPPaymentProvider which is used for performing the transaction once all the data from the user is collected.

    checkoutID

    The checkout Id of the transaction. Must be not nil or empty.

    settings

    The OPPCheckoutSettings used for these payment pages. These settings are provided to customize the appearance and functionality of the payment pages. If nil, default settings will be created.

    Return Value

    Returns an OPPCheckoutProvider for displaying in-App payment pages. Returns nil if provider or checkoutID are not set.

  • Opens an in-App payment page for collecting user input and submitting a transaction. First the list of payment methods from the checkout settings will be displayed.

    Declaration

    Objective-C

    - (void)presentCheckoutForSubmittingTransactionCompletionHandler:
                (nonnull void (^)(OPPTransaction *_Nullable,
                                  NSError *_Nullable))completionHandler
                                                       cancelHandler:
                                                           (void (^_Nullable)(void))
                                                               cancelHandler;

    Swift

    func presentCheckout(forSubmittingTransactionCompletionHandler completionHandler: @escaping (OPPTransaction?, (any Error)?) -> Void, cancelHandler: (() -> Void)? = nil)

    Parameters

    completionHandler

    A block executed when the transaction is completed. You need to send the request to your server to get the transaction status.

    cancelHandler

    A block executed if the user closes the payment page prematurely.

  • Opens an in-App payment page for collecting user input and submitting a transaction. Payment form for the choosen payment method will be opened. If no user input is required in app (e.g. PayPal), shopper will be redirected directly to the issuer web page.

    Declaration

    Objective-C

    - (void)presentCheckoutWithPaymentBrand:(nonnull NSString *)paymentBrand
                             loadingHandler:(void (^_Nullable)(BOOL))loadingHandler
                          completionHandler:
                              (nonnull void (^)(OPPTransaction *_Nullable,
                                                NSError *_Nullable))
                                  completionHandler
                              cancelHandler:(void (^_Nullable)(void))cancelHandler;

    Swift

    func presentCheckout(withPaymentBrand paymentBrand: String, loadingHandler: ((Bool) -> Void)?, completionHandler: @escaping (OPPTransaction?, (any Error)?) -> Void, cancelHandler: (() -> Void)? = nil)

    Parameters

    paymentBrand

    The payment brand for transaction.

    loadingHandler

    A block executed whenever SDK sends request to the server or receives the response. You can start or stop loading animation based on inProgress parameter.

    completionHandler

    A block executed when the transaction is completed. You need to send the request to your server to get the transaction status.

    cancelHandler

    A block executed if the user closes the payment page prematurely.

  • Closes the in-App payment page. The delegate is not informed if this method is being called.

    Declaration

    Objective-C

    - (void)dismissCheckoutAnimated:(BOOL)animated
                         completion:(void (^_Nullable)(void))completion;

    Swift

    func dismissCheckout(animated: Bool) async

    Parameters

    animated

    Specifies whether the payment page should be dismissed using an animation or immediately without an animation.

    completion

    The completion handler, if provided, will be invoked after the checkout screen will be dismissed.

  • Requests checkout info and saves in shared checkout details.

    Declaration

    Objective-C

    + (void)cps_obtainCheckoutInfoCompletionHandler:
        (nonnull void (^)(NSError *_Nullable))completion;

    Swift

    class func cps_obtainCheckoutInfoCompletionHandler() async throws
  • Prepare and merge brands, load brands validations and image urls.

    Declaration

    Objective-C

    + (void)cps_initCheckoutWithCompletion:
        (nonnull void (^)(NSError *_Nullable))completion;

    Swift

    class func cps_initCheckout() async throws
  • Requests brand validations and saves in shared checkout details.

    Declaration

    Objective-C

    + (void)cps_initValidatorForPaymentBrands:
                (nonnull NSArray<OPPPaymentBrand> *)paymentBrands
                                   completion:(nonnull void (^)(NSError *_Nullable))
                                                  completion;

    Swift

    class func cps_initValidator(forPaymentBrands paymentBrands: [OPPPaymentBrand]) async throws
  • Requests urls for images and saves in shared image loader.

    Declaration

    Objective-C

    + (void)
        cps_initImageLoaderForPaymentBrands:
            (nonnull NSArray<OPPPaymentBrand> *)paymentBrands
                                   provider:(nonnull OPPPaymentProvider *)provider
                                 completion:(nonnull void (^)(NSError *_Nullable))
                                                completion;

    Swift

    class func cps_initImageLoader(forPaymentBrands paymentBrands: [OPPPaymentBrand], provider: OPPPaymentProvider) async throws
  • Tries to send transaction, transaction can be aborted in delegate. If current displaying view controller should be dissmissed after transaction submission, pass it in currentVC parameter, otherwise pass nil.

    Declaration

    Objective-C

    - (void)cps_trySendTransactionWithPaymentParams:
                (nonnull OPPPaymentParams *)paymentParams
                                   dismissCurrentVC:
                                       (nullable UIViewController<
                                           SFSafariViewControllerDelegate> *)
                                           currentVC;

    Swift

    func cps_trySendTransaction(with paymentParams: OPPPaymentParams, dismissCurrentVC currentVC: (any UIViewController & SFSafariViewControllerDelegate)?)
  • Sends transaction to Server without calling callbacks. If current displaying view controller should be dissmissed after transaction submission, pass it in currentVC parameter, otherwise pass nil.

    Declaration

    Objective-C

    - (void)cps_sendTransactionWithPaymentParams:
                (nonnull OPPPaymentParams *)paymentParams
                                dismissCurrentVC:
                                    (nullable UIViewController<
                                        SFSafariViewControllerDelegate> *)currentVC;

    Swift

    func cps_sendTransaction(with paymentParams: OPPPaymentParams, dismissCurrentVC currentVC: (any UIViewController & SFSafariViewControllerDelegate)?)
  • Creates payment params for payment brand which does not require custom UI to be presented

    Declaration

    Objective-C

    - (nonnull OPPPaymentParams *)
        cps_createPaymentParamsWithoutUiForPaymentBrand:
            (nonnull NSString *)paymentBrand
                                                  token:(nullable OPPToken *)token
                                                  error:(NSError *_Nullable
                                                             *_Nullable)error;

    Swift

    func cps_createPaymentParamsWithoutUi(forPaymentBrand paymentBrand: String, token: OPPToken?, error: NSErrorPointer) -> OPPPaymentParams
  • Updates payment params with provided checkout ID. Logs changes if checkout ID differs.

    Declaration

    Objective-C

    - (void)cps_updatePaymentParams:(nonnull OPPPaymentParams *)paymentParams
                         checkoutID:(nonnull NSString *)checkoutID;

    Swift

    func cps_update(_ paymentParams: OPPPaymentParams, checkoutID: String)
  • Creates a transaction with specified payment params. Applies checkoutInfo settings to update transaction.

    Declaration

    Objective-C

    - (nonnull OPPTransaction *)cps_prepareTransactionWithPaymentParams:
        (nonnull OPPPaymentParams *)paymentParams;

    Swift

    func cps_prepareTransaction(with paymentParams: OPPPaymentParams) -> OPPTransaction
  • Dismiss checkout view controller with completion.

    Declaration

    Objective-C

    + (void)cps_dismissViewController:(nullable UIViewController *)viewController
                           completion:(nonnull void (^)(void))completion;

    Swift

    class func cps_dismiss(_ viewController: UIViewController?) async
  • Returns details view controller for payment brand

    Declaration

    Objective-C

    - (nullable OPPRootViewController *)cpu_detailsViewControllerWithPaymentBrand:
        (nonnull NSString *)paymentBrand;

    Swift

    func cpu_detailsViewController(withPaymentBrand paymentBrand: String) -> OPPRootViewController?
  • Returns details view controller for payment brand with token if needed, otherwise nil

    Declaration

    Objective-C

    - (nullable OPPRootViewController *)
        cpu_detailsViewControllerWithPaymentBrand:(nonnull NSString *)paymentBrand
                                            token:(nullable OPPToken *)token;

    Swift

    func cpu_detailsViewController(withPaymentBrand paymentBrand: String, token: OPPToken?) -> OPPRootViewController?
  • Returns details view controller for payment brand with token and transaction if needed, otherwise nil

    Declaration

    Objective-C

    - (nullable OPPRootViewController *)
        cpu_detailsViewControllerWithPaymentBrand:(nonnull NSString *)paymentBrand
                                            token:(nullable OPPToken *)token
                                      transaction:
                                          (nullable OPPTransaction *)transaction;

    Swift

    func cpu_detailsViewController(withPaymentBrand paymentBrand: String, token: OPPToken?, transaction: OPPTransaction?) -> OPPRootViewController?
  • Returns NO if payment method selection screen should be skipped, otherwise NO

    Declaration

    Objective-C

    + (BOOL)cpu_shouldEnablePaymentMethodSelectionScreen;

    Swift

    class func cpu_shouldEnablePaymentMethodSelectionScreen() -> Bool