Public parameters
Request URL
https://baseUrl/v3/2020/pay/{mchid}/{appid}
Request Path parameter
parameters | must | type | length | desc |
---|
mchid | Yes | string | 32 | # |
appid | Yes | string | 32 | # |
- example
- https://baseUrl/v3/2020/pay/MCH88888/APP100
Method
- Content-type: application/x-www-form-urlencoded; charset=UTF-8
Signature string
payment signature
SHA1(action_type+out_trade_no+amt+currency+ip+nonce_str+key)
retrieve signature
SHA1(action_type+out_trade_no+nonce_str+key)
refund signature
SHA1(action_type+txid+refund_amt+refund_reason+nonce_str+key)
Request Parameters
Payment parameters
parameters | must | type | length | desc |
---|
action_type | Yes | string | 10 | PAY or PAY_3DS |
out_trade_no | Yes | string | 255 | order no |
amt | Yes | string | 12,2 | transaction amount |
currency | Yes | string | 3 | transaction currency |
ip | Yes | string | 255 | # |
nonce_str | Yes | string | 16 | 16 characters or fewer or fewer. For more information |
sign | Yes | string | 255 | Please see the Signature string |
card.num | Yes | string | 255 | # |
card.year | Yes | string | 4 | # |
card.month | Yes | string | 2 | # |
card.cvv | Yes | string | 4 | # |
customer.first_name | Yes | string | 255 | # |
customer.last_name | Yes | string | 255 | # |
customer.country | Yes | string | 2 | Please see the Country Code |
customer.state | Yes | string | 255 | # |
customer.city | Yes | string | 255 | # |
customer.address | Yes | string | 255 | # |
customer.postcode | Yes | string | 255 | # |
customer.email | Yes | string | 255 | # |
customer.mobile | Yes | string | 255 | # |
shipping.first_name | Yes | string | 255 | # |
shipping.last_name | Yes | string | 255 | # |
shipping.country | Yes | string | 2 | Please see the Country Code |
shipping.state | Yes | string | 255 | # |
shipping.city | Yes | string | 255 | # |
shipping.address | Yes | string | 255 | # |
shipping.postcode | Yes | string | 255 | # |
shipping.email | Yes | string | 255 | # |
shipping.mobile | Yes | string | 255 | # |
goods[0].name | Yes | string | 255 | goods name |
goods[0].quantity | Yes | string | 9 | goods quantity |
goods[0].price | Yes | string | 12,2 | goods price |
callback_url | Yes[3DS] | string | | Asynchronous notification URL for transaction orders |
redirect_url | Yes[3DS] | string | | Redirect URL for transaction orders |
Example
<?php
$request = new HttpRequest();
$request->setUrl('https://baseUrl/v3/2020/pay/MCH88888/APP100');
$request->setMethod(HTTP_METH_POST);
$request->setContentType('application/x-www-form-urlencoded');
$request->setPostFields([
'out_trade_no' => '4086d438-f2b1-eb59-7943',
'amt' => '1111.00',
'currency' => 'USD',
'ip' => '1.1.1.1',
'nonce_str' => '58k5EZTmB5ZnSTPn',
'sign' => '40b00f6898f66ee74d1d12a8228019f00508665a',
'card.num' => '4242424242424242',
'card.year' => '2023',
'card.month' => '12',
'card.cvv' => '123',
'customer.first_name' => 'Alex',
'customer.last_name' => 'Bob',
'customer.country' => 'US',
'customer.state' => 'NY',
'customer.city' => 'New York',
'customer.address' => 'Address 123',
'customer.postcode' => '313222',
'customer.email' => 'alexx@gmail.com',
'customer.mobile' => '45671345',
'shipping.first_name' => 'Alex',
'shipping.last_name' => 'Bob',
'shipping.country' => 'US',
'shipping.state' => 'NY',
'shipping.city' => 'New York',
'shipping.address' => 'Address 123',
'shipping.postcode' => '313222',
'shipping.email' => 'alexx@gmail.com',
'shipping.mobile' => '45671345',
'goods[0].name' => 'cap',
'goods[0].quantity' => '1',
'goods[0].price' => '100.00',
'action_type' => 'PAY',
'callback_url' => 'https://www.shop.com/callback',
'redirect_url' => 'https://www.shop.com/redirect'
]);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
Payment Response example
{
"out_trade_no": "acb5c930-5a77-74a6-48d0",
"txid": "S1578594295660978176",
"amt": "100.00",
"ccy": "USD",
"code": "0000",
"msg": "Payment Success",
"bill": "yourwebsite.com",
"form_url": "https://www.3ds.com/to"
}
Payment Response parameter
parameters | must | type | desc |
---|
out_trade_no | Yes | string | # |
txid | Yes | string | # |
amt | Yes | string | # |
ccy | Yes | string | # |
code | Yes | string | # |
msg | Yes | string | # |
bill | Yes | string | # |
3D Secure notification parameters/Redirect for transaction parameters
parameters | type | desc |
---|
tradeNo | string | # |
orderNo | string | # |
amount | string | # |
currency | string | # |
code | string | # |
msg | string | # |
sign | string | SHA256(tradeNo+orderNo+amount+currency+code+msg+key) |
Returning an HTTP status of 200 indicates successful receipt of the notification
Retrieve parameters
parameters | must | type | length | desc |
---|
action_type | Yes | string | 10 | RETRIEVE |
out_trade_no | Yes | string | 255 | # |
nonce_str | Yes | string | 255 | # |
sign | Yes | string | 255 | # |
Example
<?php
$request = new HttpRequest();
$request->setUrl('https://baseUrl/v3/2020/pay/MCH88888/APP100');
$request->setMethod(HTTP_METH_POST);
$request->setContentType('application/x-www-form-urlencoded');
$request->setPostFields([
'out_trade_no' => '4086d438-f2b1-eb59-7943',
'nonce_str' => '58k5EZTmB5ZnSTPn',
'sign' => '40b00f6898f66ee74d1d12a8228019f00508665a',
'action_type' => 'RETRIEVE'
]);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
Retrieve Response example
{
"out_trade_no": "2f9876bb-ee66-2de3-4ef4",
"txid": "S1578617547481456640",
"amt": "100.00",
"ccy": "USD",
"code": "0000",
"msg": "Payment Success"
}
Retrieve Response parameter
parameters | must | type | desc |
---|
out_trade_no | Yes | string | # |
txid | Yes | string | # |
amt | Yes | string | # |
ccy | Yes | string | # |
code | Yes | string | # |
msg | Yes | string | # |
Refund parameters
parameters | must | type | length | desc |
---|
action_type | Yes | string | 10 | REFUND |
txid | Yes | string | 255 | # |
refund_amt | Yes | string | 12,2 | # |
refund_reason | Yes | string | 255 | # |
nonce_str | Yes | string | 255 | # |
sign | Yes | string | 255 | # |
Example
<?php
$request = new HttpRequest();
$request->setUrl('https://baseUrl/v3/2020/pay/MCH88888/APP100');
$request->setMethod(HTTP_METH_POST);
$request->setContentType('application/x-www-form-urlencoded');
$request->setPostFields([
'nonce_str' => '58k5EZTmB5ZnSTPn',
'sign' => '40b00f6898f66ee74d1d12a8228019f00508665a',
'action_type' => 'REFUND',
'txid' => 'S1578568969333547008',
'refund_amt' => '100.00',
'refund_reason' => 'test'
]);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
Refund Response example
{
"out_trade_no": "b2948e87-3b4b-8774-7aa3",
"txid": "S1578568969333547008",
"code": "2007",
"msg": "Refund apply success"
}
Refund Response parameter
parameters | must | type | desc |
---|
out_trade_no | Yes | string | # |
txid | Yes | string | # |
code | Yes | string | # |
msg | Yes | string | # |
Appendix
Country Code
Country | Code |
---|
Afghanistan | AF |
ÅlandIslands | AX |
Albania | AL |
Algeria | DZ |
AmericanSamoa | AS |
Andorra | AD |
Angola | AO |
Anguilla | AI |
Antarctica | AQ |
AntiguaandBarbuda | AG |
Argentina | AR |
Armenia | AM |
Aruba | AW |
Australia | AU |
Austria | AT |
Azerbaijan | AZ |
Bahamas | BS |
Bahrain | BH |
Bangladesh | BD |
Barbados | BB |
Belarus | BY |
Belgium | BE |
Belize | BZ |
Benin | BJ |
Bermuda | BM |
Bhutan | BT |
Bolivia(PlurinationalStateof) | BO |
Bonaire,SintEustatiusandSaba[d] | BQ |
BosniaandHerzegovina | BA |
Botswana | BW |
BouvetIsland | BV |
Brazil | BR |
BritishIndianOceanTerritory | IO |
BruneiDarussalam | BN |
Bulgaria | BG |
BurkinaFaso | BF |
Burundi | BI |
CaboVerde | CV |
Cambodia | KH |
Cameroon | CM |
Canada | CA |
CaymanIslands | KY |
CentralAfricanRepublic | CF |
Chad | TD |
Chile | CL |
China | CN |
ChristmasIsland | CX |
Cocos(Keeling)Islands | CC |
Colombia | CO |
Comoros | KM |
Congo | CG |
Congo,DemocraticRepublicofthe | CD |
CookIslands | CK |
CostaRica | CR |
Côted’Ivoire | CI |
Croatia | HR |
Cuba | CU |
Curaçao | CW |
Cyprus | CY |
Czechia | CZ |
Denmark | DK |
Djibouti | DJ |
Dominica | DM |
DominicanRepublic | DO |
Ecuador | EC |
Egypt | EG |
ElSalvador | SV |
EquatorialGuinea | GQ |
Eritrea | ER |
Estonia | EE |
Eswatini | SZ |
Ethiopia | ET |
FalklandIslands(Malvinas) | FK |
FaroeIslands | FO |
Fiji | FJ |
Finland | FI |
France | FR |
FrenchGuiana | GF |
FrenchPolynesia | PF |
FrenchSouthernTerritories | TF |
Gabon | GA |
Gambia | GM |
Georgia | GE |
Germany | DE |
Ghana | GH |
Gibraltar | GI |
Greece | GR |
Greenland | GL |
Grenada | GD |
Guadeloupe | GP |
Guam | GU |
Guatemala | GT |
Guernsey | GG |
Guinea | GN |
Guinea-Bissau | GW |
Guyana | GY |
Haiti | HT |
HeardIslandandMcDonaldIslands | HM |
HolySee | VA |
Honduras | HN |
HongKong | HK |
Hungary | HU |
Iceland | IS |
India | IN |
Indonesia | ID |
Iran(IslamicRepublicof) | IR |
Iraq | IQ |
Ireland | IE |
IsleofMan | IM |
Israel | IL |
Italy | IT |
Jamaica | JM |
Japan | JP |
Jersey | JE |
Jordan | JO |
Kazakhstan | KZ |
Kenya | KE |
Kiribati | KI |
Korea(DemocraticPeople’sRepublicof) | KP |
Korea,Republicof | KR |
Kuwait | KW |
Kyrgyzstan | KG |
LaoPeople’sDemocraticRepublic | LA |
Latvia | LV |
Lebanon | LB |
Lesotho | LS |
Liberia | LR |
Libya | LY |
Liechtenstein | LI |
Lithuania | LT |
Luxembourg | LU |
Macao | MO |
Madagascar | MG |
Malawi | MW |
Malaysia | MY |
Maldives | MV |
Mali | ML |
Malta | MT |
MarshallIslands | MH |
Martinique | MQ |
Mauritania | MR |
Mauritius | MU |
Mayotte | YT |
Mexico | MX |
Micronesia(FederatedStatesof) | FM |
Moldova,Republicof | MD |
Monaco | MC |
Mongolia | MN |
Montenegro | ME |
Montserrat | MS |
Morocco | MA |
Mozambique | MZ |
Myanmar | MM |
Namibia | NA |
Nauru | NR |
Nepal | NP |
Netherlands | NL |
NewCaledonia | NC |
NewZealand | NZ |
Nicaragua | NI |
Niger | NE |
Nigeria | NG |
Niue | NU |
NorfolkIsland | NF |
NorthMacedonia | MK |
NorthernMarianaIslands | MP |
Norway | NO |
Oman | OM |
Pakistan | PK |
Palau | PW |
Palestine,Stateof | PS |
Panama | PA |
PapuaNewGuinea | PG |
Paraguay | PY |
Peru | PE |
Philippines | PH |
Pitcairn | PN |
Poland | PL |
Portugal | PT |
PuertoRico | PR |
Qatar | QA |
Réunion | RE |
Romania | RO |
RussianFederation | RU |
Rwanda | RW |
SaintBarthélemy | BL |
SaintHelena,AscensionandTristandaCunha[e] | SH |
SaintKittsandNevis | KN |
SaintLucia | LC |
SaintMartin(Frenchpart) | MF |
SaintPierreandMiquelon | PM |
SaintVincentandtheGrenadines | VC |
Samoa | WS |
SanMarino | SM |
SaoTomeandPrincipe | ST |
SaudiArabia | SA |
Senegal | SN |
Serbia | RS |
Seychelles | SC |
SierraLeone | SL |
Singapore | SG |
SintMaarten(Dutchpart) | SX |
Slovakia | SK |
Slovenia | SI |
SolomonIslands | SB |
Somalia | SO |
SouthAfrica | ZA |
SouthGeorgiaandtheSouthSandwichIslands | GS |
SouthSudan | SS |
Spain | ES |
SriLanka | LK |
Sudan | SD |
Suriname | SR |
SvalbardandJanMayen[f] | SJ |
Sweden | SE |
Switzerland | CH |
SyrianArabRepublic | SY |
Taiwan,ProvinceofChina | TW |
Tajikistan | TJ |
Tanzania,UnitedRepublicof | TZ |
Thailand | TH |
Timor-Leste | TL |
Togo | TG |
Tokelau | TK |
Tonga | TO |
TrinidadandTobago | TT |
Tunisia | TN |
Turkey | TR |
Turkmenistan | TM |
TurksandCaicosIslands | TC |
Tuvalu | TV |
Uganda | UG |
Ukraine | UA |
UnitedArabEmirates | AE |
UnitedKingdomofGreatBritainandNorthernIreland | GB |
UnitedStatesofAmerica | US |
UnitedStatesMinorOutlyingIslands[h] | UM |
Uruguay | UY |
Uzbekistan | UZ |
Vanuatu | VU |
Venezuela(BolivarianRepublicof) | VE |
VietNam | VN |
VirginIslands(British) | VG |
VirginIslands(U.S.) | VI |
WallisandFutuna | WF |
WesternSahara | EH |
Yemen | YE |
Zambia | ZM |
Zimbabwe | ZW |