- 新平台
该接口用于支付完成后获取支付结果使用。
https://api-reference.checkout.com/#operation/getPaymentDetails
通过pay | sid_id 查询支付结果
沙箱环境地址:https://api.sandbox.checkout.com/payments/{id}
生产环境地址:https://api.checkout.com/payments/{id}
通过URL中添加Path参数来获取指定支付的最新状态
| Path 参数名 | 是否必填 | 说明 |
|---|---|---|
| id | - [x] |
| 正则表达式:^(pay|sid)_(\w{26})$
该id为调用Create HPP或者Payment完成支付后返回。
具体见后文如何获取pay | sid id |
成功返回报文示例:
GET https://api.sandbox.checkout.com/payments/pay_g26ap2k3dtt2vdx5shygqfsk2e{"id": "pay_g26ap2k3dtt2vdx5shygqfsk2e","requested_on": "2022-04-24T03:30:12Z","source": {"id": "src_3t5guzlqpsyuxliofkvgbodcxy","type": "card","billing_address": {"country": "US"},"expiry_month": 1,"expiry_year": 2023,"name": "L L","scheme": "Visa","last4": "4242","fingerprint": "038243847473D6ABE9CDF2E1E812A656CC71C3A5552C09CB3D1FE6E3AC676C84","bin": "424242","card_type": "Credit","card_category": "Consumer","issuer": "JPMORGAN CHASE BANK NA","issuer_country": "US","product_id": "A","product_type": "Visa Traditional","avs_check": "S","cvv_check": "Y","payouts": true,"fast_funds": "d"},"amount": 5000,"currency": "EUR","payment_type": "Regular","reference": "abc-123","status": "Captured","approved": true,"3ds": {"downgraded": false,"enrolled": "Y","authentication_response": "Y","cryptogram": "3ec010c5-df25-4c6e-be52-e4a3","xid": "08f88368-711f-4491-89c5-49c7963174dd","version": "2.1.0"},"risk": {"flagged": false},"customer": {"id": "cus_lygzjadnmwkuvdnmu4ymohd7uy"},"billing_descriptor": {"name": "","city": "London"},"metadata": {"mode": "payment","cancel_url": "http://127.0.0.1:3000/result","correlationId": "4d28f42c-1bdb-4a28-87a9-c69db0ab7129","correlation_id": "4d28f42c-1bdb-4a28-87a9-c69db0ab7129"},"eci": "05","scheme_id": "956063208697024","actions": [{"id": "act_fha4huunf6mkvmcsxjnqb3st7q","type": "Capture","response_code": "10000","response_summary": "Approved"},{"id": "act_g26ap2k3dtt2vdx5shygqfsk2e","type": "Authorization","response_code": "10000","response_summary": "Approved"}],"_links": {"self": {"href": "https://api.sandbox.checkout.com/payments/pay_g26ap2k3dtt2vdx5shygqfsk2e"},"actions": {"href": "https://api.sandbox.checkout.com/payments/pay_g26ap2k3dtt2vdx5shygqfsk2e/actions"},"refund": {"href": "https://api.sandbox.checkout.com/payments/pay_g26ap2k3dtt2vdx5shygqfsk2e/refunds"}}}
通过reference查询支付结果
也可以通过增加param来获取指定支付的最新状态
沙箱环境地址:https://api.sandbox.checkout.com/payments?reference={{reference}}
生产环境地址:https://api.checkout.com/payments?reference={{reference}}
| Param 参数名 | 是否必填 | 说明 |
|---|---|---|
| reference | - [x] |
| reference为原Payment请求中商户侧的订单id |
当商户发送了重复的reference时,查询结果中会以数组的形式返回所有支付单信息。
成功返回报文示例-存在唯一reference:
{"total_count": 1,"skip": 0,"limit": 10,"data": [{"id": "pay_wcxurpsg7ui2dbuwx2mnhn23b4","requested_on": "2022-06-29T09:22:53Z","source": {"id": "src_hdsc6vjgjnwexphsly46tbuu6e","type": "card","billing_address": {"country": "HK"},"expiry_month": 2,"expiry_year": 2023,"scheme": "Visa","last4": "4242","fingerprint": "67CF46597CE027875ED8230F168703A1D49E8D10622180AE58BB08813B3233D3","bin": "424242","card_type": "Credit","card_category": "Consumer","issuer": "JPMORGAN CHASE BANK NA","issuer_country": "US","product_id": "A","product_type": "Visa Traditional","avs_check": "S","cvv_check": "Y","payouts": true,"fast_funds": "d"},"amount": 300,"currency": "USD","payment_type": "Regular","reference": "ORD-TEST-2206","description": "Set of 3 masks","status": "Captured","approved": true,"risk": {"flagged": false},"customer": {"id": "cus_lxuppkhxqzfetaaaoxmjvxeybm","email": "abc@163.com"},"billing_descriptor": {"name": "","city": "London"},"shipping": {"address": {"address_line1": "Checkout.com","address_line2": "90 Tottenham Court Road","city": "London","state": "London","zip": "W1T 4TJ","country": "HK"},"phone": {"country_code": "1","number": "415 555 2671"}},"scheme_id": "411080072971738","_links": {"self": {"href": "https://api.sandbox.checkout.com/payments/pay_wcxurpsg7ui2dbuwx2mnhn23b4"},"actions": {"href": "https://api.sandbox.checkout.com/payments/pay_wcxurpsg7ui2dbuwx2mnhn23b4/actions"},"refund": {"href": "https://api.sandbox.checkout.com/payments/pay_wcxurpsg7ui2dbuwx2mnhn23b4/refunds"}}}]}
成功返回报文示例-存在多个相同的reference:
Get https://api.sandbox.checkout.com//payments?reference=ORD-Test-2022-23{"total_count": 12,"skip": 0,"limit": 10,"data": [{"id": "pay_gyhf5oyvhdbutgzol4lscn7kfi","requested_on": "2022-06-23T07:01:41.3999122Z","source": {"type": "card","expiry_month": 12,"expiry_year": 2025,"scheme": "Visa","last4": "7863","fingerprint": "C8A6B037924E78BECC5C76AD6D895D9BE0D43C3030AA079317E554B84E0EB7A3","bin": "453962","card_type": "DEBIT","card_category": "CONSUMER","issuer": "BANC INTERNACIONAL DANDORRA, S.A.","issuer_country": "AD"},"amount": 1005,"currency": "USD","payment_type": "Regular","reference": "ORD-Test-2022-23","description": "Set of 3 masks","status": "Declined","approved": false,"3ds": {"downgraded": false,"enrolled": "Y","authentication_response": "N","version": "2.1.0","challenged": false},"risk": {"flagged": false},"customer": {"id": "cus_57x7gb4wtxquxn3gqye2hujnt4","email": "123@test.com","name": "1234567"},"billing_descriptor": {"name": "SUPERHEROES.COM","city": "GOTHAM"},"shipping": {"address": {"address_line1": "Checkout.com","address_line2": "90 Tottenham Court Road","city": "London","state": "London","zip": "W1T 4TJ","country": "GB"},"phone": {"country_code": "+1","number": "415 555 2671"}},"payment_ip": "111.111.111.1","metadata": {"coupon_code": "NY2018","partner_id": "123989","udf1": "1234567"},"_links": {"self": {"href": "https://api.sandbox.checkout.com/payments/pay_gyhf5oyvhdbutgzol4lscn7kfi"},"actions": {"href": "https://api.sandbox.checkout.com/payments/pay_gyhf5oyvhdbutgzol4lscn7kfi/actions"}}},{"id": "pay_ychk42fsoeqefeqbz65ocr55gy","requested_on": "2022-06-23T06:50:27.3871995Z","source": {"id": "src_33yoxu6f6fdujclo33v43oyf6q","type": "card","expiry_month": 12,"expiry_year": 2025,"scheme": "Visa","last4": "4242","fingerprint": "71580B426F1D190D29087FF265D8F48DF1AD34EDE41C27CBFF9D23C1A14D1776","bin": "424242","card_type": "CREDIT","card_category": "CONSUMER","issuer_country": "GB","product_id": "F","product_type": "Visa Classic","avs_check": "G","payment_account_reference": "V001533349648389224"},"expires_on": "2022-07-23T06:50:39.2830225Z","amount": 1005,"currency": "USD","payment_type": "Regular","reference": "ORD-Test-2022-23","description": "Set of 3 masks","status": "Captured","approved": true,"3ds": {"downgraded": false,"enrolled": "Y","authentication_response": "Y","cryptogram": "AAABAVIREQAAAAAAAAAAAAAAAAA=","xid": "4f422d6d-3cb5-4efc-ae20-48b43216af81","version": "2.1.0","challenged": true},"balances": {"total_authorized": 1005,"total_voided": 0,"available_to_void": 0,"total_captured": 1005,"available_to_capture": 0,"total_refunded": 0,"available_to_refund": 1005},"risk": {"flagged": false},"customer": {"id": "cus_57x7gb4wtxquxn3gqye2hujnt4","email": "123@test.com","name": "1234567"},"billing_descriptor": {"name": "SUPERHEROES.COM","city": "GOTHAM"},"shipping": {"address": {"address_line1": "Checkout.com","address_line2": "90 Tottenham Court Road","city": "London","state": "London","zip": "W1T 4TJ","country": "GB"},"phone": {"country_code": "+1","number": "415 555 2671"}},"payment_ip": "111.111.111.1","metadata": {"coupon_code": "NY2018","partner_id": "123989","udf1": "1234567"},"eci": "05","scheme_id": "547583399099070","_links": {"self": {"href": "https://api.sandbox.checkout.com/payments/pay_ychk42fsoeqefeqbz65ocr55gy"},"actions": {"href": "https://api.sandbox.checkout.com/payments/pay_ychk42fsoeqefeqbz65ocr55gy/actions"},"refund": {"href": "https://api.sandbox.checkout.com/payments/pay_ychk42fsoeqefeqbz65ocr55gy/refunds"}}},{"id": "pay_kx4obw2lptbuvhzrdzlv3lp6ti","requested_on": "2022-06-23T06:49:49.1610796Z","source": {"id": "src_mi2hv7zzpjfebjjnrsj2rhtmjy","type": "card","expiry_month": 12,"expiry_year": 2025,"scheme": "Mastercard","last4": "9682","fingerprint": "CC08517F2B99EEA15A87891C1B5E74867E793AD6C4116422F049996EF80BADE6","bin": "543782","card_type": "CREDIT","card_category": "CONSUMER","issuer": "TAISHIN INTERNATIONAL BANK","issuer_country": "TW","product_id": "MCS","product_type": "Standard MasterCard® Card","avs_check": "S","payment_account_reference": ""},"amount": 1005,"currency": "USD","payment_type": "Regular","reference": "ORD-Test-2022-23","description": "Set of 3 masks","status": "Declined","approved": false,"3ds": {"downgraded": false,"enrolled": "Y","version": "2.1.0","challenged": false},"risk": {"flagged": false},"customer": {"id": "cus_57x7gb4wtxquxn3gqye2hujnt4","email": "123@test.com","name": "1234567"},"billing_descriptor": {"name": "SUPERHEROES.COM","city": "GOTHAM"},"shipping": {"address": {"address_line1": "Checkout.com","address_line2": "90 Tottenham Court Road","city": "London","state": "London","zip": "W1T 4TJ","country": "GB"},"phone": {"country_code": "+1","number": "415 555 2671"}},"payment_ip": "111.111.111.1","metadata": {"coupon_code": "NY2018","partner_id": "123989","udf1": "1234567"},"_links": {"self": {"href": "https://api.sandbox.checkout.com/payments/pay_kx4obw2lptbuvhzrdzlv3lp6ti"},"actions": {"href": "https://api.sandbox.checkout.com/payments/pay_kx4obw2lptbuvhzrdzlv3lp6ti/actions"}}},{"id": "pay_fldc2qja2rsezn3o4tfakdwzgq","requested_on": "2022-06-23T06:33:40.62936Z","source": {"type": "card","expiry_month": 12,"expiry_year": 2025,"scheme": "Mastercard","last4": "9682","fingerprint": "CC08517F2B99EEA15A87891C1B5E74867E793AD6C4116422F049996EF80BADE6","bin": "543782","card_type": "CREDIT","card_category": "CONSUMER","issuer": "TAISHIN INTERNATIONAL BANK","issuer_country": "TW","product_id": "MCS"},"amount": 1005,"currency": "USD","payment_type": "Regular","reference": "ORD-Test-2022-23","description": "Set of 3 masks","status": "Pending","3ds": {"downgraded": false,"enrolled": "Y","version": "2.1.0"},"risk": {"flagged": false},"customer": {"id": "cus_57x7gb4wtxquxn3gqye2hujnt4","email": "123@test.com","name": "1234567"},"billing_descriptor": {"name": "SUPERHEROES.COM","city": "GOTHAM"},"shipping": {"address": {"address_line1": "Checkout.com","address_line2": "90 Tottenham Court Road","city": "London","state": "London","zip": "W1T 4TJ","country": "GB"},"phone": {"country_code": "+1","number": "415 555 2671"}},"payment_ip": "111.111.111.1","metadata": {"coupon_code": "NY2018","partner_id": "123989","udf1": "1234567"},"_links": {"self": {"href": "https://api.sandbox.checkout.com/payments/pay_fldc2qja2rsezn3o4tfakdwzgq"},"actions": {"href": "https://api.sandbox.checkout.com/payments/pay_fldc2qja2rsezn3o4tfakdwzgq/actions"}}},{"id": "pay_hk5nzpfzbkaunezs6vl54migri","requested_on": "2022-06-23T06:48:09.9967319Z","source": {"id": "src_mi2hv7zzpjfebjjnrsj2rhtmjy","type": "card","expiry_month": 12,"expiry_year": 2025,"scheme": "Mastercard","last4": "9682","fingerprint": "CC08517F2B99EEA15A87891C1B5E74867E793AD6C4116422F049996EF80BADE6","bin": "543782","card_type": "CREDIT","card_category": "CONSUMER","issuer": "TAISHIN INTERNATIONAL BANK","issuer_country": "TW","product_id": "MCS","product_type": "Standard MasterCard® Card","avs_check": "S","payment_account_reference": ""},"amount": 1005,"currency": "USD","payment_type": "Regular","reference": "ORD-Test-2022-23","description": "Set of 3 masks","status": "Declined","approved": false,"3ds": {"downgraded": false,"enrolled": "Y","version": "2.1.0","challenged": false},"risk": {"flagged": false},"customer": {"id": "cus_57x7gb4wtxquxn3gqye2hujnt4","email": "123@test.com","name": "1234567"},"billing_descriptor": {"name": "SUPERHEROES.COM","city": "GOTHAM"},"shipping": {"address": {"address_line1": "Checkout.com","address_line2": "90 Tottenham Court Road","city": "London","state": "London","zip": "W1T 4TJ","country": "GB"},"phone": {"country_code": "+1","number": "415 555 2671"}},"payment_ip": "111.111.111.1","metadata": {"coupon_code": "NY2018","partner_id": "123989","udf1": "1234567"},"_links": {"self": {"href": "https://api.sandbox.checkout.com/payments/pay_hk5nzpfzbkaunezs6vl54migri"},"actions": {"href": "https://api.sandbox.checkout.com/payments/pay_hk5nzpfzbkaunezs6vl54migri/actions"}}},{"id": "pay_kpproj7wylwexb7tnz6rvbf6za","requested_on": "2022-06-23T06:46:38.5503044Z","source": {"type": "card","expiry_month": 12,"expiry_year": 2025,"scheme": "Visa","last4": "9271","fingerprint": "C7554274164DC90AD78DBDBCDB764AE61947422B724698D709176FCF41957C30","bin": "427576","card_type": "CREDIT","issuer": "OCEANFIRST BANK N.A.","issuer_country": "US"},"amount": 1005,"currency": "USD","payment_type": "Regular","reference": "ORD-Test-2022-23","description": "Set of 3 masks","status": "Declined","approved": false,"3ds": {"downgraded": false,"enrolled": "Y","authentication_response": "N","version": "2.1.0","challenged": false},"risk": {"flagged": false},"customer": {"id": "cus_57x7gb4wtxquxn3gqye2hujnt4","email": "123@test.com","name": "1234567"},"billing_descriptor": {"name": "SUPERHEROES.COM","city": "GOTHAM"},"shipping": {"address": {"address_line1": "Checkout.com","address_line2": "90 Tottenham Court Road","city": "London","state": "London","zip": "W1T 4TJ","country": "GB"},"phone": {"country_code": "+1","number": "415 555 2671"}},"payment_ip": "111.111.111.1","metadata": {"coupon_code": "NY2018","partner_id": "123989","udf1": "1234567"},"_links": {"self": {"href": "https://api.sandbox.checkout.com/payments/pay_kpproj7wylwexb7tnz6rvbf6za"},"actions": {"href": "https://api.sandbox.checkout.com/payments/pay_kpproj7wylwexb7tnz6rvbf6za/actions"}}},{"id": "pay_lecutghc3bku7fphy4yfvzgxfq","requested_on": "2022-06-23T06:26:17.843292Z","source": {"type": "card","expiry_month": 12,"expiry_year": 2025,"scheme": "Visa","last4": "4242","fingerprint": "71580B426F1D190D29087FF265D8F48DF1AD34EDE41C27CBFF9D23C1A14D1776","bin": "424242","card_type": "CREDIT","card_category": "CONSUMER","issuer_country": "GB","product_id": "F"},"amount": 1000,"currency": "USD","payment_type": "Regular","reference": "ORD-Test-2022-23","description": "Set of 3 masks","status": "Pending","3ds": {"downgraded": false,"enrolled": "Y","version": "2.1.0"},"risk": {"flagged": false},"customer": {"id": "cus_57x7gb4wtxquxn3gqye2hujnt4","email": "123@test.com","name": "1234567"},"billing_descriptor": {"name": "SUPERHEROES.COM","city": "GOTHAM"},"shipping": {"address": {"address_line1": "Checkout.com","address_line2": "90 Tottenham Court Road","city": "London","state": "London","zip": "W1T 4TJ","country": "GB"},"phone": {"country_code": "+1","number": "415 555 2671"}},"payment_ip": "111.111.111.1","metadata": {"coupon_code": "NY2018","partner_id": "123989","udf1": "1234567"},"_links": {"self": {"href": "https://api.sandbox.checkout.com/payments/pay_lecutghc3bku7fphy4yfvzgxfq"},"actions": {"href": "https://api.sandbox.checkout.com/payments/pay_lecutghc3bku7fphy4yfvzgxfq/actions"}}},{"id": "pay_3qo4r3vdlrqulm2xlfsbthvevy","requested_on": "2022-06-23T06:34:08.7072384Z","source": {"type": "card","expiry_month": 12,"expiry_year": 2025,"scheme": "Visa","last4": "9271","fingerprint": "C7554274164DC90AD78DBDBCDB764AE61947422B724698D709176FCF41957C30","bin": "427576","card_type": "CREDIT","issuer": "OCEANFIRST BANK N.A.","issuer_country": "US"},"amount": 1005,"currency": "USD","payment_type": "Regular","reference": "ORD-Test-2022-23","description": "Set of 3 masks","status": "Declined","approved": false,"3ds": {"downgraded": false,"enrolled": "Y","authentication_response": "N","version": "2.1.0","challenged": false},"risk": {"flagged": false},"customer": {"id": "cus_57x7gb4wtxquxn3gqye2hujnt4","email": "123@test.com","name": "1234567"},"billing_descriptor": {"name": "SUPERHEROES.COM","city": "GOTHAM"},"shipping": {"address": {"address_line1": "Checkout.com","address_line2": "90 Tottenham Court Road","city": "London","state": "London","zip": "W1T 4TJ","country": "GB"},"phone": {"country_code": "+1","number": "415 555 2671"}},"payment_ip": "111.111.111.1","metadata": {"coupon_code": "NY2018","partner_id": "123989","udf1": "1234567"},"_links": {"self": {"href": "https://api.sandbox.checkout.com/payments/pay_3qo4r3vdlrqulm2xlfsbthvevy"},"actions": {"href": "https://api.sandbox.checkout.com/payments/pay_3qo4r3vdlrqulm2xlfsbthvevy/actions"}}},{"id": "pay_2zwn4vfrl2fe3f6vberu5hqz74","requested_on": "2022-06-23T06:29:55.5802922Z","source": {"id": "src_mi2hv7zzpjfebjjnrsj2rhtmjy","type": "card","expiry_month": 12,"expiry_year": 2025,"scheme": "Mastercard","last4": "9682","fingerprint": "CC08517F2B99EEA15A87891C1B5E74867E793AD6C4116422F049996EF80BADE6","bin": "543782","card_type": "CREDIT","card_category": "CONSUMER","issuer": "TAISHIN INTERNATIONAL BANK","issuer_country": "TW","product_id": "MCS","product_type": "Standard MasterCard® Card","avs_check": "S","payment_account_reference": ""},"amount": 1005,"currency": "USD","payment_type": "Regular","reference": "ORD-Test-2022-23","description": "Set of 3 masks","status": "Declined","approved": false,"3ds": {"downgraded": false,"enrolled": "Y","version": "2.1.0","challenged": false},"risk": {"flagged": false},"customer": {"id": "cus_57x7gb4wtxquxn3gqye2hujnt4","email": "123@test.com","name": "1234567"},"billing_descriptor": {"name": "SUPERHEROES.COM","city": "GOTHAM"},"shipping": {"address": {"address_line1": "Checkout.com","address_line2": "90 Tottenham Court Road","city": "London","state": "London","zip": "W1T 4TJ","country": "GB"},"phone": {"country_code": "+1","number": "415 555 2671"}},"payment_ip": "111.111.111.1","metadata": {"coupon_code": "NY2018","partner_id": "123989","udf1": "1234567"},"_links": {"self": {"href": "https://api.sandbox.checkout.com/payments/pay_2zwn4vfrl2fe3f6vberu5hqz74"},"actions": {"href": "https://api.sandbox.checkout.com/payments/pay_2zwn4vfrl2fe3f6vberu5hqz74/actions"}}},{"id": "pay_k3ztmuseu44uzo3ceced6btaay","requested_on": "2022-06-23T06:28:54.6638826Z","source": {"id": "src_33yoxu6f6fdujclo33v43oyf6q","type": "card","expiry_month": 12,"expiry_year": 2025,"scheme": "Visa","last4": "4242","fingerprint": "71580B426F1D190D29087FF265D8F48DF1AD34EDE41C27CBFF9D23C1A14D1776","bin": "424242","card_type": "CREDIT","card_category": "CONSUMER","issuer_country": "GB","product_id": "F","product_type": "Visa Classic","avs_check": "G","payment_account_reference": "V001953367319328872"},"expires_on": "2022-07-23T06:29:04.3750285Z","amount": 1005,"currency": "USD","payment_type": "Regular","reference": "ORD-Test-2022-23","description": "Set of 3 masks","status": "Captured","approved": true,"3ds": {"downgraded": false,"enrolled": "Y","authentication_response": "Y","cryptogram": "AAABAVIREQAAAAAAAAAAAAAAAAA=","xid": "778324c3-e770-470b-95b6-f3054dca2499","version": "2.1.0","challenged": true},"balances": {"total_authorized": 1005,"total_voided": 0,"available_to_void": 0,"total_captured": 1005,"available_to_capture": 0,"total_refunded": 0,"available_to_refund": 1005},"risk": {"flagged": false},"customer": {"id": "cus_57x7gb4wtxquxn3gqye2hujnt4","email": "123@test.com","name": "1234567"},"billing_descriptor": {"name": "SUPERHEROES.COM","city": "GOTHAM"},"shipping": {"address": {"address_line1": "Checkout.com","address_line2": "90 Tottenham Court Road","city": "London","state": "London","zip": "W1T 4TJ","country": "GB"},"phone": {"country_code": "+1","number": "415 555 2671"}},"payment_ip": "111.111.111.1","metadata": {"coupon_code": "NY2018","partner_id": "123989","udf1": "1234567"},"eci": "05","scheme_id": "910226692214436","_links": {"self": {"href": "https://api.sandbox.checkout.com/payments/pay_k3ztmuseu44uzo3ceced6btaay"},"actions": {"href": "https://api.sandbox.checkout.com/payments/pay_k3ztmuseu44uzo3ceced6btaay/actions"},"refund": {"href": "https://api.sandbox.checkout.com/payments/pay_k3ztmuseu44uzo3ceced6btaay/refunds"}}}]}
如何获取pay|sid_id
pay id是Checkout.com对于一笔支付请求全生命周期的唯一id,如后续发生了退款,拒付等,都可以使用pay id进行关联。
sid id是使用了Checkout.com 3DS服务后返回的session id,也可以用支付状态的查询。
1. HPP - 在重定向URL中
当用户在Hosted Payment Page完成支付并返回商户后,会在URL中添加pay id参数。当发起的支付为非3DS时参数名为cko-payment-id,发起的支付为3DS时参数名为cko-session-id:
如:
http://127.0.0.1:3000/result?cko-payment-id=pay_nixj7hl4mqa2voubnsgqnyj4vy
http://127.0.0.1:3000/result?cko-session-id=sid_eiac54qsba5u7mc345t3z3cg5e
2. iFrame - 在Payment同步返回中获取
当一笔支付请求通过后端API发起后,Checkout.com的返回报文中会包含这笔支付对应的pay id,对于3DS和非3DS场景都适用。如:
{"id": "pay_o7celawubynk3bxb3zcvyphi34","action_id": "act_o7celawubynk3bxb3zcvyphi34","amount": 100,"currency": "EUR","approved": true,"status": "Authorized","auth_code": "644416","scheme_id": "573899136006756","response_code": "10000","response_summary": "Approved","risk": {"flagged": false},"source": {"id": "src_pztzr25mrs6ehbmydsf3gl7lmm","type": "card","billing_address": {"address_line1": "Checkout.com","address_line2": "90 Tottenham Court Road","city": "London","state": "London","zip": "W1T 4TJ","country": "GB"},"phone": {"country_code": "1","number": "415 555 2671"},"expiry_month": 2,"expiry_year": 2023,"name": "eliz11","last4": "5580","fingerprint": "4CEB14B6CB325EFEA1394B1ECCAAFF4A19877A5D782548C95EC3B500D487404C","bin": "455657","avs_check": "S","cvv_check": "Y"},"customer": {"id": "cus_jdfhuetl57pelcl5cj5agl3tne","name": "eliz11"},"processed_on": "2022-04-24T03:43:52Z","reference": "PAYIN-TOPUP","processing": {"acquirer_transaction_id": "5625123245","retrieval_reference_number": "761892595599"},"_links": {"self": {"href": "https://api.sandbox.checkout.com/payments/pay_o7celawubynk3bxb3zcvyphi34"},"actions": {"href": "https://api.sandbox.checkout.com/payments/pay_o7celawubynk3bxb3zcvyphi34/actions"},"capture": {"href": "https://api.sandbox.checkout.com/payments/pay_o7celawubynk3bxb3zcvyphi34/captures"},"void": {"href": "https://api.sandbox.checkout.com/payments/pay_o7celawubynk3bxb3zcvyphi34/voids"}}}
{"id": "pay_ktvg6sa6bpq2lbjh4rlbomywta","status": "Pending","reference": "PAYIN-TOPUP","customer": {"id": "cus_ix6rhmhqxyuude22dg2odmy6iy","name": "eliz11"},"3ds": {"downgraded": false,"enrolled": "Y"},"_links": {"self": {"href": "https://api.sandbox.checkout.com/payments/pay_ktvg6sa6bpq2lbjh4rlbomywta"},"redirect": {"href": "https://3ds2-sandbox.ckotech.co/interceptor/3ds_ms5rgq3gaqoejdehwibrzpeenu"}}}
3. iFrame - 在重定向URL中
当用户使用3DS进行支付时,支付完成后会与Hosted Payment Page类似重定向到商户定义的URL,并添加pay id参数,参数名为cko-session-id。如:
http://127.0.0.1:3000/result?cko-session-id=sid_ppk3w4f365delghy6zhb7h2rju
4. HPP&iFrame - 在Webhook中获取
对于HPP或者iFrame都可以通过Webhook获取pay id。
如类型payment_approved/payment_decline的Webhook,以下为示例:
{"id": "evt_vha2gih6tl5u5ebrpajhm727fe","type": "payment_approved","created_on": "2019-06-07T08:25:21Z","data": {"action_id": "act_waji5li3mqtetnaor77xmow4bq","payment_type": "REGULAR","auth_code": "007895","response_code": "10000","response_summary": "Approved","scheme_id": "638284745624527","source": {"id": "src_isu5yyegxg4e5l5yadnpu6y744","type": "card","billing_address": {},"expiry_month": 12,"expiry_year": 2025,"scheme": "VISA","last_4": "4242","fingerprint": "71580b426f1d190d29087ff265d8f48df1ad34ede41c27cbff9d23c1a14d1776","bin": "424242","card_type": "Credit","card_category": "Consumer","issuer": "JPMORGAN CHASE BANK NA","issuer_country": "US","product_id": "A","product_type": "Visa Traditional","avs_check": "S","cvv_check": ""},"customer": {"id": "cus_gs47qn23bqmefhkmlpokm7vzxm"},"processing": {"acquirer_transaction_id": "8137549556","retrieval_reference_number": "000007895269"},"amount": 10000,"metadata": {},"risk": {"flagged": false},"id": "pay_waji5li3mqtetnaor77xmow4bq","currency": "EUR","processed_on": "2019-06-07T08:25:21Z","reference": "ORD-5023-4E89"},"_links": {"self": {"href": "https://api.sandbox.checkout.com/events/evt_vha2gih6tl5u5ebrpajhm727fe"},"payment": {"href": "https://api.sandbox.checkout.com/payments/pay_waji5li3mqtetnaor77xmow4bq"}}}
{"id": "evt_h3wfa5symn3ehof6fbgilpu5fm","type": "payment_declined","created_on": "2019-06-07T08:27:26Z","data": {"action_id": "act_pfyq4sdkrvoexn737g2e26c3xm","payment_type": "REGULAR","auth_code": "000000","response_code": "20005","response_summary": "Declined - Do Not Honour","scheme_id": "638284745624527","amount": 5,"source": {"id": "src_isu5yyegxg4e5l5yadnpu6y744","type": "card","expiry_month": 12,"expiry_year": 2025,"scheme": "VISA","last_4": "4242","fingerprint": "71580b426f1d190d29087ff265d8f48df1ad34ede41c27cbff9d23c1a14d1776","bin": "424242","card_type": "Credit","card_category": "Consumer","issuer": "JPMORGAN CHASE BANK NA","issuer_country": "US","product_id": "A","product_type": "Visa Traditional","avs_check": "S","cvv_check": ""},"customer": {"id": "cus_gs47qn23bqmefhkmlpokm7vzxm"},"processing": {"acquirer_transaction_id": "8137549596","retrieval_reference_number": "000896481776"},"id": "pay_pfyq4sdkrvoexn737g2e26c3xm","currency": "EUR","processed_on": "2019-06-07T08:27:26Z","reference": "ORD-5023-4E89"},"_links": {"self": {"href": "https://api.sandbox.checkout.com/events/evt_h3wfa5symn3ehof6fbgilpu5fm"},"payment": {"href": "https://api.sandbox.checkout.com/payments/pay_pfyq4sdkrvoexn737g2e26c3xm"}}}
如何判断支付结果
不同支付方式会对应不同的支付状态,以下主要针对卡支付进行说明。
在查询结果中,主要通过两个参数来进行结果的判断
status:表示当前交易的状态approved:表示授权或请款是否成功
主要状态判断逻辑如下:
| approved | status | 支付结果 |
|---|---|---|
| true | Authorized | 授权成功,待请款(扣款) |
| true | Card Verified | 验卡成功 |
| true | Partially Captured | 部分请款成功(部分扣款成功) |
| true | Captured | 全额请款成功(全额扣款成功) |
| false | Declined | 支付失败 |
| true | Partially Refunded | 部分退款成功 |
| true | Refunded | 全额退款成功 |
| true | Voided | 授权已撤销 |
| 空 | Pending | 等待3DS验证结果 |
其中最重要的是 approved = true 且 status = Captured,表示请款成功(扣款成功)。
使用sid_id查询
在3DS支付场景下,若使用sid_id进行查询时,根据3DS验证的状态可能出现以下几类返回:
- 若3DS验证尚未完成
status = Pending,不返回action_id这一object
{"id": "pay_blm2tkmqurwere5rkd6x7cvdxu","requested_on": "2022-06-29T08:50:04.2902423Z","source": {"type": "card","billing_address": {"country": "HK"},"expiry_month": 2,"expiry_year": 2023,"scheme": "Visa","last4": "4242","fingerprint": "67CF46597CE027875ED8230F168703A1D49E8D10622180AE58BB08813B3233D3","bin": "424242","card_type": "CREDIT","card_category": "CONSUMER","issuer_country": "GB","product_id": "F"},"amount": 100010,"currency": "USD","payment_type": "Regular","reference": "PAYIN-TOPUP","description": "Set of 3 masks","status": "Pending","3ds": {"downgraded": false,"enrolled": "Y","version": "2.1.0"},"risk": {"flagged": false},"customer": {"id": "cus_s6ba5uw54r7uhcstltrubhrcaq","email": "abc@163.com"},"billing_descriptor": {"name": "test_merchant","city": " "},"shipping": {"address": {"address_line1": "Checkout.com","address_line2": "90 Tottenham Court Road","city": "London","state": "London","zip": "W1T 4TJ","country": "HK"},"phone": {"country_code": "+1","number": "415 555 2671"}},"_links": {"self": {"href": "https://api.sandbox.checkout.com/payments/pay_blm2tkmqurwere5rkd6x7cvdxu"},"actions": {"href": "https://api.sandbox.checkout.com/payments/pay_blm2tkmqurwere5rkd6x7cvdxu/actions"},"redirect": {"href": "https://api.sandbox.checkout.com/sessions-interceptor/sid_dszjr3brue6epfvlvyq4lv6okm"}}}
- 若3DS验证失败
status = Declined,不返回action_id这一object
{"id": "pay_iag2yexmxktkjpvvk4rdp2qvwi","requested_on": "2022-06-29T09:00:49Z","source": {"type": "card","billing_address": {"country": "HK"},"expiry_month": 2,"expiry_year": 2023,"scheme": "Visa","last4": "4242","fingerprint": "67CF46597CE027875ED8230F168703A1D49E8D10622180AE58BB08813B3233D3","bin": "424242","card_type": "Credit","card_category": "Consumer","issuer": "JPMORGAN CHASE BANK NA","issuer_country": "US","product_id": "A","product_type": "Visa Traditional"},"amount": 300,"currency": "USD","payment_type": "Regular","reference": "PAYIN-TOPUP","description": "Set of 3 masks","status": "Declined","approved": false,"3ds": {"downgraded": false,"enrolled": "Y","authentication_response": "N","version": "2.1.0"},"risk": {"flagged": false},"customer": {"id": "cus_lxuppkhxqzfetaaaoxmjvxeybm","email": "abc@163.com"},"shipping": {"address": {"address_line1": "Checkout.com","address_line2": "90 Tottenham Court Road","city": "London","state": "London","zip": "W1T 4TJ","country": "HK"},"phone": {"country_code": "1","number": "415 555 2671"}},"actions": [],"_links": {"self": {"href": "https://api.sandbox.checkout.com/payments/pay_iag2yexmxktkjpvvk4rdp2qvwi"},"actions": {"href": "https://api.sandbox.checkout.com/payments/pay_iag2yexmxktkjpvvk4rdp2qvwi/actions"}}}
- 3DS验证成功
除了包含3DS相关信息外,在action这个object中还会返回authorization或capture的结果
{"id": "pay_eehq4zhpwzdkfbzz6si722uoqu","requested_on": "2022-06-29T09:03:16Z","source": {"id": "src_hdsc6vjgjnwexphsly46tbuu6e","type": "card","billing_address": {"country": "HK"},"expiry_month": 2,"expiry_year": 2023,"scheme": "Visa","last4": "4242","fingerprint": "67CF46597CE027875ED8230F168703A1D49E8D10622180AE58BB08813B3233D3","bin": "424242","card_type": "Credit","card_category": "Consumer","issuer": "JPMORGAN CHASE BANK NA","issuer_country": "US","product_id": "A","product_type": "Visa Traditional","avs_check": "S","cvv_check": "Y","payouts": true,"fast_funds": "d"},"amount": 300,"currency": "USD","payment_type": "Regular","reference": "PAYIN-TOPUP","description": "Set of 3 masks","status": "Captured","approved": true,"3ds": {"downgraded": false,"enrolled": "Y","authentication_response": "Y","cryptogram": "AAABAVIREQAAAAAAAAAAAAAAAAA=","xid": "28d018f8-4e6f-4ac3-a541-36a462715567","version": "2.1.0"},"risk": {"flagged": false},"customer": {"id": "cus_lxuppkhxqzfetaaaoxmjvxeybm","email": "abc@163.com"},"billing_descriptor": {"name": "","city": "London"},"shipping": {"address": {"address_line1": "Checkout.com","address_line2": "90 Tottenham Court Road","city": "London","state": "London","zip": "W1T 4TJ","country": "HK"},"phone": {"country_code": "1","number": "415 555 2671"}},"eci": "05","scheme_id": "511146744364556","actions": [{"id": "act_wfhatmkcuat25iel7thkbfkj6a","type": "Capture","response_code": "10000","response_summary": "Approved"},{"id": "act_eehq4zhpwzdkfbzz6si722uoqu","type": "Authorization","response_code": "10000","response_summary": "Approved"}],"_links": {"self": {"href": "https://api.sandbox.checkout.com/payments/pay_eehq4zhpwzdkfbzz6si722uoqu"},"actions": {"href": "https://api.sandbox.checkout.com/payments/pay_eehq4zhpwzdkfbzz6si722uoqu/actions"},"refund": {"href": "https://api.sandbox.checkout.com/payments/pay_eehq4zhpwzdkfbzz6si722uoqu/refunds"}}}
