Android APIs

Class:com.scanforpay.sdk.ScanForPayPayTask
void pay(String request);

Create payment request.

request is the same format as the common request to ScanForPay Server. The basic format please see Request format.

Signature calculating must be implemented on server side.
Request Body
Name Parameter Type Required Description
Store ID storeNo String (15) Y Assigned by scanforpay
Partner Order No. partnerOrderNo String (32) Y Generated by merchant
20180802100000001
Wallet wallet String (10) C Wechat: wechat pay
Alipay: Alipay
AlipayHK: AlipayHK
Goods extra amount goodsExtraAmount int N Optional
The unit of the transaction amount is the smallest unit of the currency
If the currency is RMB, the unit is Fen. So if the transaction amount is 1 Yuan, 100 should be passed;if curreny is JPY, the unit is Japanese Yen
Goods amount goodsAmount int N Optional
The unit of the transaction amount is the smallest unit of the currency
If the currency is RMB, the unit is Fen. So if the transaction amount is 1 Yuan, 100 should be passed;if curreny is JPY, the unit is Japanese Yen
Currency currency String (10) Y The transaction currency must be the same as the merchant transaction currency
Trasaction Amount orderAmount int Y The unit of the transaction amount is the smallest unit of the currency
If the currency is RMB, the unit is Fen. So if the transaction amount is 1 Yuan, 100 should be passed;if curreny is JPY, the unit is Japanese Yen
Transaction Description orderTitle String(100) N Description
Operator Id operatorId String(20) N 10001
Notify url notifyUrl String(200) N System will call this url when payment succeed.
If this is empty, system will not notify the result
Full request example
{"request":{"header":{"requestTime":"2018-07-25T18:06:05+08:00","partnerNo":"10001","signType":"SHA256","version":"1.0","reqMsgId":"fd03f269-3180-4575-8af0-8f6cf324fb0f"},"body":{"merchantId":"100010000000002","partnerOrderNo":"p20180725180605466813","orderAmount":2100,"orderTitle":"Consume","barcode":"284447106610060508","operatorId":"211918","terminalNo":"123456","notifyUrl":"http://192.168.31.72:8080/ScanForPay/notify"}},"signature":"2d2d5c66a67a24b5e13705cc38f34d93c395a7d9e0e4ff9425c9ce07b806a1cc"}
void setSandBox(Boolean sandBox);

Request in sandbox or not. true: sandbox, false: production

void setListener(ScanForPayResultListener listener);

Set Listener, need to be set before calling pay method.

Interface: com.scanforpay.sdk.ScanForPayResultListener
@Override
void onSuccess(ScanForPayResult result); 
@Override
void onFail(ScanForPayResult result);

Success callback:When the payment is successful, the callback will be entered. If the status in the result is SUCCESS_CODE, the payment status is successful, and the member variable params of ScanForPayResult needs to be sent to the server for signature verification.

Failed callback: Failure or user cancellation will enter the callback, but the error code will be converted to a negative number when payment is canceled by the client. If the code in result is a negative number, it can be left unprocessed.

Class:com.scanforpay.sdk.ScanForPayResult
int getCode();

Get code。Definitions:

    public static final int SUCCESS_CODE = 0; // Success
    public static final int PARAMS_ERROR = 100; // Request parameters are not correct
String getMsg();

Get messages.

String getStatus();

Payment status: 1 means success, others are unsuccessful.

String getParams();

Get the order information from the callback result. Its format is the same as the general response format. Refer to Response Format.

Params Body
Name Parameter Type Required Description
Response code code int(5) Y 1:success,Others: fail
Response message msg varchar (100) Y Response message
Order Number orderNo varchar(32) C Generated by scanforpay
Merchant Order Number partnerOrderNo String (32) Y Generated by merchant
20180802100000001
Transaction amount orderAmount int Y The unit of the transaction amount is the smallest unit of the currency
If the currency is RMB, the unit is Fen. So if the transaction amount is 1 Yuan, 100 should be passed;if curreny is JPY, the unit is Japanese Yen
Wallet wallet String (10) Y Wechat: Wechat Pay
Alipay: Alipay
Transaction Status status int Y 0:To be Paid
1:Success
2:Fail
3:Refunded
Transation Time payTime String(25) N Date time with timezone, see RFC 3339 Section 5.6 for details.
2018-07-25T17:54:00+08:00
Currency currency varchar(5) Y JPY
Buyer account buyer varchar(30) N c*@gmail.com
Buyer ID buyerId varchar(30) N 208xxxxxxxxxx012
Params example
{"response":{"header":{"partnerNo":"10001","respTime":"2018-07-25T18:06:12+08:00","signType":"SHA256","version":"1.0","reqMsgId":"213ca19e-c75f-450d-9acf-46e860570bb9"},"body":{"code":1,"msg":"success","orderNo":"2018072518060757","partnerOrderNo":"p20180725180605466813","payTime":"2018-07-25T18:06:12+08:00","orderAmount":2100,"wallet":"Alipay","currency":"JPY","status":1,"buyer":"cd****@qq.com","buyerId":"208xxxxxxxxxx012"}},"signature":"0710b2630b467c14b3d54295def7f89be61097c21472547823b43c58f3466b08"}

results matching ""

    No results matching ""