Paymentwall website uses cookies to store your browsing preferences on your device. However, cookies do not collect personal information.

For more information about how we use cookies, check our cookie policy

Close

Documentation

New Documentation Getting Started API Libraries APIs Checklists Flows Integrations Mobile SDKs Reference Smart TV SDK SpiderPipe Testing Payments
Contacts
If you still have questions regarding integration, please email us at devsupport@paymentwall.com

Brick Android SDK

Attachments

Requirements

Android 2.2 (API Level 8) and above

Integration steps:

Our SDK can be integrated just in a few quick and easy steps. See how simple it is:

1. As the SDK is delievered as a JAR package, just drop it into your project under libs folder

2. Add following permissions to your AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET"/>

3. Import class

import com.paymentwall.sdk.brick.Brick;
import com.paymentwall.sdk.brick.BrickCard;
import com.paymentwall.sdk.brick.BrickError;
import com.paymentwall.sdk.brick.BrickToken;

4. Create and validate a card

Just create a new BrickCard object with required parameters as below. This object will store card details and also help you to validate it:

BrickCard brickCard = new BrickCard(CARD_NUMBER, EXP_MONTH, EXP_YEAR, CVV);

Our SDK supports 2- and 4-digits format of expiration year field, so you can use the most convenient format for you.

brickCard = new BrickCard("4242424242424242", "11", "2016", "123");

brickCard = new BrickCard("4242424242424242", "11", "16", "123");

BrickCard help you to validate each field or validate all the card details at once:

brickCard.isNumberValid();
brickCard.isExpValid();
brickCard.isCvcValid();

//or launch all the validations at once

brickCard.isValid();

5. Creating the one-time token

To create a one-time token base on the BrickCard object, you need to create an instance of Brick and provide your public key. Then just call createToken() method giving it previosly created BrickCard and finally handle the callback function. 

We support Asynchronous and Synchronous call to retrieve the token

Asynchronous method

In case of succesfull token creating, the BrickToken object will be returned to onBrickSuccess callback function so you can get its details. You should then send the token to your backend and complete the payment using our Brick API.

Otherwise use BrickError object from onBrickError method to get error message if something went wrong.

Brick.createToken(context, PUBLIC_KEY, brickCard, new Brick.Callback() {
    @Override
    public void onBrickSuccess(BrickToken brickToken) {

    }

    @Override
    public void onBrickError(BrickError error) {

    }
});

Synchronous method

This method returns BrickToken if the token creation is successful or throws BrickError if it's failed.

try {
    BrickToken brickToken = Brick.createToken(PUBLIC_KEY, brickCard);
} catch (BrickError brickError) {

}

Getting the token

String token = brickToken.getToken();

BrickError is an exception thrown from the token creation process. Error kind can be get via:

BrickError.Kind errorKind = brickError.getKind();

There are different error kinds:

Kind Reason
Kind.INVALID Cannot pass pre-check process due to invalid card info or invalid public key
Kind.NETWORK Network error, ie: cannot connect to Paymentwall system, the internet connection is not available
Kind.HTTP The library is outdated or Paymentwall system is facing some problems
Kind.REJECTED Token creation is rejected due to invalid card info or public key
Kind.SERVER Paymentwall system is facing some problems
Kind.UNEXPECTED There are some problems with the device. Should crash the app.

When the error kind is Kind.REJECTED, a detailed response is also attached and can be retrieved via

if(brickError.getKind() == BrickError.Kind.REJECTED) {
    BrickResponse brickResponse = brickError.getResponse();
    String errorCode = brickResponse.getCode();
    String errorMessage = brickResponse.getError();
    String errorType = brickResponse.getType();
}

The errorCode is explained in Brick Document

This page needs JavaScript
Your browser is
not supported anymore.
Please update to the more recent one.
This page needs JavaScript
This page needs JavaScript.
Please enable it in your browser settings and try again.
Мы используем файлы cookie, чтобы вам было удобнее пользоваться сайтом. Используя сайт Paymentwall, вы соглашаетесь с нашей Политикой использования файлов cookie.