developer:android

Android eBizCharge SDK

The eBizCharge Android SDK and payment library bundle offers developers two different options of implementing our payment gateway within their Android apps. The SDK provides complete access to the gateway, giving developers the tools to manage a wide range of features, including transactions, products, and customers. The payment library provides a prebuilt activity that developers can use to obtain payment information from the end-user.

The SDK and payment library both require Android 2.3.3+ (API 10+).

Download the bundle . It contains the SDKebizcharge-payment.zip, the payment library, and a demo app for the payment library.

eBizCharge SDK

The documentation for this SDK can be found inside the bundle.

Payment Library

The payment library uses the SDK to communicate with the gateway. The payment method is determined by the getCommand() method from the instance of TransactionRequest that is passed to this library's activity. See below for an example.

This library currently can only process credit card sales (Command.CC_SALE) and authorizations (Command.CC_AUTH). More payment methods will be added in the future.

Note: This library uses the Android v7 appcompat support library. Please see Google's Support Library Setup guide for more information on how to add the v7 support library.

Getting Started

  1. Read Google's Managing Projects guide to learn how to add this library into your new/existing projects.
  2. Once you have added this library to your project, go to the PaymentLibraryConstants class:
    1. Set SANDBOX_MODE to true to use the sandbox environment for testing and development by using PaymentLibraryConstants.setSandboxMode(true). Set SANDBOX_MODE to false when your app is ready to go live.
    2. Obtain the source key and pin from our website for these constants: SOURCE_KEY, SOURCE_PIN
    3. Use PaymentLibraryConstants.setSourceKey(“sourcekey”) and PaymentLibraryConstants.setSourcePin(“sourcePin”) and their respective getters to set/get the source key and pin.
  3. Note, the source key and pin for the sandbox environment will differ from those for the production environment. Do not forget to update the source key and pin before your app goes live.
  4. If using Eclipse IDE, either go to your project's project.properties file and add the following line to the end:
    manifestmerger.enabled=true

    or declare this library's activity in your app's manifest:

    <activity
        android:name="com.ebizcharge.library.payment.PaymentLibraryActivity"
        android:label="@string/app_name" />
  5. This library requires permission to access the internet. Declare the following in your app's manifest if you did not choose the manifestmerger option in the previous step:
    <uses-permission android:name="android.permission.INTERNET" />
  6. Now you can launch this library from any of your activities.

Example Code

Here is a code snippet for creating a new transaction request and calling this library to process the transaction as a credit card sale.

CurrencyAmount subtotal = new CurrencyAmount("10.00");
CurrencyAmount tax = new CurrencyAmount(0, 2);
String invoice = "123456";
 
TransactionRequest request = new TransactionRequest();
request.setCommand(Command.CC_SALE); // credit card sale
request.setTotal(subtotal.add(tax));
request.setTax(tax);
request.setInvoice(invoice);
 
Intent i = new Intent(this, PaymentLibraryActivity.class);
i.putExtra(PaymentLibraryConstants.TRANSACTION_REQUEST, request);
startActivityForResult(i, REQUEST_PAYMENT_LIBRARY);

The results of the transaction processing will be returned in your activity's onActivityResult method.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK && requestCode == REQUEST_PAYMENT_LIBRARY) {
        TransactionResponse response = data
                .getParcelableExtra(PaymentLibraryConstants.TRANSACTION_RESPONSE);
 
        if (response == null) { // something wrong happened when communicating with the gateway
            GatewayException exception = data
                    .getParcelableExtra(PaymentLibraryConstants.GATEWAY_EXCEPTION);
            exception.printStackTrace();
        } else {
            String msg = "Transaction #: " + response.getRefNum() + ", Result: "
                    + response.getResult() +", Error: " + response.getError();
            Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
        }
    }
}

Library Reference

Class Description Link
TransactionRequest Transaction details to submit See SDK reference for more information
TransactionResponse Response from gateway See SDK reference for more information
CurrencyAmount A class to handle money See SDK reference for more information
GatewayException Exception if transaction couldn't be sent to gateway See SDK reference for more information

Changelog

Version Change
1.1 Support for cash, check, and ACH payment methods
1.0 Initial release
developer/android.txt · Last modified: 2015/12/14 11:38 by yaya

Page Tools