# Implementation with Android App SDK

### :white\_check\_mark: Import the SDK aar into your Android project

![](https://1288750261-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld5XVMQHp74noDIXTus%2F-M6kPjeKx8gCOd8aTTn9%2F-M6kPnsSJ4gz_lM8AbRY%2Fimage.png?alt=media\&token=3e655f7e-ae59-4dc0-81da-61bf7f88ee76)

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

• Choose “**import .JAR/.AAR Package**”

![](https://1288750261-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld5XVMQHp74noDIXTus%2F-M6kQb9qnxxFwkNwrJvG%2F-M6kR-QFgL5-8JCyRhHU%2Fimage.png?alt=media\&token=fa8047a5-daf0-457c-93c7-4dd2e92a4108)

• Browse to path of the file “**sdk-alipay\_release.aar**”, select it by click “OK”, then“finish”&#x20;

![](https://1288750261-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld5XVMQHp74noDIXTus%2F-M6kR6VXyvwuILx7jZ3i%2F-M6kR_sUSTYPCQkYTlBb%2Fimage.png?alt=media\&token=8cd14709-2259-4d17-9c3e-e158475ff83a)

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

![](https://1288750261-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld5XVMQHp74noDIXTus%2F-M6kRdu97DWn3F4wWNI3%2F-M6kRm9P_nCbnZG-hxqM%2Fimage.png?alt=media\&token=8afd8e44-b1f2-4142-8e7a-a18d9090a22e)

### :white\_check\_mark: Implement the SDK in your Android project

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

• implement the payment SDK as following the code sample&#x20;

```

/**
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);
}

```

:ballot\_box\_with\_check: Replace the server\_url, merchant\_id, operator\_id with the values from OTT PAY. Create an instance of **ConsumeStarter**, set the OnCompleteListener, and then invoke the **consumeImp** method to activate the payment page in your mobile’s Alipay app.

![](https://1288750261-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld5XVMQHp74noDIXTus%2F-M6kTdZQL9UbGEsP8G29%2F-M6kTog9YXGtM4sChkwH%2Fimage.png?alt=media\&token=48910bb7-f4d8-4e7f-adc8-daee6d063156)

:point\_right: Here is the sdk for android app for download

{% file src="<https://1288750261-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld5XVMQHp74noDIXTus%2F-M6ldXDZrbryBCzfoa2q%2F-M6leU6KsRFcevbvXhGM%2Fandroidsdk-ottalipay_release.zip?alt=media&token=e3ef7da9-6d17-4a14-9374-f29d437aaf7d>" %}
API SDK for Android App
{% endfile %}

&#x20;
