一、JayaPay API Reference
本文档面向具有开发能力的技术人员
Java语言可以直接参考右侧的Java代码示例
欢迎您联系我们,请在Telegram Messenger 👨💻 Caesar. 欢迎咨询.
二、说明
统一请求方式
HTTP POST
ContentType
application/json
签名sign
右侧阴暗区域为签名工具类
import com.google.gson.JsonObject;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import javax.crypto.Cipher;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* <p>
* JayaPay RSA签名工具类
* </p>
*
* @author JayaPay
*/
public class JayaPayRequestUtil {
/**
* 验证签名
* @param params
* @return
*/
public static boolean verifySign(JsonObject params, String publickey) throws InvalidKeySpecException, NoSuchAlgorithmException {
String platSign = params.remove("platSign").getAsString(); // 签名
List<String> paramNameList = new ArrayList<>(params.keySet());
Collections.sort(paramNameList);
StringBuilder stringBuilder = new StringBuilder();
for (String name : paramNameList) {
stringBuilder.append(params.get(name).getAsString());
}
System.out.println("keys:" + stringBuilder);
String decryptSign = publicDecrypt(platSign, getPublicKey(publickey));
System.out.println("decryptSign:" + decryptSign);
return stringBuilder.toString().equals(decryptSign);
}
/**
* 私钥加密
* @param data
* @param privateKey
* @return
*/
public static String privateEncrypt(String data, RSAPrivateKey privateKey){
try{
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.ENCRYPT_MODE, privateKey);
return Base64.encodeBase64String(rsaSplitCodec(cipher, Cipher.ENCRYPT_MODE, data.getBytes("UTF-8"), privateKey.getModulus().bitLength()));
}catch(Exception e){
throw new RuntimeException("加密字符串[" + data + "]时遇到异常", e);
}
}
/**
* 公钥解密
* @param data
* @param publicKey
* @return
*/
public static String publicDecrypt(String data, RSAPublicKey publicKey){
try{
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.DECRYPT_MODE, publicKey);
return new String(rsaSplitCodec(cipher, Cipher.DECRYPT_MODE, Base64.decodeBase64(data), publicKey.getModulus().bitLength()), "UTF-8");
}catch(Exception e){
throw new RuntimeException("解密字符串[" + data + "]时遇到异常", e);
}
}
/**
* 得到私钥
* @param privateKey 密钥字符串(经过base64编码)
*/
public static RSAPrivateKey getPrivateKey(String privateKey) throws NoSuchAlgorithmException, InvalidKeySpecException {
//通过PKCS#8编码的Key指令获得私钥对象
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(Base64.decodeBase64(privateKey));
RSAPrivateKey key = (RSAPrivateKey) keyFactory.generatePrivate(pkcs8KeySpec);
return key;
}
/**
* 得到公钥
* @param publicKey 密钥字符串(经过base64编码)
*/
public static RSAPublicKey getPublicKey(String publicKey) throws NoSuchAlgorithmException, InvalidKeySpecException {
//通过X509编码的Key指令获得公钥对象
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(Base64.decodeBase64(publicKey));
RSAPublicKey key = (RSAPublicKey) keyFactory.generatePublic(x509KeySpec);
return key;
}
private static byte[] rsaSplitCodec(Cipher cipher, int opmode, byte[] datas, int keySize){
int maxBlock = 0;
if(opmode == Cipher.DECRYPT_MODE){
maxBlock = keySize / 8;
}else{
maxBlock = keySize / 8 - 11;
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
int offSet = 0;
byte[] buff;
int i = 0;
try{
while(datas.length > offSet){
if(datas.length-offSet > maxBlock){
buff = cipher.doFinal(datas, offSet, maxBlock);
}else{
buff = cipher.doFinal(datas, offSet, datas.length-offSet);
}
out.write(buff, 0, buff.length);
i++;
offSet = i * maxBlock;
}
}catch(Exception e){
throw new RuntimeException("加解密阀值为["+maxBlock+"]的数据时发生异常", e);
}
byte[] resultDatas = out.toByteArray();
IOUtils.closeQuietly(out);
return resultDatas;
}
public static String doPost(String url,String json) throws IOException {
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(url);
StringEntity s = new StringEntity(json);
s.setContentEncoding("UTF-8");
s.setContentType("application/json");//发送json数据需要设置contentType
post.setEntity(s);
HttpResponse res = client.execute(post);
if(res.getStatusLine().getStatusCode() == HttpStatus.SC_OK){
return EntityUtils.toString(res.getEntity());// 返回json格式:
}
return null;
}
}
签名统一生成规则:
基于RSA的签名验证方式。
将所有非空参数的key按照ASCII排序后,取参数值(不包含Key)进行拼接后
采用RAS算法对字符串计算,算出签名字符串.
参数示例值
参数 | 类型 |
---|---|
merchantCode | S820211021094748000001 |
method | BCA |
orderNum | T1642592278863 |
payMoney | 150.60 |
productDetail | Test Pay |
notifyUrl | your notify ur |
dateTime | 2022-01-01 10:55:00 |
name | JackMa |
expiryPeriod | 1440 |
[email protected] | |
phone | 082122965511 |
拼接字符串
示例
首先根据参数Key按照ASCII排序,排序后加密字符串.
StrA = 2022-01-01 10:55:[email protected] notify
urlT1642593166888150.60082122965511Test Pay
计算签名
使用您在JayaPay商户后台配置的密钥对,用您的私钥进行加密计算RSA(StrA)获取到最终的签名字符串
sign = IMLn23c4orM+7pZhHoRmbjrol4X33jeAqFxbZuQ+pnznBIGhb6Ail3qQPmKwcuhNCt536nmldpbWI72
k1lDxd0zZ95ZHElcNzwTFHFKtd8063uy6rFaxaW6DQ47t4U/95dpGfHAZe0GiIFAQ6xQquaoLINyQa4QqL+cpB
JFEg1dyW6GYLFSdJnx7ycQvFYllmOpGZmdPLny62GvrCWvkiIARUsmc9fpkpTx5UQEDTgmhwdCKBkhHVsx2AiQ
bYDxZ5WBuU1GZeiJjPuzSxvzWP6VoQBsfpwTI5kdJs6aQCekGO2/YScD+tGgrm2J89Pc/axPcb1xZzsi5SxpWh
feabQ\u003d\u003d
三、配置商户公钥信息
1.绑定谷歌验证码
登录商户后台-个人中心-安全信息
,使用谷歌验证器扫描页面二维码绑定您的账号
2.RSA密钥对生成地址
POST http://pay.hehebo.com:15082/index-rsa.jsp
3.配置公钥
点击收付款配置-API配置
,填入您的公钥信息并保存.配置完成
4.商户后台地址
https://merchant.jayapayment.com/
四、法币代收下单
代收下单支持法币与数字货币(USDT/BTC/ETH/TRX)交易
如果您想使用数字货币交易,请设置orderType=1,并传入对应的货币币种Currency和网络netWork
使用数字货币进行交易时,币种和链网络是必传项,您需要告诉我们您想使用何种数字货币进行交易
可以使用的币种暂时只支持USDT
同时您需要告诉我们你们想使用哪种链网络(TRC20/BEP20/OMNI/ERC20/TRX)进行交易
目前可以使用的链网络为TRC20
我们后续会推出其他币种和网络的交易,敬请期待
1.代码示例
代码示例仅供参考,具体参数说明请参考请求参数说明
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.util.Map;
import java.util.TreeMap;
public class JayaPayDemo {
// 测试账号
private static final String MCH_ID = "S820211021094748000001"; // 商户号
private static final String PLAT_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2JoMfFqLsSJjAiCahEnlP3aRj8yCT+WHzR+VvPBTw9S1i7iYWb+MY09CG/HYuHF4+IxshXDJygmndxKf/esuwPybS8mAd//yubHpmZsmBqg1FffT8VH1APa6ZRWASUp4U01ZrbCCp35QA8FuWrJGMJxGx4xk7KUtV2yujxC8noQIDAQAB"; // 平台公钥
private static final String MCH_PRIVATE_KEY = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAJU8gKFKD0luIYx7X8+JRdCIE0UDBctS6LjXxWLEv/EO7jDBTid6zYP1KmNgpd2DAWWtBFBSQ+gcNwVZZSBHJiSDqVvvJVs2FEbeBvfdv4X93+IYRAXksBasSW5Tpdshbo82pVL4V7wuKCuFLk9UxBHbpQjWAbfyF66RmwIbZD71AgMBAAECgYBjPe7UU2nDDSfmQg0++CyjNjqKRC5QPfxhH6w1uF1kMueXKJWOj42n2RutJpJmsj31nY8m0u4xpsG4HvCu/GGSFhhKZCHLvzp41oY2ubYj9nuFNU//81LycQjulWo2y0UUBY0k2piEt+SwPaiUNbT6nMxNMjlnjRe2okp/3rw+KQJBANG3YlZWoVbCEqzy64bJJLxiPsCA5ErGB0NzRGitq44xkhqGtR8ZZQyVz40pruNa58d73O2xyJSy5+fmZGn4E+sCQQC2LBnguj0CSCKub0mPDcunTTz9V79VXBBZdlB1/YGmRUx2s4sQrJNZS7rL4EqBQ3maIRnG+s+AXCSTfsYrV6CfAkEAxugnVfpelhoGepEAgNuggyivmgfl/2Gpm/jk5l/qOjib+ZrQiQmeBPzGWX4yiSM8eMDrP2sC8r5pJFMp5DRONwJBAJ4n4XuSFJ9jgwCPy3vvzSv9SYLk6E6yM9uHdUlKgoGYzk6Lh6M9QFuY/J49plFdBDiEnj16yCU3WeXXfTJpzB8CQQDMNMR/rIOTE9xGybS3mlQbt22AUnO6XhupWcckEKW4nPGxATwYBQzCY3i/9FTGN0vA+9ZPC2cwHtNxI2kXf3Vp"; // 商户私钥
private static final String payUrl = "https://openapi.jayapayment.com/gateway/prepaidOrder";
private static final String cashUrl = "https://openapi.jayapayment.com/gateway/cash";
private static final String payNotify = "your notify url";
private static final String cashNotify = "your notify url";
public static void main(String[] args) throws Exception {
// 代收
pay();
}
private static void pay() throws Exception {
Map<String, String> requestParams = new TreeMap<>();
requestParams.put("merchantCode", MCH_ID);
requestParams.put("orderType", "0"); // 订单类型(0-法币交易)
requestParams.put("method", "BCA"); // 支付渠道
requestParams.put("orderNum", "T1642592278863"); // 商户订单号
requestParams.put("payMoney", "150"); // 订单金额
requestParams.put("name", "JackMa");// 客户名称
requestParams.put("phone", "082122965511"); // 手机号
requestParams.put("email", "[email protected]");// 客户邮箱
requestParams.put("notifyUrl", payNotify);// 回调地址
requestParams.put("dateTime", "20220101235959");// 时间戳 格式 yyyyMMddHHmmss
requestParams.put("expiryPeriod", "1440"); // 过期时间 单位(分)
requestParams.put("productDetail", "Test Pay");// 订单详情
StringBuilder stringBuilder = new StringBuilder();
for (String key : requestParams.keySet()) {
stringBuilder.append(requestParams.get(key)); // 拼接参数
}
String keyStr = stringBuilder.toString(); // 得到待加密的字符串
System.out.println("keyStr:" + keyStr);
String signedStr = JayaPayRequestUtil.privateEncrypt(keyStr, JayaPayRequestUtil.getPrivateKey(MCH_PRIVATE_KEY)); // 私钥加密
requestParams.put("sign", signedStr);
String postJson = new Gson().toJson(requestParams);
System.out.println("Post Json Params:" + postJson);
String responseJson = JayaPayRequestUtil.doPost(payUrl, postJson); // 发送 post json请求
System.out.println("Response Msg:" + responseJson);
}
}
<?php
// 平台公钥,从密钥配置中获取
// platform public key, from Secret key config
$platPublicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiaKBgQCcEUIvQ/5L+SWbHOeR8VFeZvLbUk7V7OeEAQlQwIVLSZMTef3KtsOKKAsUYPf/aAcKRzZZXECODsPQiDPcdZvM/rFkgrFWkR7lPjTj5SiPxGaiK2Z2sne7A8aDF7fV/D7lfmEwNdZ7FWKVEB84/81BHnlGUwb5HpRTISG+boSO6wIDAQAB';
// 商户私钥,商户自己生成
// mchchant private key
$mchPrivateKey = 'MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMigm7rtWnTeNagwFzGTH+Uw1ypbiy7VhIoFJbgSYSSHdCaXWdT/l2+2fQlEYgAETVZ/IXB29MCnrf3O0dwRFXiipIbsm5zyqSLiS6cKXe8zN1/PlQWUbEt5wyWm0GADB/4bV6eu6gA7sGXmjQqrzfKZkcie3aK7+7ry1NFxTI51AgMBAAECgYEAklqXQAVlt1tiSQ7L3J425jp6u6uMHN4lkYmvuleuBbfKQ1yla3wIPLYjAF+iHeEFidOz0Rb19JRdmIkHDkJoJg2W27LvO6RdUwzgRnsuA3OuNz97w08B3aXXbPmB91nTFjKSlUsbh3IQWP71noxW+iKn844EW5hC5Gvn4L3quAECQQDrz1r0VKIbBSBB2aLuz1XyD/TBT2aRhvOKf0XtTRiQhNjtJxoQmvNbbhvUwj8an7HyCuihAbdbrC2ymFFyOSDZAkEA2c4Yudi48C6COrroi1cWgPlEFeGJXP/V1k5loZ1n2vstYAGPhAB4wUnFBLDvMqaBzWJt7MRkiazT8KnBQCDY/QJAMXpNlEyZwt+deBOpO0BnwSWV7mWxmMFfImU4D+WITPbC7aexsWBBxaJh1o93XCe715RwYTAR//stj3akSDoyaQJAa4FKuxC51/Nc3Fg9R+modeiTLqmv/3NXvPvdNjRXesLX1rduex0wfVdII9ShfEKrdxDKaT9W0NyzD+r6NAkCkQJBAMAnTgPYf0f7rh417GdoP7R7Nwi8KBKwPHlmfRukibOQlKt9xjqpsKJwglLn8pcnXbYbswXIdqzuBvIGAe3OWNg=';
// 商户ID,从商户信息中获取
// merchent ID from idntask, from User info
$merchantCode = 'YOUR MERCHANT ID';
// 支付金额 pay money
$payMoney = '20000';
// Payment method of your choice refer: https://doc.jayapayment.com/#3-2 - method字段
$method = 'BCA';
//订单类型(0-法币交易)
$orderType = '0';
// 商户订单号
// Merchant system unique order number
$orderNum = 'T'.date("YmdHis",time());
// 描述
// The virtual account description
$productDetail = 'Test Pay';
$dateTime = date("YmdHis",time());
// 邮箱
// Customer's email address
$email = '[email protected]';
// 手机号码
// Customer's mobile number
$phone = '082112345678';
// 在付款确认页面显示的转账对象
// Display name on bank confirmation display
$name = 'Neo';
// 回调地址
// url for callback
$notifyUrl = 'http://example.com/callback';
// 订单过期时间 Order expiration time
$expiryPeriod = '1000';
$params = array(
'merchantCode' => $merchantCode,
'orderType' => $orderType,
'method' => $method,
'orderNum' => $orderNum,
'payMoney' => $payMoney,
'name' => $name,
'email' => $email,
'phone' => $phone,
'notifyUrl' => $notifyUrl,
'dateTime' => $dateTime,
'expiryPeriod' => $expiryPeriod,
'productDetail' => $productDetail
);
ksort($params);
$params_str = '';
foreach ($params as $key => $val) {
$params_str = $params_str . $val;
}
$sign = pivate_key_encrypt($params_str, $mchPrivateKey);
$params['sign'] = $sign;
$params_string = json_encode($params);
$url = 'https://openapi.jayapayment.com/gateway/prepaidOrder';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $params_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($params_string))
);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
//execute post
$request = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($httpCode == 200)
{
$result = json_decode($request, true);
echo "platRespCode :". $result['platRespCode'] . "\n";
echo "platRespMessage :". $result['platRespMessage'] . "\n";
echo "platOrderNum :". $result['platOrderNum'] . "\n";
echo "orderNum :". $result['orderNum'] . "\n";
echo "method :". $result['method'] . "\n";
echo "name :". $result['name'] . "\n";
echo "email :". $result['email'] . "\n";
echo "vaNumber :". $result['vaNumber'] . "\n";
echo "payMoney :". $result['payMoney'] . "\n";
echo "payFee :". $result['payFee'] . "\n";
echo "productDetail :". $result['productDetail'] . "\n";
echo "platSign :". $result['platSign'] . "\n";
$decryptStr = public_key_decrypt($result['platSign'], $platPublicKey);
echo "decryptStr :". $decryptStr . "\n";
}
else {
echo $httpCode;
}
function pivate_key_encrypt($data, $pivate_key)
{
$pivate_key = '-----BEGIN PRIVATE KEY-----'."\n".$pivate_key."\n".'-----END PRIVATE KEY-----';
$pi_key = openssl_pkey_get_private($pivate_key);
$crypto = '';
foreach (str_split($data, 117) as $chunk) {
openssl_private_encrypt($chunk, $encryptData, $pi_key);
$crypto .= $encryptData;
}
return base64_encode($crypto);
}
function public_key_decrypt($data, $public_key)
{
$public_key = '-----BEGIN PUBLIC KEY-----'."\n".$public_key."\n".'-----END PUBLIC KEY-----';
$data = base64_decode($data);
$pu_key = openssl_pkey_get_public($public_key);
$crypto = '';
foreach (str_split($data, 128) as $chunk) {
openssl_public_decrypt($chunk, $decryptData, $pu_key);
$crypto .= $decryptData;
}
return $crypto;
}
2.请求地址
我们提供了两种代收下单模式,您可以根据自身需求,自行选择:
一种是通过我们的收银台进行获取支付信息
一种是直接请求api获取支付信息
收银台(模式1):
POST https://openapi.jayapayment.com/gateway/prepaidOrder
api(模式2):
POST https://openapi.jayapayment.com/gateway/pay
模式2无法使用OVO进行支付,OVO需要在收银台上输入手机号
模式2 QRIS会返回两种数据二维码Url和二维码原始数据,可以通过 payData 是否以Http开头来判断
注:所有的参数中,不要填写中文!!!
3.请求参数
参数 | 类型 | 必填 | 描述 | 示例 |
---|---|---|---|---|
merchantCode | string(32) | Y | 商户ID,在商户平台-个人中心-个人信息 中获取 |
S820211021094748000001 |
orderType | string(10) | Y | 订单类型 | 0-法币交易 |
method | string(16) | N | 支付方式 1.如果需要指定支付方式,可以在右侧的示例支付方式列表中选择其一; 2.如果不指定支付方式,则可不传该参数(仅限收银台模式),可以在我们的收银台页面中选择某个支付方式。 |
BCA MANDIRI PERMATA CIMB BNI MAYBANK DANAMON BRI BSI BNC OVO DANA LINKAJA SHOPEEPAY QRIS GOPAY_QRIS ALFAMART TRANSFER_BCA |
orderNum | string(64) | Y | 商户订单号 | 10000001 |
payMoney | int(10) | Y | 付款金额(只能为整数,不能有小数 | 150000 |
productDetail | string(100) | Y | 付款描述 | Test goods |
notifyUrl | string(164) | Y | 订单支付成功异步通知地址(用来接收订单交易成功后的通知) | https://host:port/notifyUrl |
dateTime | string(32) | Y | 时间戳格式:yyyyMMddHHmmss | 20190101235959 |
expiryPeriod | int(5) | Y | 订单过期时间(单位:分钟) 。如无特殊要求,过期时间尽量设置大一点,时间太短容易过期 | 1440 |
name | string(64) | Y | 客户名称 | Jack |
string(64) | Y | 用户邮箱 | [email protected] | |
phone | string(32) | Y | 用户手机号码 | 1234567890 |
sign | string(255) | Y | 签名 | fnbSOvY83pr8hXg+FdNNYi2ubQUGNv/qGYc4TjRl+XxO2jo92dyjKHFU9/4hNECilMooOcH |
4.请求报文示例
{
"merchantCode": "S820211021094748000001",
"orderType": "0",
"method": "BCA",
"orderNum": "T1642593166888",
"payMoney": "10000",
"productDetail": "Test Pay",
"notifyUrl": "your notify url",
"dateTime": "2022-01-01 10:55:00",
"expiryPeriod": "1440",
"name": "JackMa",
"email": "[email protected]",
"phone": "082122965511",
"sign": "fnbSOvY83pr8hXg+FdNNYi2ubQUGNv/qGYc4TjRl+Xxd1yc9fpkpTx5UQEDTgmhwdCKBkhHVsx2AiQbYDxZ5WBuU1GZeiJ"
}
5.响应参数
参数 | 类型 | 必填 | 描述 | 示例 |
---|---|---|---|---|
platRespCode | String | Y | 请求业务是否成功 | FAIL:失败\SUCCESS:成功 |
platRespMessage | String | Y | 接口响应信息提示 | Request Transaction Success |
platOrderNum | String | Y | 平台订单号 | PI1453242857400963072 |
payMoney | string | Y | 支付金额 | 10000 |
payFee | string | Y | 手续费金额 | 5.32 |
method | String | Y | 支付方式 | BCA |
productDetail | String | Y | 产品详情 | apple |
name | String | Y | 客户名称 | Jack |
String | Y | 客户邮件 | [email protected] | |
orderNum | String | Y | 商户订单号 | 23645782 |
url | Object | N | 收银台链接 | 请求收银台下单(模式1),'platRespCode'为SUCCESS时返回 |
payData | Object | N | 支付信息 | 请求代收下单(模式2),'platRespCode'为SUCCESS时返回 |
6.成功响应报文示例
收银台下单(模式1)成功响应报文示例
{
"platOrderNum": "BCA1483771634191044608",
"payMoney": "10000",
"payFee": "10",
"method": "BCA",
"productDetail": "Test Pay",
"name": "JackMa",
"orderNum": "T1642593166888",
"platRespCode": "SUCCESS",
"platRespMessage": "Request Transaction Success",
"url": "https://openapi.jayapayment.com/gateway/order/BCA123456789",
"email": "[email protected]"
}
代收下单(模式2)成功响应报文示例
{
"platOrderNum": "BCA1483771634191044608",
"payMoney": "150",
"payFee": "16",
"method": "BCA",
"productDetail": "Test Pay",
"name": "JackMa",
"orderNum": "T1642593166888",
"platRespCode": "SUCCESS",
"platRespMessage": "Request Transaction Success",
"payData": "874961198466",
"email": "[email protected]"
}
代收下单(模式2) method="TRANSFER_BCA"成功响应报文示例
实际支付金额请使用payData中的realMoney
{
"method": "TRANSFER_BCA",
"productDetail": "test",
"orderNum": "150311839",
"platRespCode": "SUCCESS",
"platOrderNum": "PT190E8295D740A063",
"payMoney": "20000",
"payFee": "0",
"name": "Jack",
"platRespMessage": "Request Transaction Success",
"payData": "{\"billOrderNum\":\"PAY1805524081089486881\",\"realMoney\":\"20002\",\"custAccNo\":\"0948594334\",\"expireTime\":\"2024-06-25 15:56:00\",\"transCode\":\"1KQ7DLMB\",\"custAccName\":\"DSASD1\"}",
"email": "[email protected]"
}
失败响应报文示例
{
"platRespCode": "FAIL",
"platRespMessage": "the orderNum already exists"
}
7.代收异步通知
请注意:当前代收业务只有在订单支付成功的时候才有回调通知
进行验签时,要用 商户后台-收付款配置-API配置
中提供的平台公钥
进行解密!!!
接受异步通知后,需响应 SUCCESS
字符串
否则JayaPay将继续发起5次通知
import com.google.gson.JsonObject;
public class JayaPayNotify {
// 测试账号
private static final String MCH_ID = "S820211021094748000001"; // 商户号
private static final String PLAT_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2JoMfFqLsSJjAiCahEnlP3aRj8yCT+WHzR+VvPBTw9S1i7iYWb+MY09CG/HYuHF4+IxshXDJygmndxKf/esuwPybS8mAd//yubHpmZsmBqg1FffT8VH1APa6ZRWASUp4U01ZrbCCp35QA8FuWrJGMJxGx4xk7KUtV2yujxC8noQIDAQAB"; // 平台公钥
public static void main(String[] args) throws Exception {
// 代收
JsonObject notifyBody = new jsonObject();
boolean verifyResult = JayaPayRequestUtil.verifySign(notifyBody,PLAT_PUBLIC_KEY);
if (verifyResult) {
// ... 签名验证通过,处理正常的业务逻辑
} else {
// ... 签名验证错误
}
}
}
<?php
$res = json_decode(file_get_contents('php://input'), true);
$platSign = $res['platSign'];
unset($res['platSign']);
$public_key = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDFJ/AmUV4Z8udG8aOBUt/kEwc/DbxF5Gtfw6Y00NHQ4Pz2X2x9IxjUZxn2dnFxmrmhqKNlfwXOqyejhBzi0pSHyGoI4XP9IEfZGO6YkSb9DCY1ZxX8fDl2G+tPCbWYTVO4JutFmzTWgk1Uhhu6L9dlOMUHvZf3/6czA/a9C7azXwIDAQAB';
$decryptSign = public_key_decrypt($platSign, $public_key);
$params = $res;
ksort($params);
$params_str = '';
foreach ($params as $key => $val) {
$params_str = $params_str . $val;
}
if($params_str == $decryptSign) {
if($res['code'] == '00') {
echo 'success';
}
else {
echo 'fail';
}
}
else {
echo 'fail';
}
function public_key_decrypt($data, $public_key)
{
$public_key = '-----BEGIN PUBLIC KEY-----'."\n".$public_key."\n".'-----END PUBLIC KEY-----';
$data = base64_decode($data);
$pu_key = openssl_pkey_get_public($public_key);
$crypto = '';
foreach (str_split($data, 128) as $chunk) {
openssl_public_decrypt($chunk, $decryptData, $pu_key);
$crypto .= $decryptData;
}
return $crypto;
}
参数 | 描述 | 示例 |
---|---|---|
code | 响应状态 | 00 |
msg | 响应信息 | SUCCESS |
status | 支付结果 | INIT_ORDER:订单初始化 NO_PAY:未支付 SUCCESS:支付成功 PAY_CANCEL:撤销 PAY_ERROR:支付失败 |
platOrderNum | 平台订单号 | BK_1563278763273 |
orderNum | 商户订单号 | T1231511321515 |
method | 支付方式 | Requested method |
name | 客户名称 | Neo |
payMoney | 代收金额 | 100000 |
payFee | 手续费 | 500 |
邮箱 | [email protected] | |
phone | 手机号 | 123456798 |
platSign | 平台签名 | ja6R8eukQY9jc8zrhtf34654ungj7u8sdgdfjfs |
8.异步通知报文示例
{
"code": "00",
"msg": "SUCCESS",
"status": "SUCCESS",
"platOrderNum": "BCA1483771634191044608",
"orderNum": "T1642593166888",
"method": "BCA",
"name": "JackMa",
"payMoney": "150",
"payFee": "16",
"email": "[email protected]",
"phone": "123456789",
"platSign": "ja6R8eukQY9jc8zrhtf34654ungj7u8sdgdfjfs"
}
五、数字代收下单
代收下单支持法币与数字货币(USDT/BTC/ETH/TRX)交易 如果您想使用数字货币交易,请设置orderType=1;
通过商户用户ID来区分不同用户的交易
我们的数字代收订单分两个模式:有单模式和无单模式
Ex: 收银台版本(v1.0和v3.0属于有单模式版本;v2.0和v4.0属于无单模式)
Ex: v1.0、v2.0-只展示支付地址
Ex: v3.0、v4.0-展示二维码和支付地址两种方式
您需要告诉我们您想使用何种数字货币和链网络进行交易(TRC20/BEP20/OMNI/ERC20/TRX) 我们后续会推出其他币种和网络的交易,敬请期待
1.代码示例
代码示例仅供参考,具体参数说明请参考请求参数说明
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.util.Map;
import java.util.TreeMap;
public class JayaPayDemo {
// 测试账号
private static final String MCH_ID = "S820211021094748000001"; // 商户号
private static final String PLAT_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2JoMfFqLsSJjAiCahEnlP3aRj8yCT+WHzR+VvPBTw9S1i7iYWb+MY09CG/HYuHF4+IxshXDJygmndxKf/esuwPybS8mAd//yubHpmZsmBqg1FffT8VH1APa6ZRWASUp4U01ZrbCCp35QA8FuWrJGMJxGx4xk7KUtV2yujxC8noQIDAQAB"; // 平台公钥
private static final String MCH_PRIVATE_KEY = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAJU8gKFKD0luIYx7X8+JRdCIE0UDBctS6LjXxWLEv/EO7jDBTid6zYP1KmNgpd2DAWWtBFBSQ+gcNwVZZSBHJiSDqVvvJVs2FEbeBvfdv4X93+IYRAXksBasSW5Tpdshbo82pVL4V7wuKCuFLk9UxBHbpQjWAbfyF66RmwIbZD71AgMBAAECgYBjPe7UU2nDDSfmQg0++CyjNjqKRC5QPfxhH6w1uF1kMueXKJWOj42n2RutJpJmsj31nY8m0u4xpsG4HvCu/GGSFhhKZCHLvzp41oY2ubYj9nuFNU//81LycQjulWo2y0UUBY0k2piEt+SwPaiUNbT6nMxNMjlnjRe2okp/3rw+KQJBANG3YlZWoVbCEqzy64bJJLxiPsCA5ErGB0NzRGitq44xkhqGtR8ZZQyVz40pruNa58d73O2xyJSy5+fmZGn4E+sCQQC2LBnguj0CSCKub0mPDcunTTz9V79VXBBZdlB1/YGmRUx2s4sQrJNZS7rL4EqBQ3maIRnG+s+AXCSTfsYrV6CfAkEAxugnVfpelhoGepEAgNuggyivmgfl/2Gpm/jk5l/qOjib+ZrQiQmeBPzGWX4yiSM8eMDrP2sC8r5pJFMp5DRONwJBAJ4n4XuSFJ9jgwCPy3vvzSv9SYLk6E6yM9uHdUlKgoGYzk6Lh6M9QFuY/J49plFdBDiEnj16yCU3WeXXfTJpzB8CQQDMNMR/rIOTE9xGybS3mlQbt22AUnO6XhupWcckEKW4nPGxATwYBQzCY3i/9FTGN0vA+9ZPC2cwHtNxI2kXf3Vp"; // 商户私钥
private static final String payUrl = "https://openapi.jayapayment.com/gateway/prepaidOrder";
private static final String cashUrl = "https://openapi.jayapayment.com/gateway/cash";
private static final String payNotify = "your notify url";
private static final String cashNotify = "your notify url";
public static void main(String[] args) throws Exception {
// 代收
pay();
}
private static void pay() throws Exception {
Map<String, String> requestParams = new TreeMap<>();
requestParams.put("merchantCode", MCH_ID);
requestParams.put("orderType", "1"); // 订单类型(1-数字货币交易)
requestParams.put("mchUserId", "10001"); // 商户用户ID
requestParams.put("method", "USDT"); // 数字货币类型USDT/BTC/ETH/TRX(可不传)
requestParams.put("orderNum", "T1642592278863"); // 商户订单号(有单模式必传,无单模式不传)
requestParams.put("payMoney", "1.000001"); // 订单金额(最大支持6位小数)
requestParams.put("name", "JackMa");// 客户名称
requestParams.put("phone", "082122965511"); // 手机号
requestParams.put("email", "[email protected]");// 客户邮箱
requestParams.put("notifyUrl", payNotify);// 回调地址
requestParams.put("dateTime", "20220101235959");// 时间戳 格式 yyyyMMddHHmmss
requestParams.put("expiryPeriod", "1440"); // 过期时间 单位(分)
requestParams.put("currency", "USDT"); // 数字货币币种(如果指定了method,则必传)
requestParams.put("netWork", "TRC20"); // 链网络(如果指定了method,则必传)
requestParams.put("orderVersion", "v1.0"); // 收银台版本(v1.0和v3.0属于有单模式版本;v2.0和v4.0属于无单模式)
StringBuilder stringBuilder = new StringBuilder();
for (String key : requestParams.keySet()) {
stringBuilder.append(requestParams.get(key)); // 拼接参数
}
String keyStr = stringBuilder.toString(); // 得到待加密的字符串
System.out.println("keyStr:" + keyStr);
String signedStr = JayaPayRequestUtil.privateEncrypt(keyStr, JayaPayRequestUtil.getPrivateKey(MCH_PRIVATE_KEY)); // 私钥加密
requestParams.put("sign", signedStr);
String postJson = new Gson().toJson(requestParams);
System.out.println("Post Json Params:" + postJson);
String responseJson = JayaPayRequestUtil.doPost(payUrl, postJson); // 发送 post json请求
System.out.println("Response Msg:" + responseJson);
}
}
<?php
// 平台公钥,从密钥配置中获取
// platform public key, from Secret key config
$platPublicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiaKBgQCcEUIvQ/5L+SWbHOeR8VFeZvLbUk7V7OeEAQlQwIVLSZMTef3KtsOKKAsUYPf/aAcKRzZZXECODsPQiDPcdZvM/rFkgrFWkR7lPjTj5SiPxGaiK2Z2sne7A8aDF7fV/D7lfmEwNdZ7FWKVEB84/81BHnlGUwb5HpRTISG+boSO6wIDAQAB';
// 商户私钥,商户自己生成
// mchchant private key
$mchPrivateKey = 'MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMigm7rtWnTeNagwFzGTH+Uw1ypbiy7VhIoFJbgSYSSHdCaXWdT/l2+2fQlEYgAETVZ/IXB29MCnrf3O0dwRFXiipIbsm5zyqSLiS6cKXe8zN1/PlQWUbEt5wyWm0GADB/4bV6eu6gA7sGXmjQqrzfKZkcie3aK7+7ry1NFxTI51AgMBAAECgYEAklqXQAVlt1tiSQ7L3J425jp6u6uMHN4lkYmvuleuBbfKQ1yla3wIPLYjAF+iHeEFidOz0Rb19JRdmIkHDkJoJg2W27LvO6RdUwzgRnsuA3OuNz97w08B3aXXbPmB91nTFjKSlUsbh3IQWP71noxW+iKn844EW5hC5Gvn4L3quAECQQDrz1r0VKIbBSBB2aLuz1XyD/TBT2aRhvOKf0XtTRiQhNjtJxoQmvNbbhvUwj8an7HyCuihAbdbrC2ymFFyOSDZAkEA2c4Yudi48C6COrroi1cWgPlEFeGJXP/V1k5loZ1n2vstYAGPhAB4wUnFBLDvMqaBzWJt7MRkiazT8KnBQCDY/QJAMXpNlEyZwt+deBOpO0BnwSWV7mWxmMFfImU4D+WITPbC7aexsWBBxaJh1o93XCe715RwYTAR//stj3akSDoyaQJAa4FKuxC51/Nc3Fg9R+modeiTLqmv/3NXvPvdNjRXesLX1rduex0wfVdII9ShfEKrdxDKaT9W0NyzD+r6NAkCkQJBAMAnTgPYf0f7rh417GdoP7R7Nwi8KBKwPHlmfRukibOQlKt9xjqpsKJwglLn8pcnXbYbswXIdqzuBvIGAe3OWNg=';
// 商户ID,从商户信息中获取
// merchent ID from idntask, from User info
$merchantCode = 'YOUR MERCHANT ID';
// 商户用户ID
$mchUserIid = '100001';
// 支付金额 pay money(最大支持6位小数)
$payMoney = '1.000001';
// 支付方式 参考: (USDT/BTC/ETH/TRX)
$method = 'USDT';
//订单类型(0-法币交易,1-数字货币交易)
$orderType = '1';
// 商户订单号(有单模式必传,无单模式不传)
$orderNum = 'T'.date("YmdHis",time());
//时间戳 格式 yyyyMMddHHmmss
$dateTime = date("YmdHis",time());
// 邮箱(Customer's email address)
$email = '[email protected]';
// 手机号码(Customer's mobile number)
$phone = '082112345678';
// 在付款确认页面显示的转账对象(Display name on bank confirmation display)
$name = 'Neo';
// 回调地址(notify url)
$notifyUrl = 'http://example.com/callback';
// 订单过期时间 Order expiration time
$expiryPeriod = '1000';
// 数字货币币种(如果指定了method,则必传)
$currency = 'USDT';
// 链网络(如果指定了method,则必传)
$netWork = 'TRC20';
// 收银台版本(v1.0和v3.0属于有单模式版本;v2.0和v4.0属于无单模式)
$orderVersion = 'v1.0';
$params = array(
'merchantCode' => $merchantCode,
'orderType' => $orderType,
'mchUserIid' => $mchUserIid,
'method' => $method,
'orderNum' => $orderNum,
'payMoney' => $payMoney,
'name' => $name,
'email' => $email,
'phone' => $phone,
'notifyUrl' => $notifyUrl,
'dateTime' => $dateTime,
'expiryPeriod' => $expiryPeriod,
'currency' => $currency,
'netWork' => $netWork,
'orderVersion' => $orderVersion
);
ksort($params);
$params_str = '';
foreach ($params as $key => $val) {
$params_str = $params_str . $val;
}
$sign = pivate_key_encrypt($params_str, $mchPrivateKey);
$params['sign'] = $sign;
$params_string = json_encode($params);
$url = 'https://openapi.jayapayment.com/gateway/prepaidOrder';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $params_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($params_string))
);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
//execute post
$request = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($httpCode == 200)
{
$result = json_decode($request, true);
echo "platRespCode :". $result['platRespCode'] . "\n";
echo "platRespMessage :". $result['platRespMessage'] . "\n";
echo "mchUserIid :". $result['mchUserIid'] . "\n";
echo "platOrderNum :". $result['platOrderNum'] . "\n";
echo "orderNum :". $result['orderNum'] . "\n";
echo "method :". $result['method'] . "\n";
echo "name :". $result['name'] . "\n";
echo "email :". $result['email'] . "\n";
echo "vaNumber :". $result['vaNumber'] . "\n";
echo "payMoney :". $result['payMoney'] . "\n";
echo "payFee :". $result['payFee'] . "\n";
echo "currency :". $result['currency'] . "\n";
echo "netWork :". $result['netWork'] . "\n";
echo "orderVersion :". $result['orderVersion'] . "\n";
echo "platSign :". $result['platSign'] . "\n";
$decryptStr = public_key_decrypt($result['platSign'], $platPublicKey);
echo "decryptStr :". $decryptStr . "\n";
}
else {
echo $httpCode;
}
function pivate_key_encrypt($data, $pivate_key)
{
$pivate_key = '-----BEGIN PRIVATE KEY-----'."\n".$pivate_key."\n".'-----END PRIVATE KEY-----';
$pi_key = openssl_pkey_get_private($pivate_key);
$crypto = '';
foreach (str_split($data, 117) as $chunk) {
openssl_private_encrypt($chunk, $encryptData, $pi_key);
$crypto .= $encryptData;
}
return base64_encode($crypto);
}
function public_key_decrypt($data, $public_key)
{
$public_key = '-----BEGIN PUBLIC KEY-----'."\n".$public_key."\n".'-----END PUBLIC KEY-----';
$data = base64_decode($data);
$pu_key = openssl_pkey_get_public($public_key);
$crypto = '';
foreach (str_split($data, 128) as $chunk) {
openssl_public_decrypt($chunk, $decryptData, $pu_key);
$crypto .= $decryptData;
}
return $crypto;
}
2.请求地址
我们提供了两种代收下单模式,您可以根据自身需求,自行选择:
一种是通过我们的收银台进行获取钱包地址
一种是直接请求api获取钱包地址
收银台(模式1):
POST https://openapi.jayapayment.com/gateway/prepaidOrder
api(模式2):
POST https://openapi.jayapayment.com/gateway/pay
注:所有的参数中,不要填写中文!!!
3.数字代收请求参数
参数 | 类型 | 必填 | 描述 | 示例 |
---|---|---|---|---|
merchantCode | string(32) | Y | 商户ID,在商户平台-个人中心-个人信息 中获取 |
S820211021094748000001 |
orderType | string(10) | Y | 订单类型 | 1-数字货币交易 |
mchUserId | string(32) | Y | 商户用户ID(您的用户唯一标识,请勿传特殊字符、空格等) | 100001 |
method | string(16) | N | **支付方式 1.如果需要指定支付方式,可以在右侧的示例支付方式列表中选择其一; 2.如果不指定支付方式,则可不传该参数(仅限收银台模式),可以在我们的收银台页面中选择某个支付方式 API模式必传 |
USDT BTC ETH TRX |
currency | string(20) | N | 数字货币币种(如果指定支付方式,则必传) | USDT |
netWork | string(100) | N | 链网络(如果指定支付方式,则必传) | TRC20 |
orderNum | string(64) | N | 商户订单号(有单模式必传,无单模式不传) | TEST123456789 |
payMoney | int(10) | Y | 付款金额(最大允许6位小数) | 1.000001 |
notifyUrl | string(164) | Y | 订单支付成功异步通知地址(用来接收订单交易成功后的通知) | https://host:port/notifyUrl |
dateTime | string(32) | Y | 时间戳格式:yyyyMMddHHmmss | 20190101235959 |
expiryPeriod | int(5) | Y | 订单过期时间(单位:分钟) | 720 |
name | string(64) | Y | 客户名称 | Jack |
string(64) | Y | 用户邮箱 | [email protected] | |
phone | string(14) | Y | 用户手机号码 | 081234567890 |
orderVersion | string(20) | N | 收银台模式必传 API模式不传 收银台版本(v1.0和v3.0属于有单模式版本;v2.0和v4.0属于无单模式) |
v1.0 |
sign | string(255) | Y | 签名 | fnbSOvY83pr8hXg+FdNNYi2ubQUGNv/qGYc4TjRl+XxO2jo92dyjKHFU9/4hNECilMooOcH |
4.请求报文示例
{
"merchantCode": "S82024547076582341",
"orderType": "1",
"mchUserId": "10001",
"method": "USDT",
"currency": "USDT",
"netWork": "TRC20",
"orderNum": "T1346856312",
"payMoney": "1.00000001",
"notifyUrl": "your notify url",
"dateTime": "2022-01-01 10:55:00",
"expiryPeriod": "1440",
"name": "JackMa",
"email": "[email protected]",
"phone": "08123456789",
"sign": "252534+FdNNYi2ubQUGNv/3534535+56546"
}
5.响应参数
参数 | 类型 | 必填 | 描述 | 示例 |
---|---|---|---|---|
platRespCode | String | Y | 请求业务是否成功 | FAIL:失败\SUCCESS:成功 |
platRespMessage | String | Y | 接口响应信息提示 | Request Transaction Success |
mchUserId | String | Y | 商户用户ID | 10001 |
platOrderNum | String | Y | 平台订单号 | PI1453242857400963072 |
orderNum | String | Y | 商户订单号 | 23645782 |
currency | String | Y | 币种 | USDT |
netWork | String | Y | 链网络 | TRC20 |
payMoney | string | Y | 支付金额 | 1.00000001 |
url | String | Y | 收银台模式时,返回收银台链接 | 'platRespCode'为'SUCCESS'时返回 |
inAddress | String | Y | API模式时,返回钱包地址 | 'platRespCode'为'SUCCESS'时返回 |
6.成功响应报文示例
{
"platRespCode": "SUCCESS",
"url": "https://openapi.jayapayment.com/cashier?orderNum=PRE1626161123977859130123",
"mchUserId": "10001",
"platOrderNum": "PRE16263464579134560",
"payMoney": "1.00000000",
"currency": "USDT",
"netWork": "TRC20",
"platSign": "U79dat+657456fFt6Sqmf85GCP7V5JwW1arIUwUjlGkCs3TtvHfpDVaMi2fl+cfNGYSrCOZfursVwjiwJmka+44FyaGrrEOE9tKwODiZo/2534634/y61g0D9pzH17IVcr7Mc8BrweO7X4Pw==",
"platRespMessage": "Request Transaction Success"
}
失败响应报文示例
{
"platRespCode": "FAIL",
"platRespMessage": "the orderNum already exists"
}
7.数字代收异步通知
请注意:当前业务只有在订单支付成功的时候才有回调通知接收到。
进行验签时,要用 商户后台-收付款配置-API配置
中提供的平台公钥
进行解密!!!
数字货币有两种特殊情况:无单模式以及支付金额与下单金额不符,为此我们将异步通知进行了调整,如下:
1.如果是上述特殊情况,我们会生成一笔新的成功订单进行通知,您需要根据通知的信息进行验证,并生成新的订单;
2.根据通知的商户订单号(orderNum)查询是否您的系统存在该订单,建议您在下单成功时同时存储我们的平台订单号(platOrderNum),做双步校验;
3.根据通知的参数specialStatus(0-默认,1-特殊状态)判断,如果为1则判断为上述特殊情况.
JayaPay结果异步通知后,需响应 SUCCESS
字符串
否则JayaPay将继续向下游发起5次通知
import com.google.gson.JsonObject;
public class JayaPayNotify {
// 测试账号
private static final String MCH_ID = "S820211021094748000001"; // 商户号
private static final String PLAT_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2JoMfFqLsSJjAiCahEnlP3aRj8yCT+WHzR+VvPBTw9S1i7iYWb+MY09CG/HYuHF4+IxshXDJygmndxKf/esuwPybS8mAd//yubHpmZsmBqg1FffT8VH1APa6ZRWASUp4U01ZrbCCp35QA8FuWrJGMJxGx4xk7KUtV2yujxC8noQIDAQAB"; // 平台公钥
public static void main(String[] args) throws Exception {
// 代收
JsonObject notifyBody = new jsonObject();
boolean verifyResult = JayaPayRequestUtil.verifySign(notifyBody,PLAT_PUBLIC_KEY);
if (verifyResult) {
// ... 签名验证通过,处理正常的业务逻辑
} else {
// ... 签名验证错误
}
}
}
<?php
$res = json_decode(file_get_contents('php://input'), true);
$platSign = $res['platSign'];
unset($res['platSign']);
$public_key = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDFJ/AmUV4Z8udG8aOBUt/kEwc/DbxF5Gtfw6Y00NHQ4Pz2X2x9IxjUZxn2dnFxmrmhqKNlfwXOqyejhBzi0pSHyGoI4XP9IEfZGO6YkSb9DCY1ZxX8fDl2G+tPCbWYTVO4JutFmzTWgk1Uhhu6L9dlOMUHvZf3/6czA/a9C7azXwIDAQAB';
$decryptSign = public_key_decrypt($platSign, $public_key);
$params = $res;
ksort($params);
$params_str = '';
foreach ($params as $key => $val) {
$params_str = $params_str . $val;
}
if($params_str == $decryptSign) {
if($res['code'] == '00') {
echo 'success';
}
else {
echo 'fail';
}
}
else {
echo 'fail';
}
function public_key_decrypt($data, $public_key)
{
$public_key = '-----BEGIN PUBLIC KEY-----'."\n".$public_key."\n".'-----END PUBLIC KEY-----';
$data = base64_decode($data);
$pu_key = openssl_pkey_get_public($public_key);
$crypto = '';
foreach (str_split($data, 128) as $chunk) {
openssl_public_decrypt($chunk, $decryptData, $pu_key);
$crypto .= $decryptData;
}
return $crypto;
}
参数 | 描述 | 示例 |
---|---|---|
code | 响应状态 | 00 |
msg | 响应信息 | SUCCESS |
mchUserId | 商户用户ID | 10001 |
platOrderNum | 平台订单号 | BK_1563278763273 |
orderNum | 商户订单号 | T1231511321515 |
method | 支付方式 | USDT |
currency | 币种 | USDT |
netWork | 链网络 | TRC20 |
status | 支付结果 | INIT_ORDER: 订单初始化 NO_PAY: 未支付 SUCCESS: 支付成功 PAY_CANCEL: 撤销 PAY_ERROR: 支付失败 |
payMoney | 代收金额 | 100000 |
payFee | 手续费 | 500 |
客户邮箱 | [email protected] | |
hashCode | 交易哈希 | 5e5c356af0ewrhgnf3d757h8a6a5506cc66354620 |
sendAddress | 发送地址 | TDBbbeAB32WE576DVGE82GEC5BhsZs4 |
specialStatus | 特殊状态(0-默认,1-特殊状态) | 0 |
platSign | 平台签名 | ja6R8eukQY9jc8z |
8.异步通知报文示例
{
"code": "00",
"msg": "SUCCESS",
"mchUserId": "100001",
"platOrderNum": "BCA1483771634191044608",
"orderNum": "T1642593166888",
"method": "USDT",
"currency": "USDT",
"netWork": "TRC20",
"status": "SUCCESS",
"payMoney": "1.0000001",
"payFee": "0.000016",
"email": "[email protected]",
"phone": "08123456789",
"hashCode": "5e5c356af0ewrhgnf3d757h8a6a5506cc66354620",
"sendAddress": "TDBbbeAB32WE576DVGE82GEC5BhsZs4",
"specialStatus": "0",
"platSign": "ja6R8eukQY9jc8zrhtf34654ungj7u8sdgdfjfs"
}
六、法币代付下单
1.代码示例
代码示例仅供参考,具体参数说明请参考请求参数说明
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.util.Map;
import java.util.TreeMap;
public class JayaPayDemo {
private static final String MCH_ID = "S820211021094748000001"; // 商户号
private static final String PLAT_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2JoMfFqLsSJjAiCahEnlP3aRj8yCT+WHzR+VvPBTw9S1i7iYWb+MY09CG/HYuHF4+IxshXDJygmndxKf/esuwPybS8mAd//yubHpmZsmBqg1FffT8VH1APa6ZRWASUp4U01ZrbCCp35QA8FuWrJGMJxGx4xk7KUtV2yujxC8noQIDAQAB"; // 平台公钥
private static final String MCH_PRIVATE_KEY = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAJU8gKFKD0luIYx7X8+JRdCIE0UDBctS6LjXxWLEv/EO7jDBTid6zYP1KmNgpd2DAWWtBFBSQ+gcNwVZZSBHJiSDqVvvJVs2FEbeBvfdv4X93+IYRAXksBasSW5Tpdshbo82pVL4V7wuKCuFLk9UxBHbpQjWAbfyF66RmwIbZD71AgMBAAECgYBjPe7UU2nDDSfmQg0++CyjNjqKRC5QPfxhH6w1uF1kMueXKJWOj42n2RutJpJmsj31nY8m0u4xpsG4HvCu/GGSFhhKZCHLvzp41oY2ubYj9nuFNU//81LycQjulWo2y0UUBY0k2piEt+SwPaiUNbT6nMxNMjlnjRe2okp/3rw+KQJBANG3YlZWoVbCEqzy64bJJLxiPsCA5ErGB0NzRGitq44xkhqGtR8ZZQyVz40pruNa58d73O2xyJSy5+fmZGn4E+sCQQC2LBnguj0CSCKub0mPDcunTTz9V79VXBBZdlB1/YGmRUx2s4sQrJNZS7rL4EqBQ3maIRnG+s+AXCSTfsYrV6CfAkEAxugnVfpelhoGepEAgNuggyivmgfl/2Gpm/jk5l/qOjib+ZrQiQmeBPzGWX4yiSM8eMDrP2sC8r5pJFMp5DRONwJBAJ4n4XuSFJ9jgwCPy3vvzSv9SYLk6E6yM9uHdUlKgoGYzk6Lh6M9QFuY/J49plFdBDiEnj16yCU3WeXXfTJpzB8CQQDMNMR/rIOTE9xGybS3mlQbt22AUnO6XhupWcckEKW4nPGxATwYBQzCY3i/9FTGN0vA+9ZPC2cwHtNxI2kXf3Vp"; // 商户私钥
private static final String cashUrl = "https://openapi.jayapayment.com/gateway/cash";
private static final String cashNotify = "http://host:port/notify";
public static void main(String[] args) throws Exception {
cash();
}
private static void cash() throws Exception {
Map<String, String> requestParams = new TreeMap<>();
requestParams.put("merchantCode", MCH_ID);
requestParams.put("orderNum", "186888188666"); // 商户订单号
requestParams.put("method", "Transfer"); // 收款方式(Transfer)
requestParams.put("orderType", "0"); // 订单类型(0-法币交易,1-数字货币交易)
requestParams.put("money", "125"); // 订单金额,不支持小数位
requestParams.put("feeType", "0"); // 手续费类型(0-帐内扣除,1-帐外扣除)
requestParams.put("dateTime", "20200101235959");// 时间戳 格式 yyyyMMddHHmmss
requestParams.put("number", "2021071209403321313122"); // 客户银行卡号
requestParams.put("bankCode", "014"); // 印尼银行编码:参考附录I 代付
requestParams.put("name", "test cash name"); // 客户名称
requestParams.put("mobile", "082122965511"); // 客户手机号
requestParams.put("email", "[email protected]"); // 客户邮箱
requestParams.put("description", "test cash"); // 描述
requestParams.put("notifyUrl", cashNotify); // 回调地址
StringBuilder stringBuilder = new StringBuilder();
for (String key : requestParams.keySet()) {
stringBuilder.append(requestParams.get(key)); // 拼接参数
}
String keyStr = stringBuilder.toString(); // 得到待加密的字符串
System.out.println("keyStr:" + keyStr);
String signedStr = JayaPayRequestUtil.privateEncrypt(keyStr, JayaPayRequestUtil.getPrivateKey(MCH_PRIVATE_KEY)); // 私钥加密
requestParams.put("sign", signedStr);
String postJson = new Gson().toJson(requestParams);
System.out.println("Post Json Params:" + postJson);
String responseJson = JayaPayRequestUtil.doPost(cashUrl, postJson); // 发送 post json请求
System.out.println("Response Msg:" + responseJson);
boolean pass = JayaPayRequestUtil.verifySign(new Gson().fromJson(responseJson, JsonObject.class), PLAT_PUBLIC_KEY); // 签名验证
if (pass) {
// ... 签名验证通过,执行正常的业务逻辑
} else {
// ... 签名验证错误
}
}
}
<?php
// 平台公钥,从密钥配置中获取
// platform public key, from Secret key config
$platPublicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiaKBgQCcEUIvQ/5L+SWbHOeR8VFeZvLbUk7V7OeEAQlQwIVLSZMTef3KtsOKKAsUYPf/aAcKRzZZXECODsPQiDPcdZvM/rFkgrFWkR7lPjTj5SiPxGaiK2Z2sne7A8aDF7fV/D7lfmEwNdZ7FWKVEB84/81BHnlGUwb5HpRTISG+boSO6wIDAQAB';
// 商户私钥,商户自己生成
// mchchant private key
$mchPrivateKey = 'MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMigm7rtWnTeNagwFzGTH+Uw1ypbiy7VhIoFJbgSYSSHdCaXWdT/l2+2fQlEYgAETVZ/IXB29MCnrf3O0dwRFXiipIbsm5zyqSLiS6cKXe8zN1/PlQWUbEt5wyWm0GADB/4bV6eu6gA7sGXmjQqrzfKZkcie3aK7+7ry1NFxTI51AgMBAAECgYEAklqXQAVlt1tiSQ7L3J425jp6u6uMHN4lkYmvuleuBbfKQ1yla3wIPLYjAF+iHeEFidOz0Rb19JRdmIkHDkJoJg2W27LvO6RdUwzgRnsuA3OuNz97w08B3aXXbPmB91nTFjKSlUsbh3IQWP71noxW+iKn844EW5hC5Gvn4L3quAECQQDrz1r0VKIbBSBB2aLuz1XyD/TBT2aRhvOKf0XtTRiQhNjtJxoQmvNbbhvUwj8an7HyCuihAbdbrC2ymFFyOSDZAkEA2c4Yudi48C6COrroi1cWgPlEFeGJXP/V1k5loZ1n2vstYAGPhAB4wUnFBLDvMqaBzWJt7MRkiazT8KnBQCDY/QJAMXpNlEyZwt+deBOpO0BnwSWV7mWxmMFfImU4D+WITPbC7aexsWBBxaJh1o93XCe715RwYTAR//stj3akSDoyaQJAa4FKuxC51/Nc3Fg9R+modeiTLqmv/3NXvPvdNjRXesLX1rduex0wfVdII9ShfEKrdxDKaT9W0NyzD+r6NAkCkQJBAMAnTgPYf0f7rh417GdoP7R7Nwi8KBKwPHlmfRukibOQlKt9xjqpsKJwglLn8pcnXbYbswXIdqzuBvIGAe3OWNg=';
// 商户ID,从商户信息中获取
// merchent ID from idntask, from User info
$merchantCode = 'YOUR MERCHANT ID';
// 商户订单号
// Merchant system unique order number
$orderNum = 'T'.date("YmdHis",time());
// 支付方式
// Payment method
$method = 'Transfer';
//订单类型(0-法币交易)
$orderType = '0';
// 出款金额 withdraw money
$money = '20000';
// 手续费类型(0-帐内扣除,1-帐外扣除)
$feeType = '1';
// 时间戳 格式 yyyyMMddHHmmss
$dateTime = date("YmdHis",time());
// 客户银行卡号
$number = '123456';
// 银行编码(详情参考文档底部)
$bankCode = '014';
// 在付款确认页面显示的转账对象
// Display name on bank confirmation display
$name = 'Neo';
// 手机号码
// Customer's mobile number
$mobile = '082112345678';
// 邮箱
// Customer's email address
$email = '[email protected]';
// 描述
// The virtual account description
$description = 'Test Withdraw';
// 回调地址
// url for callback
$notifyUrl = 'http://example.com/callback';
$params = array(
'merchantCode' => $merchantCode,
'orderType' => $orderType,
'method' => $method,
'orderNum' => $orderNum,
'money' => $money,
'feeType' => $feeType,
'dateTime' => $dateTime,
'number' => $number,
'bankCode' => $bankCode,
'name' => $name,
'mobile' => $mobile,
'email' => $email,
'notifyUrl' => $notifyUrl,
'description' => $description
);
ksort($params);
$params_str = '';
foreach ($params as $key => $val) {
$params_str = $params_str . $val;
}
$sign = pivate_key_encrypt($params_str, $mchPrivateKey);
$params['sign'] = $sign;
$params_string = json_encode($params);
$url = 'https://openapi.jayapayment.com/gateway/cash';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $params_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($params_string))
);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
//execute post
$request = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($httpCode == 200)
{
$result = json_decode($request, true);
echo "platRespCode :". $result['platRespCode'] . "\n";
echo "platRespMessage :". $result['platRespMessage'] . "\n";
echo "platOrderNum :". $result['platOrderNum'] . "\n";
echo "orderNum :". $result['orderNum'] . "\n";
echo "status :". $result['status'] . "\n";
echo "statusMsg :". $result['statusMsg'] . "\n";
echo "money :". $result['money'] . "\n";
echo "fee :". $result['fee'] . "\n";
echo "feeType :". $result['feeType'] . "\n";
echo "bankCode :". $result['bankCode'] . "\n";
echo "number :". $result['number'] . "\n";
echo "name :". $result['name'] . "\n";
echo "description :". $result['description'] . "\n";
echo "platSign :". $result['platSign'] . "\n";
$decryptStr = public_key_decrypt($result['platSign'], $platPublicKey);
echo "decryptStr :". $decryptStr . "\n";
}
else {
echo $httpCode;
}
function pivate_key_encrypt($data, $pivate_key)
{
$pivate_key = '-----BEGIN PRIVATE KEY-----'."\n".$pivate_key."\n".'-----END PRIVATE KEY-----';
$pi_key = openssl_pkey_get_private($pivate_key);
$crypto = '';
foreach (str_split($data, 117) as $chunk) {
openssl_private_encrypt($chunk, $encryptData, $pi_key);
$crypto .= $encryptData;
}
return base64_encode($crypto);
}
function public_key_decrypt($data, $public_key)
{
$public_key = '-----BEGIN PUBLIC KEY-----'."\n".$public_key."\n".'-----END PUBLIC KEY-----';
$data = base64_decode($data);
$pu_key = openssl_pkey_get_public($public_key);
$crypto = '';
foreach (str_split($data, 128) as $chunk) {
openssl_public_decrypt($chunk, $decryptData, $pu_key);
$crypto .= $decryptData;
}
return $crypto;
}
2.请求地址
POST https://openapi.jayapayment.com/gateway/cash
注:所有的参数中,不要填写中文!!!
3.请求参数
参数 | 类型 | 必填 | 描述 | 示例 |
---|---|---|---|---|
merchantCode | string(32) | Y | 商户ID,在商户平台-个人中心-个人信息 中获取 |
S820211021094748000001 |
orderType | string(10) | Y | 订单类型 | 0-法币交易 |
method | string(16) | Y | 收款方式 | Transfer |
orderNum | string(50) | Y | 商户订单号 | 10000001 |
money | string(16) | Y | 代付金额(不支持小数点位,请勿传小数) | 150000 |
feeType | String(1) | Y | 手续费类型 | 0:代付金额内扣除,1:手续费另计 |
bankCode | string(32) | Y | 银行编号 | 014(参考附录Ⅱ BankCode目录) |
number | string(50) | Y | 客户银行卡号 | 12312431241 |
name | String(50) | Y | 客户名称 | Jack |
mobile | string(14) | Y | 用户手机号码 | 081234567890 |
string(64) | Y | 用户邮箱 | [email protected] | |
notifyUrl | string(164) | Y | 回调地址 | http://notify.com |
dateTime | string(32) | Y | 时间戳格式:yyyyMMddHHmmss | 20200101235959 |
description | string(255) | Y | 按请求参数返回 | 代付下单 |
sign | string | Y | 签名 | Yg+ePvTFhiRrARcZKBcRG0l89rqisPIuZQStYqBIwSMPaqvqbc3dFevgS9jt |
4.请求报文示例
{
"merchantCode": "S820211021094748000001",
"orderType": "0",
"method": "Transfer",
"orderNum": "186888188666",
"money": "50000",
"feeType": "1",
"bankCode": "014",
"number": "2021071209403321313122",
"name": "test cash name",
"mobile": "082122965511",
"email": "[email protected]",
"notifyUrl": "your notify url",
"dateTime": "2021-07-12 09:41:00",
"description": "test cash",
"sign": "Yg+ePvTFhiRrARcZKBcRG0l89rqisPIuZQStYqBIwSMPaqwH77qRXI1J+jElOBpa"
}
5.响应参数
参数 | 类型 | 必填 | 描述 | 示例 |
---|---|---|---|---|
platRespCode | String | Y | 请求业务是否成功 | FAIL:失败\SUCCESS:成功 |
platRespMessage | String | Y | 接口响应信息提示 | 请求成功 |
platOrderNum | String | Y | 平台订单号 | PI1453242857400963072 |
orderNum | String | Y | 商户订单号 | 23645782 |
status | int | Y | 订单状态 | 0-待处理 1-处理中 2-代付成功 4-代付失败 5-银行代付中 |
statusMsg | String | Y | 订单状态信息 | Apply |
money | string | Y | 代付金额 | 150000 |
fee | String | Y | 手续费金额 | 12.25 |
feeType | String | Y | 手续费类型 | 0:订单内扣除,1:手续费另计 |
bankCode | String | N | 银行编号 | 014(参考附录Ⅱ BankCode小节) |
number | String | Y | 客户银行卡号 | 12312431241 |
name | String | Y | 客户名称 | Jack |
description | String | Y | 按请求参数返回 | 代付下单 |
platSign | String | Y | 签名 | PI1453242857400963072 |
6.代付响应报文示例
{
"platRespCode": "SUCCESS",
"platRespMessage": "Request success",
"platOrderNum": "W0620220119174331000001",
"orderNum": "186888188666",
"status": 0,
"statusMsg": "Apply",
"money": "50000",
"fee": "7",
"feeType": "0",
"bankCode": "014",
"number": "2021071209403321313122",
"name": "test cash name",
"description": "test cash",
"platSign": "E5uNF7B9NXyhtlRo2I7/KVHN4Sbz0c3VbwCLpH3vjUpv6Cai+bmJA/Q8dVE2RJRe1+dsbzg=="
}
7.代付异步通知
进行验签时,要用 商户后台-收付款配置-API配置
中提供的平台公钥
进行解密!!!
JayaPay结果异步通知后,需响应 SUCCESS
字符串
否则JayaPay将继续向下游发起5次通知。
参数 | 描述 | 示例 |
---|---|---|
platOrderNum | 平台订单号 | BK_1563278763273 |
orderNum | 商户订单号 | T1231511321515 |
money | 代付金额 | 100000(不支持小数点) |
feeType | 订单结果状态 | 手续费类型, 0:订单内扣除 1:手续费另计 |
fee | 手续费 | 500 |
name | 客户名称 | Neo |
number | 客户银行卡号 | 45649849659456 |
bankCode | 到账银行 | 014(参考附录Ⅱ BankCode小节) |
status | 订单状态 | 0-待处理 1-处理中 2-代付成功 4-代付失败 5-银行代付中 |
statusMsg | 订单状态描述 | Payout Success |
description | 订单描述 | 商户上传原样返回 |
platSign | 平台签名 | ja6R8eukQY9jc8... |
8.异步通知报文示例
{
"platOrderNum": "W0620220119174331000001",
"orderNum": "186888188666",
"money": "50000",
"fee": "7",
"feeType": "0",
"name": "test cash name",
"number": "2021071209403321313122",
"bankCode": "014",
"status": "2",
"statusMsg": "SUCCESS",
"description": "test cash",
"platSign": "LGEpz2LjbZ6Iyvn+zLc/+t26AaH0aEhHVD62lSCdo6XIkAg86AUncCvmym62wVoE3r2+dHnv27qi/01UQDcqFK8DYioRCcydYSjB4QRVezG3fcZlhWrACmWGacnXkE7p5zChL7pK5h0HuBhbo1zKt4FunQR6QMmcBVfv7YfB3W0"
}
七、数字代付下单
代付下单支持法币与数字货币(USDT/BTC/ETH/TRX)交易 如果您想使用数字货币交易,请设置orderType=1,并传入对应的货币币种Currency和网络netWork 使用数字货币进行交易时,币种和链网络是必传项 您需要告诉我们您想使用何种数字币和链网络(TRC20/BEP20/OMNI/ERC20/TRX)进行交易 当使用数字货币进行交易时,您需要传入您的inAddress用以收取数字货币 我们后续会推出其他币种和网络的交易,敬请期待
1.代码示例
代码示例仅供参考,具体参数说明请参考请求参数说明
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.util.Map;
import java.util.TreeMap;
public class JayaPayDemo {
private static final String MCH_ID = "S820211021094748000001"; // 商户号
private static final String PLAT_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2JoMfFqLsSJjAiCahEnlP3aRj8yCT+WHzR+VvPBTw9S1i7iYWb+MY09CG/HYuHF4+IxshXDJygmndxKf/esuwPybS8mAd//yubHpmZsmBqg1FffT8VH1APa6ZRWASUp4U01ZrbCCp35QA8FuWrJGMJxGx4xk7KUtV2yujxC8noQIDAQAB"; // 平台公钥
private static final String MCH_PRIVATE_KEY = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAJU8gKFKD0luIYx7X8+JRdCIE0UDBctS6LjXxWLEv/EO7jDBTid6zYP1KmNgpd2DAWWtBFBSQ+gcNwVZZSBHJiSDqVvvJVs2FEbeBvfdv4X93+IYRAXksBasSW5Tpdshbo82pVL4V7wuKCuFLk9UxBHbpQjWAbfyF66RmwIbZD71AgMBAAECgYBjPe7UU2nDDSfmQg0++CyjNjqKRC5QPfxhH6w1uF1kMueXKJWOj42n2RutJpJmsj31nY8m0u4xpsG4HvCu/GGSFhhKZCHLvzp41oY2ubYj9nuFNU//81LycQjulWo2y0UUBY0k2piEt+SwPaiUNbT6nMxNMjlnjRe2okp/3rw+KQJBANG3YlZWoVbCEqzy64bJJLxiPsCA5ErGB0NzRGitq44xkhqGtR8ZZQyVz40pruNa58d73O2xyJSy5+fmZGn4E+sCQQC2LBnguj0CSCKub0mPDcunTTz9V79VXBBZdlB1/YGmRUx2s4sQrJNZS7rL4EqBQ3maIRnG+s+AXCSTfsYrV6CfAkEAxugnVfpelhoGepEAgNuggyivmgfl/2Gpm/jk5l/qOjib+ZrQiQmeBPzGWX4yiSM8eMDrP2sC8r5pJFMp5DRONwJBAJ4n4XuSFJ9jgwCPy3vvzSv9SYLk6E6yM9uHdUlKgoGYzk6Lh6M9QFuY/J49plFdBDiEnj16yCU3WeXXfTJpzB8CQQDMNMR/rIOTE9xGybS3mlQbt22AUnO6XhupWcckEKW4nPGxATwYBQzCY3i/9FTGN0vA+9ZPC2cwHtNxI2kXf3Vp"; // 商户私钥
private static final String cashUrl = "https://openapi.jayapayment.com/gateway/cash";
private static final String cashNotify = "http://host:port/notify";
public static void main(String[] args) throws Exception {
cash();
}
private static void cash() throws Exception {
Map<String, String> requestParams = new TreeMap<>();
requestParams.put("merchantCode", MCH_ID);
requestParams.put("orderType", "1"); // 订单类型(1-数字货币交易)
requestParams.put("method", "USDT"); // 收款方式(USDT/BTC/ETH/TRX)
requestParams.put("orderNum", "186888188666"); // 商户订单号
requestParams.put("money", "1.000001"); // 订单金额,最大支持6位小数
requestParams.put("feeType", "1"); // 手续费类型(0:代付金额内扣除,1:手续费另计)
requestParams.put("dateTime", "20200101235959");// 时间戳 格式 yyyyMMddHHmmss
requestParams.put("name", "test cash name"); // 客户名称
requestParams.put("mobile", "082122965511"); // 客户手机号
requestParams.put("email", "[email protected]"); // 客户邮箱
requestParams.put("notifyUrl", cashNotify); // 回调地址
requestParams.put("currency", "USDT"); // 数字货币币种(当orderType=1(数字货币交易)时,是必填项,否则会无法完成交易)
requestParams.put("netWork", "TRC20"); // 链网络(当orderType=1(数字货币交易)时,是必填项,否则无法完成交易)
requestParams.put("inAddress", "zkif74bhvkf8934rgg6"); // 入账地址(当orderType=1(数字货币交易)时,是必填项,否则无法完成交易)
StringBuilder stringBuilder = new StringBuilder();
for (String key : requestParams.keySet()) {
stringBuilder.append(requestParams.get(key)); // 拼接参数
}
String keyStr = stringBuilder.toString(); // 得到待加密的字符串
System.out.println("keyStr:" + keyStr);
String signedStr = JayaPayRequestUtil.privateEncrypt(keyStr, JayaPayRequestUtil.getPrivateKey(MCH_PRIVATE_KEY)); // 私钥加密
requestParams.put("sign", signedStr);
String postJson = new Gson().toJson(requestParams);
System.out.println("Post Json Params:" + postJson);
String responseJson = JayaPayRequestUtil.doPost(cashUrl, postJson); // 发送 post json请求
System.out.println("Response Msg:" + responseJson);
boolean pass = JayaPayRequestUtil.verifySign(new Gson().fromJson(responseJson, JsonObject.class), PLAT_PUBLIC_KEY); // 签名验证
if (pass) {
// ... 签名验证通过,执行正常的业务逻辑
} else {
// ... 签名验证错误
}
}
}
2.请求地址
POST https://openapi.jayapayment.com/gateway/cash
注:所有的参数中,不要填写中文!!!
3.请求参数
参数 | 类型 | 必填 | 描述 | 示例 |
---|---|---|---|---|
merchantCode | string(32) | Y | 商户ID,在商户平台-个人中心-个人信息 中获取 |
S820211021094748000001 |
orderType | string(10) | Y | 订单类型 | 1-数字货币交易 |
method | string(16) | Y | 收款方式 | USDT BTC ETH TRX |
orderNum | string(50) | Y | 商户订单号 | 186888188666 |
money | string(32,8) | Y | 代付金额 | 1.000001(最大支持6位小数)如果feeType选择0的话,因为涉及到手续费,所以麻烦您先以3位小数的金额进行代付下单 |
feeType | String(1) | Y | 手续费类型 | 0:代付金额内扣除 1:手续费另计 |
name | String(50) | Y | 客户名称 | Jack |
mobile | string(14) | Y | 用户手机号码 | 081234567890 |
string(64) | Y | 用户邮箱 | [email protected] | |
notifyUrl | string(164) | Y | 回调地址 | https://***.com |
dateTime | string(32) | Y | 时间戳格式:yyyyMMddHHmmss | 20200101235959 |
currency | string(20) | Y | 数字货币币种 | USDT |
netWork | string(100) | Y | 链网络 | TRC20 |
inAddress | string(255) | Y | 入账地址 | vboj3457vbiae5y35y |
4.请求报文示例
{
"merchantCode": "S820211021094748000001",
"orderType": "1",
"method": "USDT",
"orderNum": "186888188666",
"money": "1.00000001",
"feeType": "1",
"name": "test cash name",
"mobile": "082122965511",
"email": "[email protected]",
"notifyUrl": "your notify url",
"dateTime": "2021-07-12 09:41:00",
"currency": "USDT",
"netWork": "TRC20",
"inAddress": "vboj3457vbiae5y35y",
"sign": "Yg+ePvTFhiRrARcZKBcRG0l89rqisPIuZQStYqBIwSMPaqwH77qRXI1J+jElOBpa"
}
5.响应参数
参数 | 类型 | 描述 | 示例 |
---|---|---|---|
platRespCode | String | 请求业务是否成功 | FAIL:失败\SUCCESS:成功 |
platRespMessage | String | 接口响应信息提示 | 请求成功 |
platOrderNum | String | 平台订单号 | PI1453242857400963072 |
status | String | 订单状态 | 0 |
statusMsg | String | 订单状态信息 | Apply |
orderNum | String | 商户订单号 | 23645782 |
money | string | 代付金额 | 1.00000001 |
fee | String | 手续费金额 | 12.25 |
feeType | String | 手续费类型 | 0:代付金额内扣除 1:手续费另计 |
name | String | 客户名称 | Jack |
currency | string | 数字货币币种 | USDT |
netWork | string | 链网络 | TRC20 |
platSign | String | 签名 | PI1453242857400963072 |
6.响应报文示例
{
"platRespCode": "SUCCESS",
"platRespMessage": "Request success",
"platOrderNum": "W0620220119174331000001",
"orderNum": "186888188666",
"status": "0",
"statusMsg": "Apply",
"money": "1.00000001",
"fee": "7",
"feeType": "1",
"currency": "USDT",
"netWork": "TRC20",
"platSign": "E5uNF7B9NXyhtlRo2I7/KVHN4Sbz0c3VbwCLpH3vjUpv6Cai+bmJA/Q8dVE2RJRe1+dsbzg=="
}
7.数字代付异步通知
接收到结果异步通知后,需响应 SUCCESS
字符串,不包含引号,不是Json格式。
否则JayaPay将继续向下游发起5次通知。
参数 | 描述 | 示例 |
---|---|---|
platOrderNum | 平台订单号 | BK_1563278763273 |
orderNum | 商户订单号 | T1231511321515 |
money | 代付金额 | 1.000001(最大支持6位小数) |
feeType | 订单结果状态 | 手续费类型, 0:代付金额内扣除,1:手续费另计 |
fee | 手续费 | 500 |
currency | 币种 | USDT |
netWork | 链网络 | TRC20 |
name | 客户名称 | Neo |
status | 订单状态 | 0-待处理 1-处理中 2-代付成功 4-代付失败 5-银行代付中 |
statusMsg | 订单状态描述 | Payout Success |
hashCode | 交易哈希 | 5e5c356af0ewrhgnf3d757h8a6a5506cc66354620 |
inAddress | 接收地址 | TDBbbeAB32WE576DVGE82GEC5BhsZs4 |
sendAddress | 发送地址 | TDBbbeAB32WE576DVGE82GEC5BhsZs4 |
platSign | 平台签名 | ja6R8eukQY9jc8... |
8.异步通知报文示例
{
"platOrderNum": "W0620220119174331000001",
"orderNum": "186888188666",
"money": "1.00000001",
"fee": "0.0001",
"feeType": "1",
"currency": "USDT",
"netWork": "TRC20",
"name": "test cash name",
"status": "2",
"statusMsg": "SUCCESS",
"hashCode": "5e5c356af0ewrhgnf3d757h8a6a5506cc66354620",
"inAddress": "Twrgtehsd576gsdre876d2545C5Br23324",
"sendAddress": "TDBbbeAB32WE576DVGE82GEC5BhsZs4",
"platSign": "LGEpz2LjbZ6Iyvn+zLc/+t26AaH0aEhHVD62lSCdo6XIkAg86AUncCvmym62wVoE3r2+dHnv27qi/01UQDcqFK8DYioRCcydYSjB4QRVezG3fcZlhWrACmWGacnXkE7p5zChL7pK5h0HuBhbo1zKt4FunQR6QMmcBVfv7YfB3W0"
}
八、订单查询
1.订单查询
import com.google.gson.JsonObject;
public class OrderQuery {
// 测试账号
private static final String MCH_ID = "S820211021094748000001"; // 商户号
private static final String PLAT_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2JoMfFqLsSJjAiCahEnlP3aRj8yCT+WHzR+VvPBTw9S1i7iYWb+MY09CG/HYuHF4+IxshXDJygmndxKf/esuwPybS8mAd//yubHpmZsmBqg1FffT8VH1APa6ZRWASUp4U01ZrbCCp35QA8FuWrJGMJxGx4xk7KUtV2yujxC8noQIDAQAB"; // 平台公钥
private static final String MCH_PRIVATE_KEY = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAJU8gKFKD0luIYx7X8+JRdCIE0UDBctS6LjXxWLEv/EO7jDBTid6zYP1KmNgpd2DAWWtBFBSQ+gcNwVZZSBHJiSDqVvvJVs2FEbeBvfdv4X93+IYRAXksBasSW5Tpdshbo82pVL4V7wuKCuFLk9UxBHbpQjWAbfyF66RmwIbZD71AgMBAAECgYBjPe7UU2nDDSfmQg0++CyjNjqKRC5QPfxhH6w1uF1kMueXKJWOj42n2RutJpJmsj31nY8m0u4xpsG4HvCu/GGSFhhKZCHLvzp41oY2ubYj9nuFNU//81LycQjulWo2y0UUBY0k2piEt+SwPaiUNbT6nMxNMjlnjRe2okp/3rw+KQJBANG3YlZWoVbCEqzy64bJJLxiPsCA5ErGB0NzRGitq44xkhqGtR8ZZQyVz40pruNa58d73O2xyJSy5+fmZGn4E+sCQQC2LBnguj0CSCKub0mPDcunTTz9V79VXBBZdlB1/YGmRUx2s4sQrJNZS7rL4EqBQ3maIRnG+s+AXCSTfsYrV6CfAkEAxugnVfpelhoGepEAgNuggyivmgfl/2Gpm/jk5l/qOjib+ZrQiQmeBPzGWX4yiSM8eMDrP2sC8r5pJFMp5DRONwJBAJ4n4XuSFJ9jgwCPy3vvzSv9SYLk6E6yM9uHdUlKgoGYzk6Lh6M9QFuY/J49plFdBDiEnj16yCU3WeXXfTJpzB8CQQDMNMR/rIOTE9xGybS3mlQbt22AUnO6XhupWcckEKW4nPGxATwYBQzCY3i/9FTGN0vA+9ZPC2cwHtNxI2kXf3Vp"; // 商户私钥
private static final String orderQueryUrl = "https://openapi.jayapayment.com/gateway/query";
public static void main(String[] args) throws Exception {
// 代收
query();
}
private static void query() throws Exception {
Map<String, String> requestParams = new TreeMap<>();
requestParams.put("merchantCode", MCH_ID);
requestParams.put("queryType", "CASH_QUERY"); // 支付渠道
requestParams.put("orderNum", "186888188666"); // 商户订单号
requestParams.put("platOrderNum", "PRE186888188666"); // 平台订单号
requestParams.put("dateTime", "20220101105500");// 时间戳 格式 yyyyMMddHHmmss
StringBuilder stringBuilder = new StringBuilder();
for (String key : requestParams.keySet()) {
stringBuilder.append(requestParams.get(key)); // 拼接参数
}
String keyStr = stringBuilder.toString(); // 得到待加密的字符串
System.out.println("keyStr:" + keyStr);
String signedStr = JayaPayRequestUtil.privateEncrypt(keyStr, JayaPayRequestUtil.getPrivateKey(MCH_PRIVATE_KEY)); // 私钥加密
requestParams.put("sign", signedStr);
String postJson = new Gson().toJson(requestParams);
System.out.println("Post Json Params:" + postJson);
String responseJson = JayaPayRequestUtil.doPost(orderQueryUrl, postJson); // 发送 post json请求
System.out.println("Response Msg:" + responseJson);
}
}
请求地址
POST https://openapi.jayapayment.com/gateway/query
注:商户订单号和平台订单号两者必需传递其中一个,也可以同时传递
请求参数
参数 | 是否必填(Y-是,N-否) | 类型 | 描述 | 示例 |
---|---|---|---|---|
merchantCode | Y | string(32) | 商户ID,在商户平台-个人中心-个人信息 中获取 |
S820190712000002 |
queryType | Y | string(16) | 查询类型 | 代收:ORDER_QUERY 代付:CASH_QUERY |
orderNum | Y | string(64) | 商户订单号 | T1231511321515 |
platOrderNum | Y | string(64) | 平台订单号 | PRE1234567890 |
dateTime | Y | string(18) | 时间戳 | 20191018105510 yyyy-MM-dd HH:mm:ss |
sign | Y | string | RSA签名 | ja6R8eukQ... |
响应参数
参数 | 类型 | 必填 | 描述 | 示例 |
---|---|---|---|---|
success | BOOLEAN | Y | 接口响应 | true/false |
code | int | Y | 接口响应码 | 1000代表查询成功,其他的都为查询失败 |
message | String | Y | 接口响应信息 | 返回具体响应信息 |
data | Json | Y | 接口响应参数 | 以下参数都在data中返回,如失败则为null |
msg | String | Y | 订单状态详细信息 | Request Transaction Success |
platOrderNum | String | Y | 平台订单号 | PI1453242857400963072 |
amount | String | Y | 支付金额 | 1500 |
fee | string | Y | 手续费金额 | 5 |
orderNum | String | Y | 商户订单号 | 23645782 |
inAddress | string | N | 入账地址 | TLRx8JXsDidC7PYVLmeD6Bhk5k5CUjnPV3 |
sendAddress | String | N | 出账地址 | TLRx8JcxDidC7PYVLmeD6Bhk5k5CUjnPV3 |
platRespCode | String | Y | 请求业务是否成功 | FAIL:失败\SUCCESS:成功 |
platRespMessage | String | Y | 接口响应信息提示 | Request Transaction Success |
status | int/String | Y | 订单状态 | 代收状态返回string类型,代付状态返回int类型 |
2.请求报文示例
{
"dateTime": "20220101105500",
"merchantCode": "S820211021094748000001",
"orderNum": "T1642593166888",
"platOrderNum": "PRE1642593166888",
"queryType": "ORDER_QUERY",
"sign": "lGw1OJcuUL0MGaIq44U2u2bFM5dalJJuT/G6mQWbIBT9dmVAJaLwR125emPDXYYSdnOtNxja86A2VJJLf40BCg2HevHolebvt2ay3ukCQaUhwNkIGz4KF0Ud+XMUA36LoFTWZbDYv9y8vgCnWxwZFKj7ePrfLxc+TA7jpqv65lQ\u003d"
}
3.代收订单查询响应报文示例
{
"success": true,
"code": 1000,
"message": "Success",
"data": {
"msg": "Payment Success",
"platOrderNum": "BCA1483771634191044608",
"amount": "150",
"fee": "16",
"orderNum": "T1642593166888",
"platRespCode": "SUCCESS",
"platRespMessage": "success",
"status": "SUCCESS"
}
}
4.代付订单查询响应报文示例
{
"success": true,
"code": 1000,
"message": "Success",
"data": {
"msg": "test cash",
"platOrderNum": "W0620220119174331000001",
"amount": "125",
"fee": "7",
"orderNum": "186888188666",
"platRespCode": "SUCCESS",
"platRespMessage": "success",
"status": 2
}
}
九、银行账户查询
1.银行账户查询
import com.google.gson.JsonObject;
public class OrderQuery {
// 测试账号
private static final String MCH_ID = "S820211021094748000001"; // 商户号
private static final String PLAT_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2JoMfFqLsSJjAiCahEnlP3aRj8yCT+WHzR+VvPBTw9S1i7iYWb+MY09CG/HYuHF4+IxshXDJygmndxKf/esuwPybS8mAd//yubHpmZsmBqg1FffT8VH1APa6ZRWASUp4U01ZrbCCp35QA8FuWrJGMJxGx4xk7KUtV2yujxC8noQIDAQAB"; // 平台公钥
private static final String MCH_PRIVATE_KEY = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAJU8gKFKD0luIYx7X8+JRdCIE0UDBctS6LjXxWLEv/EO7jDBTid6zYP1KmNgpd2DAWWtBFBSQ+gcNwVZZSBHJiSDqVvvJVs2FEbeBvfdv4X93+IYRAXksBasSW5Tpdshbo82pVL4V7wuKCuFLk9UxBHbpQjWAbfyF66RmwIbZD71AgMBAAECgYBjPe7UU2nDDSfmQg0++CyjNjqKRC5QPfxhH6w1uF1kMueXKJWOj42n2RutJpJmsj31nY8m0u4xpsG4HvCu/GGSFhhKZCHLvzp41oY2ubYj9nuFNU//81LycQjulWo2y0UUBY0k2piEt+SwPaiUNbT6nMxNMjlnjRe2okp/3rw+KQJBANG3YlZWoVbCEqzy64bJJLxiPsCA5ErGB0NzRGitq44xkhqGtR8ZZQyVz40pruNa58d73O2xyJSy5+fmZGn4E+sCQQC2LBnguj0CSCKub0mPDcunTTz9V79VXBBZdlB1/YGmRUx2s4sQrJNZS7rL4EqBQ3maIRnG+s+AXCSTfsYrV6CfAkEAxugnVfpelhoGepEAgNuggyivmgfl/2Gpm/jk5l/qOjib+ZrQiQmeBPzGWX4yiSM8eMDrP2sC8r5pJFMp5DRONwJBAJ4n4XuSFJ9jgwCPy3vvzSv9SYLk6E6yM9uHdUlKgoGYzk6Lh6M9QFuY/J49plFdBDiEnj16yCU3WeXXfTJpzB8CQQDMNMR/rIOTE9xGybS3mlQbt22AUnO6XhupWcckEKW4nPGxATwYBQzCY3i/9FTGN0vA+9ZPC2cwHtNxI2kXf3Vp"; // 商户私钥
private static final String orderQueryUrl = "https://openapi.jayapayment.com/gateway/verify";
public static void main(String[] args) throws Exception {
query();
}
private static void query() throws Exception {
Map<String, String> requestParams = new TreeMap<>();
requestParams.put("merchantCode", MCH_ID);
requestParams.put("bankCode", "014"); // 银行编码(参考文档最后的银行编码列表)
requestParams.put("accountNumber", "08123456789"); // 银行卡号
requestParams.put("dateTime", "20220101105500");// 时间戳 格式 yyyyMMddHHmmss
StringBuilder stringBuilder = new StringBuilder();
for (String key : requestParams.keySet()) {
stringBuilder.append(requestParams.get(key)); // 拼接参数
}
String keyStr = stringBuilder.toString(); // 得到待加密的字符串
System.out.println("keyStr:" + keyStr);
String signedStr = JayaPayRequestUtil.privateEncrypt(keyStr, JayaPayRequestUtil.getPrivateKey(MCH_PRIVATE_KEY)); // 私钥加密
requestParams.put("sign", signedStr);
String postJson = new Gson().toJson(requestParams);
System.out.println("Post Json Params:" + postJson);
String responseJson = JayaPayRequestUtil.doPost(orderQueryUrl, postJson); // 发送 post json请求
System.out.println("Response Msg:" + responseJson);
}
}
请求地址
POST https://openapi.jayapayment.com/gateway/verify
注意:账号验证接口准确率不是完全准确,存在一定的误差,验证失败不一定代表账号不可用,请谨慎使用!!!
请求参数
参数 | 类型 | 描述 | 示例 |
---|---|---|---|
merchantCode | string(32) | 商户ID,在商户平台-个人中心-个人信息 中获取 |
S820211021094748000001 |
bankCode | string(32) | 银行编码(参考文档最后的银行编码列表) | 014 |
accountNumber | string(30) | 银行卡号 | 08123456789 |
dateTime | string(32) | 时间戳 | 20220101105500 yyyy-MM-dd HH:mm:ss |
sign | string | RSA签名 | ja6R8eukQ... |
响应参数
参数 | 类型 | 必填 | 描述 | 示例 |
---|---|---|---|---|
platRespCode | String | Y | 请求业务是否成功 | FAIL:失败\SUCCESS:成功 |
platRespMessage | String | Y | 接口响应信息提示 | Request Transaction Success |
accountName | String | Y | 账户名称 | OKTAVIANE KAEMPE |
2.请求报文示例
{
"dateTime": "20220101105500",
"bankCode": "014",
"merchantCode": "S820211021094748000001",
"sign": "X/o+IQUzLJqYe9Feid9Uww72mJGOvhJS9dps+EBO7oSWh1P4gboeIfGjVggYViuYsFgYgYR/DZGJEIfo1EUChrZyVZnzGHtd61QhOqRmXCtAwfMGlDgBerEGEl6/JMKmcJbFEjxxJf8fl9HzVUp0T+Q6W5kR/9yWPT7Aask7V7k=",
"accountNumber": "08123456789"
}
3.响应报文示例
{
"accountName": "OKTAVIANE KAEMPE",
"platRespCode": "SUCCESS",
"platRespMessage": "SUCCESS"
}
十、账户余额查询
1.账户余额查询
import com.google.gson.JsonObject;
public class OrderQuery {
// 测试账号
private static final String MCH_ID = "S820211021094748000001"; // 商户号
private static final String PLAT_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2JoMfFqLsSJjAiCahEnlP3aRj8yCT+WHzR+VvPBTw9S1i7iYWb+MY09CG/HYuHF4+IxshXDJygmndxKf/esuwPybS8mAd//yubHpmZsmBqg1FffT8VH1APa6ZRWASUp4U01ZrbCCp35QA8FuWrJGMJxGx4xk7KUtV2yujxC8noQIDAQAB"; // 平台公钥
private static final String MCH_PRIVATE_KEY = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAJU8gKFKD0luIYx7X8+JRdCIE0UDBctS6LjXxWLEv/EO7jDBTid6zYP1KmNgpd2DAWWtBFBSQ+gcNwVZZSBHJiSDqVvvJVs2FEbeBvfdv4X93+IYRAXksBasSW5Tpdshbo82pVL4V7wuKCuFLk9UxBHbpQjWAbfyF66RmwIbZD71AgMBAAECgYBjPe7UU2nDDSfmQg0++CyjNjqKRC5QPfxhH6w1uF1kMueXKJWOj42n2RutJpJmsj31nY8m0u4xpsG4HvCu/GGSFhhKZCHLvzp41oY2ubYj9nuFNU//81LycQjulWo2y0UUBY0k2piEt+SwPaiUNbT6nMxNMjlnjRe2okp/3rw+KQJBANG3YlZWoVbCEqzy64bJJLxiPsCA5ErGB0NzRGitq44xkhqGtR8ZZQyVz40pruNa58d73O2xyJSy5+fmZGn4E+sCQQC2LBnguj0CSCKub0mPDcunTTz9V79VXBBZdlB1/YGmRUx2s4sQrJNZS7rL4EqBQ3maIRnG+s+AXCSTfsYrV6CfAkEAxugnVfpelhoGepEAgNuggyivmgfl/2Gpm/jk5l/qOjib+ZrQiQmeBPzGWX4yiSM8eMDrP2sC8r5pJFMp5DRONwJBAJ4n4XuSFJ9jgwCPy3vvzSv9SYLk6E6yM9uHdUlKgoGYzk6Lh6M9QFuY/J49plFdBDiEnj16yCU3WeXXfTJpzB8CQQDMNMR/rIOTE9xGybS3mlQbt22AUnO6XhupWcckEKW4nPGxATwYBQzCY3i/9FTGN0vA+9ZPC2cwHtNxI2kXf3Vp"; // 商户私钥
private static final String orderQueryUrl = "https://openapi.jayapayment.com/gateway/interface/getBalance";
public static void main(String[] args) throws Exception {
query();
}
private static void query() throws Exception {
Map<String, String> requestParams = new TreeMap<>();
requestParams.put("merchantCode", MCH_ID);
requestParams.put("currency", "IDR"); // 币种(IDR)
StringBuilder stringBuilder = new StringBuilder();
for (String key : requestParams.keySet()) {
stringBuilder.append(requestParams.get(key)); // 拼接参数
}
String keyStr = stringBuilder.toString(); // 得到待加密的字符串
System.out.println("keyStr:" + keyStr);
String signedStr = RequestUtil.privateEncrypt(keyStr, RequestUtil.getPrivateKey(MCH_PRIVATE_KEY)); // 私钥加密
requestParams.put("sign", signedStr);
String postJson = new Gson().toJson(requestParams);
System.out.println("Post Json Params:" + postJson);
String responseJson = RequestUtil.doPost(orderQueryUrl, postJson); // 发送 post json请求
System.out.println("Response Msg:" + responseJson);
}
}
请求地址
POST https://openapi.jayapayment.com/gateway/interface/getBalance
请求参数
参数 | 必填 | 类型 | 描述 | 示例 |
---|---|---|---|---|
merchantCode | Y | string(32) | 商户ID,在商户平台-个人中心-个人信息 中获取 |
S820211021094748000001 |
currency | N | string(20) | 币种 | IDR(不传展示所有货币单位的余额) |
sign | Y | string | RSA签名 | ja6R8eukQ... |
响应参数
参数 | 类型 | 必填 | 描述 | 示例 |
---|---|---|---|---|
success | BOOLEAN | Y | 接口响应 | true/false |
code | int | Y | 接口响应码 | 1000代表查询成功,其他的都为查询失败 |
message | String | Y | 接口响应信息 | 返回具体响应信息 |
data | Json | Y | 接口响应参数 | 以下参数都在data中返回,如失败则为null |
mchId | String | Y | 商户ID | S8202110212321300001 |
mchName | String | Y | 商户名称 | test |
mchNo | String | Y | 商户编号 | TP123 |
currency | string | Y | 币种 | IDR |
balance | String | Y | 可用余额 | 1000.00 |
freeze | String | Y | 冻结余额 | 10.00 |
waitingSettleAmount | String | Y | 待结算金额 | 200.00 |
freezeWaitingSettleAmount | String | Y | 冻结待结算金额 | 100.00 |
totalAmount | String | Y | 全部金额(可用余额+冻结余额+待结算金额+冻结待结算金额) | 20000.00 |
2.请求报文示例
{
"merchantCode": "S8202110212321300001",
"currency": "IDR",
"sign": "X/o+IQUzLJqYe9Feid9Uww72mJGOvhJSJEIfo1EUChrZyVZnzGHtd61QhOqRmXCtAwk7V7k="
}
3.响应报文示例
{
"success": true,
"code": 1000,
"message": "SUCCESS",
"data": [
{
"mchId": "S82022091232130000001",
"mchName": "test",
"mchNo": "test",
"country": "INDONESIA",
"currency": "IDR",
"balance": "1000000.01",
"freeze": "10.00",
"waitingSettleAmount": "10.00",
"freezeWaitingSettleAmount": "20.00",
"totalAmount": "1000040.01"
}
]
}
十一、可选参数附录
Ⅰ 代收业务
1 Status 参数
字段值 | 说明 |
---|---|
INIT_ORDER | 订单初始化 |
NO_PAY | 未支付 |
SUCCESS | 支付成功 |
PAY_CANCEL | 撤销 |
PAY_ERROR | 支付失败 |
Ⅱ 代付业务
1 Status 参数
字段值 | 说明 |
---|---|
0 | 待处理 |
1 | 已受理 |
2 | 代付成功 |
4 | 代付失败 |
5 | 银行代付中 |
2 BankCode 参数
银行编码 | 银行简称 | 银行名称 |
---|---|---|
116 | ACEH | Bank Aceh Syariah |
1160 | ACEH_UUS | Bank Agris UUS |
945 | AGRIS | Bank IBK Indonesia |
494 | AGRONIAGA | Bank Agroniaga |
466 | ANDARA | Bank Andara |
531 | ANGLOMAS | Anglomas International Bank |
061 | ANZ | Bank ANZ Indonesia |
020 | ARTA_NIAGA_KENCANA | Bank Arta Niaga Kencana |
037 | ARTHA | Bank Artha Graha Internasional |
542 | ARTOS | Bank ARTOS/ Bank Jago |
129 | BALI | BPD Bali |
459 | BISNIS_INTERNASIONAL | Bank Bisnis Internasional |
040 | BANGKOK | Bangkok Bank |
558 | BANTEN | BPD Banten |
014 | BCA | Bank Central Asia(BCA) |
536 | BCA_SYR | Bank Central Asia (BCA) Syariah |
133 | BENGKULU | Bank Bengkulu |
110 | BJB | Bank Jawa Barat(BJB) |
425 | BJB_SYR | Bank BJB Syariah |
009 | BNI | Bank Negara Indonesia(BNI) |
427 | BNI_SYR | Bank BNI Syariah |
069 | BOC | BANK OF CHINA LIMITED |
002 | BRI | Bank Rakyat Indonesia(BRI) |
422 | BRI_SYR | Bank BRI Syariah |
1450 | BNP_PARIBAS | Bank BNP Paribas |
4510 | BSI | Bank Syariah Indonesia(BSI) |
200 | BTN | Bank Tabungan Negara (BTN) |
2000 | BTN_UUS | Bank Tabungan Negara (BTN) UUS |
213 | BTPN | Bank BTPN |
5470 | BTPN_SYARIAH | BTPN Syariah |
547 | BTPN_SYR | Bank BTPN Syariah |
441 | BUKOPIN | Wokee/Bukopin |
521 | BUKOPIN_SYR | Bank Bukopin Syariah |
076 | BUMI_ARTA | Bank Bumi Arta |
054 | CAPITAL | Bank Capital Indonesia |
949 | CHINATRUST | CTBC Indonesia |
559 | CNB | Centratama Nasional Bank(CNB) |
022 | CIMB | Bank CIMB Niaga |
0220 | CIMB_UUS | Bank CIMB Niaga UUS |
031 | CITIBANK | Citibank |
950 | COMMONWEALTH | Bank Commonwealth |
112 | BPD_DIY | BPD DIY |
011 | DANAMON | Bank Danamon |
0110 | DANAMON_UUS | Bank Danamon UUS |
046 | DBS | Bank DBS Indonesia |
526 | DINAR_INDONESIA | Bank Dinar Indonesia |
111 | DKI | Bank DKI |
778 | DKI_UUS | Bank DKI UUS |
562 | FAMA | Bank Fama International |
699 | EKA | Bank EKA |
161 | GANESHA | Bank Ganesha |
484 | HANA | LINE Bank/KEB Hana |
567 | HARDA_INTERNASIONAL | Allo Bank/Bank Harda Internasional |
2120 | HIMPUNAN_SAUDARA | Bank Himpunan Saudara 1906 |
041 | HSBC | HSBC |
164 | ICBC | Bank ICBC Indonesia |
513 | INA_PERDANA | Bank Ina Perdana |
555 | INDEX_SELINDO | Bank Index Selindo |
146 | INDIA | Bank of India Indonesia |
115 | JAMBI | Bank Jambi |
472 | JASA_JAKARTA | Bank Jasa Jakarta |
113 | JAWA_TENGAH | Bank Jateng |
114 | JATIM | Bank Jatim |
095 | JTRUST | Bank JTrust Indonesia |
123 | KALIMANTAN_BARAT | BPD Kalimantan Barat/Kalbar |
1230 | KALIMANTAN_BARAT_UUS | BPD Kalimantan Barat UUS |
122 | KALIMANTAN_SELATAN | BPD Kalimantan Selatan/Kalsel |
1220 | KALIMANTAN_SELATAN_UUS | BPD Kalimantan Selatan UUS |
125 | KALIMANTAN_TENGAH | BPD Kalimantan Tengah (Kalteng) |
124 | KALIMANTAN_TIMUR | BPD Kalimantan Timur |
1240 | KALIMANTAN_TIMUR_UUS | BPD Kalimantan Timur UUS |
535 | KESEJAHTERAAN_EKONOMI | Seabank/Bank Kesejahteraan Ekonomi(BKE) |
121 | LAMPUNG | BPD Lampung |
131 | MALUKU | Bank Maluku |
008 | MANDIRI | Bank Mandiri |
564 | MANTAP | Bank MANTAP |
548 | MULTI_ARTA_SENTOSA | Bank Multi Arta Sentosa(MAS) |
157 | MASPION | Bank Maspion Indonesia |
097 | MAYAPADA | Bank Mayapada |
016 | MAYBANK | Bank Maybank |
947 | MAYBANK_SYR | Bank Maybank Syariah Indonesia |
553 | MAYORA | Bank Mayora Indonesia |
426 | MEGA | Bank Mega |
506 | MEGA_SYR | Bank Mega Syariah |
151 | MESTIKA_DHARMA | Bank Mestika Dharma |
485 | MNC_INTERNASIONAL | Motion/Bank MNC Internasional |
147 | MUAMALAT | Bank Muamalat Indonesia |
491 | MITRA_NIAGA | Bank Mitra Niaga |
048 | MIZUHO | Bank Mizuho Indonesia |
503 | NATIONALNOBU | Bank National Nobu |
128 | NUSA_TENGGARA_BARAT | BPD Nusa Tenggara Barat(NTB) |
1280 | NUSA_TENGGARA_BARAT_UUS | BPD Nusa Tenggara Barat (NTB) UUS |
130 | NUSA_TENGGARA_TIMUR | BPD Nusa Tenggara Timur(NTT) |
145 | NUSANTARA_PARAHYANGAN | Bank Nusantara Parahyangan |
028 | OCBC | Bank OCBC NISP |
0280 | OCBC_UUS | Bank OCBC NISP UUS |
019 | PANIN | Bank Panin |
517 | PANIN_SYR | Panin Dubai Syariah |
132 | PAPUA | Bank Papua |
013 | PERMATA | Bank Permata |
0130 | PERMATA_UUS | Bank Permata UUS |
520 | PRIMA_MASTER | Bank Prima Master |
167 | QNB_KESAWAN | QNB KESAWAN |
1670 | QNB_INDONESIA | QNB Indonesia |
5260 | OKE | Bank Oke Indonesia |
089 | RABOBANK | Rabobank International Indonesia |
047 | RESONA | Bank Resona Perdania |
119 | RIAU_DAN_KEPRI | BPD Riau Dan Kepri |
1190 | RIAU_DAN_KEPRI_UUS | BPD Riau Dan Kepri UUS |
523 | SAHABAT_SAMPOERNA | Bank Sahabat Sampoerna |
498 | SBI_INDONESIA | Bank SBI Indonesia |
152 | SHINHAN | Bank Shinhan Indonesia |
153 | SINARMAS | Bank Sinarmas |
050 | STANDARD_CHARTERED | Standard Chartered Bank |
134 | SULAWESI | Bank Sulteng |
135 | SULAWESI_TENGGARA | Bank Sultra |
126 | SULSELBAR | Bank Sulselbar |
1260 | SULSELBAR_UUS | Bank Sulselbar UUS |
127 | SULUT | BPD Sulawesi Utara(SulutGo) |
118 | SUMATERA_BARAT | BPD Sumatera Barat |
1180 | SUMATERA_BARAT_UUS | BPD Sumatera Barat UUS |
120 | SUMSEL_DAN_BABEL | BPD Sumsel Babel |
1200 | SUMSEL_DAN_BABEL_UUS | Bank Sumsel Babel UUS |
117 | SUMUT | Bank Sumut |
1170 | SUMUT_UUS | Bank Sumut UUS |
1530 | SINARMAS_UUS | Bank Sinarmas UUS |
045 | MITSUI | Bank Sumitomo Mitsui Indonesia |
451 | MANDIRI_SYR | Bank Syariah Mandiri(BSM) |
042 | TOKYO | Bank of Tokyo |
023 | UOB | TMRW/Bank UOB Indonesia |
566 | VICTORIA_INTERNASIONAL | Bank Victoria International |
405 | VICTORIA_SYR | Bank Victoria Syariah |
212 | WOORI | Bank Woori Saudara |
490 | YUDHA_BHAKTI | Neo Commerce/Bank Yudha Bhakti(BNC) |
1120 | DAERAH_ISTIMEWA_UUS | BPD_Daerah_Istimewa_Yogyakarta_(DIY) |
5590 | CENTRATAMA | Bank Centratama |
088 | CCB | CCB Indonesia |
067 | DEUTSCHE | Deutsche Bank |
032 | JPMORGAN | JPMORGAN CHASE BANK |
5640 | MANDIRI_TASPEN | Bank Mandiri Taspen Pos |
501 | RBS | Royal Bank of Scotland (RBS) |
10001 | OVO | OVO |
10002 | DANA | DANA |
10003 | GOPAY | GOPAY |
10006 | MULTICOR | Bank MULTICOR |
10008 | SHOPEEPAY | SHOPEEPAY |
10009 | LINKAJA | LINKAJA |
10010 | MUTIARA | Bank MUTIARA |