Standard Checkout
Overview
Items you will need:
- The Zip Android SDK
- The Start Checkout call in your Android app
- An order confirmation endpoint on your server
Implementation
The Zip Android SDK
- Please see the link to our SDK where our current version number can be seen - https://repo1.maven.org/maven2/com/quadpay/quadpay/
How to start a Zip checkout
Add Zip
Add
mavenCentral()
to your repositories then add
implementation 'com.quadpay:quadpay:0.3.8@aar'
to build.gradle
Consult your account manager about the version you should include!
Initialize the Zip SDK
Your merchant id will be provided by your Zip account manager.
QuadPay.initialize(new QuadPay.Configuration.Builder("<your-merchant_id>")
.setEnvironment(QuadPay.Environment.SANDBOX)
.setLocale(QuadPay.Locale.US)
.build()
);
Begin the Zip checkout flow
Once presented the customer will be shown the Zip checkout flow.
final QuadPayCheckoutDetails details = new QuadPayCheckoutDetails();
details.amount = "100";
details.customerFirstName = "Zip";
details.customerLastName = "Customer";
details.customerEmail = "[email protected]";
details.customerPhoneNumber = "+15555555555";
details.customerAddressLine1 = "123 Main St";
details.customerAddressLine2 = "10th Floor";
details.customerPostalCode = "10003";
details.customerCity = "New York";
details.customerState = "NY";
details.customerCountry = "US";
details.merchantReference = "<your-unique-order-id>";
QuadPay.startCheckout(<your activity instance>, details);
Implement the checkout delegate functions
These functions give your application information regarding the result of the Zip checkout flow.
Register for activity results
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (QuadPay.handleQuadPayActivityResults(
this,
requestCode,
resultCode,
data
)) {
return;
}
super.onActivityResult(requestCode, resultCode, data);
}
Checkout Success
This function returns an order id you may use to confirm an order has been created.
@Override
public void checkoutSuccessful(String orderId) {
// The user has completed checkout -- the order id must be used to confirm the transaction from the backend
}
Checkout Cancelled
This function is called when the user cancels the Zip process or is declined.
@Override
public void checkoutCancelled(String reason) {
// A reason describing why checkout was cancelled is returned
}
Confirming your Zip orders
As soon as your customer has completed checkout an order id will be issued. To finalize the transaction this order id must be submitted to Zip's confirmation endpoint. The order id will last for 24 hours under default settings to be confirmed.
The timing of your shipping can be any time after you have confirmed the order. When submitting the order id you will have a chance to finalize the order amount.
Post the order id to the confirmation endpoint
See https://docs.quadpay.com/docs/custom-integration-guide#signing-requests for information regarding signing requests
Post:
curl -X post https://gateway.quadpay.com/orders/{orderId}/confirm
-H 'content-type: application/json'
-H 'X-QP-Signature: [signature]'
-d '{
"orderId": [orderId],
"totalOrderAmount": <number>, (optional)
"taxAmount": <number>, (optional),
"shippingAmount": <number>, (optional)
}'
An order id will be returned:
{
"orderId": [order id]
}
Service after confirmation
Once the order has been confirmed and an order id has been received the user should be guided to a success page.
This order id can also be used to update the order using our normal orders integration api at https://docs.quadpay.com/docs/custom-integration-guide
Updated over 1 year ago