Skip to content

Latest commit

 

History

History
255 lines (183 loc) · 13.2 KB

首都在线项目支付签名接口文档.md

File metadata and controls

255 lines (183 loc) · 13.2 KB

首都在线项目支付签名接口文档

验证方式

使用RS512生成JWT Token,payload部分需包含:

{
  "iss": "https://dqsdx.cn",
  "aud": "https://capitalonline.net"
}
以Node.js举例
const jwt = require('jsonwebtoken');
const fs = require('fs');

const payload = {
  "iss": "https://dqsdx.cn",
  "aud": "https://capitalonline.net"
};

const privateKey = fs.readFileSync('sandbox_key.pem');
const token = jwt.sign(payload, privateKey, { expiresIn: 6000, algorithm: 'RS512' });

console.log(token);

支付宝签名接口

POST /alipay/sign

请参见支付宝文档 https://opendocs.alipay.com/common/057k53?pathHash=7b14a0af 拼接待签名字符串并传入请求body。所有Content-Type均为text/plain;charset=UTF-8

支付宝待签名参数示例
app_id=9021000137636299&biz_content={"out_trade_no":"daniel82AAAA000032333361X01","total_amount":"0.01","subject":"测试商品","product_code":"FAST_INSTANT_TRADE_PAY"}&charset=UTF-8&format=json&method=alipay.trade.page.pay&sign_type=RSA2&timestamp=2024-05-24 12:05:02&version=1.0
请求头部格式
Key Value
Authorization Bearer $token
响应
Code Content-Type Response
200 text/plain;charset=UTF-8 OK(返回签名)
401 text/plain;charset=UTF-8 Unauthorized
400 text/plain;charset=UTF-8 BadRequest
cURL示例
curl -v -X POST 'https://sandbox.dqsdx.cn:7654/alipay/sign' \
    -H 'Authorization: Bearer eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2Rxc2R4LmNuIiwiYXVkIjoiaHR0cHM6Ly9jYXBpdGFsb25saW5lLm5ldCIsImlhdCI6MTcxNjUxOTEyMywiZXhwIjoxNzE2NTI1MTIzfQ.XAwde9TjPER36vX2hWwi5_KIb4OaIgZYEhLXyRitMjzXBICuWgUwPpVifAzvgZLQKaQS_RGCFSCxl-WbYOHvi3xfOCSqYGTBFXpu90lGrRO3Xax0DTqoJvBlzCqAjL_111kgkoouLnm-oaK0RgpyzPKc1fFMDlun7Hfg2BENGmH0BrydkjmnBmT-E3ath9kcFyhDxyFIZypQr9ZDjkh9jjzu9UlJ2rEROnh8TCxPjR1IOoZR1OZObdT00Y2yemzrc-nURaPRMWYevXpUML3Iy_zZoX0QialauvIJikW1az68glMm6q27khe_PpcrqXARu0PV3l-4pcfUUIeAcwIP6ePAE3tbmEBrp_oHrQE9NHZTpJr54NQZOelSROzeGKjg_6qfuZaQk3YU_VdyPU5sN7-syH958nIWJ0vXcfDF-e3He1Cnpd8-0yKYK8QD7m9_BYbuOJtb2_eO0IFWvk_C0ne8sVDew4mefKnMnew6F6ml6ycCDmrwj3b1CBhWE3nR' \
    -d 'app_id=9021000137636299&biz_content={"out_trade_no":"daniel82AAAA000032333361X01","total_amount":"0.01","subject":"测试商品","product_code":"FAST_INSTANT_TRADE_PAY"}&charset=UTF-8&format=json&method=alipay.trade.page.pay&sign_type=RSA2&timestamp=2024-05-24 12:05:02&version=1.0'
返回结果
Q6B2HjzFSgbV6LhGczMOFr23sefzfUTyFtsA7Cf75i3IpBEDsvYJA06ZL6V2bxBRtfPtj3A9htibDwNYi9rOctIRDMX0tavboHKFZGqTPfvzJubx36nJ6YOUiPw3iUQ//gqJuY+7eXGsU7n0QflL5E4Rjvu/Jy21cFS5QiTyVCdNc1UMcanqxl27RhBFEsjb9BM91A8kklluKLcNp8R8T2/Hgwx8F5/cI/31rNhyr/jx+flnwun/nWpE4M6Qw7TUusxIMkvhrL5k5kits2hAqCs5Ozl6mzJmfE8KYbb7SNn8OMqLB+3s23SPrRtrnQlX6pVV2iHCbkld6gJ6k/tqyg==
拼接好的用于跳转支付宝的URL示例
https://openapi-sandbox.dl.alipaydev.com/gateway.do?app_id=9021000137636299&biz_content=%7B%22out_trade_no%22%3A%22daniel82AAAA000032333361X01%22%2C%22total_amount%22%3A%220.01%22%2C%22subject%22%3A%22%E6%B5%8B%E8%AF%95%E5%95%86%E5%93%81%22%2C%22product_code%22%3A%22FAST_INSTANT_TRADE_PAY%22%7D&charset=UTF-8&format=json&method=alipay.trade.page.pay&sign_type=RSA2&timestamp=2024-05-24%2012%3A05%3A02&version=1.0&sign=Q6B2HjzFSgbV6LhGczMOFr23sefzfUTyFtsA7Cf75i3IpBEDsvYJA06ZL6V2bxBRtfPtj3A9htibDwNYi9rOctIRDMX0tavboHKFZGqTPfvzJubx36nJ6YOUiPw3iUQ%2F%2FgqJuY%2B7eXGsU7n0QflL5E4Rjvu%2FJy21cFS5QiTyVCdNc1UMcanqxl27RhBFEsjb9BM91A8kklluKLcNp8R8T2%2FHgwx8F5%2FcI%2F31rNhyr%2Fjx%2Bflnwun%2FnWpE4M6Qw7TUusxIMkvhrL5k5kits2hAqCs5Ozl6mzJmfE8KYbb7SNn8OMqLB%2B3s23SPrRtrnQlX6pVV2iHCbkld6gJ6k%2Ftqyg%3D%3D

支付宝验签接口

POST /alipay/verify

用于验证支付宝异步通知notify_url接受到的签名与返回结果是否一致。请直接将notify_url body接收到的字符串传入请求body,内容类型为text/plain; charset=utf-8。

支付宝通知字符串示例
gmt_create=2024-05-27+11%3A50%3A21&charset=utf-8&gmt_payment=2024-05-27+11%3A50%3A28&notify_time=2024-05-27+11%3A50%3A30&subject=%E6%B5%8B%E8%AF%95%E5%95%86%E5%93%81&sign=IXIWu4QJmCaXQN6rpAIhX2eqPJojJjbj21%2FyC1sPPYSAAItZICP%2FUCZDhCo20KOZfCM7cZY7dTRE9kjHeaYUVKe42hYbY6HyaSNBqyO2qJGvzE2fNIxocSYuTqnSHIVHfOJMO9xS%2BmUI4LKcXfeP2IHSf04uu8%2BpYEPWI%2B3xES003UhjbxIM%2F1h%2BgW%2BVLc5qzwnnE9rMelNJZS3SD%2FWC%2FvVS1LWgyMigQRJ%2B542JqgdKhKRc4JlQaLX%2FJaHa2oqfsGN3hSKgADEuaaZXgjSTOYhL6hCQP2Tu%2FwRPzNzK4AhgcGFA1Iss9f%2B9TW2o9wHaV3A4sr8994WF6x8d9CBlFA%3D%3D&buyer_id=2088722036135292&invoice_amount=0.01&version=1.0&notify_id=2024052701222115029135290503255301&fund_bill_list=%5B%7B%22amount%22%3A%220.01%22%2C%22fundChannel%22%3A%22ALIPAYACCOUNT%22%7D%5D&notify_type=trade_status_sync&out_trade_no=daniel82AAAA000032848949&total_amount=0.01&trade_status=TRADE_SUCCESS&trade_no=2024052722001435290503183711&auth_app_id=9021000137636299&receipt_amount=0.01&point_amount=0.00&buyer_pay_amount=0.01&app_id=9021000137636299&sign_type=RSA2&seller_id=2088721036135284
请求头部格式
Key Value
Authorization Bearer $token
响应
Code Content-Type Response
200 application/json OK(返回Json)
401 text/plain;charset=UTF-8 Unauthorized
400 text/plain;charset=UTF-8 BadRequest
返回参数
Name Type Desc
result bool true表示签名匹配,false表示不匹配
exception string 解析字符串出错时抛出的异常信息
cURL示例
curl -v -X POST 'https://sandbox.dqsdx.cn:7654/alipay/verify' \
    -H 'Authorization: Bearer eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2Rxc2R4LmNuIiwiYXVkIjoiaHR0cHM6Ly9jYXBpdGFsb25saW5lLm5ldCIsImlhdCI6MTcxNjUxOTEyMywiZXhwIjoxNzE2NTI1MTIzfQ.XAwde9TjPER36vX2hWwi5_KIb4OaIgZYEhLXyRitMjzXBICuWgUwPpVifAzvgZLQKaQS_RGCFSCxl-WbYOHvi3xfOCSqYGTBFXpu90lGrRO3Xax0DTqoJvBlzCqAjL_111kgkoouLnm-oaK0RgpyzPKc1fFMDlun7Hfg2BENGmH0BrydkjmnBmT-E3ath9kcFyhDxyFIZypQr9ZDjkh9jjzu9UlJ2rEROnh8TCxPjR1IOoZR1OZObdT00Y2yemzrc-nURaPRMWYevXpUML3Iy_zZoX0QialauvIJikW1az68glMm6q27khe_PpcrqXARu0PV3l-4pcfUUIeAcwIP6ePAE3tbmEBrp_oHrQE9NHZTpJr54NQZOelSROzeGKjg_6qfuZaQk3YU_VdyPU5sN7-syH958nIWJ0vXcfDF-e3He1Cnpd8-0yKYK8QD7m9_BYbuOJtb2_eO0IFWvk_C0ne8sVDew4mefKnMnew6F6ml6ycCDmrwj3b1CBhWE3nR' \
    -d 'gmt_create=2024-05-27+11%3A50%3A21&charset=utf-8&gmt_payment=2024-05-27+11%3A50%3A28&notify_time=2024-05-27+11%3A50%3A30&subject=%E6%B5%8B%E8%AF%95%E5%95%86%E5%93%81&sign=IXIWu4QJmCaXQN6rpAIhX2eqPJojJjbj21%2FyC1sPPYSAAItZICP%2FUCZDhCo20KOZfCM7cZY7dTRE9kjHeaYUVKe42hYbY6HyaSNBqyO2qJGvzE2fNIxocSYuTqnSHIVHfOJMO9xS%2BmUI4LKcXfeP2IHSf04uu8%2BpYEPWI%2B3xES003UhjbxIM%2F1h%2BgW%2BVLc5qzwnnE9rMelNJZS3SD%2FWC%2FvVS1LWgyMigQRJ%2B542JqgdKhKRc4JlQaLX%2FJaHa2oqfsGN3hSKgADEuaaZXgjSTOYhL6hCQP2Tu%2FwRPzNzK4AhgcGFA1Iss9f%2B9TW2o9wHaV3A4sr8994WF6x8d9CBlFA%3D%3D&buyer_id=2088722036135292&invoice_amount=0.01&version=1.0&notify_id=2024052701222115029135290503255301&fund_bill_list=%5B%7B%22amount%22%3A%220.01%22%2C%22fundChannel%22%3A%22ALIPAYACCOUNT%22%7D%5D&notify_type=trade_status_sync&out_trade_no=daniel82AAAA000032848949&total_amount=0.01&trade_status=TRADE_SUCCESS&trade_no=2024052722001435290503183711&auth_app_id=9021000137636299&receipt_amount=0.01&point_amount=0.00&buyer_pay_amount=0.01&app_id=9021000137636299&sign_type=RSA2&seller_id=2088721036135284'
返回示例
HTTP/1.1 200 OK
Content-Length: 39
Connection: close
Content-Type: application/json
Date: Thu, 30 May 2024 03:56:04 GMT
Server: Kestrel

{
  "result": true,
  "exception": ""
}

发送验证码

POST /sendSms

当前阿里云发送频率设置(同号码):

  • 每分钟内发送上限 5 条
  • 每小时内发送上限 10 条
  • 每个自然日内发送上限 20 条
请求头部格式
Key Value
Authorization Bearer $token
请求参数
Key Type Description
phoneNumber long 手机号
返回参数
Name Type Desc
result bool true表示发送成功,false表示不成功
code int 后台生成的验证码
err string 出错信息
cURL示例
curl -X "POST" "https://sandbox.dqsdx.cn:7654/sendSms" \
     -H 'Authorization: Bearer eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2Rxc2R4LmNuIiwiYXVkIjoiaHR0cHM6Ly9jYXBpdGFsb25saW5lLm5ldCIsImlhdCI6MTcxNjk2MzQ0MywiZXhwIjoxNzQ4NDk5NDQzfQ.S7hyWhRGlvHGRB6iWu1kkcg3FwDMXgPXwvXKwxEjHwtzeqb-LZGyxoGe6fy47IH4-ZaUIz2ogtDFCl2N7C-ygRBgRyHXsYkidYunpMyPgH_M4bhsqqrXM9g3qoWCU5agq3y9m8WdTX3fB-cWLpt0ZbV8_Tui6I5SUFSdfV0tF6mCu8Td_LhykJPCyPeOM8i1qR5SVY5su6AVPoCj8KbbiL5hNcrGQJdlUZBRbWkUi5Zsfd9Mz6VGLKK18R6rgzpeRCfE-TA8AqmFtZdOTeTRobHYUV9OEjzyFXqqkz4qRv5kAfvGuNQ7__FHT0jhtWxalr2y4SjHYLKE_1iKJ-AjyoGzGd4ulUFLeZz-yELxrRgk-g4sX3eati8iNmAEMPsA-sPvS9HYAhYyTriZZhgpTevLMSJn9qGBSSmt7V7zH4_QbS88aSfa_i3gIgBZdsrzQ7-wK4DIP8yWbkZ9VYoTVM3vgt0v0AH6LyDA9xGuKE1Rf1VnD7pQDAr2m4Dq7lXK' \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
  "phoneNumber": 159014298
}'
返回示例
HTTP/1.1 200 OK
Content-Length: 96
Connection: close
Content-Type: application/json
Date: Wed, 19 Jun 2024 03:04:35 GMT
Server: Kestrel

{
  "result": false,
  "code": 472359,
  "err": "错误信息: 手机号码格式错误, PhoneNumber: 159014298"
}

验证验证码

POST /verifySmsCode

请求头部格式
Key Value
Authorization Bearer $token
请求参数
Key Type Description
phoneNumber long 手机号
verifyCode int 验证码
返回参数
Name Type Desc
result bool true表示验证码匹配,false表示不匹配
err string 出错信息
cURL示例
curl -X "POST" "https://sandbox.dqsdx.cn:7654/verifySmsCode" \
     -H 'Authorization: Bearer eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2Rxc2R4LmNuIiwiYXVkIjoiaHR0cHM6Ly9jYXBpdGFsb25saW5lLm5ldCIsImlhdCI6MTcxNjk2MzQ0MywiZXhwIjoxNzQ4NDk5NDQzfQ.S7hyWhRGlvHGRB6iWu1kkcg3FwDMXgPXwvXKwxEjHwtzeqb-LZGyxoGe6fy47IH4-ZaUIz2ogtDFCl2N7C-ygRBgRyHXsYkidYunpMyPgH_M4bhsqqrXM9g3qoWCU5agq3y9m8WdTX3fB-cWLpt0ZbV8_Tui6I5SUFSdfV0tF6mCu8Td_LhykJPCyPeOM8i1qR5SVY5su6AVPoCj8KbbiL5hNcrGQJdlUZBRbWkUi5Zsfd9Mz6VGLKK18R6rgzpeRCfE-TA8AqmFtZdOTeTRobHYUV9OEjzyFXqqkz4qRv4kAfvGuNQ7__FHT0jhtWxalr2y4SjHYLKE_1iKJ-AjyoGzGd4ulUFLeZz-yELxrRgk-g4sX3eati8iNmAEMPsA-sPvS9HYAhYyTriZZhgpTevLMSJn9qGBSSmt7V7zH4_QbS88aSfa_i3gIgBZdsrzQ7-wK4DIP8yWbkZ9VYoTVM3vgt0v0AH6LyDA9xGuKE1Rf1VnX7pQDAr2m4Dq7lXK' \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
  "verifyCode": 334433,
  "phoneNumber": 15901429815
}'
返回示例
HTTP/1.1 200 OK
Content-Length: 91
Connection: close
Content-Type: application/json
Date: Wed, 19 Jun 2024 02:53:49 GMT
Server: Kestrel

{
  "result": false,
  "err": "The input string '3522101aa' was not in a correct format."
}