提交表单

介绍

该接口用于上传用户支付账户信息。

接口说明

请求方式: POST

请求路径: /open/api/v4/merchant/payment/account/create

请求参数

Header参数:

参数名必选类型说明
access-tokenYstring免登录 accessToken 值,可以从免登录获取 token 接口获取
appidYstring应用的唯一标识
timestampYstring当前 UTC 13 位时间戳, 5 分钟内有效
signYstring签名,签名方式可参考这里

Body参数:

参数必选描述
payWayCodeY支付方式code
(信用卡:10001、Apple Pay:501、Google Pay:701)
fiatY法币code eg:USD
sideYonramp:BUY
offramp:SELL
formDataY该表单字段由⽀付表单获取,AES加密

示例Onramp:

{
    "payWayCode": "10001",
    "fiat": "USD",
    "side": "BUY",
    "formData": { //该表单字段由⽀付表单获取,AES加密
        "firstName": "8GKayC4glgkm1FLYTnWABA==",
        "lastName": "7AaakfM3yYa6cKLfMfPrKA==",
        "cardNumber": "vRiCGA2er2uAnTjZclG8eNKyfzr3f4knee0a2WUICZQ=",
        "cardExpireYear": "f66exC/oSmldbTH1Y/MKLw==", //该字段需要填写四位数字,例:2029
        "cardExpireMonth": "YY4WKHYhzkehZdzOGRgynQ==",//该字段需要填写兩位数字,例:09
        "cardCvv": "3QuPKpNgSSqVppgQP56TOg==",
        "country": "U7umtG41RPdUlDQGNF+UZQ==",
        "state": "smIOTJQqtc30HwGO05WkOQ==",
        "city": "JRfOQJdgjIv5KTQ0URHP7w==",
        "postcode": "vfLvOorGDB4rxYAdpddaUQ==",
        "address": "a+7p1pewEBvGC4KL/hb96Q=="
    }
}

示例Offramp:

{
    "payWayCode": "94100",
    "fiat": "USD",
    "side": "SELL",
    "formData": { //该表单字段由⽀付表单获取,AES加密
        "givName": "8GKayC4glgkm1FLYTnWABA==",
        "surName": "7AaakfM3yYa6cKLfMfPrKA==",
        "country": "+k9tf411qmfdCrdUPc+nYQ==",
        "address":
"iGJtleVXc45y4N+PVRg5Mp/WRms/Sz/4UFbzAmuk6rTrYz/Mn/zKLPuPZY5M5w+zkkAD6RJLY9i
SZrwLZprRRL4DbKc84/RzouJimbI+qLU=",
 "area": "/ET6RnTOnu1BTC5Abxj2mg==",
        "phone": "21NAxYvDwi1BADiE8aPS2Q==",
        "locationId": "ZKpeTo//iTUQu794AfkNcQ==",
        "bankId": "ZKpeTo//iTUQu794AfkNcQ==",
        "accountNo": "8Pr/qusk+R3XhR8g+ebe4w=="
    }
}

响应参数

示例:

{
	"success": true,
	"returnCode": "0000",
	"returnMsg": "SUCCESS",
	"extend": "",
	"data": {
		"userAccountId": 16784,
		"cardBrand": "MASTER_CARD",//信用卡类别MASTER_CARD、VISA(payWayCode=10001)返回
		"firstSixDigits": "******",//信用卡前6位(payWayCode=10001)返回
		"lastFourDigits": "****"//信用卡后4位(payWayCode=10001)返回
	},
	"traceId": "67298861a81a9572d84df2b4c00e10a3"
}

注意

  • 用户使用信用卡成功支付后(payWayCode=10001),请保存用户卡成功交易的userAccountId,不可再次用该卡信息请求提交表单接口。
  • 使用用户的userAccountId,直接创建订单,可以参考:

AES 加密

出于安全考虑,⽀付表单字段数据需要进⾏AES加密操作后提交,加密⽅法如下:

public class AESUtil {

    public static String encrypt(String plainText, String secretKeyData)  {
        try {
            byte[] plainTextData = plainText.getBytes(StandardCharsets.UTF_8);
            byte[] secretKey = secretKeyData.getBytes(StandardCharsets.UTF_8);
            String iv = new String(secretKey).substring(0, 16);

            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");

            byte[] dataBytes = plainTextData;
            int plaintextLength = dataBytes.length;
            byte[] plaintext = new byte[plaintextLength];
            System.arraycopy(dataBytes, 0, plaintext, 0, dataBytes.length);

            SecretKeySpec keyspec = new SecretKeySpec(secretKey, "AES");
            IvParameterSpec ivspec = new IvParameterSpec(iv.getBytes());

            cipher.init(Cipher.ENCRYPT_MODE, keyspec, ivspec);
            byte[] encrypted = cipher.doFinal(plaintext);

            return new String(Base64.getEncoder().encode(encrypted));

        } catch (Exception e) {
            log.error("AES encrypting exception , msg is {}" , e.toString(), e);
        }
        return null;
    }

    public static String decrypt(String cipherText, String secretKeyData) {
        try {

            byte[] cipherTextData = cipherText.getBytes(StandardCharsets.UTF_8);
            byte[] secretKey = secretKeyData.getBytes(StandardCharsets.UTF_8);
            String iv = new String(secretKey).substring(0, 16);

            byte[] encrypted = Base64.getDecoder().decode(cipherTextData);

            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
            SecretKeySpec keyspec = new SecretKeySpec(secretKey, "AES");
            IvParameterSpec ivspec = new IvParameterSpec(iv.getBytes());

            cipher.init(Cipher.DECRYPT_MODE, keyspec, ivspec);

            byte[] original = cipher.doFinal(encrypted);
            String originalString = new String(original);
            return originalString;
        } catch (Exception e) {
            log.error("AES decrypting exception: msg is {}" , e.toString(), e);
        }
        return null;
    }
}