Android Application SDK Implementation

Import SDK aar into your Android project

In Android Studio, choose File→Project Structure→Dependencies, then select the “+” on the “Modules” panel

Select “import .JAR/.AAR Package

Browse the path of the file “sdk-alipay_release.aar”, click “OK” to confirm, and click “finish

The package will be imported into your project as a dependency in your Android project

Implement the SDK in your Android project

In your payment activity, import com.ottpay.sdk.*
Follow the code sample to implement payment SDK
/**
call alipay sdk pay. Call SDK payment
*/
public void pay(View v) {
 String server_url = //OTT Pay inApp API URL
 String merchant_id= //OTT PAY merchant id
 String shop_id= //OTT PAY store id,optional for future usage
 String operator_id= //OTT Pay operator Id
 String currency= //currency “CAD” or ”USD”
 String amount XXXXXXXXXXXXXXXXXX//pay amount in cents
 String call_back_url=XXXXXXXXXXXXXXXXXX//call back URL
 String biz_type = ALIPAYONLINE //if currency “USD”,using
APUSDONLINE
 order_id = XXXXXXXXXXXXXXXXXX // your own user id
 ConsumeStarter starter = new ConsumeStarter();

 starter.setOnCompleteListener(new OnCompleteListener() {
  @Override
  public void onComplete(String rspString) {
    Toast.makeText(MainActivity.this, rspString,
    Toast.LENGTH_SHORT).show();
  }
  });
  starter.consumeImp(MainActivity.this, server_url, merchant_id,
        shop_id, operator_id, currency, amount, order_id, call_back_url, biz_type);
}
Replace server_url, merchant_id, operator_id with values from OTT PAY. Create a ConsumeStarter instance, set OnCompleteListener, and then call the consumeImp method to activate the payment page in the Mobile Alipay application.

This is the SDK for the Android application for download