Shanghai AllPay Technology Co., Ltd.
AllPay provides access plug-ins (hereinafter referred to as "SDK") for customers based on mobile APP payments to help customers achieve fast, secure and centralized access to payment channels.
The merchant gateway sends the order information to the AllPay gateway, and the AllPay gateway processes the transaction serial number, ie tn, back to the merchant gateway, and tn is used as a parameter to adjust the mobile app payment control. Please refer to the specific AllPay Gateway Docking Document
Start the interface of the payment control, the interface is defined as follows:
public static void pay(Activity activity,String tn,boolean mode)
::: tip Parameter Description activity - Active object used to initiate the payment control.
tn - Transaction serial number. Required parameter for app payment. Merchants get from the AllPay backend.
mode - AllPay background environment ID, true means to initiate a transaction from the AllPay formal environment, false means to initiate a transaction from the AllPay test environment. :::
1.Add api("io.github.goallpay:allpaysdk:5.2.+") under the dependencies of the build.gradle file in the Application Module.
2.Add in the build.gradle file of the Application Module
repositories {
mavenCentral()
maven {
url 'https://s01.oss.sonatype.org/content/repositories/releases/'
}
}
Call the payment control in the following way:
/**
* tn - Transaction serial number. Required parameter for app payment. Merchants get from the AllPay backend.
* false represents the test environment, true represents the formal environment.
*/
AllPayEngine.Pay(ShopCartActivity.this, tn, false);
After the payment is completed, obtain the payment control payment result, and add the corresponding processing logic, just implement the onActivityResult() method in the Activity, and the example code is as follows:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (data == null) {
return;
}
if (requestCode == AllPayConst.VTPAY_PAY_REQUESR_CODE&& resultCode == AllPayConst.VTPAY_PAY_RESULT_CODE) {
String result = data.getExtras().getString("pay_result");
}
}
pay_result, which is a json string, in the following format:
{
"state": "cancel",
"paymentSchema": "UP",
"orderNum": "604337497032",
"errorDetail": "user cancel operation "
}
Message description:
Add in the code in the Application AndroidManifest.xml
<!-- wpay sdk begin -->
<activity
android:name="com.allpayx.sdk.wxapi.WXPayEntryActivity"
android:exported="true"
android:launchMode="singleTop" />
<activity-alias
android:name=".wxapi.WXPayEntryActivity"
android:exported="true"
android:launchMode="singleTop"
android:targetActivity="com.allpayx.sdk.wxapi.WXPayEntryActivity" />
<!-- wpay sdk end -->
If you have problems debugging, please contact us: support@allpayx.com