1.1 Audience and Purpose
This guide is for application developers who want to integrate Motion Pay Technology payment gateway. Once integrated, the merchant’s site will be able to get the payment by Alipay and Wechat.
1.2 Platform
The sample code is in a JAVA project build by JDK 8. You can import it to Eclipse to run it.
Please download JDK 8 and install it to the default folder.
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Please download IDE for Java EE Developers Oxygen packages:
http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/oxygenr
Save the sample SDK into your workspace and import it to Eclipse. Then you should be able to run the code in the src folder as Java Application.
The request is using HTTP POST to send to the gateway URL, the result is returned in a JSON String encoded by UTF-8.
The interface version is v1_1. The URL will looks like this, XXXXX need to replaced with the function name:
http://motionpaytech.com/wizarposStatement-server/{version}/pay/XXXXX
All the post request need to have mid in the parameter.
Mid and RSA key:
- RSA Key: Please contact Motion Pay for it.
- Mid for testing: 100305100000002
Work flow
The merchant server needs put all the required parameters into a JSON string, encrypt it with the public key we provided, then send the request by POST the specified URL. After you get the response from this URL, you can decrypt it with the same key to get a JSON string with the result in parameters.
Please try to run PrePayTest.java as Java Application to test this function. The code is in motionPay\huishangpay\src\com\wizarpos\pay\test folder.
The URL for the request:
http://motionpaytech.com/wizarposStatement-server/v1_1/pay/prePay
The QR code generated will expire in 3 minutes. After you get the QR code URL, you can use this website to generate it into an image.
http://www.qr-code-generator.com/
Then use your wechat or alipay to scan the image to finish the payment.
The payment result will be sent to the merchant asynchronously with the POST method by the URL in the “return_url” parameter.
The request and response JSON string is encrypted by RSA.
Request Parameters:
Parameter Name | Type | Required | Description |
mid | String | Yes | Motion Pay Merchant Id |
pay_channel | String | Yes | Payment Channel
Alipay: A Wechat: W |
terminal_no | String | Yes | Terminal number |
goods_info | String | Yes | Product name (no more than 128 characters no space) |
out_trade_no | String | Yes | Merchant order number (no more than 30 numbers) |
spbill_create_ip | String | No | The IP of the merchant server (not required) |
total_fee | Integer | Yes | Amount of payment in CAD cents
For example: 113 means $1.13 |
Version | String | Yes | Version Number (“1.1”) |
return_url | String | Yes | Call back URL for the payment result. Please check chapter 3 for the parameters.
For example the success payment will send this JSON string in the request for the call back URL: {“code”:”0″,”message”:”success”} |
The return parameters from the server:
Parameter Name | Type | Required | Description |
Code | String | Yes | Return code. See chapter 3 for more detail. |
message | String | Yes | Return message |
content | String | Yes | Return content (Only Returned when the code=0)
(Encrypted by RSA) |
mid | Yes | Motion Pay Merchant ID | |
pay_channel | String | Yes | Pay channel:
Alipay: A Wechat: W |
out_trade_no | String | Yes | Motion Pay Transaction Id |
transaction_id | String | Yes | Motion Pay Transaction Id |
qrcode | String | Yes | QR code URL address for payment |
Sample Request Parameters:
{
“mid”: “100105100000173”, “pay_channel”: “A”, “terminal_no”: “WP14521000000010” “goods_info”: “test_payment”, “out_trade_no”: ” 2015122910573300010″, “total_fee”: “1”, “version”: “1.1”, “return_url”: “http://” } |
Response:content was encrypted
{
“code”: “0”, “message”: “success”, “content”: “22559763c53560dbbe110c7f64963221c36508bbd028a60ba876e9ff970e36cf779f6aab79fa4fa2d405c124fd443f6be00f41806e0989c07255ddf4491420ed46346e767bb94c1d803668a450de9b3fff3a51068f591e1ddf90043aac2f7c5209109a99fe456adeb97cf679372431e5f7dac6b6c029de3a4ff15f86b9c4c33748fe2c81d742ee2760382f82682e4da0deb4cae1b5701a830c77edd914ee2f8d6fffc05ee2bd0a86469a139465137dcb8cb07147e6bc965508bce2fa182d53ff02b3565b457f4d3a25cb90190f4cbc538f830772d296d4754bce20d34d11c691788228a383fbd2cd9032fc7ca44c6603440e447c16a522dc0bf5ca0f15857a0e” //content was encrypted } |