Implementation with Android App SDK

In Android Studio, choose File→Project Structure→Dependencies • In “Modules”panel, choose “+”

• Choose “import .JAR/.AAR Package

• Browse to path of the file “sdk-alipay_release.aar”, select it by click “OK”, then“finish”

• The package will be imported to the project as dependency of your app in your Android project

• In you payment activity, import com.ottpay.sdk.*

• implement the payment SDK as following the code sample


/**
call alipay sdk pay. 调用 SDK 支付
*/
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);
}

Last updated