PayBright Android SDK is a library written in java that allows you to provide PayBright payment option in your own app.
Download via Gradle
Download via Maven
PayBright integration consists of two steps: Configure and Checkout
Set the API Key and token obtained from PayBright in PBConfig once (preferably in the Actvity's onCreate method) as follows
PBConfig.getInstance().initialize(PBConfig.PBEnvironment.Sandbox, "API_KEY", "API_TOKEN");
Checkout creation is the process in which a customer uses PayBright to pay for a purchase in your store. This process is governed by PBInstance object (which is set up in PBConfig shared object), and requires four parameters/objects:
- PBCustomer: details of the customer
- PBCustomerBilling: customer's billing address details
- PBCustomerShipping: customer's shipping address details
- PBProduct: item details
PBCustomer customerObj = new PBCustomer("[email protected]", "James", "Testhetfield", null);
PBCustomerBilling customerBillingObj = new PBCustomerBilling("270 Rue Olier", null, "Chicoutimi", null, "CA", "+1-613-987-6543", "QC", "G7G 4J3");
PBCustomerShipping customerShippingObj = new PBCustomerShipping("270 Rue Olier", null, "Chicoutimi", "Shopify", "CA", "James", "Testhetfield", "+1-613-987-6543", "QC", "G7G 4J3");
PBProduct productObj = new PBProduct(2625.0, "CAD", "PaymentGatewayTesting - #4682855809085", "#4682855809085", null, "sdk", "4682855809085", "CA", "PaymentGatewayTesting", "https://checkout.shopify.com/services/ping/notify_integration/paybright/19629019", "https://paymentgatewaytesting.myshopify.com/19629019/checkouts/84044f7a52ff18a84dd1f2b5cd46b387?key=0c4978718a87a00e5ac1456b577b5695", "https://paymentgatewaytesting.myshopify.com/19629019/checkouts/84044f7a52ff18a84dd1f2b5cd46b387/offsite_gateway_callback");
PBConfig.getInstance().instanceObj = new PBInstance(customerObj, customerBillingObj, customerShippingObj, productObj);
Add PBWebView into your AndroidManifest.xml
Once the PBInstance has been constructed, set it in PBConfig shared object and you may use PBViewController. This initiates the flow which guides the user through the PayBright checkout process. An example of how this is implemented is provided as follows
new PBViewController(this, this);
The flow ends once the user has successfully confirmed the checkout, canceled the checkout, or encountered an error in the process. In each of these cases, PayBright will send a message to the PBWebViewDelegate along with additional information about the result.
A demo app that integrates PayBright is included in the repo.
minSdkVersion 16 is required to use PayBright
Updated over 2 years ago