Android Swift Objective-C

Integrated Checkout

The iOS & Android SDKs expose a simple drop-in Checkout interface with a robust configuration API for web and mobile web integrations.

Integrate

Open Checkout


public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        pl.api_key = "test_client_key_3bezxdVdCLpYP9yJ5odpg";

        Payload.checkout(new pl.Payment(){{
            set("amount", 10.0);
        }}).processed((pl.Payment pmt) -> {
            handleSuccess(pmt);
        }).error((Exception err) -> {
            handleError(err);
        });
    }
}
import UIKit
import PayloadAPI

class ViewController: UIViewController, PayloadPaymentDelegate {
    override func viewDidLoad() {
        super.viewDidLoad()
        Payload.api_key = "test_client_key_3bezxdVdCLpYP9yJ5odpg"

        Payload.Checkout(Payload.Payment([
            "amount": 10.0
        ]), delegate: self)
    }

}
#import <UIKit/UIKit.h>
#import <Payload/Payload-Swift.h>

@interface ViewController : UIViewController<PayloadPaymentDelegate>
@end
@interface ViewController ()
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.checkout = [[Checkout alloc] init:[[Payment alloc] init:@{
        @"amount": @10,
        @"processing_id": @"acct_3bfCMwa8OwUbYOvUQKTGi",
    }] delegate: self ];
}

@end

To open the Checkout UI, you must call Payload.Checkout with a Payload Payment object. The minimum required fields for the Payment object are amount and processing_id.

Once a payment request is submitted to beginTransaction, you can track the progress of a transaction by monitoring the payment events described below.

Watch for Events

You can wait for callback events from the Checkout plugin. The available events are processing, processed, declined, and error. For a detailed breakdown, see Processing Payments.


Close Checkout

public class MainActivity extends Activity {
    Payload.Checkout checkout;
    ...
    private void closeCheckout() {
        this.checkout.close()
    }
}
class ViewController: UIViewController, PayloadPaymentDelegate {
    Payload.Checkout checkout;
    ...
    func closeCheckout() {
        self.checkout.close()
    }
}
@interface ViewController ()
@property Checkout *checkout;
@end

@implementation ViewController

- (void)closeCheckout {
    [self.checkout close]
}

@end

By default, once a transaction has been processed the Checkout will dismiss automatically. The user can also dismiss the Checkout plugin.

The Checkout plugin can be dismissed programmatically using the 'close' method.


Theme

/* Android theme customization coming soon */

PayloadFormLabel.appearance().textColor = UIColor.blueColor();
PayloadCard.appearance().backgroundColor = UIColor.cyanColor();
PayloadCardContainer.appearance().backgroundColor = UIColor.lightGrayColor();
PayloadPayBtn.appearance().backgroundColor = UIColor.blueColor();
Class Name Description
PayloadFormLabel The labels above the inputs
PayloadTitle The title text on the Checkout view
PayloadCardContainer The card display container
PayloadCard The card display example
PayloadCardLabel The labels above the inputted text in the card display
PayloadCardTextField The inputted text in the card display
PayoadPayBtn The pay button at the bottom of the page

Processing Payments


Events

Processing

The processing event is triggered once the information has been keyed in and the payment request has been submitted to Payload for processing.

Processed

The processed event is triggered if the requested payment was approved and successfully processed.

Declined

The declined event is triggered if a payment attempt is unsuccessful. You can inspect the declined reason by reviewing the status_code and status_message attributes.

Error

The error event is triggered if an error occurs while attempting to process the payment request.

Error Description
UnknownRequestError An unknown network error occurred
LostConnectivity Connectivity was lost and offline payments is disabled
RequestError A request error occurred.
Inspect error_type, error_description, and details for information.