Alipay+ ACQP Android SDK interfaces
The following sections introduce the interfaces that are provided by the Alipay+ ACQP Android SDK.
Note: The payment sheet mentioned in the following sections is also known as the Alipay+ checkout page.
1. Overview
This section describes the interfaces that are used in the interaction between the SDK and your project.
1.1 API (ACQP -> SDK)
Interface name | Description |
setConfiguration | Set up the SDK. |
inquirePaymentOption | Inquire about the availability of and how to render the Alipay+ payment method on the payment method page. |
showPaymentSheet | Show the payment sheet for the user to complete the payment. |
1.2 SPI (SDK -> ACQP)
Interface name | Description |
log | Provide a delegate that you can use to log the user behavior or exceptions. |
2. APIs
setConfiguration
Use this API to set up the SDK with required configurations before you use other APIs. The configuration is stored in the RAM and may be used in the internal logic of the other APIs.
Method signature
public static void setConfiguration(IAPConfiguration configuration);
Input parameters
Name | Type | Length | Description | Required |
configuration | / | An object that includes the parameters for setting up the SDK. See IAPConfiguration for details. | M |
Output parameters
N/A
Sample code
IAPConfiguration configuration = new IAPConfiguration();
configuration.envType = "SANDBOX";
configuration.acquirerId = "XXX";
configuraiton.merchantId = "YYY";
configuration.language = "ZZZ";
AlipayPlusClient.setConfiguration(configuration);
inquirePaymentOption
Use this API to inquire whether the Alipay+ payment method is available and if so, related data about the Alipay+ payment method, such as the Alipay+ logo information and promotion information.
Method signature
public static void inquirePaymentOption(Context context, IAPInquirePaymentOptionParams params, IAPInquirePaymentCallback<IAPPaymentOption> callback);
Input parameters
Name | Type | Length | Description | Required |
context | Context | / | The context of the Android activity. | M |
params | / | An object that contains the parameters for querying the data about the Alipay+ payment method. | M | |
callback | IAPInquirePaymentCallback<IAPPaymentOption> | / | A callback that is used to return the query result. | M |
Parameters in the callback function
Name | Type | Length | Description | Required |
paymentOption | / | The data about the Alipay+ payment method. This parameter is returned if the inquiry is successful. | O | |
errorCode | String | / | The error code about the inquiry. This parameter is returned if the inquiry failed. See ErrorCode for details. | O |
errorMessage | String | / | The error message about the inquiry. This parameter is returned if the inquiry failed. See ErrorCode for details. | O |
Output parameters
N/A
Sample code
IAPInquirePaymentOptionParams params = new IAPInquirePaymentOptionParams();
params.paymentCurrency = "PHP";
params.logoPattern = "YYY";
AlipayPlusClient.inquirePaymentOption(context, params, new IAPInquirePaymentCallback() {
@override
public void onSuccess(IAPPaymentOption paymentOption) {
//render your chekout element view
}
public void onFailure(String errorCode, String errorMessage) {
//continue to execute your own logic
}
})
showPaymentSheet
Use this API to show the payment sheet for the user to complete the payment. During the lifecycle of the payment sheet, you can receive callbacks about key events, such as when the user clicks the cancel button or when the user clicks the Pay Now button.
Method signature
public static void showPaymentSheet(Context context, String paymentData, IAPPaymentSheetEventCallback callback);
Input parameters
Name | Type | Length | Description | Required |
context | Context | / | The context of the Android activity. | M |
paymentData | String | / | The payment data that is used for rendering the payment sheet. | M |
callback | IAPPaymentSheetEventCallback | / | The callback that is used to return the status of the payment sheet. | M |
Parameters in the callback function
Name | Android type | Length | Description | Required |
sheetEvent | / | An object that describes the event that occurred when the status of the payment sheet changed. | O |
Output parameters
N/A
Sample code
String paymentData = "XXX";
AlipayPlusClient.showPaymentSheet(context, paymentData, new IAPPaymentSheetEventCallback<IAPPaymentSheetEvent>() {
public void onSheetEvent(IAPPaymentSheetEvent event) {
switch(event.name) {
case "EVENT_SELECT_AND_PAY":
//your own logic
break;
case "EVENT_THROW_EXCEPTION":
//your own logic
break;
case "EVENT_USER_CANCEL":
//your own logic
break;
case "EVENT_SHOW_SUCCESS":
//your own logic
break;
}
}
})
3. SPIs
log
Implement this SPI to log the user behavior or exceptions during the interaction between the user and the SDK.
Method signature
void log(String name, Map parameter) ;
Input parameters
Parameters
Name | Type | Length | Description |
name | String | / | The name of the behavior or exception. |
parameter | Map<String,String> | / | The extra information. |
Output parameters
N/A
Sample code
public class LogServiceProvider implements LogService {
void log(NSString name, Map parameter) {
//your own logic
}
}
AlipayPlustClient.logService = new LogServiceProvider();
4. Appendices
public class IAPConfiguration
Item | Type | Description | Required |
merchantId | String | The unique ID that is assigned by the ACQP to identify a merchant. Note: The value of this parameter must be the same as the one that is specified when calling the pay API. | M |
acquirerId | String | The unique ID that is assigned by Alipay+ to identify an ACQP. | M |
language | String | The language that is preferred by the user. The value of the parameter consists of a language code following the ISO-639 standard and a country code following the ISO-3166 standard. The codes are connected by an underscore. For example, Valid values are:
Note: If a valid value is specified for the language parameter, the specified language is used. Otherwise, the English language is used. | O |
envType | String | The type of environment where the SDK is installed. The value of this parameter affects the gateway address of the requests that are initiated from the SDK. Valid values:
Default value: | O |
public class IAPInquirePaymentOptionParams
Item | Type | Description | Required |
paymentCurrency | String | The payment currency that is supported by the merchant. The value of this parameter must be an alphabetic code that follows the ISO 4217 standard, for example, "EUR" for Euros. | M |
logoPattern | String | The pattern of the logo, such as
| O |
public class IAPPaymentOption
Item | Type | Description | Required |
enabled | boolean | Indicates whether the Alipay+ payment method is available. | M |
logos | List<Logo> | The logo information of the Alipay+ payment method. Note: Nullable if the value of the enabled parameter is | O |
brandName | String | The brand name of the Alipay+ payment method. Note: Nullable if the value of the enabled parameter is | O |
disableReason | String | The reason why the Alipay+ payment method is unavailable. Note: The value of this parameter is null if the value of the enabled parameter is | O |
paymentMethodType | String | The payment method that is provided by Alipay+. Valid values are:
| M |
promoNames | List<String> | The list of promotion campaigns in the language that is preferred by the user. Each element in the array is a string that indicates the promotion name, such as Currently, the array contains only one element indicating one specific promotion campaign, which is the best offer that Alipay+ recommends to be displayed alongside the logo, rather than multiple different promotion campaigns. | O |
public class Logo
Item | Type | Description | Required |
logoName | String | The name of the logo. | O |
logoUrl | String | The URL of the logo. | O |
logoPattern | String | The pattern of the logo, such as
| O |
logoWidth | String | The width of the logo. | O |
logoHeight | String | The height of the logo. | O |
public class IAPPaymentSheetEvent
Item | Type | Description | Required |
name | String(constant value) | The name of the event that occurred in the lifecycle of the payment sheet. | M |
message | String | The message that is related to the event. | O |
constant values and possible messages
Name | Description |
EVENT_SELECT_AND_PAY | The event where the user selected an MPP and clicked Pay Now to get redirected to the MPP app or WAP page. |
EVENT_THROW_EXCEPTION | The event where an exception is thrown. |
EVENT_USER_CANCEL | The event where the user clicked Close to cancel the payment. |
EVENT_SHOW_SUCCESS | The event where the payment sheet was successfully rendered. |
public interface IAPInquirePaymentCallback
Return type | Method | Description |
void | onSuccess(IAPPaymentOption result) | The callback function that is used to return the data about the Alipay+ payment method. |
void | onFailure(String errorCode, String errorMessage) | The callback function that is used to return the error code and error message. |
public interface IAPPaymentSheetEventCallback
Return type | Method | Description |
void | onSheetEvent(IAPPaymentSheetEvent event) | The callback function that is used to return the event that occurred when the status of the payment sheet changed. |
ErrorCode
Error code | Error message | Description |
1001 | PARAM_ILLEGAL | Illegal parameters exist. |
1002 | INVALID_NETWORK | A network error occurs. |
1003 | SYSTEM_ERROR | A system error occurs. |