直连-虚拟产品
网关地址
POST
https://sandbox.j-pay.net/pay_index
测试账号
商户号:10153
ApiKey: 9k8rx7j0fxa7deb250huvghfbbjnu23h
测试卡号
卡号 | 有效期 | cvv | |
---|---|---|---|
4242424242424242 | 12 2027 | 123 | 测试成功 |
4000000000001018 | 12 2027 | 123 | 测试失败 |
4141414141414141 | 12 2027 | 123 | 测试跳转 |
请求参数
参数名称 | 类型 | 是否必填 | 参与签名 | 参数说明 |
---|---|---|---|---|
pay_memberid | String | 是 | 是 | 平台分配商户号 |
pay_orderid | String | 是 | 是 | 上送订单号唯一, 字符长度 20 |
pay_applydate | String | 是 | 是 | 提交时间, 时间格式:2016-12-26 18:18:18 |
pay_bankcode | String | 是 | 是 | 银行编码, 参考后续说明:901 |
pay_notifyurl | String | 是 | 是 | 服务端返回地址.(POST 返回数据) |
pay_callbackurl | String | 是 | 是 | 页面跳转返回地址(POST 返回数据) |
pay_amount | String | 是 | 是 | 商品金额 |
pay_md5sign | String | 是 | 否 | 请看 MD5 签名字段格式 |
pay_currency | String | 是 | 否 | 币种代码,大写字母 (USD) |
pay_url | String | 是 | 否 | 网站URL, 需提交审核、带http(s):// |
pay_cardno | String | 是 | 否 | 卡号 |
pay_cardmonth | String | 是 | 否 | 2位月份 (02) |
pay_cardyear | String | 是 | 否 | 4位年份 (2023) |
pay_cardcvv | String | 是 | 否 | cvv |
+pay_productname | String | 是 | 否 | 商品信息,参数由下列一组数据,通过JSON格式组成,注意参数名大小写敏感。本字段以JSON数组字符串来填值。示例:[{"sku":"123456789","productName":"MacBook Pro","productImage":"产品图片地址","attributes":"Size:US8 Color:blue","price":"11000.00","quantity":"1"},{"sku":"9876543231","productName":"IPhone 12","productImage":"产品图片地址","attributes":"Size:US8 Color:blue","price":"11000.00","quantity":"1"}] |
「sku | String | 否 | 否 | 商品编号 (唯一) |
「productName | String | 是 | 否 | 产品名称 |
「productImage | String | 否 | 否 | 产品图片URL |
「attributes | String | 否 | 否 | 产品属性 |
「price | String | 是 | 否 | 产品价格 |
「quantity | String | 是 | 否 | 产品数量 |
pay_firstname | String | 是 | 否 | 账单名字 |
pay_lastname | String | 是 | 否 | 账单姓氏 |
pay_street_address1 | String | 否 | 否 | 账单地址1 |
pay_street_address2 | String | 否 | 否 | 账单地址2 |
pay_city | String | 否 | 否 | 账单城市 |
pay_postcode | String | 否 | 否 | 账单邮编 |
pay_state | String | 否 | 否 | 账单州/省 |
pay_country_iso_code_2 | String | 是 | 否 | 账单国家 |
pay_email_address | String | 是 | 否 | 账单邮箱 |
pay_telephone | String | 是 | 否 | 账单电话 |
shipping_firstname | String | 否 | 否 | 收件名字 |
shipping_lastname | String | 否 | 否 | 收件姓氏 |
shipping_street_address1 | String | 否 | 否 | 收件地址1 |
shipping_street_address2 | String | 否 | 否 | 收件地址2 |
shipping_city | String | 否 | 否 | 收件城市 |
shipping_state | String | 否 | 否 | 收件州/省 |
shipping_postcode | String | 否 | 否 | 收件邮编 |
shipping_country_iso_code_2 | String | 否 | 否 | 收件国家 |
shipping_telephone | String | 否 | 否 | 收件电话 |
pay_ip | String | 是 | 否 | 用户IP地址 |
pay_useragent | String | 是 | 否 | 用户浏览器信息 |
pay_language | String | 是 | 否 | 语言 |
system | String | 是 | 否 | 网站系统, 如:Shopyy/Shopline |
请求支付返回参数
参数名称 | 类型 | 参数说明 |
---|---|---|
status | Int | status = 0:SUCCESS status = 1:3d支付跳转 status = 2 :failed |
msg | String | 下单成功 or 下单失败 |
url | String | 3d支付跳转地址 |
返回示例
Transaction successful : {
"status": 0,
"msg": "transaction success"
}
Transaction failed : {
"status": 2,
"msg": "transaction failed"
}
Redirect/3ds payment successful : {
"status": 1,
"url": "redirectUrl"
}
3DS验证
跳转支付和直接信用卡支付需要3DS验证
同步返回:(application/x-www-form-urlencoded)
参数名称 | 类型 | 是否必填 | 参数说明 |
---|---|---|---|
paymentStatus | String | 是 | Succeeded: 成功 Fail:失败 Processing:处理中 |
orderID | String | 是 | 订单号 |
示例
https://www.xxxx.com/callback.html?paymentStatus=succeeded&orderID=1001
异步返回:(application/x-www-form-urlencoded)
参数名称 | 类型 | 是否必填 | 参数说明 |
---|---|---|---|
memberid | String | 是 | 商户 ID |
orderid | String | 是 | 商户订单号 |
amount | String | 是 | 提交的订单金额 |
true_amount | String | 是 | 买家实际付款的金额 |
transaction_id | String | 是 | 平台订单号 |
returncode | String | 是 | “00” 为成功 "2":为失败 |
datetime | String | 是 | 交易时间,格式:20220419000114 |
sign | String | 否 | 请看验证签名字段格式 |
attach | String |
Array{
["memberid"]=>
string(5) "10012"
["orderid"]=>
string(7) "7758292"
["transaction_id"]=>
string(20) "20230117104641499957"
["amount"]=>
string(5) "85.95"
["true_amount"]=>
string(5) "85.95"
["datetime"]=>
string(14) "20230117111809"
["returncode"]=>
string(2) "00"
["sign"]=>
string(32) "48CF5D99A2ADE25DCEF73BC1B1136B9E"
["attach"]=>
string(0) ""
}
Demo
- Javascript
- Php
- Python
import { md5 } from "js-md5";
import axios from "axios";
const KEY = "9k8rx7j0fxa7deb250huvghfbbjnu23h";
const MEMBER_ID = "10153";
let query = {
pay_memberid: MEMBER_ID,
pay_orderid: "O" + Date.now().valueOf(),
pay_applydate: "2024-07-18 06:22:55",
pay_bankcode: "901",
pay_notifyurl: "https://www.google.com",
pay_callbackurl: "https://www.google.com",
pay_amount: "6",
};
let signData = [];
Object.keys(query)
.sort()
.forEach((key) => signData.push(`${key}=${query[key]}`));
signData.push(`key=${KEY}`);
Object.assign(query, {
pay_md5sign: md5(signData.join("&")).toUpperCase(),
pay_url: "https://www.google.com",
pay_currency: "USD",
pay_cardno: "4242424242424242",
pay_cardmonth: "08",
pay_cardyear: "2026",
pay_cardcvv: "123",
pay_productname: JSON.stringify([
{
productName: "Game Coin",
price: "6.00",
quantity: " 1",
}
]),
pay_firstname: "Rodrigo",
pay_lastname: "lopez",
pay_country_iso_code_2: "CL",
pay_email_address: "[email protected]",
pay_telephone: "+920508435",
pay_ip: "186.156.221.158",
pay_useragent:
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.43",
pay_language: "zh",
system: "shopyy",
});
axios
.request({
url: "https://sandbox.j-pay.net/pay_index",
method: "post",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
data: query,
})
.then(({ data }) => {
console.log("success", data);
})
.catch((error) => {
console.log("error", error);
});
$url = 'https://sandbox.j-pay.net/pay_index';
$memberid = 10153;
$secretKey = '9k8rx7j0fxa7deb250huvghfbbjnu23h';
$data = [
'pay_memberid' => $memberid,
'pay_orderid' => 'O' . date('YmdHis', time()),
'pay_applydate' => date('Y-m-d H:i:s', time()),
'pay_bankcode' => '901',
'pay_notifyurl' => 'https://www.google.com',
'pay_callbackurl' => 'https://www.google.com',
'pay_amount' => '10.00',
];
ksort($data);
$md5str = "";
foreach ($data as $key => $val) {
if (!empty($val)) {
$md5str = $md5str . $key . "=" . $val . "&";
}
}
$sign_str = $md5str . 'key=' . $secretKey;
$sign = strtoupper(md5($sign_str));
$data = array_merge($data, [
'pay_md5sign' => $sign,
'pay_url' => 'https://www.google.com',
'pay_currency' => 'USD',
'pay_cardno' => '4242424242424242',
'pay_cardmonth' => '08',
'pay_cardyear' => '2026',
'pay_cardcvv' => '123',
'pay_productname' => json_encode([
[
'productName' => 'Game Coin',
'price' => '10.00',
'quantity' => ' 1',
]
]),
'pay_firstname' => 'Rodrigo',
'pay_lastname' => 'lopez',
'pay_country_iso_code_2' => 'CL',
'pay_email_address' => '[email protected]',
'pay_telephone' => '+920508435',
'pay_ip' => '186.156.221.158',
'pay_useragent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.43',
'pay_language' => 'es',
'system' => 'shopyy'
]);
$header = [
'Content-Type: application/x-www-form-urlencoded',
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER , false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
$data = curl_exec($ch);
if (curl_error($ch)) {
echo 'Curl error: ' . curl_error($ch);
}
curl_close($ch);
var_dump($data);
import hashlib
import requests
import time
import json
url = 'https://sandbox.j-pay.net/pay_index'
key = '9k8rx7j0fxa7deb250huvghfbbjnu23h'
memberid = '10153'
params = {
'pay_memberid': memberid,
'pay_orderid': 'O' + time.strftime('%Y%m%d%H%M%S', time.localtime()),
'pay_applydate': time.strftime('%Y%m%d%H%M%S', time.localtime()),
'pay_bankcode': '901',
'pay_notifyurl': 'http://www.google.com',
'pay_callbackurl': 'http://www.google.com',
'pay_amount': '10.00',
}
strParam = ''
for p in sorted(params):
strParam = strParam + str(p) + "=" + str(params[p]) + '&'
strParam = strParam + 'key' + '=' + key
parmStr = strParam.encode("utf-8")
m = hashlib.md5()
m.update(parmStr)
params['pay_md5sign'] = m.hexdigest().upper()
otherParms = {
"pay_url": "http://www.google.com",
"pay_currency": "USD",
"pay_cardno": "4242424242424242",
"pay_cardmonth": "08",
"pay_cardyear": "2026",
"pay_cardcvv": "123",
"pay_productname": json.dumps([
{
"productName": "Game Coin",
"price": "10.00",
"quantity": " 1"
}
]),
"pay_firstname": "Rodrigo",
"pay_lastname": "lopez",
"pay_country_iso_code_2": "CL",
"pay_email_address": "[email protected]",
"pay_telephone": "+920508435",
"pay_ip": "186.156.221.158",
"pay_useragent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.43",
"pay_language": "es",
"system": "shopyy"
}
res = requests.post(url = url, data = dict(params, **otherParms))
print('response:' + res.text)