1
- [About This Guide](./1) - [Introduction](./2) - [Product Flow and User Interaction](./4) - [Product Flow](./4) - [Merchant Direct](./4) - [Merchant Scans with System Integrator](./5) - [Merchant Scans with Acquirer](./6) - [Merchant Scans with Integrator and Acquirer](./7) - [User Interaction](./3) - [Main Flows](./36) - [Pay Flow](./15) - [Cancel Flow](./16) - [Refund Flow](./37) - [Query Flow](./18) - [Quick Integration](./44) - [Prerequisites](./39) - [Implementing APIs](./40) - [Implementing Error Handling](./43) - [Viewing Reconciliation Files](./41) - [Testing in Sandbox Environment](./42) - [Mock Services](./45) - [Reconciliation Files](./29) - [SFTP Connection](./29) - [Transaction File Format](./30) - [Settlement File Format](./31) - [API List](./9) - [The Payment Interface](./9) - [The Request Parameter](./9) - [The Return Parameter](./20) - [The Error Code](./21) - [Offline to online scenarios](./28) - [The Cancel Interface](./32) - [The Request Parameter](./33) - [The Return Parameter](./35) - [The Error Code](./34) - [The Refund Interface](./11) - [The Request Parameter](./11) - [The Return Parameter](./24) - [The Error Code](./25) - [The Query Interface](./12) - [The Request Parameter](./12) - [The Return Parameter](./26) - [The Error Code](./27) - [The Secondary Merchant Info Interface](./46) - [The Request Parameter](./46#request) - [The Return Parameter](./46#sync) - [The Error Code](./46#error) - [Digital Signature](./13) - [Digital Algorithms](./13) - [RSA Key Generation with Open SSL](./14)
HK wallet - Barcode

About This Guide

Audience

This document targets at the technical person who are intending to integrate with the Barcode Payment solution.

Conventions

Interface

In this context, the interface is the channel that the Alipay system provides the relevant service by invoking the corresponding APIs with the required parameter values. Throughout this guide, we may use interface and service interchangeably.

Customer Support

For technical questions, please contact Global Merchant Technical Support.
For non-technical questions, like how to sign up with Alipay, please contact Global Merchant Business Support .

Generate Pre-sign string

Parameters to sign

In the list of request and response parameters, all of them need to be signed except sign and sign_type. (sign_type also needs to be signed in some cases in the list of request parameters)

Generate Pre-sign string

Use the following code to package the data:


		//package the request parameters
		Map sParaTemp = new HashMap();
		sParaTemp.put("service", AlipayConfig.service);
                sParaTemp.put("partner", AlipayConfig.partner);
                sParaTemp.put("_input_charset", AlipayConfig.input_charset);
		sParaTemp.put("notify_url", AlipayConfig.notify_url);
		sParaTemp.put("return_url", AlipayConfig.return_url);
		sParaTemp.put("out_trade_no", out_trade_no);
		sParaTemp.put("subject", subject);
		sParaTemp.put("total_fee", total_fee);
		sParaTemp.put("body", body);
		sParaTemp.put("currency", currency);
		sParaTemp.put("product_code", product_code);
		split_fund_info = split_fund_info.replaceAll("\"", "'");
		sParaTemp.put("split_fund_info", split_fund_info);

		sParaTemp.put("secondary_merchant_id",secondary_merchant_id);
		sParaTemp.put("secondary_merchant_name",secondary_merchant_name);
		sParaTemp.put("secondary_merchant_industry",secondary_merchant_industry);
  
Rearrange parameters in the data set alphabetically
And connect rearranged parameters with &:

_input_charset=utf-8&app_pay=Y&body=test&currency=USD&notify_url=http://d4779318.ngrok.io/new_create_forex_trade_wap_JAVA-UTF-8-RSA/notify_url.jsp&out_trade_no=test20170901162***&partner=2088101122136***&product_code=NEW_WAP_OVERSEAS_SELLER&return_url=http://d4779318.ngrok.io/new_create_forex_trade_wap_JAVA-UTF-8-RSA/return_url.jsp&service=create_forex_trade_wap&subject=test123&total_fee=0.01

This is the pre-sign string.

  • Parameters without a value, can be excluded from sign;
  • Charset in sign must be consistent with the charset used previously
  • If _input_charset is passed, it also shall be signed.
  • According to HTTP protocol, special character like &,@ needs to do URL encoding, therefore the request receiver can get correct value. In this situation, pre-sign string shall be the original value instead of encoded one. For example: calling a particular API need to sign the parameter email, the pre-sign string shall be email=test@msn.com, rather than email=test%40msn.com.

Signature Generation

MD5 Signature

Private Key is necessary for MD5 signature. The MD5 private key is the 32-byte string which is composed of English letters and numbers. Partner can log on the Merchant Service Center (https://global.alipay.com) to check the private key.

After the partner receives the pre-sign string during requesting, the private key should be appended to the pre-sign string to generate the new string. Then this new string would be calculated with the MD5 signature algorithm by the MD5 signature function. Thus, the result 32-byte string is the signature result string. (the value is given to parameter “sign”)  

After receiving the pre-sign string during responding from Alipay system, the next step is the same as the procedure of Sign for request. When the 32-byte signature result string is generated, it should be verified whether the value is equal to the value of the parameter “sign”. If equal, the verification would be passed.

RSA, RSA2 Signature

Both private key and public key are necessary for RSA signature. Both private key and public key are generated with OPENSSL by partner. Partner and Alipay need to exchange their own public key. Therefore, partner uses Alipay public key and partner private key.

After the partner receives the pre-sign string during requesting, the partner private key and the pre-sign string are used in the RSA signature algorithm by the RSA signature function to get the result string. (the value is given to parameter “sign”)

After receiving the pre-sign string during responding from Alipay system, the Alipay public key, the pre-sign string and the parameter “sign” are used in the RSA signature asymmetric algorithm by the RSA signature function to accomplish the signature verification.

OpenSSL installation

RSA key pair generation

For Java developers, we need to remove the header, footer, <CR>, and space from the pkcs8 private key output in the console. For.NET and PHP developer, there is no need for the pkcs8 operation.

After the above steps, the user could see two files under the current folder (C:\OpenSSL-Win32\bin for Windows), rsaprivatekey.pem and rsapublickey.pem.
The former is the private key while the latter is the public key. The merchant should keep the private key and exchange the public key with Alipay for signature verification. The following are the examples on how to use the key pair.

Upload the public key

Contact Global Merchant Technical Support to upload the public key. Please sign with the matching private key in the key pair.

This file consists of two parts: the header and record detail.

File header  

The file header contains a list of the following fields (the field names are not showing in the file):

Occurring sequence in the header

Field

Type

Description

1

Partner

String(16)

2088123456543210

2

Payment_time

String(10)

The day that transaction happens, the format is YYYY-MM-DD HH:MM:SS

3

Total_count

Number(9)

The total number of the records in this file

 

Record Detail

 No.

Field

Type(Byte)

Description

1

Partner_transaction_id

String(64)

A numbered transaction ID(unique in partner system)it is equal to “partner_trans_id” when transaction type is in (payment,reversal,reverse); it is equal to “partner_refund_id” when transaction type is refund

2

Transaction_id

String(64)

A numbered transaction ID (Unique inside the Alipay system)

3

Transaction_amount

Number(9,2)

Same to the definition given in the interface part;

It is in the currency given below.

4

Charge_amount

Number(9,2)

Commission fee

5

Currency

String(8)

The currency given in the transaction request.

6

Payment_time

String(19)

The time of transaction;

Format: YYYY-MM-DD HH:MM:SS

7

Transaction_type

String(8)

Transaction type:
PAYMENT

REVERSAL

REFUND

CANCEL

8

Remark

String(256)

Remark

9

Secondary_merchant_industry

String(4)

Industry classification identifier

10

Secondary_merchant_name

String

Secondary merchant name (or a taxi company name)

11

Operator_name

String

Operator name (store name field)

12

Order_scene

String

Order scenarios:

Scan QR code mode : shopQrCode

Barcode mode: It is blank

13

Trans_currency

String(8)

List currency

14

Trans_amount

Number(9,2)

Amount in list currency/refund amount in list currency

15

Trans_forex_rate

String

Exchange rate of list currency against settlement currency

An example of file content:

Partner:208800000000|Payment_time: 2013-12-02|Total_count:4

Partner_transaction_id|Transaction_id|Transaction_amount|Charge_amount|Currency|Payment_time|Transaction_type|Remark|Secondary_merchant_industry|Secondary_merchant_name|Operator_name|Order_scene|Trans_currency|Trans_amount|Trans_forex_rate 0001|201312020445|100|3|HKD|2013-12-02 10:45:42|PAYMENT||5812|xxx|xxx|shopQrCode|TWD|100|0.031 0002|201312020446|100|3|HKD|2013-12-02 10:45:13|REVERSAL||5812|xxx|xxx|shopQrCode|TWD|100|0.031 0003|201312020448|100|3|HKD|2013-12-02 10:45:09|REFUND|Refund|5812|xxx|xxx|shopQrCode|TWD|100|0.031

 

Record detail

No.

Field

Type

Description

1

Partner_transaction_ id

String(64)

A numbered transaction ID (unique inside the partner system), it is equal to:

  • "transaction_id" when canceling a transaction;
  • "partner_trans_id" when type is normal transaction;
  • "partner_refund_id" when type is refundament transaction;
  • "partner_trans_id" when the "partner_refund_id" is blank, such as 2010121000000002
  • 2

    Transaction_id

    String(64)

    A numbered transaction ID (Unique inside the Alipay system)such as 2015021021001001230099088888

    3

    Amount

    Number(9,2)

    The amount of fund in foreign currency.

    4

    Rmb_amount

    Number(9,2)

    The amount of fund in CNY currency

    5

    fee

    Number(9,2)

    The amount of commission fee in foreign currency

    6

    Settlement

    Number(9,2)

    Settlement amount in foreign currency

    7

    Rmb_settlement

    Number(9,2)

    Settlement amount in CNY currency

    8

    Currency

    String(10)

    Abbreviated currency code, such as USD

    9

    Rate

    Number(8,6)

    Currency rate

    10

    Payment_time

    String(19)

    YYYY-MM-DD HH:MM:SS

    Empty if the status being “failed” or “waiting”, e.g. 2016-02-10 01:01:01

    11

    Settlement_time

    String(19)

    YYYY-MM-DD HH:MM:SS
    Empty if unliquidated

    12

    Type

    String(1)

    Normal transaction:P
    Refunding transaction:R

    13

    Status

    String(1)

    Normal transaction:
    L: Liquidated
    Refundament transaction :
    L: Liquidated

    14

    Remarks

    String(256)

    An optional field. If the transaction is refundament, reason field will be displayed in this column ,if the transaction is a payment ,subject field will be displayed in this column

    15

    Secondary_merchant_industry

    String(4)

    Industry classification identifier( MCC )

    16

    Secondary_merchant_name

    String

    Secondary merchant name (or a taxi company name)

    17

    Operator_name

    String

    Operator name (store name field)

    18

    Order_scene

    String

    Order scenarios:

    Scan QR code mode : shopQrCode

    19

    Trans_currency

    String(10)

    List currency

    20

    Trans_amount

    Number(9,2)

    Transaction amount in list currency/refund amount in list currency

    21

    Trans_forex_rate

    String

    Exchange rate of list currency against settlement currency

    An example of file content:

    Partner_transaction_id|Transaction_id|Amount|Rmb_amount|Fee|Settlement|Rmb_settlement|Currency|Rate|Payment_time|Settlement_time|Type|Status|Remarks|Secondary_merchant_industry|Secondary_merchant_name|Operator_name|Order_scene|Trans_currency|Trans_amount|Trans_forex_rate

    EASA-20170801233604653-5GP0GVWNY|2017080221001004060213245489|369.30|2001.38|2.22|367.08|1989.37|AUD|5.41940000|2017-08-02 07:36:46|2017-08-03 15:46:00|P|L||5311|xxx|xxx|shopQrCode|AUD|369.30|1

     

    Request parameter is the request data provided to Alipay by merchant when conducting data interaction with Alipay so that further process can be conducted by Alipay based on these data.

    The gateway URL:

    Environment HTTPS request URL
    Production environment https://intlmapi.alipay.com/gateway.do
    Test environment https://mapi.alipaydev.com/gateway.do

    If you want to use Alipay sandbox to test the integration, see the sandbox handbook for details.

    If you are still using the previous sandbox gateway https://openapi.alipaydev.com, please use the https://mapi.alipaydev.com/gateway.do gateway instead. This gateway adjustment is caused by a system difference between the Alipay international sandbox test environment and the Alipay domestic sandbox test environment.

    Request parameters

     

    Parameter

     

    Type (Byte Length)

     

    Parameter Description

     

    Nullable

     

    Example

    Basic Parameters

    service

    String

    Interface name

    N

    alipay.acquire.cancel

    partner

    String(1

    6)

    Unique Alipay user number corresponding to authorized Alipay account number.

    Composed of 16 numbers beginning with 2088.

    N

    2088101125328850

    _input_

    charset

    String

    Encoding format used in merchant’s website, such as  utf-8, gbk, gb2312, etc

    N

    utf-8

    sign_type

    String

    Four values, namely, DSA, RSA, RSA2 and MD5 can be chosen; and must be capitalized

    N

    MD5

    sign

    String

    Please refer to “7 Signature Mechanism”.

    N

    363a752668ee2b3b8f1

    24c623bd028ad

    timestamp

    String

    Time stamp of the merchant server sending request, accurate to the millisecond.

    N

    1456507704121

    terminal_timestamp

    String

    Time stamp of the terminal sending request, accurate to the millisecond.

    Y

    1456507704102

    Business Parameters

    out_tra de_no

    String(6

    4)

    Unique order No. in Alipay’s merchant’s website

    N

    99003911198989

    trade_

    no

    String(6

    4)

    The trade serial number of the trade in Alipay system.

    16 bits at least and 64 bits at most.

    If out_trade_no and  trade_no are transmitted at the same time, trade_no shall govern.

    Y

    2013112611001004680

    073956707

    Part of the parameter type is String. Length range is not specified, which indicates that the system will not check out the length of the parameter.

     

    Example

    https://intlmapi.alipay.com/gateway.do?sign=83cff02d58eeb51f9343f475aeb06654&_input_charset=utf-8&out_trade_no=2017082100005665&partner=2088021966388155&service=alipay.acquire.cancel&timestamp=20170821193901

    Synchronous Return by XML

    Alipay will return result data to merchant after it has completed the processing of request data so as to facilitate further processing conducted by merchant based on these data.

    The result returned can be divided into two types, one is the result of normal business acceptance and process, the other is system-level abnormity or transmitted data error. For the normal business acceptance and process, merchant is required to analyze response code to judge whether business is processed successfully.

    List

     

    Parameter

    Type (Range of Length)

    Parameter Description

    Nullable

    Example

     

    Basic Parameters

     

    is_success

    String

    Request succeeds or not. Successful request does not mean the business is accepted and processed successfully.

    Ÿ   T means success

    Ÿ   F means failure

    N

    T

     

    sign_type

    String

    Four values, namely, DSA, RSA, RSA2 and MD5 can be chosen and must be capitalized

    Y

    MD5

     

    sign

    String

    Please refer to Signature Mechanism for details.

    Y

    fc209d86b57b2adb23

    254a897ebaa7d9

     

    error

    String

    This parameter does not exist if request succeeds;

    This parameter will be error code if request fails. Please refer to Error Code for details.

    Y

    ILLEGAL_SIGN

     

    Business Parameters

     

    result_code

    String(3

    2)

    Response code of cancel processing result.

    Ÿ   SUCCESS: successful refund

    Ÿ   FAIL: unsuccessful refund

    Ÿ   UNKNOWN: unknown result

    N

    SUCCESS

     

    trade_no

    String(6

    4)

    Trade number of the trade in Alipay system

    16 bits at least and 64 bits at most

    Y

    201311201100100433

    0000121536

    out_trade_no

    String(6

    4)

    Unique order ID in order system in corresponding merchant’s website other than Alipay trade number.

    Uniqueness of this parameter in merchant’s website shall be guaranteed. This is a parameter transmitted upon corresponding request, which shall be returned in its original shape.

    Y

    99003911198989

     

    retry_flag

    String(1)

    Y: The cancel failed due to retriable error

    N: The cancel failed due to non-retriable error

    Y

    Y

     

    action

    String(10)

    The action of cancel.

    close: only closed the transaction, but no refund.

    refund: had a refund.

    Y

    close

     

    detail_error_cod

    e

    String(4

    8)

    Give cause description to the response code returned. Please refer to Error Code for details.

    If the response code of result_code is SUCCESS, this parameter shall not be returned.

    Y

    TRADE_STATUS_ER ROR

     

    detail_er ror_des

    String(6

    4)

     

    Give literal statement as to the detailed error code. If the response code of result_code is SUCCESS, this parameter shall not be returned.

    Y

    Trade status is illegal.

     

                 
    With the evolution of Alipay server, the parameters returned synchronously may return more child nodes, procedure user is required to ignore the child nodes beyond the document description.

    Example

    Business is accepted and processed normally, and cancel is conducted successfully:
    <?xml version="1.0" encoding="utf-8"?> 
     <alipay> 
         <is_success>T</is_success> 
         <request> 
           <param name="sign">66b3a14ec95846f01d42564e6953c81b</param> 
           <param name="_input_charset">UTF-8</param> 
           <param name="sign_type">MD5</param> 
           <param name="service">alipay.acquire.cancel</param> 
           <param name="partner">2088101126765726</param> 
           <param name="out_trade_no">99003911198989</param> 
           <param name="timestamp">1456507705033</param> 
         </request> 
         <response> 
           <alipay> 
             <result_code>SUCCESS</result_code> 
             <out_trade_no>3406822113320232</out_trade_no> 
             <trade_no>2013111511001004390000105126</trade_no> 
             <action>refund</action> 
           </alipay> 
         </response> 
         <sign>3afc92ac4708425ab74ecb2c4e58ef56</sign> 
         <sign_type>MD5</sign_type> 
     </alipay> 
       

    Request succeeds, business processing fails:

    <?xml version="1.0" encoding="utf-8"?> 
     <alipay> 
       <is_success>T</is_success> 
       <request> 
         <param name="sign">66b3a14ec95846f01d42564e6953c81b</param> 
         <param name="_input_charset">UTF-8</param> 
         <param name="sign_type">MD5</param> 
         <param name="service">alipay.acquire.cancel</param> 
         <param name="partner">2088101126765726</param> 
         <param name="out_trade_no">99003911198989</param> 
         <param name="timestamp">1456507705033</param> 
       </request> 
       <response> 
         <alipay> 
          <result_code>FAIL</result_code> 
          <detail_error_code>TRADE_STATUS_ERROR</detail_error_code> 
          <detail_error_des>illegal trade status</detail_error_des> 
         </alipay> 
        </response> 
        <sign>fc209d86b57b2adb23254a897ebaa7d9</sign> 
        <sign_type>RSA</sign_type> 
     </alipay> 
    

    ŸRequest fails or the data accessed are incorrect

    <?xml version="1.0" encoding="utf-8"?> 
     <alipay> 
         <is_success>F</is_success> 
         <error>ILLEGAL_SIGN</error> 
     </alipay>
    

    Error List

    Error Code

    Description

    Action

    SYSTEM_ERROR

    Alipay system is currently not available.

    Retry this request with the exact parameters.

    Refer Case 2 at here for detailed instruction.

    ILLEGAL_SIGN

    Illegal signature.

    Please read chapter Digital Signature

    INVALID_PARAMETER

    Parameter error.

    Please check the standard of each request parameter according to the API specification

    ILLEGAL_ARGUMENT

    Parameter error.

    Please check each request parameter according to the API specification, contact Alipay technical support if this error persists

    ILLEGAL_PARTNER

    Incorrect partner ID.

    Please make sure the value of partner parameter matches the partner value provided by Alipay, contact Alipay technical support if this error persists

    ILLEGAL_EXTERFACE

    Interface configure error.

    Please make sure that the service parameters has the same value with the one in API specification, contact Alipay technical support if this error persists

    ILLEGAL_PARTNER_EXTERFACE

    Partner ID do not have access privilege.

    Make sure your agreement with Alipay has been finalized. Contact Alipay technical support if needed.

    ILLEGAL_SIGN_TYPE

    Illegal sign type.

    Please make sure the value of sign_type is among MD5,DSA and RSA, contact Alipay technical support if this error persists

    HAS_NO_PRIVILEGE

    Has no privilege.

    Please contact Alipay technical support

    REASON_TRADE_BEEN_FREEZEN

    Corresponding trade has been frozen due to security issues.

    Please contact Alipay technical support

    TRADE_NOT_EXIST

    Cannot find corresponding trade according to input “partner_trans_id”.

    1) Make sure the partner_trans_id is correct 2)if the issue persists, please contact Alipay Technical Support

    TRADE_STATUS_ERROR

    Corresponding trade status is not allowed for current operate.

    1) Make sure the trade status is correct 2)if the issue persists, please contact Alipay technical support

    BUYER_ERROR

    The buyer does not exist.

    Please contact Alipay technical support.

    BUYER_ENABLE_STATUS_FORBID

    Buyer account status prohibits the refund.

    Please contact Alipay technical support.

    SELLER_ERROR

    The seller does not exist.

    Please contact Alipay technical support.

    MERCHANT_BALANCE_NOT_ENOUGH

    Merchant balance is not enough for refund.

    Try again later after new transactions occurred.

    TRADE_CANCEL_TIME_OUT

    The cancellation request is beyond the opening hours.

    Please use the refund interface instead.

    SELLER_BALANCE_NOT_ENOUGH

    Insufficient balance of seller.

    Try again later after new transactions occurred.

    REASON_TRADE_REFUND_FEE_ERR

    Invalid refund amount.

    Please contact Alipay technical support for help.

    TRADE_HAS_FINISHED

    Transaction completed.

    Please use the refund interface instead.

    Handling result of alipay.acquire.cancel

    Case 1. When the invocation failed with network issue or request timeouted, so got no response from Alipay

    Case 2. Received response from Alipay, but (1) is_success=F and error=SYSTEM_ERROR, or (2) is_success=T and result_code=FAIL and detail_error_code=SYSTEM_ERROR, or (3) is_success=T and result_code=UNKNOWN.

    Case 3. Received response from Alipay, and is_success=T and result_code=SUCCESS. Mark merchant cancel order as processed successfully

    Case 4. Received response from Alipay, and (1) is_success=F and error=!SYSTEM_ERROR, or (2) is_success=T and result_code=FAIL and detail_error_code!=SYSTEM_ERROR. Mark merchant cancel order as failed. Refer specific error code for instrunction

    Pseudo code:

    try{
      if(isCase3){ //CASE 3
        doSuccessProcess();
      }
      else if(isCase4){ //CASE 4
        doFailureProcess();
      }
      else{ //CASE 2
       
        retrySuccess = retryWithSameParameters(); //Retry every 3 seconds, up to 5 times.
    
        if(retrySuccess){
          doSuccessProcess();
        }
        else{
          //request Alipay tech support.
        }
      }
    
    }catch (Exception ex){ // CASE 1
    
        retrySuccess = retryWithSameParameters(); //Retry every 3 seconds, up to 5 times.
    
        if(retrySuccess){
          doSuccessProcess();
        }
        else{
          //request Alipay tech support.
        }
      }
    }

    Generate Pre-sign string

    Parameters to sign

    In the list of request and response parameters, all of them need to be signed except sign and sign_type. (sign_type also needs to be signed in some cases in the list of request parameters)

    Generate Pre-sign string

    Use the following code to package the data:

    
    		//package the request parameters
    		Map sParaTemp = new HashMap();
    		sParaTemp.put("service", AlipayConfig.service);
                    sParaTemp.put("partner", AlipayConfig.partner);
                    sParaTemp.put("_input_charset", AlipayConfig.input_charset);
    		sParaTemp.put("notify_url", AlipayConfig.notify_url);
    		sParaTemp.put("return_url", AlipayConfig.return_url);
    		sParaTemp.put("out_trade_no", out_trade_no);
    		sParaTemp.put("subject", subject);
    		sParaTemp.put("total_fee", total_fee);
    		sParaTemp.put("body", body);
    		sParaTemp.put("currency", currency);
    		sParaTemp.put("product_code", product_code);
    		split_fund_info = split_fund_info.replaceAll("\"", "'");
    		sParaTemp.put("split_fund_info", split_fund_info);
    
    		sParaTemp.put("secondary_merchant_id",secondary_merchant_id);
    		sParaTemp.put("secondary_merchant_name",secondary_merchant_name);
    		sParaTemp.put("secondary_merchant_industry",secondary_merchant_industry);
      
    Rearrange parameters in the data set alphabetically
    And connect rearranged parameters with &:

    _input_charset=utf-8&app_pay=Y&body=test&currency=USD&notify_url=http://d4779318.ngrok.io/new_create_forex_trade_wap_JAVA-UTF-8-RSA/notify_url.jsp&out_trade_no=test20170901162***&partner=2088101122136***&product_code=NEW_WAP_OVERSEAS_SELLER&return_url=http://d4779318.ngrok.io/new_create_forex_trade_wap_JAVA-UTF-8-RSA/return_url.jsp&service=create_forex_trade_wap&subject=test123&total_fee=0.01

    This is the pre-sign string.

    • Parameters without a value, can be excluded from sign;
    • Charset in sign must be consistent with the charset used previously
    • If _input_charset is passed, it also shall be signed.
    • According to HTTP protocol, special character like &,@ needs to do URL encoding, therefore the request receiver can get correct value. In this situation, pre-sign string shall be the original value instead of encoded one. For example: calling a particular API need to sign the parameter email, the pre-sign string shall be email=test@msn.com, rather than email=test%40msn.com.

    Signature Generation

    MD5 Signature

    Private Key is necessary for MD5 signature. The MD5 private key is the 32-byte string which is composed of English letters and numbers. Partner can log on the Merchant Service Center (https://global.alipay.com) to check the private key.

    After the partner receives the pre-sign string during requesting, the private key should be appended to the pre-sign string to generate the new string. Then this new string would be calculated with the MD5 signature algorithm by the MD5 signature function. Thus, the result 32-byte string is the signature result string. (the value is given to parameter “sign”)  

    After receiving the pre-sign string during responding from Alipay system, the next step is the same as the procedure of Sign for request. When the 32-byte signature result string is generated, it should be verified whether the value is equal to the value of the parameter “sign”. If equal, the verification would be passed.

    RSA, RSA2 Signature

    Both private key and public key are necessary for RSA signature. Both private key and public key are generated with OPENSSL by partner. Partner and Alipay need to exchange their own public key. Therefore, partner uses Alipay public key and partner private key.

    After the partner receives the pre-sign string during requesting, the partner private key and the pre-sign string are used in the RSA signature algorithm by the RSA signature function to get the result string. (the value is given to parameter “sign”)

    After receiving the pre-sign string during responding from Alipay system, the Alipay public key, the pre-sign string and the parameter “sign” are used in the RSA signature asymmetric algorithm by the RSA signature function to accomplish the signature verification.

    During the payment process of a transaction, it is possible to encounter issues such as system exception or network accessibility. In such a scenario, you need to reverse the transaction. To implement this reversing, we would like to highlight the notes of below:

    1. In this integration, please use the CANCEL to reverse a transaction, and the interface name is: alipay.acquire.cancel;
    2. For a transaction that has been successfully paid, the CANCEL is able to refund the transaction within the transaction day (GMT+8).;
    3. Comparing with the REFUND service, if a transaction can be refunded by this CANCEL interface, the transaction fee that hass been charged by Alipay will always be refunded as well;
    4. For a transaction has encountered technical issues during making the payment, the CANCEL is able to roll back all the actions have been performed in the Alipay system regarding the specific transaction;
    5. For the full list of parameters and error code of this CANCEL service, please refer the interface API document for details. 

    For a transaction that has been successfully paid, the customer can request the merchant for refunding as long as the refunding period is still valid, and the merchant can make use of the refunding interface to achieve the goal.

    For the integration of the refunding service, we would like to highlight:

    1. The refund service name is: alipay.acquire.overseas.spot.refund;
    2. The refunding service is only applicable to a transaction that has been successfully paid;
    3. The refunding of a transaction can be full or partial, i.e. the refunding amount can respectively be the same as or less than the original transaction amount that has been paid;
    4. Regarding whether Alipay will return the charged fee of the original transaction, it depends on your contract with Alipay.
    5. Comparing with the cancel interface (alipay.acquire.cancel), this service does not impose the 24-hours constraint, i.e. the merchant server can invoke this service at any time that between the moment when the transaction was paid and the time before the refunding period expires;
    6. If a refunding request encounters a failure, please retry for a reasonable number of times. 

    Parameter List

    Parameter

    Type (Byte)

    Description

    Nullable

    Example

    is_success

    String(1)

    It indicates that a request is accepted by Alipay gateway.

    l  T for accepted

    No

    T

    sign_type

    String

    The type could be DSA, RSA or MD5;

     

    Capital letters only.

    No

    MD5

    sign

    String(32)

    See “4 Digital Signature”.

    No

    59c7275cf3c82f038b7c0076f9888926

    payment_inst

    String(32)

    This parameter identifies the wallet version:

    ALIPAYCN, ALIPAYHK

    No

    ALIPAYHK

    result_code

    String(32)

    To describe the response status of a request:

    SUCCESS, FAIL

    No

    SUCCESS

    error

    String(48)

    To describe the reason of the result_code when it is failed/unknown, leave it blank when result_code is success.

    Yes

    TRANS_NOT_FOUND

    alipay_trans _status

    String(32)

    WAIT_BUYER_PAY,

    TRADE_SUCCESS,

    TRADE_CLOSED

    Yes

    TRADE_SUCCESS

    alipay_buyer_login_id

    String(20)

    The buyer’s Alipay login Id, the id might be an email or mobile number.

    The id is partially masked for privacy.

    YES

    cao***@126.com  or 186***22156

    alipay_buyer_user_id

    String(16)

    This ID stands for each Alipay account number ,unique in Alipay system start with “2088”

    No

    2088102130896433

    partner_trans_id

    String(64)

    Equal to the partner_trans_id given in the request

    No

    201311221000000002

    alipay_trans_id

    String(64)

    On the partner’s payment request, the alipay system creates a transaction id to handle it.

    The alipay_trans_id has one-one association with partner + partner_trans_id.

    YES

    201311221703338463

    alipay_pay_time

    String(16)

    The time of the transaction has been paid.

    Format:YYYYMMDDHHMMSS

    YES

    201311212323

    currency

    String(8)

    The currency used for labeling the price of the transaction;

    No

    USD

    trans_amount

    Number(9,2)

    the transaction amount in the currency given above;

     

    Range: 0.01-100000000.00. Two digits after decimal point.

    No

    39.25

    m_discount_forex_amount

    Number(9,2)

    If coupons/vouchers are used in the transaction, the discount amount redeened in the settlement currency will be returned. Otherwise, no return.

    Yes

    2.19

    Parameters rejected by Alipay gateway:

    Parameter

    Type (Byte)

    Description

    Nullable

    Example

    is_success

    String(1)

    It indicates that a request is rejected by Alipay gateway.

    l  F for rejected

    No

    F

    sign_type

    String

    The type could be DSA, RSA or MD5;

     

    Capital letters only.

    No

    MD5

    sign

    String(32)

    See “4 Digital Signature”.

    No

    59c7275cf3c82f038b7c0076f9888926

    detail_error_code

    String(48)

    To describe the reason of the result_code when it is failed/unknown, leave it blank when result_code is success.

    Yes

    TRANS_NOT_FOUND

    detail_error_des

    String(48)

    To describe the reason of the result_code when it is failed/unknown, leave it blank when result_code is success.

    Yes

    New parameter??? needs to get list from Dev team

    Please also note that details_error_code and details_error_description parameter value are subject to be newly introduced further; please consider when coding to handle forward compatibility for this further error code introduction.

    A response example

    Normal input:

    <?xmlversion="1.0"encoding="UTF-8"?> 
     <alipay> 
      <is_success>T</is_success> 
      <request> 
       <param name="_input_charset">UTF-8</param> 
       <param name="partner_trans_id">2010121000000002</param> 
       <param name="partner">2088102012343978</param> 
       <param name="service">alipay.acquire.overseas.query</param> 
       <param name="sign">22904adafb1806178b410d2d5c9c02a3</param> 
       <param name="sign">c7d17d40111b8264975a6bfba77962cb</param> 
      </request> 
      <response> 
       <alipay> 
        <alipay_trans_id>2011091703338463</alipay_trans_id> 
        <partner_trans_id>201311221000000002</partner_trans_id> 
        <alipay_buyer_login_id>cao***@126.com</alipay_buyer_login_id> 
        <alipay_pay_time>20131120155823</alipay_pay_time> 
        <trans_amount>39.25</trans_amount> 
        <payment_inst>ALIPAYCN</payment_inst>
        <result_code>SUCCESS</result_code> 
        <alipay_trans _status>TRADE_SUCCESS</alipay_trans _status> 
       </alipay> 
      </response> 
      <sign>6fb8a322f15cfd0fcfe65301b10f6994</sign> 
      <sign_type>MD5</sign_type> 
     </alipay> 
     

    Error output:

    <?xml version="1.0" encoding="UTF-8"?> 
     <alipay> 
      <is_success>F</is_success> 
      <error>ILLEGAL_SIGN</error> 
      <sign>02f6b289c46b8d0c1ea62b4f78637c1a</sign> 
      <sign_type>MD5</sign_type> 
     </alipay> 
    

    This file consists of two parts: the header and record detail.

    File header  

    The file header contains a list of the following fields (the field names are not showing in the file):

    Occurring sequence in the header

    Field

    Type

    Description

    1

    Partner

    String(16)

    2088123456543210

    2

    Payment_time

    String(10)

    The day that transaction happens, the format is YYYY-MM-DD HH:MM:SS

    3

    Total_count

    Number(9)

    The total number of the records in this file

     

    Record Detail

     No.

    Field

    Type(Byte)

    Description

    1

    Partner_transaction_id

    String(64)

    A numbered transaction ID(unique in partner system)it is equal to “partner_trans_id” when transaction type is in (payment,reversal,reverse); it is equal to “partner_refund_id” when transaction type is refund

    2

    Transaction_id

    String(64)

    A numbered transaction ID (Unique inside the Alipay system)

    3

    Transaction_amount

    Number(9,2)

    Same to the definition given in the interface part;

    It is in the currency given below.

    4

    Charge_amount

    Number(9,2)

    Commission fee

    5

    Currency

    String(8)

    The currency given in the transaction request.

    6

    Payment_time

    String(19)

    The time of transaction;

    Format: YYYY-MM-DD HH:MM:SS

    7

    Transaction_type

    String(8)

    Transaction type:
    PAYMENT

    REVERSE

    REFUND

    8

    Remark

    String(256)

    Remark

    9

    Secondary_merchant_industry

    String(4)

    Industry classification identifier

    10

    Secondary_merchant_name

    String

    Secondary merchant name (or a taxi company name)

    11

    Secondary_merchant_id

    String

    Secondary merchant id

    12

    Operator_name

    String

    Operator name (store name field)

    13

    Order_scene

    String

    Order scenarios:

    Scan Merchant QR code mode: shopQrCode

    Barcode mode: paymentQrCode

    Scan Transaction QR code mode: transactionQrCode

    14

    Trans_currency

    String(8)

    List currency

    15

    Trans_amount

    Number(9,2)

    Amount in list currency/refund amount in list currency

    16

    Trans_forex_rate

    String

    Exchange rate of list currency against settlement currency

    17

    Issue

    String

    Indicates the payment type:ALIPAYCN for Alipay mainland user, ALIPAYHK for Alipay HK user.

    An example of file content:

    Partner:208800000000|Payment_time: 2017-04-27|Total_count:3

    Partner_transaction_id|Transaction_id|Transaction_amount|Charge_amount|Currency|Payment_time|Transaction_type|Remark|Secondary_merchant_industry|Secondary_merchant_name|Secondary_merchant_id|Operator_name|Order_scene|Trans_currency|Trans_amount|Trans_forex_rate|Issue

    test001|2017042721001000000000000001|352.50|4.23|HKD|2017-04-27 07:20:14|PAYMENT||||331|||||1|ALIPAYCN

    test002|2017042721001000000000000002|37.50|0.45|HKD|2017-04-27 08:30:21|PAYMENT||||302|||||1|ALIPAYCN

    test003|2017042721001000000000000003|120.00|1.44|HKD|2017-04-28 11:08:26|REVERSAL||||349|||||1|ALIPAYHK

     

    Record detail

    No.

    Field

    Type

    Description

    1

    Partner_transaction_ id

    String(64)

    A numbered transaction ID (Unique inside the partner system),it is equal to “partner_trans_id” when type is normal transaction ; it is equal to “partner_refund_id” when type is refundament transaction; it is equal to “partner_trans_id” when  the  “partner_refund_id” is blank, such as 2010121000000002

    2

    Transaction_id

    String(64)

    A numbered transaction ID (Unique inside the Alipay system)such as 2015021021001001230099088888

    3

    Amount

    Number(9,2)

    The amount of fund in foreign currency.

    4

    Fee

    Number(9,2)

    The amount of commission fee in foreign currency

    5

    Settlement

    Number(9,2)

    Settlement amount in foreign currency

    6

    Currency

    String(10)

    Abbreviated currency code, such as USD

    7

    Payment_time

    tring(19)

    YYYY-MM-DD HH:MM:SS

    Empty if the status being “failed” or “waiting”, e.g. 2016-02-10 01:01:01

    8

    Settlement_time

    String(19)

    YYYY-MM-DD HH:MM:SS
    Empty if unliquidated

    9

    Type

    String(1)

    Normal transaction:P
    Refunding transaction:R

    10

    Status

    String(1)

    Normal transaction:
    P : Payment made    L: Liquidated
    Refundament transaction :
    W:wait to be proceed P:refund success
    F: failed    L:Liquidated

    11

    Remarks

    String(256)

    An optional field. If the transaction is refundament, reason field will be displayed in this column ,if the transaction is a payment ,subject field will be displayed in this column

    12

    Secondary_merchant_industry

    String(4)

    Industry classification identifier( MCC )

    13

    Secondary_merchant_name

    String

    Secondary merchant name (or a taxi company name)

    14

    Secondary_merchant_id

    String

    Secondary merchant id

    15

    Operator_name

    String

    Operator name (store name field)

    16

    Order_scene

    String

    Order scenarios:

    Scan Merchant QR code mode: shopQrCode

    Barcode mode: paymentQrCode

    Scan Transaction QR code mode: transactionQrCode

    17

    Trans_currency

    String(10)

    List currency

    18

    Trans_amount

    Number(9,2)

    Transaction amount in list currency/refund amount in list currency

    19

    Trans_forex_rate

    String

    Exchange rate of list currency against settlement currency

    20

    Issue

    String

    Indicates the payment type:ALIPAYCN for Alipay mainland user, ALIPAYHK for Alipay HK user.

    An example of file content:

    Partner_transaction_id|Transaction_id|Amount|Fee|Settlement|Currency|Payment_time|Settlement_time|Type|Status|Remarks|Secondary_merchant_industry|Secondary_merchant_name|Secondary_merchant_id|Operator_name|Order_scene|Trans_currency|Trans_amount|Trans_forex_rate|Issue

    test001|2017042721001000000000000001|352.50|4.23|348.27|HKD|2017-04-27 07:20:14|2017-04-28 15:36:00|P|L||||331|||||1|ALIPAYCN

    test002|2017042721001000000000000002|37.50|0.45|37.05|HKD|2017-04-27 08:30:21|2017-04-28 15:36:00|P|L||||302|||||1|ALIPAYCN

     

    The Alipay system has implemented the White List mechanism, and the partner needs to notify Alipay of its public IPs. Then, we will release a username together with password to the partner to test the accessibility and reconciliation file parsing/cron job. If these testings are successful, the partner can push the system to the production.

    The file naming rule is:

    1. $PID_transaction_$YYYYMMDD.txt;
    2. $PID_settlement_$YYYYMMDD.txt

     

    Parameter List

    Parameters accepted by Alipay gateway:

    Parameter

    Type (Byte)

    Description

    Nullable

    Example

    is_success

    String(1)

    It indicates that a request is accepted by Alipay gateway.

    l  T for accepted

    No

    T

    sign_type

    String

    The type could be DSA, RSA or MD5;

     

    Capital letters only.

    No

    MD5

    sign

    String(32)

    See “4 Digital Signature”.

    No

    59c7275cf3c82f038b7c0076f9888926

    result_code

    String(32)

    To describe the response status of a request:

    SUCCESS, FAILED, UNKNOW.

    No

    SUCCESS

    error

    String(48)

    To describe the reason of the result_code when it is failed/unknown, leave it blank when result_code is success.

    Yes

    TRANS_NOT_FOUND

    partner_trans_id

    String(64)

    Equal to the partner_trans_id given in the request

    No

    201311221000000002

    alipay_trans_id

    String(64)

    On the partner’s payment request, the alipay system creates a transaction id to handle it.

    The alipay_trans_id has one-one association with partner + partner_trans_id.

    Yes

    201311221703338463

    partner_refund_id

    String(64)

    The refund order id on partner system.

     

    partner_refund_id together with partner identify a refund transaction

    No

    301012133000002

    refund_amount

    Number(9,2)

    Less than or equal to the original transaction amount and the left transaction amount if ever refunded.

     

    No

    39.25

    currency

    String(10)

    The refund currency. CNY is not supported.

    No

    HKD

    Parameters rejected by Alipay gateway:

    Parameter

    Type (length range)

    Description

    Nullable

    Example

    is_success

    String(1)

    It indicates that a request is rejected by Alipay gateway.

    l  F for rejected

    No

    F

    sign_type

    String

    The type could be DSA, RSA or MD5;

     

    Capital letters only.

    No

    MD5

    sign

    String(32)

    See “4 Digital Signature”.

    No

    59c7275cf3c82f038b7c0076f9888926

    error

    String(48)

    To describe the reason of the result_code when it is failed/unknown, leave it blank when result_code is success.

    Yes

    TRANS_NOT_FOUND

    A response example

    Normal input:

    <?xmlversion="1.0"encoding="UTF-8"?> 
     <alipay> 
      <is_success>T</is_success> 
      <request> 
       <param name="_input_charset">UTF-8</param> 
       <param name="partner_trans_id">2010121000000002</param> 
       <param name="partner">2088102012343978</param> 
       <param name="service">alipay.acquire.overseas.pay</param> 
       <param name="partner_refund_id">301012133000002</param> 
       <param name="refund_amount">39.25</param> 
       <param name="currency">HKD</param> 
       <param name="refund_reson">back</param> 
       <param name="sign">22904adafb1806178b410d2d5c9c02a3</param> 
       <param name="sign_type">MD5</param> 
      </request> 
      <response> 
       <alipay> 
        <partner_trans_id>2010121000000002</partner_trans_id> 
        <alipay_trans_id>201311221703338463</alipay_trans_id> 
        <partner_refund_id>301012133000002</partner_refund_id> 
        <refund_amount>39.25</refund_amount> 
        <currency>HKD</currency> 
        <result_code>SUCCESS</result_code> 
       </alipay> 
      </response> 
      <sign>6fb8a322f15cfd0fcfe65301b10f6994</sign> 
      <sign_type>MD5</sign_type> 
     </alipay> 
     

    Error output:

    <?xml version="1.0" encoding="UTF-8"?> 
     <alipay> 
       <is_success>F</is_success> 
       <error>ILLEGAL_SIGN</error> 
       <sign>02f6b289c46b8d0c1ea62b4f78637c1a</sign> 
       <sign_type>MD5</sign_type> 
     </alipay> 
    

    What is a mock service

    The mock service provides simulations of different payment results to get you familiarized with the possible payment scenarios beforehand. With the simulated scenarios provided in a sandbox environment, you can test failed payment processes with different types of responses and learn to handle exception scenarios. The mock service aims to optimize your exception and error handling abilities and therefore, improve your Alipay integration quality with lower integration cost and better user experience.

    Previously, many exception scenarios are difficult or even impossible to be simulated. With the mock service, you can run test cases for all the scenarios and see whether the response is as designed. Besides the default mock rules, you can also customize mock rules for exception scenarios based on your business requirements. By now, the mock service supports the process of payment, cancel, refund, and query.

    How to use a mock service

    Before using a mock service, you need to have an Alipay merchant account. See Creating an Alipay merchant account

    Watch the following video to have a quick overview of how to use a Mock service:

    1. Log in your sandbox and go to the mock service part. By now, the mock service supports the following 4 APIs:

    2. Configure mock rules by specifying mock API requests and corresponding responses.
    Two types of mock rules exist for each API: default rules and custom rules.

    3. Send an API request that matches the specified mock rules. You will receive a corresponding mock response and then process it. For example, you can send an alipay.acquire.overseas.spot.pay request with the following mock rule. See the below sample code and a corresponding mock response for details. The default mock rule:

    Samples

    Sample request:

    http://mapi.alipaydev.com/gateway.do?client_info=%7B%22client_ip%22%3A%2210.20.30.40%22%7D&identity_code_type=barcode&memo=nomemo&trans_amount=9901&sign_type=MD5&trans_name=xxxzgl&buyer_identity_code=288888888888888888&partner_trans_id=8567745904202380&password=SJV88po0XvIptqWGM4rxP5EQ&sendFormat=normal¤cy=USD&sign=6030aea30c96e01c6e5c709c9f66a7df&agreement_info=%7B%22agreement_no%22%3A%22123%22%7D&trans_currency=USD&biz_product=OVERSEAS_MBARCODE_PAY&service=alipay.acquire.overseas.spot.pay&format_type=xml&quantity=1&partner=2088621880270354

    Sample response:

    
    <?xml version="1.0" encoding="GBK"?>
    <alipay>
         <is_success>T</is_success>
         <request>
            <param name="client_info">{"client_ip":"10.20.30.40"}</param>
            <param name="quantity">1</param>
            <param name="biz_product">OVERSEAS_MBARCODE_PAY</param>
            <param name="identity_code_type">barcode</param>
            <param name="sign">6030aea30c96e01c6e5c709c9f66a7df</param>
            <param name="memo">nomemo</param>
            <param name="trans_name">xxxzgl</param>
            <param name="trans_amount">9901</param>
            <param name="sendFormat">normal</param>
            <param name="partner_trans_id">8567745904202380</param>
            <param name="password">SJV88po0XvIptqWGM4rxP5EQ</param>
            <param name="format_type">xml</param>
            <param name="trans_currency">USD</param>
            <param name="partner">2088621880270354</param>
            <param name="agreement_info">{"agreement_no":"123"}</param>
            <param name="service">alipay.acquire.overseas.spot.pay</param>
            <param name="currency">USD</param>
            <param name="sign_type">MD5</param>
            <param name="buyer_identity_code">288888888888888888</param>
         </request>
         <response>
         	<alipay>
         		<error>SYSTEM_ERROR</error>
         		<result_code>FAILED</result_code>
         	</alipay>
         </response>
         <sign>d0117413cdf375ab667329892ab7f890</sign>
         <sign_type>MD5</sign_type>
    </alipay>
    

    Call this interface to register offline secondary merchants information into Alipay system.

    The gateway URL:

    Environment HTTPS request URL
    Production environment https://intlmapi.alipay.com/gateway.do
    Test environment https://mapi.alipaydev.com/gateway.do

    If you want to use Alipay sandbox to test the integration, see the sandbox handbook for details.

    If you are still using the previous sandbox gateway https://openapi.alipaydev.com, please use the https://mapi.alipaydev.com/gateway.do gateway instead. This gateway adjustment is caused by a system difference between the Alipay international sandbox test environment and the Alipay domestic sandbox test environment.

    Request Parameters

    Parameter

    Type (bytes)

    Description

    Optional

    Example

    Basic Parameter

    service

    String

    Service Name

    N

    alipay.overseas.secmerchant.offline.maintain

    partner

    String(16)

    A unique partner ID to identify a contracted Alipay Account.

    A 16 digit number starts with 2088.

    N

    2088*********662

    _input_charset

    String

    The charset with which the request data is encoded. For example, UTF-8, GBK, GB2312 etc.

    N

    gbk

    sign_type

    String

    DSA, RSA, or MD5, use upper case

    N

    MD5

    sign

    String

    See Digital Signature.

    N

    2118ac8fad6bc1d9e88a6cd017c18d37

    timestamp

    String

    The time when the merchant server sends request, in GMT + 8, format: yyyy-MM-dd HH:mm:ss.

    By default, the request expires in 30 minutes.

    N

    2012-12-21 17:11:16

    Business Parameter

    secondary_merchant_name

    String(128)

    Name of the secondary merchant

    N

    secMerchantName

    secondary_merchant_id

    String(64)

    The unique ID assigned by the partner to identify a secondary merchant. The ID can contain letters, numbers, and underscores.

    N

    63472327348

    store_id

    String(64)

    Store ID. For taxicabs and limousines (MCC 4121), use the license plate number.

    N

    23372327348

    store_name

    String(256)

    Store name. For taxicabs and limousines (MCC 4121), use the license plate number.

    N

    StoreName

    store_country

    String(2)

    Store registration country. A 2-letter code defined in ISO 3166.

    N

    HK

    store_address

    String(330)

    Registered address of the secondary merchant.

    N

    StoreAddress

    store_industry

    String(4)

    A 4-digit MCC code of the store. See MCC list for details.

    N

    4121

    internal_store_photo

    String(256)

    URL of the store interior photo.

    Y

    URL

    external_storefront_photo

    String(256)

    URL of the store exterior photo.

    Y

    URL

    extend_params

    String(1024)

    Taxi driver information in JSON format. JSON keys are fixed as operation_id, contact_way, and contact_person. Up to 10 drivers can be passed. Note: The value of each operation_id must be unique. This field cannot be updated incrementally. Pass this field the first time you register a driver; otherwise you cannot add it later when you update the driver information.

    Y

    [{"operation_id": "1000332", "contact_way": "13892921232", "contact_person": "driverName1"}, {"operation_id": "1082943492", "contact_way": "15839232232", "contact_person": "driverName2"}]

    Extend parameters

    Parameter

    Type (bytes)

    Description

    Optional

    Example

    operation_id

    String(64)

    Taxi driver ID. Use only numbers and letters.

    N

    1082943492

    contact_way

    String(256)

    Phone number of the taxi driver. Use “+”, numbers, spaces, and “-“.

    Y

    15839232232

    contact_person

    String(64)

    Taxi driver name

    N

    driverName2

    Some parameters of String type have no length limit and the system will not check their length.

    Sync Response

    The response is in XML format.

    Parameter

    Type (bytes)

    Description

    Optional

    Example

    Basic Parameter

    is_success

    String

    Request succeeds or not. Successful request does not mean the business request is accepted and processed successfully.

  • T means success
  • F means failure
  • N

    T

    sign_type

    String

    The value can be one of DSA, RSA, or MD5. Uppercase must be used.

    Y

    MD5

    sign

    String

    See Signature Algorithms.

    Y

    3afc92ac4708425ab74ecb2c4e58ef56

    error

    String

  • If the request succeeds, this parameter does not exist.
  • When a request fails, the value of this parameter is the error code. See Access Errors and System Errors for details.
  • Y

    PARAM_ILLEGAL

    The synchronous response may have more parameters due to the upgrade on the Alipay server side. You can ignore parameters that are not included in this API document.

    Samples

    Request Examples

    String to be signed

    extend_params=[{"operationId": "xxx", "contactWay": "xxxx", "contactPerson": "xxxx"}, {"operationId": "xxx", "contactWay": "xxxx", "contactPerson": "xxxx"}];&external_storefront_photo=https://www.baidu.com/img/bd_logo1.png&internal_store_photo=https://www.baidu.com/img/bd_logo1.png&partner=2088101147261746&secondary_merchant_id=4318163847915537&secondary_merchant_name=yihan上线商户haha01&sendFormat=normal&service=alipay.overseas.secmerchant.offline.maintain&store_address=xxxxx&store_country=HK&store_id=1263712631132&store_industry=4082

    Generated URL

    http://www.sit.alipay.net/cooperate/gateway.do?store_industry=4082&sign_type=MD5&store_id=1263712631132&store_country=HK&sendFormat=normal&sign=ffd00d45aed71fb28aa8bb8d0838cb5e&secondary_merchant_name=yihan%C9%CF%CF%DF%C9%CC%BB%A7haha01&external_storefront_photo=https%3A%2F%2Fwww.baidu.com%2Fimg%2Fbd_logo1.png&secondary_merchant_id=4318163847915537&service=alipay.overseas.secmerchant.offline.maintain&internal_store_photo=https%3A%2F%2Fwww.baidu.com%2Fimg%2Fbd_logo1.png&partner=2088101147261746&store_address=xxxxx&extend_params=%5B%7B%22operationId%22%3A+%22xxx%22%2C++%22contactWay%22%3A+%22xxxx%22%2C+%22contactPerson%22%3A+%22xxxx%22%7D%2C+%7B%22operationId%22%3A+%22xxx%22%2C++%22contactWay%22%3A+%22xxxx%22%2C+%22contactPerson%22%3A+%22xxxx%22%7D%5D%3B

    The sample is for reference only. Alipay gateway is https://mapi.alipay.com/gateway.do?.

    Response Examples

    Request succeeds and the registration is successful:

    
    <?xml version="1.0" encoding="utf-8"?>
    <alipay>
        <is_success>T</is_success>
        <request>
            <param name="secondary_merchant_id">2015051446800462</param>
            <param name="secondary_merchant_name">hanguo</param>
            <param name="sign_type">MD5</param>
            <param name="secondary_merchant_industry">4378</param>
            <param name="sign">2118ac8fad6bc1d9e88a6cd017c18d37</param>
            <param name="register_country">CA</param>
            <param name="_input_charset">UTF-8</param>
            <param name="register_address">HANGZHOU</param>
            <param name="service">alipay.overseas.secmerchant.offline.maintain</param>
            <param name="site_infos">[{"site_type":"WEB","site_url":"https://alipay.com","site_name":"websit"}]</param>
            <param name="partner">2088101142878662</param>
            <param name="timestamp">2018-08-03 00:28:32</param>
        </request>
    <response>
        <alipay>
            <result_code>SUCCESS</result_code>
        </alipay>
    </response>
        <sign>3afc92ac4708425ab74ecb2c4e58ef56</sign>
        <sign_type>MD5</sign_type>
    </alipay>
    

    Request fails or the access data are wrong:

    
    <?xml version="1.0" encoding="utf-8"?>
    <alipay>
        <is_success>F</is_success>
        <error>ILLEGAL_SIGN</error>
    </alipay>
    

    Error Codes

    Business Logic Errors

    Returned result

    Description

    Solution

    MCC_CAN_NOT_MODIFY

    The MCC passed in cannot match the original MCC.

    Please ensure that the passed MCC is the same as the original MCC.

    MCC_TYPE_ILLEGAL

    The MCC is invalid.

    Modify the MCC type and then try again.

    PARAM_ILLEGAL

    The parameter is illegal. The parameter is too long, parameter format is wrong, or a required parameter is not passed.

    Please check and rectify the parameter according to the API document.

    SYSTEM_ERROR

    Alipay system error

    Please try again later.

    LBS_GEOGRAPHIC_INFORMATION_INVALID

    The address cannot match the country/region, or the address cannot be located.

    Please ensure that the address is valid.

    CATEGORY_NOT_SUPPORT_DRIVER

    When store_industry is 4121 and extend_params is not passed when you request in the first time, then this error occurs when you update the store information and pass the driver information.

    Please remove the driver information from the extend_param.

    Access Errors

    Returned result

    Description

    ILLEGAL_SIGN

    Illegal signature

    ILLEGAL_DYN_MD5_KEY

    Dynamic key information is incorrect

    ILLEGAL_ENCRYPT

    Encryption is incorrect

    ILLEGAL_ARGUMENT

    Incorrect parameter

    ILLEGAL_SERVICE

    Service parameter is incorrect

    ILLEGAL_USER

    User ID is incorrect

    ILLEGAL_PARTNER

    Incorrect Partner ID

    ILLEGAL_EXTERFACE

    Interface configuration is incorrect

    ILLEGAL_PARTNER_EXTERFACE

    Partner's interface information is incorrect

    ILLEGAL_SECURITY_PROFILE

    Matching private key configuration is not found

    ILLEGAL_AGENT

    Agency ID is incorrect

    ILLEGAL_SIGN_TYPE

    The signature type is incorrect

    ILLEGAL_CHARSET

    The character set is illegal

    HAS_NO_PRIVILEGE

    Has no right to visit

    INVALID_CHARACTER_SET

    The character set is invalid

    System Errors

    When system error occurs, please contact Global Merchant Technical Support .

    Returned result

    Description

    SYSTEM_ERROR

    Alipay system error

    SESSION_TIMEOUT

    Session timeout

    ILLEGAL_TARGET_SERVICE

    Wrong target service

    ILLEGAL_ACCESS_SWITCH_SYSTEM

    Merchant is not allowed to visit system of this type

    EXTERFACE_IS_CLOSED

    The interface is closed

    客服小机器人

    NEED HELP ?