Latest update time:2020.01.08 Release notes
the merchant server first calls the [Order Placement API] to generate a prepayment order, and signs the obtained parameter prepay_id again before transferring it to the app to initiate payment.
Applicable object:Common mode Institutional mode
This API signature has no background interface interaction, and the data in the list shall be signed
the client request field (Note: The following field names are case sensitive):
Name | Variable Name | Type | Required | Description |
---|---|---|---|---|
APPID | appid | string[(32) | Yes | APPID corresponding to the mobile app applied by the merchant on the WeChat Open Platform Example:wx8888888888888888 |
Merchant ID | partnerid | string(32) | Yes | Merchant ID assigned by WeChat Pay. Example:1900000109 |
Prepayment transaction session | prepayid | string(64) | Yes | Prepayment session ID generated by WeChat, which is used in subsequent API calls. The value is valid for 2 hours. Example: WX1217752501201407033233368018 |
An extension string for order details | package | string(128) | Yes | Specify as the static value “Sign=WXPay” Example:Sign=WXPay |
Random string | noncestr | string(32) | Yes | Random string, not longer than 32 digits. It is recommended to use the random number generation algorithm. Example: 5K8264ILTKCH16CQ2502SI8ZNMTM67VS |
Timestamp | timestamp | string(10) | Yes | The current time. For details, see timestamp rules. Example:1412000000 |
Signature | sign | string(256) | Yes | Signature,Use fields appId、timeStamp、nonceStr、prepayidCalculate the signature value Note:Signature type,Default is RSA. Example:oR9d8PuhnIc+YZ8cBHFCwfgpaK9qZLhLw4jq\/xDg== |
There are four lines in the signature string, and each line is a parameter. Each line ends with \n (Newline character; the ASCII code value is 0x0A), and even the last line shall ends with \n. If the parameter itself ends with \n, an additional \n is also required
Fields and formats involved in the signature:
Official Account ID
Timestamp
Random string
An extension string for order details
Example of a string to be signed:
wx8888888888888888
1414561699
5K8264ILTKCH16CQ2502SI8ZNMTM67VS
WX1217752501201407033233368018
The signature method is the same as the signature for request data. Use the merchant private key to sign the string using the SHA256-with-RSA signature algorithm, and obtain the signature value through Base64 encoding.
$ echo -n -e \
"wx8888888888888888\n1414561699\n5K8264ILTKCH16CQ2502SI8ZNMTM67VS\nWX1217752501201407033233368018\n" \
| openssl dgst -sha256 -sign apiclient_key.pem \
| openssl base64 -A
uOVRnA4qG/MNnYzdQxJanN+zU+lTgIcnU9Bx7cob8H/4nLBiCwIUFluw==
PayReq *request = [[[PayReq alloc] init] autorelease];
request.partnerId = @"10000100";
request.prepayId= @"1101000000140415649af9fc314aa427";
request.package = @"Sign=WXPay";
request.nonceStr= @"a462b76e7436e98e0ed6e13c64b4fd1c";
request.timeStamp= @"1397527777";
request.sign= @"oR9d8PuhnIc+YZ8cBHFCwfgpaK9gd7vaRvkYD7rthRAZ\/X+QBhcCYL21N7cHCTUxbQ+EAt6Uy+lwSN22f5YZvI45MLko8Pfso0jm46v5hqcVwrk6uddkGuT+Cdvu4WBqDzaDjnNa5UK3GfE1Wfl2gHxIIY5lLdUgWFts17D4WuolLLkiFZV+JSHMvH7eaLdT9N5GBovBwu5yYKUR7skR8Fu+LozcSqQixnlEZUfyE55feLOQTUYzLmR9pNtPbPsu6WVhbNHMS3Ss2+AehHvz+n64GDmXxbX++IOBvm2olHu3PsOUGRwhudhVf7UcGcunXt8cqNjKNqZLhLw4jq\/xDg==";
[WXApi sendReq:request];
Customer Service Tel
Business Development
9:00-18:00
Monday-Friday GMT+8
Technical Support
WeChat Pay Global
ICP证