{"id":3702,"date":"2023-12-09T10:46:23","date_gmt":"2023-12-09T02:46:23","guid":{"rendered":"http:\/\/www.ponybai.com\/?p=3702"},"modified":"2023-11-25T11:02:52","modified_gmt":"2023-11-25T03:02:52","slug":"commercepayments-%e5%91%bd%e5%90%8d%e7%a9%ba%e9%97%b4","status":"publish","type":"post","link":"http:\/\/www.ponybai.com\/?p=3702","title":{"rendered":"CommercePayments \u547d\u540d\u7a7a\u95f4\u7684\u7528\u4f8b"},"content":{"rendered":"\n<p>\u67e5\u770b\u5e73\u53f0\u7684\u6f14\u7ec3\u3001\u7528\u4f8b\u548c\u53c2\u8003\u8d44\u6599\u3002<\/p>\n\n\n\n<p><samp>CommercePayments<\/samp><\/p>\n\n\n\n<p>\u82e5\u8981\u67e5\u770b\u7c7b\u53c2\u8003\u6587\u6863\uff0c\u8bf7\u8f6c\u5230\u00a0CommercePayments \u547d\u540d\u7a7a\u95f4\u3002<samp>CommercePayments<\/samp><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u00a0<strong>\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668<\/strong><br>\u4ee3\u8868\u4e86 Salesforce \u4e2d\u7684\u652f\u4ed8\u5e73\u53f0\u4e0e\u5916\u90e8\u652f\u4ed8\u7f51\u5173\u4e4b\u95f4\u7684\u6865\u6881\u3002<\/li>\n\n\n\n<li>\u4ed8\u6b3e\u6388\u6743\u64a4\u9500<strong>\u670d\u52a1<\/strong><br>\u6388\u6743\u64a4\u9500\u662f\u901a\u8fc7\u89e3\u9664\u5ba2\u6237\u4ed8\u6b3e\u65b9\u5f0f\u4e2d\u7684\u8d44\u91d1\u51bb\u7ed3\u6765\u5426\u5b9a\u6388\u6743\u7684\u4ea4\u6613\u3002<\/li>\n\n\n\n<li>\u4ee4\u724c\u5316<strong>\u670d\u52a1<\/strong><br>\u4fe1\u7528\u5361\u4ee4\u724c\u5316\u8fc7\u7a0b\u5c06\u654f\u611f\u7684\u5ba2\u6237\u4fe1\u606f\u66ff\u6362\u4e3a\u5728\u652f\u4ed8\u4ea4\u6613\u671f\u95f4\u4f7f\u7528\u7684\u4e00\u6b21\u6027\u7b97\u6cd5\u751f\u6210\u7684\u6570\u5b57\uff08\u79f0\u4e3a\u4ee4\u724c\uff09\u3002Salesforce \u5b58\u50a8\u4ee4\u724c\uff0c\u7136\u540e\u4f7f\u7528\u8be5\u4ee4\u724c\u4f5c\u4e3a\u7528\u4e8e\u4ea4\u6613\u7684\u4fe1\u7528\u5361\u7684\u8868\u793a\u5f62\u5f0f\u3002\u8be5\u4ee4\u724c\u5141\u8bb8\u60a8\u5b58\u50a8\u6709\u5173\u4fe1\u7528\u5361\u7684\u4fe1\u606f\uff0c\u800c\u65e0\u9700\u5728 Salesforce \u4e2d\u5b58\u50a8\u654f\u611f\u7684\u5ba2\u6237\u6570\u636e\uff0c\u4f8b\u5982\u4fe1\u7528\u5361\u53f7\u3002<\/li>\n\n\n\n<li>\u66ff\u4ee3\u4ed8\u6b3e\u65b9\u5f0f \u66ff\u4ee3\u4ed8\u6b3e\u65b9\u5f0f\u5141\u8bb8\u5ba2\u6237\u5b58\u50a8\u548c\u8868\u793a\u5176\u4ed6\u9884\u5b9a\u4e49\u7684\u4ed8\u6b3e\u65b9\u5f0f\uff08\u5982 \u6216\uff09\u672a\u8868\u793a\u7684<strong>\u4ed8\u6b3e\u65b9\u5f0f<\/strong><br>\u4fe1\u606f\u3002\u66ff\u4ee3\u4ed8\u6b3e\u65b9\u5f0f\u7684\u5e38\u89c1\u793a\u4f8b\u5305\u62ec CashOnDeliver\u3001Klarna \u548c\u76f4\u63a5\u501f\u8bb0\u3002API v51.0 \u53ca\u66f4\u9ad8\u7248\u672c\u4e2d\u63d0\u4f9b\u4e86\u5176\u4ed6\u4ed8\u6b3e\u65b9\u5f0f\u3002<samp>CardPaymentMethodDigitalWallet<\/samp><\/li>\n\n\n\n<li>\u5904\u7406\u4ed8\u6b3e \u5728\u652f\u4ed8\u7f51\u5173\u4e2d<strong>\u5904\u7406\u4ed8\u6b3e<\/strong><br>\u3002<\/li>\n\n\n\n<li>\u5904\u7406\u9000\u6b3e \u5728\u652f\u4ed8\u7f51\u5173\u4e2d<br><strong>\u5904\u7406\u9000\u6b3e<\/strong>\u3002<\/li>\n\n\n\n<li>\u5e42<strong>\u7b49\u6027\u51c6\u5219<\/strong><br>\u5e42\u7b49\u6027\u8868\u793a\u652f\u4ed8\u7f51\u5173\u80fd\u591f\u8bc6\u522b\u9519\u8bef\u6216\u6076\u610f\u63d0\u4ea4\u7684\u91cd\u590d\u8bf7\u6c42\uff0c\u7136\u540e\u76f8\u5e94\u5730\u5904\u7406\u91cd\u590d\u8bf7\u6c42\u3002\u4f7f\u7528\u5e42\u7b49\u7f51\u5173\u65f6\uff0c\u8bf7\u8003\u8651\u4ee5\u4e0b\u91cd\u8981\u51c6\u5219\u3002<\/li>\n\n\n\n<li>CommercePayments \u7684\u793a\u4f8b\u652f\u4ed8\u7f51\u5173\u5b9e\u73b0 \u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a GitHub \u5b58\u50a8\u5e93\uff0c\u5176\u4e2d\u5305\u542b\u5177\u6709 CommercePayments<br>\u547d\u540d\u7a7a\u95f4\u7684\u793a\u4f8b Payeezy\u00a0<strong>\u652f\u4ed8\u7f51\u5173\u5b9e\u73b0<\/strong>\u7684\u4ee3\u7801\u793a\u4f8b\u3002\u5982\u679c\u60a8\u5728\u914d\u7f6e\u652f\u4ed8\u7f51\u5173\u5b9e\u65bd\u65b9\u9762\u9700\u8981\u5e2e\u52a9\uff0c\u8bf7\u67e5\u770b\u793a\u4f8b\u4ee3\u7801\u3002<\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\">\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668<\/h1>\n\n\n\n<p>\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u4ee3\u8868\u4e86\u60a8\u7684\u652f\u4ed8\u5e73\u53f0\u4e4b\u95f4\u7684\u6865\u6881 Salesforce \u548c\u5916\u90e8\u652f\u4ed8\u7f51\u5173\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u6784\u5efa\u540c\u6b65\u7f51\u5173\u9002\u914d\u5668<\/strong><br>\u5728\u540c\u6b65\u4ed8\u6b3e\u914d\u7f6e\u4e2d\uff0cSalesforce \u4ed8\u6b3e\u5e73\u53f0\u5c06\u4ea4\u6613\u4fe1\u606f\u53d1\u9001\u5230\u7f51\u5173\uff0c\u7136\u540e\u7b49\u5f85\u5305\u542b\u6700\u7ec8\u4ea4\u6613\u72b6\u6001\u7684\u7f51\u5173\u54cd\u5e94\u3002\u53ea\u6709\u5f53\u4e8b\u52a1\u5728\u7f51\u5173\u4e2d\u6210\u529f\u65f6\uff0cSalesforce \u624d\u4f1a\u521b\u5efa\u4e8b\u52a1\u3002<\/li>\n\n\n\n<li><strong>\u8bbe\u7f6e\u540c\u6b65\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668<\/strong><br>\u5bf9\u4e8e\u652f\u4ed8\u4ea4\u6613\uff0c\u60a8\u53ef\u4ee5\u5c06 Salesforce \u914d\u7f6e\u4e3a\u4e0e\u540c\u6b65\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u4ea4\u4e92\u3002<\/li>\n\n\n\n<li>\u6784\u5efa\u5f02\u6b65\u7f51\u5173\u9002\u914d\u5668<br>\u5728<strong>\u5f02\u6b65<\/strong>\u652f\u4ed8\u914d\u7f6e\u4e2d\uff0c\u652f\u4ed8\u5e73\u53f0\u9996\u5148\u5411\u7f51\u5173\u53d1\u9001\u4ea4\u6613\u4fe1\u606f\u3002\u7f51\u5173\u901a\u8fc7\u786e\u8ba4\u5b83\u5df2\u6536\u5230\u4ea4\u6613\u8fdb\u884c\u54cd\u5e94\uff0c\u7136\u540e\u5e73\u53f0\u521b\u5efa\u5f85\u5904\u7406\u4ea4\u6613\u3002\u7f51\u5173\u53d1\u9001\u901a\u77e5\uff0c\u5176\u4e2d\u5305\u542b\u6700\u7ec8\u4e8b\u52a1\u72b6\u6001\u3002\u7136\u540e\uff0c\u5e73\u53f0\u4f1a\u76f8\u5e94\u5730\u66f4\u65b0\u4ea4\u6613\u72b6\u6001\u3002<\/li>\n\n\n\n<li><strong>\u8bbe\u7f6e\u5f02\u6b65\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668<\/strong><br>\u5bf9\u4e8e\u652f\u4ed8\u4ea4\u6613\uff0c\u60a8\u53ef\u4ee5\u5c06 Salesforce \u914d\u7f6e\u4e3a\u4e0e\u5f02\u6b65\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u4ea4\u4e92\u3002<\/li>\n\n\n\n<li>\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668<strong>\u7684\u6784\u5efa\u5668\u793a\u4f8b \u652f\u4ed8\u7f51\u5173<\/strong>\u9002\u914d\u5668\u7684\u6700\u540e\u90e8\u5206\u5e94\u5b9a\u4e49\u9002\u914d\u5668<br>\u5982\u4f55\u521b\u5efa\u8bf7\u6c42\u548c\u54cd\u5e94\u3002\u8fd9\u4e9b\u7c7b\u7684\u5b9e\u73b0\u53ef\u80fd\u4f1a\u56e0\u7f51\u5173\u548c\u5e73\u53f0\u8981\u6c42\u800c\u6709\u5f88\u5927\u5dee\u5f02\u3002\u6211\u4eec\u63d0\u4f9b\u4e86\u51e0\u4e2a\u6cdb\u578b\u793a\u4f8b\u4f9b\u67e5\u770b\u3002<\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\">\u6784\u5efa\u540c\u6b65\u7f51\u5173\u9002\u914d\u5668<\/h1>\n\n\n\n<p>\u5728\u540c\u6b65\u652f\u4ed8\u914d\u7f6e\u4e2d\uff0cSalesforce \u652f\u4ed8\u5e73\u53f0\u53d1\u9001 \u4e8b\u52a1\u4fe1\u606f\u53d1\u9001\u5230\u7f51\u5173\uff0c\u7136\u540e\u7b49\u5f85\u5305\u542b \u6700\u7ec8\u4ea4\u6613\u72b6\u6001\u3002Salesforce \u4ec5\u5728\u4ea4\u6613\u53d1\u751f\u65f6\u624d\u4f1a\u521b\u5efa\u4ea4\u6613 \u5728\u7f51\u5173\u4e2d\u6210\u529f\u3002<\/p>\n\n\n\n<p>\u540c\u6b65\u7f51\u5173\u9002\u914d\u5668\u5b9e\u73b0\u00a0<samp>PaymentGatewayAdapter \u63a5\u53e3<\/samp>\u3002\u5728\u672c\u4e3b\u9898\u4e2d\uff0c\u6211\u4eec\u5c06\u5206\u89e3\u4e00\u4e2a\u793a\u4f8b\u5f02\u6b65 \u9002\u914d\u5668\uff0c\u7136\u540e\u67e5\u770b \u7c7b\uff0c\u5b83\u9a71\u52a8\u4e86\u5927\u90e8\u5206 \u652f\u4ed8\u5e73\u53f0\u548c\u652f\u4ed8\u7f51\u5173\u4e4b\u95f4\u7684\u901a\u4fe1\u3002<samp>PaymentGatewayAdapterprocessRequest<\/samp><\/p>\n\n\n\n<p>\u6ce8\u610f<\/p>\n\n\n\n<p>\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u65e0\u6cd5\u8fdb\u884c\u5c06\u6765\u7684\u8c03\u7528\u3001\u5916\u90e8\u8c03\u7528\u3001\u5f02\u6b65\u8c03\u7528\u3001\u53ef\u6392\u961f\u7684\u8c03\u7528\u6216\u6267\u884c DML \u4f7f\u7528 SOQL\u3002<samp>System.Http<\/samp><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">PaymentGateway\u9002\u914d\u5668<\/h2>\n\n\n\n<p>\u6240\u6709\u540c\u6b65\u7f51\u5173\u90fd\u5fc5\u987b\u5b9e\u73b0\u8be5\u63a5\u53e3\u3002\u6240\u6709 PaymentGatewayAdapters \u90fd\u662f \u5b9e\u73b0\u8be5\u65b9\u6cd5\u6240\u5fc5\u9700\u7684\u3002<\/p>\n\n\n\n<p><samp>PaymentGatewayAdapter<\/samp><samp>processRequest<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>global with sharing class SampleAdapter implements commercepayments.PaymentGatewayAdapter {\n    global SampleAdapter() {}\n    \n    global commercepayments.GatewayResponse processRequest(commercepayments.paymentGatewayContext gatewayContext) {\n    }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5904\u7406\u521d\u59cb\u4ed8\u6b3e\u8bf7\u6c42<\/h2>\n\n\n\n<p>\u5f53\u652f\u4ed8\u5e73\u53f0 \u63a5\u6536\u4ed8\u6b3e API \u8bf7\u6c42\uff0c\u5e76\u5c06\u8bf7\u6c42\u4f20\u9012\u7ed9\u7f51\u5173\u9002\u914d\u5668 \u8fdb\u4e00\u6b65\u8bc4\u4f30\u3002\u9002\u914d\u5668\u901a\u8fc7\u8c03\u7528&nbsp;<strong>processRequest<\/strong>&nbsp;\u65b9\u6cd5\u5f00\u59cb\u8bf7\u6c42\u8bc4\u4f30\u8fc7\u7a0b\uff0c\u8be5\u65b9\u6cd5\u8868\u793a\u540c\u6b65\u7684\u7b2c\u4e00\u6b65 \u4ed8\u6b3e\u6d41\u7a0b\u3002\u6211\u4eec\u53ef\u4ee5\u5c06 processRequest \u5b9e\u73b0\u5206\u4e3a\u4e09\u4e2a\u90e8\u5206\u3002<\/p>\n\n\n\n<p>\u9996\u5148\uff0c\u5b83\u6784\u5efa\u4e00\u4e2a\u7f51\u5173\u53ef\u4ee5 \u7406\u89e3\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>commercepayments.RequestType requestType = gatewayContext.getPaymentRequestType();\nif (requestType == commercepayments.RequestType.Capture) {\n   req.setEndpoint('\/pal\/servlet\/Payment\/v52\/capture');\n    body = buildCaptureRequest((commercepayments.CaptureRequest)gatewayContext.getPaymentRequest());\n} else if (requestType == commercepayments.RequestType.ReferencedRefund) {\n    req.setEndpoint('\/pal\/servlet\/Payment\/v52\/refund');\n    body = buildRefundRequest((commercepayments.ReferencedRefundRequest)gatewayContext.getPaymentRequest());\n}<\/code><\/pre>\n\n\n\n<p>\u7136\u540e \u9002\u914d\u5668\u5c06\u8bf7\u6c42\u53d1\u9001\u5230\u4ed8\u6b3e \u7f51\u5173\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>req.setBody(body);\nreq.setMethod('POST');\ncommercepayments.PaymentsHttp http = new commercepayments.PaymentsHttp();\nHttpResponse res = null;\ntry {\n    res = http.send(req);\n} catch(CalloutException ce) {\n    commercepayments.GatewayErrorResponse error = new commercepayments.GatewayErrorResponse('500', ce.getMessage());\n    return error;\n}<\/code><\/pre>\n\n\n\n<p>\u6700\u540e \u9002\u914d\u5668\u521b\u5efa\u4e00\u4e2a\u54cd\u5e94\u5bf9\u8c61\u6765\u5b58\u50a8\u6765\u81ea\u7f51\u5173\u54cd\u5e94\u7684\u6570\u636e\u3002\u8fd9 \u54cd\u5e94\u5bf9\u8c61\u7684\u7c7b\u578b\u5c06\u6839\u636e\u60a8\u6700\u521d\u662f\u5426\u8fdb\u884c\u4ed8\u6b3e\u6355\u83b7\u800c\u6709\u6240\u4e0d\u540c \u7533\u8bf7\u6216\u9000\u6b3e \u8bf7\u6c42\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if ( requestType == commercepayments.RequestType.Capture) {\n   \/\/ Refer to the end of this doc for sample createCaptureResponse implementation\n    response =  createCaptureResponse(res);\n} else if ( requestType == commercepayments.RequestType.ReferencedRefund) {\n    response =  createRefundResponse(res);\n}\nreturn response;<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u8bbe\u7f6e\u540c\u6b65\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668<\/h1>\n\n\n\n<p>\u5bf9\u4e8e\u4ed8\u6b3e\u4ea4\u6613\uff0c\u60a8\u53ef\u4ee5\u5c06 Salesforce \u914d\u7f6e\u4e3a\u4e0e\u540c\u6b65 \u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u3002<\/p>\n\n\n\n<p>\u8981\u8bbf\u95ee API\uff0c\u60a8\u9700\u8981 PaymentPlatform \u7ec4\u7ec7\u6743\u9650\u3002<samp>commercepayments<\/samp><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u521b\u5efa\u60a8\u7684\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668 Apex \u7c7b\u3002\u6709\u5173\u8bf4\u660e\uff0c\u8bf7\u53c2\u9605\u6784\u5efa\u540c\u6b65\u7f51\u5173\u9002\u914d\u5668\u3002<\/li>\n\n\n\n<li>\u521b\u5efa\u547d\u540d\u51ed\u636e\u3002\n<ol class=\"wp-block-list\" style=\"list-style-type:lower-alpha\">\n<li>\u5728\u201c\u8bbe\u7f6e\u201d\u7684\u201c\u5feb\u901f\u67e5\u627e\u201d\u6846\u4e2d\uff0c\u8f93\u5165<kbd>\u201c\u547d\u540d\u51ed\u636e<\/kbd>\u201d\uff0c\u7136\u540e \u7136\u540e\u9009\u62e9<strong>\u65b0\u5efa\u3002<\/strong><\/li>\n\n\n\n<li>\u586b\u5199\u5fc5\u586b\u5b57\u6bb5\uff0c\u5305\u62ec\u652f\u4ed8\u7f51\u5173\u7684 URL\u3002<\/li>\n<\/ol>\n<\/li>\n\n\n\n<li>\u521b\u5efa\u652f\u4ed8\u7f51\u5173\u63d0\u4f9b\u5546\u3002PaymentGatewayProvider \u5bf9\u8c61\u5b58\u50a8\u6709\u5173\u4ee5\u4e0b\u5185\u5bb9\u7684\u8be6\u7ec6\u4fe1\u606f Salesforce Payments \u5728\u5904\u7406 \u4ea4\u6613\u3002\n<ol class=\"wp-block-list\" style=\"list-style-type:lower-alpha\">\n<li>\u6839\u636e\u4ee5\u4e0b\u65b9\u5f0f\u8fde\u63a5\u4ee5\u8fde\u63a5 REST API \u4e2d\u7684\u8bf4\u660e\u751f\u6210\u8bbf\u95ee\u4ee4\u724c OAuth\u3002\u54cd\u5e94\u5305\u62ec\u5c5e\u6027\u4e2d\u6307\u5b9a\u7684\u8bbf\u95ee\u4ee4\u724c\u548c\u5c5e\u6027\u4e2d\u6307\u5b9a\u7684\u670d\u52a1\u5668\u5b9e\u4f8b\u3002\u4f7f\u7528\u6b64\u4fe1\u606f\u8fdb\u884c API \u8c03\u7528 \u6784\u5efa\u652f\u4ed8\u7f51\u5173\u63d0\u4f9b\u5546\u3002<samp>access_tokeninstance_url<\/samp><\/li>\n\n\n\n<li>\u4f7f\u7528<samp>instance_url<\/samp>\u4e2d\u7684\u57df\u5bf9\u8d44\u6e90\u6267\u884c POST \u8c03\u7528\u3002\u4f8b\u5982\uff0c<samp>https:\/\/&nbsp;<var>instance_name.my.salesforce.com\/services\/data\/v<\/var>&nbsp;<var>api_version<\/var>\/tooling\/sobjects\/PaymentGatewayProvider<\/samp>\u3002\u4f7f\u7528\u6b64\u6709\u6548\u8d1f\u8f7d\u4f5c\u4e3a\u8bf7\u6c42\u6b63\u6587\uff0c\u66ff\u6362\u4e3a \u6b63\u786e\u7684\u6570\u636e\u3002<var>value<\/var><code>{ \"ApexAdapterId\": \"<em>value<\/em>\", \"DeveloperName\": \"<em>value<\/em>\", \"MasterLabel\": \"<em>value<\/em>\", \"IdempotencySupported\": \"<em>value<\/em>\", \"Comments\": \"<em>value<\/em>\" } Example: { \"ApexAdapterId\": \"01pxx0000004UU8AAM\", \"DeveloperName\": \"MyNewGatewayProvider\", \"MasterLabel\": \"My New Gateway Provider\", \"IdempotencySupported\": \"Yes\", \"Comments\": \"Custom made gateway provider.\" }<\/code><\/li>\n<\/ol>\n<\/li>\n\n\n\n<li>\u521b\u5efa\u652f\u4ed8\u7f51\u5173\u8bb0\u5f55\u3002PaymentGateway \u5bf9\u8c61\u5b58\u50a8\u6709\u5173 \u8fde\u63a5\u5230\u5916\u90e8\u652f\u4ed8\u7f51\u5173\u3002\u8bb0\u5f55\u9700\u8981\u8fd9\u4e9b\u5b57\u6bb5\u503c\u3002\n<ul class=\"wp-block-list\">\n<li>\u652f\u4ed8\u7f51\u5173\u540d\u79f0\uff1a\u5916\u90e8\u652f\u4ed8\u7f51\u5173\u7684\u540d\u79f0\u3002<\/li>\n\n\n\n<li>\u5546\u5bb6\u51ed\u8bc1 ID\uff1a\u60a8\u521b\u5efa\u7684\u6307\u5b9a\u51ed\u8bc1\u7684 ID\u3002<\/li>\n\n\n\n<li>\u652f\u4ed8\u7f51\u5173\u63d0\u4f9b\u5546 ID\uff1a\u60a8\u62e5\u6709\u7684\u652f\u4ed8\u7f51\u5173\u63d0\u4f9b\u5546\u7684 ID \u521b\u5efa\u3002<\/li>\n\n\n\n<li>\u72b6\u6001\uff1a \u5df2\u4e0a\u5e02<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h1 class=\"wp-block-heading\">\u6784\u5efa\u5f02\u6b65\u7f51\u5173\u9002\u914d\u5668<\/h1>\n\n\n\n<p>\u5728\u5f02\u6b65\u652f\u4ed8\u914d\u7f6e\u4e2d\uff0c\u652f\u4ed8\u5e73\u53f0\u9996\u5148\u53d1\u9001 \u4ea4\u6613\u4fe1\u606f\u53d1\u9001\u5230\u7f51\u5173\u3002\u7f51\u5173\u901a\u8fc7\u786e\u8ba4\u5b83\u8fdb\u884c\u54cd\u5e94 \u6536\u5230\u4ea4\u6613\uff0c\u7136\u540e\u5e73\u53f0\u521b\u5efa\u4e00\u4e2a\u5f85\u5904\u7406\u7684\u4ea4\u6613\u3002\u7f51\u5173 \u53d1\u9001\u901a\u77e5\uff0c\u5176\u4e2d\u5305\u542b\u6700\u7ec8\u4ea4\u6613\u72b6\u6001\u3002\u7136\u540e\uff0c\u5e73\u53f0\u5c06\u66f4\u65b0 \u4ea4\u6613\u7684\u72b6\u6001\u3002<\/p>\n\n\n\n<p>\u5f02\u6b65\u8fc7\u7a0b\u4e0e\u540c\u6b65\u4e8b\u52a1\u4e0d\u540c\uff0c\u5728\u540c\u6b65\u4e8b\u52a1\u4e2d\uff0c\u5e73\u53f0\u8fd9\u6837\u505a \u5728\u521d\u59cb\u7f51\u5173\u8bf7\u6c42\u4e4b\u540e\u4e0d\u521b\u5efa\u6302\u8d77\u7684\u4e8b\u52a1\u3002\u53d6\u800c\u4ee3\u4e4b\u7684\u662f\uff0c \u5e73\u53f0\u4ec5\u5728\u7f51\u5173\u53d1\u9001\u5305\u542b \u6700\u7ec8\u4ea4\u6613\u72b6\u6001\u3002\u6709\u5173\u6784\u5efa\u540c\u6b65\u9002\u914d\u5668\u7684\u4fe1\u606f\uff0c\u8bf7\u67e5\u770b\u6784\u5efa\u540c\u6b65\u7f51\u5173\u9002\u914d\u5668\u3002\u5f02\u6b65\u914d\u7f6e\u9700\u8981\u540c\u6b65\u7f51\u5173\u9002\u914d\u5668\u548c \u5f02\u6b65\u9002\u914d\u5668\u3002\u5728\u672c\u4e3b\u9898\u4e2d\uff0c\u6211\u4eec\u5c06\u6309\u4ee5\u4e0b\u65b9\u5f0f\u5206\u89e3\u793a\u4f8b\u5f02\u6b65\u9002\u914d\u5668 \u7740\u773c\u4e8e\u51e0\u4e2a\u91cd\u8981\u9886\u57df\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5b9a\u4e49\u5f02\u6b65\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668<\/li>\n\n\n\n<li>\u5904\u7406\u521d\u59cb\u4ed8\u6b3e\u8bf7\u6c42<\/li>\n\n\n\n<li>\u5904\u7406\u6765\u81ea\u652f\u4ed8\u7f51\u5173\u7684\u901a\u77e5<\/li>\n\n\n\n<li>\u4f7f\u7528\u7cfb\u7edf\u8c03\u8bd5\u65e5\u5fd7\u8c03\u8bd5\u7f51\u5173\u54cd\u5e94\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u6ce8\u610f<\/p>\n\n\n\n<p>\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u65e0\u6cd5\u8fdb\u884c\u5c06\u6765\u7684\u8c03\u7528\u3001\u5916\u90e8\u6807\u6ce8\u3001\u5f02\u6b65\u8c03\u7528\u3001\u53ef\u6392\u961f\u7684\u8c03\u7528\u6216 \u4f7f\u7528 SOQL \u6267\u884c DML\u3002<samp>System.Http<\/samp><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5f02\u6b65\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u5b9a\u4e49<\/h2>\n\n\n\n<p>\u5f02\u6b65\u7f51\u5173\u9002\u914d\u5668\u7c7b\u5fc5\u987b\u540c\u65f6\u5b9e\u73b0\u00a0<samp>PaymentGatewayAdapter \u63a5\u53e3<\/samp>\u548c\u00a0<samp>PaymentGatewayAsyncAdapter \u63a5\u53e3<\/samp>\u3002\u9002\u914d\u5668\u7c7b \u8fd8\u5fc5\u987b\u5b9e\u73b0 PaymentGatewayAdapter \u7684\u65b9\u6cd5\u548c PaymentGatewayAsyncAdapter \u7684\u65b9\u6cd5\u3002<samp>processRequestprocessNotification<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>global with sharing class SampleAdapter implements commercepayments.PaymentGatewayAsyncAdapter, commercepayments.PaymentGatewayAdapter {\n    global SampleAdapter() {}\n    \n    global commercepayments.GatewayResponse processRequest(commercepayments.paymentGatewayContext gatewayContext) {\n    }\n    \n    global commercepayments.GatewayNotificationResponse processNotification(commercepayments.PaymentGatewayNotificationContext gatewayNotificationContext) {\n    }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5904\u7406\u521d\u59cb\u4ed8\u6b3e\u8bf7\u6c42<\/h2>\n\n\n\n<p>\u5f53\u652f\u4ed8\u5e73\u53f0 \u63a5\u6536\u4ed8\u6b3e API \u8bf7\u6c42\uff0c\u5e76\u5c06\u8bf7\u6c42\u4f20\u9012\u7ed9\u7f51\u5173\u9002\u914d\u5668 \u8fdb\u4e00\u6b65\u8bc4\u4f30\u3002\u9002\u914d\u5668\u901a\u8fc7\u8c03\u7528&nbsp;<strong>processRequest<\/strong>&nbsp;\u65b9\u6cd5\u5f00\u59cb\u8bf7\u6c42\u8bc4\u4f30\u8fc7\u7a0b\uff0c\u8be5\u65b9\u6cd5\u8868\u793a\u5f02\u6b65\u7684\u7b2c\u4e00\u6b65 \u4ed8\u6b3e\u6d41\u7a0b\u3002\u6211\u4eec\u53ef\u4ee5\u5c06 processRequest \u5b9e\u73b0\u5206\u4e3a\u4e09\u4e2a\u90e8\u5206\u3002<\/p>\n\n\n\n<p>\u9996\u5148\uff0c\u5b83\u6784\u5efa\u4e00\u4e2a\u7f51\u5173\u53ef\u4ee5 \u7406\u89e3\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>commercepayments.RequestType requestType = gatewayContext.getPaymentRequestType();\nif (requestType == commercepayments.RequestType.Capture) {\n   req.setEndpoint('\/pal\/servlet\/Payment\/v52\/capture');\n    body = buildCaptureRequest((commercepayments.CaptureRequest)gatewayContext.getPaymentRequest());\n} else if (requestType == commercepayments.RequestType.ReferencedRefund) {\n    req.setEndpoint('\/pal\/servlet\/Payment\/v52\/refund');\n    body = buildRefundRequest((commercepayments.ReferencedRefundRequest)gatewayContext.getPaymentRequest());\n}<\/code><\/pre>\n\n\n\n<p>\u7136\u540e \u9002\u914d\u5668\u5c06\u8bf7\u6c42\u53d1\u9001\u5230\u4ed8\u6b3e \u7f51\u5173\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>req.setBody(body);\nreq.setMethod('POST');\ncommercepayments.PaymentsHttp http = new commercepayments.PaymentsHttp();\nHttpResponse res = null;\ntry {\n    res = http.send(req);\n} catch(CalloutException ce) {\n    commercepayments.GatewayErrorResponse error = new commercepayments.GatewayErrorResponse('500', ce.getMessage());\n    return error;\n}<\/code><\/pre>\n\n\n\n<p>\u6700\u540e \u9002\u914d\u5668\u521b\u5efa\u4e00\u4e2a\u54cd\u5e94\u5bf9\u8c61\u6765\u5b58\u50a8\u6765\u81ea\u7f51\u5173\u54cd\u5e94\u7684\u6570\u636e\u3002\u8fd9 \u54cd\u5e94\u5bf9\u8c61\u7684\u7c7b\u578b\u5c06\u6839\u636e\u60a8\u6700\u521d\u662f\u5426\u8fdb\u884c\u4ed8\u6b3e\u6355\u83b7\u800c\u6709\u6240\u4e0d\u540c \u7533\u8bf7\u6216\u9000\u6b3e \u8bf7\u6c42\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if ( requestType == commercepayments.RequestType.Capture) {\n   \/\/ Refer to the end of this doc for sample createCaptureResponse implementation\n    response =  createCaptureResponse(res);\n} else if ( requestType == commercepayments.RequestType.ReferencedRefund) {\n    response =  createRefundResponse(res);\n}\nreturn response;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5904\u7406\u6765\u81ea\u652f\u4ed8\u7f51\u5173\u7684\u901a\u77e5<\/h2>\n\n\n\n<p>\u4e4b\u540e \u5ba2\u6237\u94f6\u884c\u5904\u7406\u4ea4\u6613\u5e76\u5c06\u7ed3\u679c\u53d1\u9001\u5230\u7f51\u5173\uff0c \u7f51\u5173\u5411\u9002\u914d\u5668\u53d1\u9001\u901a\u77e5\uff0c\u6307\u793a\u5b83\u5df2\u51c6\u5907\u597d\u63d0\u4f9b \u6700\u7ec8\u4ea4\u6613\u72b6\u6001\u3002\u5bf9\u4e8e\u5f02\u6b65\u4e8b\u52a1\u6d41\u7684\u8fd9\u4e00\u90e8\u5206\uff0c \u9002\u914d\u5668\u9700\u8981\u8c03\u7528 processNotification \u7c7b\u3002\u6211\u4eec\u53ef\u4ee5\u62c6\u5206 processNotification \u5b9e\u73b0\u5206\u4e3a\u56db\u4e2a\u90e8\u5206\u3002<\/p>\n\n\n\n<p>\u4e00\u3001\u9002\u914d\u5668 \u9a8c\u8bc1\u901a\u77e5\u8bf7\u6c42\u4e2d\u7684\u7b7e\u540d\u3002\u6b32\u4e86\u89e3\u66f4\u591a\u4fe1\u606f \u9a8c\u8bc1\u7b7e\u540d\uff0c\u5ba1\u6838 [\u4e3b\u9898]\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>private Boolean verifySignature(NotificationRequest requestItem) {\n    String payload = requestItem.pspReference + ':'\n        + (requestItem.originalReference == null ? '' : requestItem.originalReference) + ':'\n        + requestItem.merchantAccountCode + ':'\n        + requestItem.merchantReference + ':'\n        + requestItem.amount.value.intValue() + ':'\n        + requestItem.amount.currencyCode + ':'\n        + requestItem.eventCode + ':'\n        + requestItem.success;\n    String myHMacKey = getHMacKey();\n    String generatedSign = EncodingUtil.base64Encode(Crypto.generateMac('hmacSHA256', Blob.valueOf(payload), \n                                EncodingUtil.convertFromHex(myHMacKey)));\n    return generatedSign.equals(requestItem.additionalData.hmacSignature);\n}<\/code><\/pre>\n\n\n\n<p>\u4e0b\u4e00\u4e2a \u9002\u914d\u5668\u5206\u6790\u7f51\u5173\u7684\u901a\u77e5\u8bf7\u6c42\u5e76\u751f\u6210\u901a\u77e5\u5bf9\u8c61\u3002 \u65b9\u6cd5 \u8bc4\u4f30\u6765\u81ea\u7f51\u5173\u7684\u901a\u77e5\u8bf7\u6c42\u9879\u7684\u6570\u636e\uff0c\u5176\u4e2d\u5305\u62ec\u72b6\u6001\u3001 referenceNumber\u3001event \u548c amount\u3002\u8be5\u5bf9\u8c61\u8bbe\u7f6e\u4e3a\u201c\u6210\u529f\u201d\u6216\u201c\u5931\u8d25\u201d\uff0c\u5177\u4f53\u53d6\u51b3\u4e8e \u5e73\u53f0\u5df2\u6210\u529f\u6536\u5230\u901a\u77e5\u3002\u5982\u679c\u901a\u77e5\u7684\u4e8b\u4ef6\u4ee3\u7801 \u8868\u793a\u7f51\u5173\u5904\u7406\u4e86\u4ed8\u6b3e\u6355\u83b7\u4e8b\u52a1\uff0c\u9002\u914d\u5668\u5c06\u6784\u5efa\u4e00\u4e2a \u901a\u77e5\u5bf9\u8c61\u3002\u5982\u679c\u4e8b\u4ef6\u4ee3\u7801\u6307\u793a\u7f51\u5173 \u5904\u7406\u9000\u6b3e\u4e8b\u52a1\u65f6\uff0c\u9002\u914d\u5668\u4f7f\u7528\u8be5\u7c7b\u751f\u6210\u901a\u77e5\u5bf9\u8c61\u3002<\/p>\n\n\n\n<p><samp>getPaymentGatewayNotificationRequest<\/samp><samp>notificationStatus<\/samp><samp>CaptureNotification<\/samp><samp>ReferencedRefundNotification<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>commercepayments.PaymentGatewayNotificationRequest gatewayNotificationRequest = gatewayNotificationContext.getPaymentGatewayNotificationRequest();\nBlob request = gatewayNotificationRequest.getRequestBody();\nSampleNotificationRequest notificationRequest = SampleNotificationRequest.parse(request.toString().replace('currency', 'currencyCode'));                \nList&lt;SampleNotificationRequest.NotificationItems&gt; notificationItems = notificationRequest.notificationItems;\nSampleNotificationRequest.NotificationRequestItem notificationRequestItem = notificationItems&#91;0].NotificationRequestItem;\n\nBoolean success = Boolean.valueOf(notificationRequestItem.success);\nString pspReference = notificationRequestItem.pspReference;\nString eventCode = notificationRequestItem.eventCode;\nDouble amount = notificationRequestItem.amount.value;\n\ncommercepayments.NotificationStatus notificationStatus = null;\nif (success) {\n    notificationStatus = commercepayments.NotificationStatus.Success;\n} else {\n    notificationStatus = commercepayments.NotificationStatus.Failed;\n}\ncommercepayments.BaseNotification notification = null;\nif ('CAPTURE'.equals(eventCode)) {\n    notification = new commercepayments.CaptureNotification();\n} else if ('REFUND'.equals(eventCode)) {\n    notification = new commercepayments.ReferencedRefundNotification();\n}\nnotification.setStatus(notificationStatus);\nnotification.setGatewayReferenceNumber(pspReference);\nnotification.setAmount(amount);<\/code><\/pre>\n\n\n\n<p>\u8fd9 \u7136\u540e\uff0c\u9002\u914d\u5668\u8bf7\u6c42\u652f\u4ed8\u5e73\u53f0\u8bb0\u5f55 \u901a\u77e5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>commercepayments.NotificationSaveResult saveResult = commercepayments.NotificationClient.record(notification);<\/code><\/pre>\n\n\n\n<p>\u90fd \u5f02\u6b65\u7f51\u5173\u8981\u6c42\u5e73\u53f0\u786e\u8ba4\u5b83\u6536\u5230\u4e86 \u901a\u77e5\uff0c\u65e0\u8bba\u5e73\u53f0\u662f\u5426\u6210\u529f\u4fdd\u5b58\u4e86\u901a\u77e5\u7684 \u6570\u636e\u3002\u5e73\u53f0\u8c03\u7528\u8be5\u7c7b\u6765\u53d1\u9001 \u786e\u8ba4\u3002<\/p>\n\n\n\n<p><samp>GatewayNotificationResponse<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>commercepayments.GatewayNotificationResponse gnr = new commercepayments.GatewayNotificationResponse();\nif (saveResult.isSuccess()) {\n    system.debug('Notification accepted by platform');\n} else {\n    system.debug('Errors in the result '+ Blob.valueOf(saveResult.getErrorMessage()));\n}\ngnr.setStatusCode(200);\ngnr.setResponseBody(Blob.valueOf('&#91;accepted]'));\nreturn gnr;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u8c03\u8bd5<\/h2>\n\n\n\n<p>\u901a\u5e38\uff0cApex \u8c03\u8bd5\u65e5\u5fd7\u53ef\u5728\u5f00\u53d1\u4eba\u5458\u63a7\u5236\u53f0\u4e2d\u627e\u5230\u3002\u4f46\u662f\uff0cSalesforce \u4e0d\u4f1a\u5728\u5f00\u53d1\u4eba\u5458\u63a7\u5236\u53f0\u4e2d\u5b58\u50a8\u6765\u81ea\u8be5\u65b9\u6cd5\u7684\u8c03\u8bd5\u65e5\u5fd7\u3002\u67e5\u770b\u6b64\u90e8\u4ef6 \uff0c\u67e5\u770b\u6536\u96c6\u6765\u5bbe\u7528\u6237\u7684\u8c03\u8bd5\u65e5\u5fd7\u00a0\u8bbe\u7f6e\u8c03\u8bd5\u65e5\u5fd7\u8bb0\u5f55\u90e8\u5206\u3002<samp>processNotification<\/samp><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u8bbe\u7f6e\u5f02\u6b65\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668<\/h1>\n\n\n\n<p>\u5bf9\u4e8e\u652f\u4ed8\u4ea4\u6613\uff0c\u60a8\u53ef\u4ee5\u5c06 Salesforce \u914d\u7f6e\u4e3a\u4e0e \u5f02\u6b65\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u3002<\/p>\n\n\n\n<p>\u8981\u8bbf\u95ee API\uff0c\u60a8\u9700\u8981 PaymentPlatform \u7ec4\u7ec7\u6743\u9650\u3002<samp>commercepayments<\/samp><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u521b\u5efa Salesforce \u7ad9\u70b9\u3002\u5728\u201c\u8bbe\u7f6e\u201d\u7684\u201c\u5feb\u901f\u67e5\u627e\u201d\u6846\u4e2d\uff0c\u8f93\u5165<kbd>\u201c\u7ad9\u70b9<\/kbd>\u201d\u3002\u5728\u201c\u7ad9\u70b9\u548c\u57df\u201d\u4e0b\uff0c\u9009\u62e9<strong>\u201c\u7ad9\u70b9<\/strong>\u201d\uff0c\u8bf7\u53c2\u9605\u8bbe\u7f6e Salesforce \u7ad9\u70b9\u3002\u5c06\u7f51\u7ad9\u7684\u516c\u5171\u8bbf\u95ee\u8bbe\u7f6e\u8bbe\u7f6e\u4e3a<strong>\u8bbf\u5ba2\u8bbf\u95ee\u4ed8\u6b3e API<\/strong>\u63a5\u53e3\u3002<\/li>\n\n\n\n<li>\u521b\u5efa\u60a8\u7684\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668 Apex \u7c7b\u3002\u5f02\u6b65\u652f\u4ed8\u7f51\u5173\u9700\u8981 \u5b9e\u73b0\u5f02\u6b65\u9002\u914d\u5668\u548c\u540c\u6b65\u9002\u914d\u5668\u3002\u6709\u5173\u5efa\u7b51\u7269\u7684\u4fe1\u606f \u7f51\u5173\u9002\u914d\u5668\uff0c\u8bf7\u53c2\u9605\u6784\u5efa\u5f02\u6b65\u7f51\u5173\u9002\u914d\u5668\u548c\u6784\u5efa\u540c\u6b65\u7f51\u5173\u9002\u914d\u5668\u3002<\/li>\n\n\n\n<li>\u5728 UI \u4e2d\u521b\u5efa\u547d\u540d\u51ed\u636e\u3002\n<ol class=\"wp-block-list\" style=\"list-style-type:lower-alpha\">\n<li>\u5728\u201c\u8bbe\u7f6e\u201d\u7684\u201c\u5feb\u901f\u67e5\u627e\u201d\u6846\u4e2d\uff0c\u8f93\u5165<kbd>\u201c\u547d\u540d\u51ed\u636e<\/kbd>\u201d\uff0c\u7136\u540e \uff0c\u7136\u540e\u9009\u62e9<strong>\u65b0\u5efa<\/strong>\u3002<\/li>\n\n\n\n<li>\u586b\u5199\u5fc5\u586b\u5b57\u6bb5\u3002\u5bf9\u4e8e URL\uff0c\u8bf7\u8f93\u5165\u652f\u4ed8\u7f51\u5173\u7684 URL\u3002<\/li>\n<\/ol>\n<\/li>\n\n\n\n<li>\u521b\u5efa\u652f\u4ed8\u7f51\u5173\u63d0\u4f9b\u5546\u3002PaymentGatewayProvider \u5bf9\u8c61\u5b58\u50a8\u6709\u5173\u4ee5\u4e0b\u5185\u5bb9\u7684\u8be6\u7ec6\u4fe1\u606f Salesforce Payments \u5728\u5904\u7406\u4ea4\u6613\u65f6\u4e0e\u4e4b\u901a\u4fe1\u7684\u652f\u4ed8\u7f51\u5173\u3002\n<ol class=\"wp-block-list\" style=\"list-style-type:lower-alpha\">\n<li>\u6839\u636e\u4ee5\u4e0b\u65b9\u5f0f\u8fde\u63a5\u4ee5\u8fde\u63a5 REST API \u4e2d\u7684\u8bf4\u660e\u751f\u6210\u8bbf\u95ee\u4ee4\u724c OAuth\u3002\u54cd\u5e94\u5305\u62ec\u5c5e\u6027\u4e2d\u6307\u5b9a\u7684\u8bbf\u95ee\u4ee4\u724c\u548c\u5c5e\u6027\u4e2d\u6307\u5b9a\u7684\u670d\u52a1\u5668\u5b9e\u4f8b\u3002\u4f7f\u7528\u6b64\u4fe1\u606f\u5236\u4f5c API \u8c03\u7528\u4ee5\u6784\u5efa\u652f\u4ed8\u7f51\u5173\u63d0\u4f9b\u7a0b\u5e8f\u3002<samp>access_tokeninstance_url<\/samp><\/li>\n\n\n\n<li>\u4f7f\u7528<samp>instance_url<\/samp>\u4e2d\u7684\u57df\u5bf9\u8d44\u6e90\u6267\u884c POST \u8c03\u7528\u3002\u4f8b\u5982\uff0c<samp>https:\/\/&nbsp;<var>instance_name.my.salesforce.com\/services\/data\/v<\/var>&nbsp;<var>api_version<\/var>\/tooling\/sobjects\/PaymentGatewayProvider<\/samp>\u3002\u4f7f\u7528\u6b64\u6709\u6548\u8d1f\u8f7d\u4f5c\u4e3a\u8bf7\u6c42\u6b63\u6587\uff0c\u66ff\u6362\u4e3a \u6b63\u786e\u7684\u6570\u636e\u3002<var>value<\/var><code>{ \"ApexAdapterId\": \"<em>value<\/em>\", \"DeveloperName\": \"<em>value<\/em>\", \"MasterLabel\": \"<em>value<\/em>\", \"IdempotencySupported\": \"<em>value<\/em>\", \"Comments\": \"<em>value<\/em>\" } Example: { \"ApexAdapterId\": \"01pxx0000004UU8AAM\", \"DeveloperName\": \"MyNewGatewayProvider\", \"MasterLabel\": \"My New Gateway Provider\", \"IdempotencySupported\": \"Yes\", \"Comments\": \"Custom made gateway provider.\" }<\/code><\/li>\n<\/ol>\n<\/li>\n\n\n\n<li>\u521b\u5efa\u652f\u4ed8\u7f51\u5173\u8bb0\u5f55\u3002PaymentGateway \u5bf9\u8c61\u5b58\u50a8\u6709\u5173 \u8fde\u63a5\u5230\u5916\u90e8\u652f\u4ed8\u7f51\u5173\u3002\u8bb0\u5f55\u9700\u8981\u8fd9\u4e9b\u5b57\u6bb5\u503c\u3002\n<ul class=\"wp-block-list\">\n<li>\u652f\u4ed8\u7f51\u5173\u540d\u79f0\uff1a\u5916\u90e8\u652f\u4ed8\u7f51\u5173\u7684\u540d\u79f0\u3002<\/li>\n\n\n\n<li>Merchant Credential ID\uff1a\u60a8\u62e5\u6709\u7684\u6307\u5b9a\u51ed\u636e\u7684 ID \u521b\u5efa\u3002<\/li>\n\n\n\n<li>\u652f\u4ed8\u7f51\u5173\u63d0\u4f9b\u5546 ID\uff1a\u652f\u4ed8\u7f51\u5173\u63d0\u4f9b\u5546\u7684 ID \u60a8\u521b\u5efa\u7684\u3002<\/li>\n\n\n\n<li>\u72b6\u6001\uff1a \u5df2\u4e0a\u5e02<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u901a\u8fc7\u5728 \u5916\u90e8\u652f\u4ed8\u7f51\u5173\u3002\u5916\u90e8\u652f\u4ed8\u7f51\u5173\u4f7f\u7528 Webhook \u53d1\u9001\u901a\u77e5\uff0c \u4f5c\u4e3a HTTP POST \u6d88\u606f\uff0c\u53d1\u9001\u5230\u5f02\u6b65\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u3002Webhook \u662f\u7ad9\u70b9\u7ec8\u7aef\u8282\u70b9\u4e0e\u652f\u4ed8\u7f51\u5173 ID \u7684\u7ec4\u5408 \u4f9b\u5e94\u5546\u3002\n<ol class=\"wp-block-list\" style=\"list-style-type:lower-alpha\">\n<li>\u5c06\u4ee5\u4e0b URL \u7528\u4e8e\u60a8\u7ad9\u70b9\u7684\u7aef\u70b9\uff0c\u5c06&nbsp;<samp>domain<\/samp>&nbsp;\u66ff\u6362\u4e3a\u60a8\u7ad9\u70b9\u7684\u57df\u548c URL\u3002\u4f8b\u5982\uff1a<samp>https:\/\/<var>MyDomainName<\/var>.my.salesforce-sites.com\/solutions\/services\/data\/v58.0\/commerce\/payments\/notify<\/samp>\u6ce8\u610f<a><\/a>\u5982\u679c\u4f60\u4e0d\u662f \u4f7f\u7528\u589e\u5f3a\u578b\u57df\u65f6\uff0c\u60a8\u7ec4\u7ec7\u7684 Salesforce \u7ad9\u70b9 URL \u4f1a\u6709\u6240\u4e0d\u540c\u3002\u6709\u5173\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605\u6211\u7684 Salesforce \u5e2e\u52a9\u4e2d\u7684\u57df URL \u683c\u5f0f\u3002<\/li>\n\n\n\n<li>\u67e5\u627e\u652f\u4ed8\u7f51\u5173\u63d0\u4f9b\u5546\u7684 ID\uff0c\u5e76\u5c06&nbsp;<samp>\uff1fprovider=ID<\/samp>&nbsp;\u67e5\u8be2\u53c2\u6570\u9644\u52a0\u5230\u7ec8\u7aef\u8282\u70b9\u3002\u4f8b\u5982\uff0c<samp>https\uff1a\/\/<var>MyDomainName.my.salesforce-sites.com\/solutions\/services\/data\/v58.0\/commerce\/payments\/notify?provider=0cJR00000004CEhMAM<\/var><\/samp><\/li>\n\n\n\n<li>\u5728\u5916\u90e8\u652f\u4ed8\u7f51\u5173\u7684\u6807\u51c6\u901a\u77e5\u4e2d\u8f93\u5165 Webhook \u8bbe\u7f6e\u3002<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n\n\n\n<h1 class=\"wp-block-heading\">\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u7684\u751f\u6210\u5668\u793a\u4f8b<\/h1>\n\n\n\n<p>\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u7684\u6700\u540e\u90e8\u5206\u5e94\u5b9a\u4e49\u9002\u914d\u5668\u7684\u521b\u5efa\u65b9\u5f0f \u8bf7\u6c42\u548c\u54cd\u5e94\u3002\u8fd9\u4e9b\u7c7b\u7684\u5b9e\u73b0\u53ef\u80fd\u4f1a\u56e0 \u7f51\u5173\u548c\u5e73\u53f0\u8981\u6c42\u3002\u6211\u4eec\u63d0\u4f9b\u4e86\u51e0\u4e2a\u6cdb\u578b\u793a\u4f8b \u56de\u987e\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f8b<\/h2>\n\n\n\n<p>buildCapture\u8bf7\u6c42<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>private String buildCaptureRequest(commercepayments.CaptureRequest captureRequest) {\n   Boolean IS_MULTICURRENCY_ORG = UserInfo.isMultiCurrencyOrganization();\n    QueryUtils qBuilderForAuth = new QueryUtils(PaymentAuthorization.SObjectType);\n    qBuilderForAuth.getSelectClause().addField('GatewayRefNumber', false);\n    qBuilderForAuth.setWhereClause(' WHERE Id =' + '\\'' + captureRequest.paymentAuthorizationId + '\\'');\n    PaymentAuthorization authObject = (PaymentAuthorization)Database.query(qBuilderForAuth.buildSOQL())&#91;0];\n\n    JSONGenerator jsonGeneratorInstance = JSON.createGenerator(true);\n    jsonGeneratorInstance.writeStartObject();\n    jsonGeneratorInstance.writeStringField('merchantAccount', '{!$Credential.Username}');\n    jsonGeneratorInstance.writeStringField('originalReference', authObject.GatewayRefNumber);\n\n    jsonGeneratorInstance.writeFieldName('modificationAmount');\n    jsonGeneratorInstance.writeStartObject();\n    jsonGeneratorInstance.writeStringField('value', String.ValueOf((captureRequest.amount * 100.0).intValue()));\n    jsonGeneratorInstance.writeEndObject();\n\n    jsonGeneratorInstance.writeEndObject();\n    return jsonGeneratorInstance.getAsString();\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f8b<\/h2>\n\n\n\n<p>createCaptureResponse<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>private commercepayments.GatewayResponse createCaptureResponse(HttpResponse response) {\n    Map&lt;String, Object&gt; mapOfResponseValues = (Map\n                        &lt;String, Object&gt;) JSON.deserializeUntyped(response.getBody());\n    Integer statusCode = response.getStatusCode();\n    String responceValue = (String)mapOfResponseValues.get('response');\n    if(statusCode == 200) {\n        system.debug('Response - success - Capture received');\n       commercepayments.CaptureResponse captureResponse = new commercepayments.CaptureResponse();\n        captureResponse.setAsync(true); \/\/ Very important to treat this as an asynchronous transaction\n        captureResponse.setGatewayReferenceNumber((String)mapOfResponseValues.get('pspReference'));\n        captureResponse.setSalesforceResultCodeInfo(new commercepayments.SalesforceResultCodeInfo(commercepayments.SalesforceResultCode.Success));\n        return captureResponse;\n    } else {\n        system.debug('Response - error - Capture not received by Gateway');\n        String message = (String)mapOfResponseValues.get('message');\n        commercepayments.GatewayErrorResponse error = new commercepayments.GatewayErrorResponse(String.valueOf(statusCode), message);\n        return error;\n    }\n}<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u4ed8\u6b3e\u6388\u6743\u64a4\u9500\u670d\u52a1<\/h1>\n\n\n\n<p>\u6388\u6743\u64a4\u9500\u662f\u901a\u8fc7\u91ca\u653e\u6765\u5426\u5b9a\u6388\u6743\u7684\u4ea4\u6613 \u5ba2\u6237\u4ed8\u6b3e\u65b9\u5f0f\u4e2d\u7684\u8d44\u91d1\u51bb\u7ed3\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6388\u6743<strong>\u53cd\u8f6cApex\u7c7b\u5b9e\u73b0<\/strong><br>\u6388\u6743\u53cd\u8f6c\u670d\u52a1\u4f7f\u7528 \u548c \u7c7b\u6765\u7ba1\u7406\u6388\u6743\u53cd\u8f6c\u4fe1\u606f\u7684\u521b\u5efa\u548c\u5b58\u50a8\u3002\u5728\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u4e2d\u5b9e\u73b0\u8fd9\u4e9b\u7c7b\u3002<samp>AuthorizationReversalRequestAuthorizationReversalResponse<\/samp><\/li>\n\n\n\n<li><strong>\u652f\u4ed8\u6388\u6743\u64a4\u9500\u670d\u52a1 API<\/strong><br>\u6388\u6743\u64a4\u9500\u662f\u6307\u901a\u8fc7\u89e3\u9664\u5ba2\u6237\u652f\u4ed8\u65b9\u5f0f\u4e2d\u7684\u8d44\u91d1\u51bb\u7ed3\u6765\u5426\u5b9a\u6388\u6743\u7684\u4ea4\u6613\u3002\u4f7f\u7528\u6388\u6743\u64a4\u9500\u670d\u52a1\uff0c\u4e3a\u7528\u6237\u63d0\u4f9b\u64a4\u9500\u672a\u5b8c\u6210\u7684\u4ed8\u6b3e\u6388\u6743\u7684\u80fd\u529b\u3002<\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\">\u6388\u6743\u64a4\u9500 Apex \u7c7b\u5b9e\u73b0<\/h1>\n\n\n\n<p>\u6388\u6743\u64a4\u9500\u670d\u52a1\u4f7f\u7528 \u548c \u7c7b\u6765\u7ba1\u7406 \u6388\u6743\u64a4\u9500\u4fe1\u606f\u3002\u5728\u652f\u4ed8\u7f51\u5173\u4e2d\u5b9e\u73b0\u8fd9\u4e9b\u7c7b \u9002\u914d\u5668\u3002<\/p>\n\n\n\n<p><samp>AuthorizationReversalRequest<\/samp><samp>AuthorizationReversalResponse<\/samp>AuthorizationReversal\u8bf7\u6c42\u8868\u793a\u6388\u6743\u64a4\u9500\u8bf7\u6c42\u3002\u6269\u5c55\u5e76\u7ee7\u627f\u5176\u6240\u6709\u65b9\u6cd5\u3002<samp>BaseRequest<\/samp><samp>AuthorizationReversalRequest<\/samp>\u4f7f\u7528\u6784\u9020\u51fd\u6570 \u5728 Salesforce \u4e2d\u5efa\u7acb\u6388\u6743\u64a4\u9500\u8bf7\u6c42\u8bb0\u5f55\u3002\u6784\u9020\u51fd\u6570\u4e0d\u5e26\u4efb\u4f55\u53c2\u6570\u3002 \u60a8\u53ef\u4ee5\u6309\u5982\u4e0b\u65b9\u5f0f\u8c03\u7528\u5b83\u3002<samp>AuthorizationReversalRequest<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CommercePayments.AuthorizationReversalRequest arr = new CommercePayments.AuthorizationReversalRequest();<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u8981\u751f\u6210\u793a\u4f8b\u6388\u6743\u64a4\u9500\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528 \u51b2\u9500\u91d1\u989d\u548c\u4ed8\u6b3e\u6388\u6743 ID \u7684\u53c2\u6570\u3002\u4f46\u662f\uff0c\u6784\u9020\u51fd\u6570\u4f1a \u4ec5\u9002\u7528\u4e8e\u6d4b\u8bd5\u4f7f\u7528\uff0c\u5982\u679c\u5728 Apex \u6d4b\u8bd5\u4e4b\u5916\u4f7f\u7528\uff0c\u5219\u4f1a\u5f15\u53d1\u5f02\u5e38 \u4e0a\u4e0b\u6587\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>commercepayments.AuthorizationReversalRequest authorizationReversalRequest = \nnew commercepayments.AuthorizationReversalRequest(80, authObj.id);<\/code><\/pre>\n\n\n\n<p>AuthorizationReversalResponse\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u53d1\u9001\u6b64\u7c7b\u4f5c\u4e3a\u6388\u6743\u64a4\u9500\u7684\u54cd\u5e94 \u8bf7\u6c42\u7c7b\u578b\u3002\u6269\u5c55\u5e76\u7ee7\u627f\u5176 \u65b9\u6cd5\u3002<samp>AbstractResponse<\/samp><samp>AuthorizationReversalResponse<\/samp>\u4f7f\u7528\u6784\u9020\u51fd\u6570 \u5728 Salesforce \u4e2d\u5efa\u7acb\u6388\u6743\u64a4\u9500\u8bf7\u6c42\u8bb0\u5f55\u3002\u6784\u9020\u51fd\u6570\u4e0d\u5e26\u4efb\u4f55\u53c2\u6570\u3002 \u60a8\u53ef\u4ee5\u6309\u5982\u4e0b\u65b9\u5f0f\u8c03\u7528\u5b83\uff1a<samp>AuthorizationReversalResponse<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CommercePayments.AuthorizationReversalResponse arp = new CommercePayments.AuthorizationReversalResponse();<\/code><\/pre>\n\n\n\n<p>\u6ce8\u610f<\/p>\n\n\n\n<p>Salesforce \u4e0d\u652f\u6301\u6279\u91cf\u64cd\u4f5c\u6216\u6388\u6743\u64a4\u9500\u4e2d\u7684\u81ea\u5b9a\u4e49\u5b57\u6bb5 \u8fc7\u7a0b\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5728\u7f51\u5173\u9002\u914d\u5668\u4e2d\u5b9e\u73b0\u53cd\u8f6c\u7c7b<\/h2>\n\n\n\n<p>\u5c06\u60a8\u7684\u53cd\u8f6c\u7c7b\u6dfb\u52a0\u5230\u60a8\u7684\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u3002\u6211\u4eec\u5efa\u8bae\u5728\u8c03\u7528\u7f51\u5173\u7684\u54cd\u5e94\u65f6\u6dfb\u52a0\u4e00\u4e2a\u53ef\u80fd\u7684\u503c\u3002<samp>AuthorizationReversal<\/samp><samp>requestType<\/samp><samp>processRequest<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>global commercepayments.GatewayResponse processRequest(commercepayments.paymentGatewayContext gatewayContext) {\n        commercepayments.RequestType requestType = gatewayContext.getPaymentRequestType();\n        commercepayments.GatewayResponse response;\n        \n        try {\n        \/\/add conditions for other requestType values here\n        \/\/..\n        else if (requestType == commercepayments.RequestType.AuthorizationReversal) {\n                response = createAuthReversalResponse((commercepayments.AuthorizationReversalRequest)gatewayContext.getPaymentRequest());}\n        \n        return response;<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\uff0c\u6dfb\u52a0\u4e00\u4e2a\u8bbe\u7f6e\u6388\u6743\u64a4\u9500\u8bf7\u6c42\u91cf\u7684\u7c7b gateway \u4fe1\u606f\u548c Salesforce \u7ed3\u679c\u4ee3\u7801\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>global commercepayments.GatewayResponse createAuthReversalResponse(commercepayments.AuthorizationReversalRequest authReversalRequest) {\n        commercepayments.AuthorizationReversalResponse authReversalResponse = new commercepayments.AuthorizationReversalResponse();\n        if(authReversalRequest.amount!=null )\n        {\n            authReversalResponse.setAmount(authReversalRequest.amount);\n        }\n        else\n        {\n             throw new SalesforceValidationException('Required Field Missing : Amount');             \n        }\n   \n        system.debug('Response - success');\n        authReversalResponse.setGatewayDate(system.now());\n        authReversalResponse.setGatewayResultCode('00');\n        authReversalResponse.setGatewayResultCodeDescription('Transaction Normal');\n        \/\/Replace 'xxxxx' with the gateway reference number.\n        authReversalResponse.setGatewayReferenceNumber('SF'+xxxxx);\n        authReversalResponse.setSalesforceResultCodeInfo(SUCCESS_SALESFORCE_RESULT_CODE_INFO);\n        return authReversalResponse;\n    }<\/code><\/pre>\n\n\n\n<p><strong>\u793a\u4f8b Apex \u8bf7\u6c42<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>String authorizationId = '0XcxXXXXXXXXXXXXXXX';\nConnectApi.AuthorizationReversalRequest authorizationReversalRequest = new ConnectApi.AuthorizationReversalRequest();\nauthorizationReversalRequest.amount = 1.0;\nauthorizationReversalRequest.comments = 'Captured from custom action';\nauthorizationReversalRequest.ipAddress = '192.162.10.3';\nauthorizationReversalRequest.email = 'testuser@example.com';\n\nConnectApi.AuthorizationReversalResponse authorizationReversalResponse = ConnectApi.Payments.reverseAuthorization(authorizationReversalRequest, authorizationId);\nString authReversalId = authorizationReversalResponse.paymentAuthAdjustment.id;\nSystem.debug(authorizationReversalResponse);\nSystem.debug(authReversalId);<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u652f\u4ed8\u6388\u6743\u64a4\u9500\u670d\u52a1API<\/h1>\n\n\n\n<p>\u6388\u6743\u64a4\u9500\u662f\u901a\u8fc7\u91ca\u653e\u6765\u5426\u5b9a\u6388\u6743\u7684\u4ea4\u6613 \u5ba2\u6237\u4ed8\u6b3e\u65b9\u5f0f\u4e2d\u7684\u8d44\u91d1\u51bb\u7ed3\u3002\u4f7f\u7528\u6388\u6743\u64a4\u9500\u670d\u52a1\u53ef\u4ee5 \u4f7f\u7528\u6237\u80fd\u591f\u64a4\u9500\u672a\u5b8c\u6210\u7684\u4ed8\u6b3e\u6388\u6743\u3002<\/p>\n\n\n\n<p>\u6709\u65f6\uff0c\u5ba2\u6237\u6267\u884c\u4ed8\u6b3e\u6388\u6743\uff0c\u4f46\u968f\u540e\u9700\u8981\u53d6\u6d88\u5168\u90e8\u6216\u90e8\u5206 \u7a0d\u540e\u6388\u6743\u3002\u4f8b\u5982\uff0c\u5ba2\u6237\u8d2d\u4e70\u4e86\u4e09\u4ef6\u5546\u54c1\uff0c\u7136\u540e\u610f\u8bc6\u5230 \u7b2c\u4e00\u4ef6\u5546\u54c1\u5df2\u7ecf\u5728\u4ed6\u4eec\u7684\u5e93\u5b58\u4e2d\u3002Commerce Payments API \u5141\u8bb8\u60a8\u64a4\u6d88\u5168\u90e8\u6216\u90e8\u5206 \u672a\u5b8c\u6210\u7684\u4ed8\u6b3e\u6388\u6743\u3002<\/p>\n\n\n\n<p>\u5ba2\u6237\u652f\u4ed8\u7f51\u5173\u6388\u6743\u4ed8\u6b3e\u540e\uff0cCommerce Payments \u5c06\u521b\u5efa\u4ed8\u6b3e \u6388\u6743\u8bb0\u5f55\uff0c\u7528\u4e8e\u5b58\u50a8\u6709\u5173\u6388\u6743\u7684\u4fe1\u606f\u3002\u5f53\u7528\u6237\u6216\u8fdb\u7a0b \u5bf9\u6388\u6743\u6267\u884c\u64a4\u9500\uff0c\u6388\u6743\u64a4\u9500\u670d\u52a1\u4f1a\u521b\u5efa\u4e00\u4e2a \u5bf9\u5b58\u50a8\u4fe1\u606f\u8fdb\u884c\u652f\u4ed8\u6388\u6743\u8c03\u6574\u3002\u8be5\u8c03\u6574\u4e0e \u6388\u6743\u3002\u5982\u679c\u4ed8\u6b3e\u6388\u6743\u4e0e\u8ba2\u5355\u4ed8\u6b3e\u6458\u8981\u76f8\u5173\u8054\uff0c\u5219\u64a4\u9500 \u91d1\u989d\u5c06\u6dfb\u52a0\u5230\u8ba2\u5355\u4ed8\u6b3e\u6458\u8981\u7684&nbsp;AuthorizationReversalAmount&nbsp;\u4e2d\uff0c\u5e76\u4ece\u5176&nbsp;AvailableToCaptureAmount&nbsp;\u4e2d\u51cf\u53bb\u3002\u4f46&nbsp;AvailableToCaptureAmount&nbsp;\u6c38\u8fdc\u4e0d\u4f1a\u4f4e\u4e8e 0\uff0c\u5373\u4f7f\u53cd\u8f6c\u4f7f\u5176 \u8ba1\u7b97\u8d1f\u6570\u3002<\/p>\n\n\n\n<p>\u6ce8\u610f<\/p>\n\n\n\n<p>\u5bf9\u4e8e\u6388\u6743\u64a4\u9500\uff0c\u652f\u4ed8\u7f51\u5173\u65e5\u5fd7\u7684&nbsp;OrderPaymentSummaryId&nbsp;\u59cb\u7ec8\u9ed8\u8ba4\u4e3a null\u3002\u5982\u679c\u6709\u4e00\u4e2a \u5173\u8054\u8ba2\u5355\u4ed8\u6b3e\u6c47\u603b\uff0c\u60a8\u7684\u4ee3\u7801\u53ef\u4ee5\u8bbe\u7f6e\u503c\u3002<\/p>\n\n\n\n<p>\u901a\u8fc7\u5411\u4ee5\u4e0b\u7ec8\u7ed3\u70b9\u53d1\u51fa POST \u8bf7\u6c42\u6765\u8c03\u7528\u6388\u6743\u64a4\u9500\u670d\u52a1\u3002<\/p>\n\n\n\n<p><strong>\u7aef\u70b9<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/commerce\/payments\/authorizations\/${*authorizationId*}\/reversals<\/code><\/pre>\n\n\n\n<p>\u8be5\u670d\u52a1\u6bcf\u6b21\u8c03\u7528\u63a5\u53d7\u4e00\u4e2a\u6388\u6743\u64a4\u9500\u8bf7\u6c42\u3002\u4ee5\u4e0b\u4ed8\u6b3e \u63a5\u53d7\u6388\u6743\u8c03\u6574 API \u53c2\u6570\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\u53c2\u6570<\/th><th>\u5fc5\u586b<\/th><th>\u63cf\u8ff0<\/th><\/tr><\/thead><tbody><tr><td>\u91cf<\/td><td>\u5fc5\u586b<\/td><td>\u4ece\u6388\u6743\u4e2d\u51b2\u9500\u7684\u91d1\u989d\u3002\u5fc5\u987b\u5927\u4e8e\u96f6\u3002Salesforce \u4e0d\u63d0\u4f9b\u4e0e \u76f8\u6bd4\u7684\u9a8c\u8bc1\u3002<samp>PaymentAuthorizationAdjustment.Amount<\/samp><samp>PaymentAuthorization.Amount<\/samp>\u5982\u679c\u652f\u4ed8\u7f51\u5173\u5141\u8bb8\u7684\u64a4\u9500\u91d1\u989d\u5927\u4e8e\u6388\u6743\u91d1\u989d \u91d1\u989d\uff0c\u5219\u6388\u6743\u7684\u7ed3\u679c\u4f59\u989d\u53ef\u4ee5\u4e3a\u8d1f\u6570\u3002\u5982\u679c\u60a8\u7684\u7f51\u5173\u652f\u6301 \u6388\u6743\u4f59\u989d\u4f4e\u4e8e\u96f6\uff0c\u5e76\u4e14\u60a8\u5e0c\u671b\u907f\u514d\u7f51\u5173\u8c03\u7528\uff0c\u8bf7\u914d\u7f6e \u9002\u914d\u5668\u67e5\u8be2\u6388\u6743\u91d1\u989d\u3001\u4f59\u989d\u548c\u603b\u51b2\u9500\u91d1\u989d\uff0c\u4e0d\u67e5\u8be2 \u5982\u679c\u4f59\u989d\u5c0f\u4e8e\u96f6\uff0c\u5219\u8c03\u7528\u7ec8\u7ed3\u70b9\u3002<\/td><\/tr><tr><td>\u5e10\u6237 ID<\/td><td>\u81ea\u9009<\/td><td>\u6b64\u6388\u6743\u64a4\u9500\u94fe\u63a5\u5230\u7684\u5e10\u6237 ID\u3002<\/td><\/tr><tr><td>\u751f\u6548\u65e5\u671f<\/td><td>\u81ea\u9009<\/td><td>\u64a4\u9500\u9002\u7528\u4e8e\u6388\u6743\u7684\u65e5\u671f\u3002<\/td><\/tr><tr><td>\u7535\u5b50\u90ae\u4ef6<\/td><td>\u81ea\u9009<\/td><td>\u6b3a\u8bc8\u53c2\u6570<\/td><\/tr><tr><td>ip\u5730\u5740<\/td><td>\u81ea\u9009<\/td><td>\u6b3a\u8bc8\u53c2\u6570<\/td><\/tr><tr><td>mac\u5730\u5740<\/td><td>\u81ea\u9009<\/td><td>\u6b3a\u8bc8\u53c2\u6570<\/td><\/tr><tr><td>\u7535\u8bdd<\/td><td>\u81ea\u9009<\/td><td>\u6b3a\u8bc8\u53c2\u6570<\/td><\/tr><tr><td>\u8bc4\u8bba<\/td><td>\u81ea\u9009<\/td><td>\u7528\u6237\u63d0\u4f9b\u7684\u6709\u5173\u6388\u6743\u64a4\u9500\u7684\u6ce8\u91ca\u3002\u5fc5\u987b\u5c0f\u4e8e 1000 \u5b57\u7b26\u3002<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u793a\u4f8b\u8bf7\u6c42\u548c\u54cd\u5e94<\/h2>\n\n\n\n<p>\u6b64\u8bf7\u6c42\u8c03\u7528\u9488\u5bf9\u6388\u6743\u7684 150 \u7f8e\u5143\u64a4\u9500\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  \"accountId\":\"\",\n  \"amount\": \"150\",*  \"comments\": \"authorization reversal request\",\n  \"effectiveDate\":\"2020-10-18T11:32:27.000Z\",\n  \"ipAddress\": \"202.95.77.70\",\n  \"macAddress\": \"00-14-22-01-23-45\",\n  \"phone\": \"100-456-67\",\n  \"email\": \"test@example.org\",\n  \"additionalData\":{\n       \/\/add additional parameters if needed\n      \"key1\":\"value1\",\n      \"key2\":\"value2\",\n      \"key3\":\"value3\",\n      \"key4\":\"value4\",\n      \"key5\":\"value5\"\n    }\n}<\/code><\/pre>\n\n\n\n<p><strong>\u793a\u4f8b\u54cd\u5e94 &#8211; \u6210\u529f<\/strong><\/p>\n\n\n\n<p>\u6210\u529f\u7684\u6388\u6743\u64a4\u9500\u54cd\u5e94\u63d0\u4f9b\u6709\u5173\u7f51\u5173\u54cd\u5e94\u7684\u4fe1\u606f \u4ee5\u53ca\u7528\u4e8e\u6784\u9020\u4ed8\u6b3e\u6388\u6743\u8c03\u6574\u5b9e\u4f53\u7684\u503c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>HPP Status Code: 201\n{\n  \"gatewayResponse\" : {\n    \"gatewayDate\" : \"2020-10-23T15:21:58.833Z\",\n    \"gatewayReferenceNumber\" : \"439XXXXXXX\",\n    \"gatewayResultCode\" : \"00\",\n    \"gatewayResultCodeDescription\" : \"Transaction Normal\",\n    \"salesforceResultCode\" : \"Success\"\n  },\n  \"paymentAuthAdjustment\" : {\n    \"amount\" : \"150.0\",\n    \"currencyIsoCode\" : \"USD\",\n    \"effectiveDate\" : \"2020-10-18T11:32:27.000Z\",\n    \"id\" : \"9tvR00000004Cf1MAE\",\n    \"paymentAuthAdjustmentNumber\" : \"PAA-00XXXXXXX\",\n    \"requestDate\" : \"2020-10-23T15:21:58.000Z\",\n    \"status\" : \"Processed\"\n  },\n  \"paymentGatewayLogs\" : &#91; {\n    \"createdDate\" : \"2020-10-23T15:21:58.000Z\",\n    \"gatewayResultCode\" : \"00\",\n    \"id\" : \"0XtXXXXXXXXXXXXXXX\",\n    \"interactionStatus\" : \"Success\"\n  } ]\n}<\/code><\/pre>\n\n\n\n<p>Salesforce \u4e2d\u751f\u6210\u7684\u4ed8\u6b3e\u6388\u6743\u8c03\u6574\u5982\u4e0b\u6240\u793a\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u8fd4\u56de\u9519\u8bef\uff0c\u5219\u54cd\u5e94\u5c06\u5305\u542b\u7f51\u5173\u7684\u9519\u8bef\u4ee3\u7801\u548c\u9519\u8bef\u6d88\u606f\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b\u54cd\u5e94 &#8211; \u9519\u8bef<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n    \"errorCode\":\"\",\n    \"errorMessage\":\"\"\n}<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u4ee3\u5e01\u5316\u670d\u52a1<\/h1>\n\n\n\n<p>\u4fe1\u7528\u5361\u4ee4\u724c\u5316\u8fc7\u7a0b\u5c06\u654f\u611f\u7684\u5ba2\u6237\u4fe1\u606f\u66ff\u6362\u4e3a \u5728\u652f\u4ed8\u4ea4\u6613\u671f\u95f4\u4f7f\u7528\u7684\u4e00\u6b21\u6027\u7b97\u6cd5\u751f\u6210\u7684\u53f7\u7801\uff0c\u79f0\u4e3a\u4ee4\u724c\u3002 Salesforce \u5b58\u50a8\u4ee4\u724c\uff0c\u7136\u540e\u4f7f\u7528\u8be5\u4ee4\u724c\u4f5c\u4e3a\u6240\u7528\u4fe1\u7528\u5361\u7684\u8868\u793a\u5f62\u5f0f \u7528\u4e8e\u4ea4\u6613\u3002\u4ee4\u724c\u5141\u8bb8\u60a8\u5b58\u50a8\u6709\u5173\u4fe1\u7528\u5361\u7684\u4fe1\u606f\uff0c\u800c\u65e0\u9700\u5b58\u50a8 Salesforce \u4e2d\u7684\u654f\u611f\u5ba2\u6237\u6570\u636e\uff0c\u4f8b\u5982\u4fe1\u7528\u5361\u53f7\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u4ee4\u724c\u5316\u670d\u52a1 Apex \u7c7b\u5b9e\u73b0<\/strong><br>\u4f7f\u7528\u4ee4\u724c\u5316\u670d\u52a1\u9690\u85cf\u654f\u611f\u7684\u5ba2\u6237\u4ed8\u6b3e\u65b9\u5f0f\u6570\u636e\u3002\u6807\u8bb0\u5316\u670d\u52a1\u4f7f\u7528 \u3001 \u548c \u3002\u5728\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u4e2d\u5b9e\u73b0\u8fd9\u4e9b\u7c7b\u3002<samp>PaymentMethodTokenizationRequestPaymentMethodTokenizationResponseCardPaymentMethodRequest<\/samp><\/li>\n\n\n\n<li><strong>\u4ee4\u724c\u5316\u670d\u52a1 API<\/strong><br>\u4fe1\u7528\u5361\u4ee4\u724c\u5316\u8fc7\u7a0b\u5c06\u654f\u611f\u7684\u5ba2\u6237\u4fe1\u606f\u66ff\u6362\u4e3a\u7b97\u6cd5\u751f\u6210\u7684\u4e00\u6b21\u6027\u6570\u5b57\uff08\u79f0\u4e3a\u4ee4\u724c\uff09\uff0c\u4ee5\u4fbf\u5728\u652f\u4ed8\u4ea4\u6613\u671f\u95f4\u4f7f\u7528\u3002Salesforce \u5b58\u50a8\u4ee4\u724c\uff0c\u7136\u540e\u4f7f\u7528\u8be5\u4ee4\u724c\u4f5c\u4e3a\u7528\u4e8e\u4ea4\u6613\u7684\u4fe1\u7528\u5361\u7684\u8868\u793a\u5f62\u5f0f\u3002\u8be5\u4ee4\u724c\u5141\u8bb8\u60a8\u5b58\u50a8\u6709\u5173\u4fe1\u7528\u5361\u7684\u4fe1\u606f\uff0c\u800c\u65e0\u9700\u5728 Salesforce \u4e2d\u5b9e\u9645\u5b58\u50a8\u654f\u611f\u7684\u5ba2\u6237\u6570\u636e\uff08\u5982\u4fe1\u7528\u5361\u53f7\uff09\u3002\u5b9e\u65bd\u6211\u4eec\u7684\u4ee4\u724c\u5316 API\uff0c\u4e3a\u60a8\u7684\u652f\u4ed8\u670d\u52a1\u6dfb\u52a0\u4ee4\u724c\u5316\u529f\u80fd\u3002<\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\">\u4ee4\u724c\u5316\u670d\u52a1 Apex \u7c7b\u5b9e\u73b0<\/h1>\n\n\n\n<p>\u4f7f\u7528\u4ee4\u724c\u5316\u670d\u52a1\u9690\u85cf\u654f\u611f\u7684\u5ba2\u6237\u4ed8\u6b3e\u65b9\u5f0f\u6570\u636e\u3002\u8fd9 \u6807\u8bb0\u5316\u670d\u52a1\u4f7f\u7528 \u3001 \u548c \u3002\u5728\u652f\u4ed8\u7f51\u5173\u4e2d\u5b9e\u73b0\u8fd9\u4e9b\u7c7b \u9002\u914d\u5668\u3002<\/p>\n\n\n\n<p><samp>PaymentMethodTokenizationRequest<\/samp><samp>PaymentMethodTokenizationResponse<\/samp><samp>CardPaymentMethodRequest<\/samp><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4ee4\u724c\u5316\u652f\u4ed8\u65b9\u5f0f\u7684\u52a0\u5bc6<\/h2>\n\n\n\n<p>CommercePayments \u4f7f\u7528 Salesforce \u5b57\u6bb5\u52a0\u5bc6\u5c06\u7f51\u5173\u4ee4\u724c\u503c\u5b89\u5168\u5730\u5b58\u50a8\u5728 \u5ba2\u6237\u4ed8\u6b3e\u65b9\u5f0f\u5b9e\u4f53\uff0c\u4f8b\u5982 DigitalWallet\u3001CardPaymentMethod \u548c AlternativePaymentMethod\u3002<\/p>\n\n\n\n<p>CardPaymentMethod \u548c DigitalWallet \u5305\u542b GatewayTokenEncrypted \u5b57\u6bb5\uff0c\u8be5\u5b57\u6bb5\u5728 API v52.0 \u53ca\u66f4\u9ad8\u7248\u672c\uff0c\u4ee5\u53ca GatewayToken \u5b57\u6bb5\uff0c\u5728 API v48.0 \u53ca\u66f4\u9ad8\u7248\u672c\u4e2d\u53ef\u7528\u3002\u53cc \u5b57\u6bb5\u5b58\u50a8\u7f51\u5173\u4ee4\u724c\u503c\u3002\u4f46\u662f\uff0cGatewayTokenEncrypted \u4f7f\u7528 Salesforce\u00a0Classic Encryption for Custom\u00a0\u7528\u4e8e\u5b89\u5168\u52a0\u5bc6\u4ee4\u724c\u7684\u5b57\u6bb5\u3002GatewayToken \u4e0d\u4f7f\u7528\u52a0\u5bc6\u3002\u81ea \u786e\u4fdd\u5b89\u5168\u4ee4\u724c\u5316\uff0c\u6211\u4eec\u5efa\u8bae\u5728\u60a8\u7684 DigitalWallets \u4e0a\u4f7f\u7528 GatewayTokenEncrypted \u548c CardPaymentMethods\u3002AlternativePaymentMethod \u5bf9\u8c61\u5c06 GatewayToken \u5b57\u6bb5\u7528\u4e8e \u4ee4\u724c\u5b58\u50a8\uff0c\u4f46\u662f\uff0c\u6b64\u5b57\u6bb5\u5728 AlternativePaymentMethods \u4e0a\u52a0\u5bc6\u3002<\/p>\n\n\n\n<p>\u5728 API \u7248\u672c 52.0 \u53ca\u66f4\u9ad8\u7248\u672c\u4e2d\uff0cCardPaymentMethods \u548c DigitalWallets \u65e0\u6cd5\u5b58\u50a8 GatewayTokenEncryption \u548c GatewayToken \u540c\u65f6\u4f4d\u4e8e\u540c\u4e00\u8bb0\u5f55\u4e0a\u3002\u5982\u679c\u60a8\u5c1d\u8bd5 \u5f53\u53e6\u4e00\u4e2a\u5b58\u5728\u65f6\u5206\u914d\u4e00\u4e2a\uff0cSalesforce \u4f1a\u629b\u51fa\u9519\u8bef\u3002<\/p>\n\n\n\n<p>\u60a8\u7684\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u4f7f\u7528 \u548c \u7c7b\u6765\u68c0\u7d22\u7f51\u5173\u4ee4\u724c \u4ece\u652f\u4ed8\u7f51\u5173\uff0c\u5728 Salesforce \u4e2d\u5bf9\u5176\u8fdb\u884c\u52a0\u5bc6\uff0c\u5e76\u5c06\u503c\u5b58\u50a8\u5728\u4ed8\u6b3e\u65b9\u5f0f\u4e0a \u5b9e\u4f53\u3002\u8ba9\u6211\u4eec\u770b\u770b\u5982\u4f55\u5728\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u4e2d\u914d\u7f6e\u8fd9\u4e9b\u7c7b\u3002<samp>PaymentMethodTokenizationRequest<\/samp><samp>PaymentMethodTokenizationResponse<\/samp><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5728\u7f51\u5173\u9002\u914d\u5668\u4e2d\u5b9e\u73b0\u6807\u8bb0\u5316\u7c7b<\/h2>\n\n\n\n<p>\u4ee5\u4e0b\u4ee3\u7801\u5728 Apex \u7c7b\u4e2d\u4f7f\u7528\u3002<samp>PaymentGatewayAdapter<\/samp><\/p>\n\n\n\n<p>\u5f53\u7c7b\u7684\u65b9\u6cd5\u6536\u5230 \u4ee4\u724c\u5316\u8bf7\u6c42\u3002\u5982\u679c\u8bf7\u6c42\u7c7b\u578b\u4e3a \uff0c\u5219\u8c03\u7528\u8be5\u65b9\u6cd5 \u5e76\u4f20\u9012\u7c7b\u7684\u5b9e\u4f8b\u3002\u8fd9 \u4f20\u9012\u7684\u5bf9\u8c61\u5305\u542b\u5730\u5740\u548c cardPaymentMethod \u652f\u4ed8\u7f51\u5173\u7ba1\u7406\u4ee4\u724c\u5316\u6240\u9700\u7684\u4fe1\u606f \u8fc7\u7a0b\u3002\u4f8b\u5982\uff1a<samp>GatewayResponse<\/samp><samp>processRequest<\/samp><samp>Tokenize<\/samp><samp>GatewayResponse<\/samp><samp>createTokenizeResponse<\/samp><samp>PaymentMethodTokenizationRequest<\/samp><samp>PaymentMethodTokenizationRequest<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>global commercepayments.GatewayResponse processRequest(commercepayments.paymentGatewayContext gatewayContext) {\n         commercepayments.RequestType requestType = gatewayContext.getPaymentRequestType();\n         commercepayments.GatewayResponse response;\n         try\n         {\n             if (requestType == commercepayments.RequestType.Tokenize) {\n                     response = createTokenizeResponse((commercepayments.PaymentMethodTokenizationRequest)gatewayContext.getPaymentRequest());\n             }\n             \/\/Add other else if statements for different request types as needed.\n             return response;\n         }\n         catch(SalesforceValidationException e)\n         {\n              commercepayments.GatewayErrorResponse error = new commercepayments.GatewayErrorResponse('400', e.getMessage());\n              return error;\n         }\n     }<\/code><\/pre>\n\n\n\n<p>\u5c06\u65b9\u6cd5\u914d\u7f6e\u4e3a \u63a5\u53d7 \u7684\u5b9e\u4f8b\uff0c\u7136\u540e\u6839\u636e\u5b83\u6536\u5230\u7684\u503c\u751f\u6210\u00a0<samp>PaymentMethodTokenizationResponse<\/samp>\u00a0\u7684\u5b9e\u4f8b \u4ece\u652f\u4ed8\u7f51\u5173\u3002tokenizeResponse \u5305\u542b\u7f51\u5173\u7684 \u6807\u8bb0\u5316\u8fc7\u7a0b\uff0c\u5982\u679c\u6210\u529f\uff0c\u5219\u6807\u8bb0\u5316\u503c\u3002\u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u8c03\u7528\u8be5\u65b9\u6cd5\u6765\u8bbe\u7f6e \u6807\u8bb0\u5316\u54cd\u5e94\u4e2d\u7684\u6807\u8bb0\u5316\u503c\u3002<samp>createTokenizeResponsePaymentMethodTokenizationRequestsetGatewayTokenEncrypted<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public commercepayments.GatewayResponse createTokenizeResponse(commercepayments.PaymentMethodTokenizationRequest tokenizeRequest) {\n         commercepayments.PaymentMethodTokenizationResponse tokenizeResponse = new commercepayments.PaymentMethodTokenizationResponse();\n         tokenizeResponse.setGatewayTokenEncrypted(encryptedValue);\n         tokenizeResponse.setGatewayTokenDetails(tokenDetails);\n         tokenizeResponse.setGatewayAvsCode(avsCode);\n         tokenizeResponse.setGatewayMessage(gatewayMessage);\n         tokenizeResponse.setGatewayResultCode(resultcode);\n         tokenizeResponse.setGatewayResultCodeDescription(resultCodeDescription);\n         tokenizeResponse.setSalesforceResultCodeInfo(resultCodeInfo);\n         tokenizeResponse.setGatewayDate(system.now());\n         return tokenizeResponse;\n     }<\/code><\/pre>\n\n\n\n<p>\u8be5\u65b9\u6cd5\u5728 Salesforce API v52.0 \u53ca\u66f4\u9ad8\u7248\u672c\u3002\u5b83\u4f7f\u7528 Salesforce \u7ecf\u5178\u52a0\u5bc6\u6765\u8bbe\u7f6e\u52a0\u5bc6 \u53ef\u4ee5\u5b58\u50a8\u5728 CardPaymentMethod \u4e0a\u7684 GatewayTokenEncrypted \u4e2d\u7684\u4ee4\u724c\u503c\uff0c\u6216\u8005 DigitalWallet\uff0c\u6216\u5728 AlternativePaymentMethod \u4e0a\u7684 GatewayToken \u4e2d\u3002\u6211\u4eec\u5efa\u8bae\u60a8\u4f7f\u7528\u6765\u786e\u4fdd\u60a8\u7684\u4ee3\u5e01\u5316\u4ed8\u6b3e \u65b9\u6cd5\u503c\u662f\u52a0\u5bc6\u4e14\u5b89\u5168\u7684\u3002<samp>setGatewayTokenEncrypted<\/samp><samp>setGatewayTokenEncrypted<\/samp><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/** @description Method to set Gateway token to persist in Encrypted Text *\/\n     global void setGatewayTokenEncrypted(String gatewayTokenEncrypted) {\n         if (gatewayTokenSet)  {\n             throwTokenError();\n         }\n         this.delegate.setGatewayTokenEncrypted(gatewayTokenEncrypted);\n         gatewayTokenEncryptedSet = true;\n     }<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u5b9e\u4f8b\u5316\u7684\u7c7b\u5df2\u5177\u6709\u7f51\u5173\u4ee4\u724c\uff0c\u5219\u4f1a\u5f15\u53d1\u9519\u8bef\u3002<samp>setGatewayTokenEncrypted<\/samp><\/p>\n\n\n\n<p>\u6ce8\u610f<\/p>\n\n\n\n<p>\u867d\u7136 PaymentMethodTokenizationResponse \u7684\u00a0<samp>setGatewayToken<\/samp>\u00a0\u65b9\u6cd5\uff08\u5728 API v48.0 \u53ca\u66f4\u9ad8\u7248\u672c\u4e2d\u53ef\u7528\uff09\u4e5f\u8fd4\u56de \u4ed8\u6b3e\u65b9\u5f0f\u4ee4\u724c\uff0c\u5219\u4ee4\u724c\u5316\u503c\u672a\u52a0\u5bc6\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u4ee4\u724c\u5316\u670d\u52a1 API<\/h1>\n\n\n\n<p>\u4fe1\u7528\u5361\u4ee4\u724c\u5316\u8fc7\u7a0b\u5c06\u654f\u611f\u7684\u5ba2\u6237\u4fe1\u606f\u66ff\u6362\u4e3a \u7b97\u6cd5\u751f\u6210\u7684\u4e00\u6b21\u6027\u53f7\u7801\uff0c\u79f0\u4e3a\u4ee4\u724c\uff0c\u7528\u4e8e\u652f\u4ed8\u4ea4\u6613\u671f\u95f4\u3002 Salesforce \u5b58\u50a8\u4ee4\u724c\uff0c\u7136\u540e\u4f7f\u7528\u8be5\u4ee4\u724c\u4f5c\u4e3a\u6240\u7528\u4fe1\u7528\u5361\u7684\u8868\u793a\u5f62\u5f0f \u7528\u4e8e\u4ea4\u6613\u3002\u4ee4\u724c\u5141\u8bb8\u60a8\u5b58\u50a8\u6709\u5173\u4fe1\u7528\u5361\u7684\u4fe1\u606f\uff0c\u800c\u65e0\u9700\u5b9e\u9645 \u5728 Salesforce \u4e2d\u5b58\u50a8\u654f\u611f\u7684\u5ba2\u6237\u6570\u636e\uff0c\u4f8b\u5982\u4fe1\u7528\u5361\u53f7\u3002\u5b9e\u65bd\u6211\u4eec\u7684 \u4ee4\u724c\u5316 API\uff0c\u7528\u4e8e\u4e3a\u60a8\u7684\u652f\u4ed8\u670d\u52a1\u6dfb\u52a0\u4ee4\u724c\u5316\u529f\u80fd\u3002<\/p>\n\n\n\n<p>\u5728\u5178\u578b\u7684\u4ee4\u724c\u5316\u8fc7\u7a0b\u4e2d\uff0c\u652f\u4ed8\u5e73\u53f0\u63a5\u53d7\u5ba2\u6237\u652f\u4ed8\u65b9\u5f0f\u6570\u636e \u5e76\u5c06\u5176\u4f20\u9012\u7ed9 Salesforce \u5916\u90e8\u652f\u4ed8\u7f51\u5173\u4e0a\u7684\u8fdc\u7a0b\u4ee4\u724c\u670d\u52a1\u670d\u52a1\u5668\u3002 \u670d\u52a1\u5668\u4e3a\u5e73\u53f0\u4e0a\u7684\u5b58\u50a8\u63d0\u4f9b\u6807\u8bb0\u5316\u503c\u3002\u4f8b\u5982\uff0c\u5ba2\u6237 \u63d0\u4f9b \u7684\u4fe1\u7528\u5361\u53f7\u3002\u4ee4\u724c\u670d\u52a1\u5668\u5b58\u50a8 \u6b64\u503c\uff0c\u5c06\u5176\u4e0e \u7684\u4ee4\u724c\u76f8\u5173\u8054\uff0c\u5e76\u53d1\u9001 \u7528\u4e8e\u5728\u5e73\u53f0\u4e0a\u5b58\u50a8\u7684\u4ee4\u724c\u3002<var>4111 1111 1111 1234<\/var><var>2537446225198291<\/var><\/p>\n\n\n\n<p>\u5728\u4e0e\u5546\u5bb6\u901a\u4fe1\u671f\u95f4\uff0c\u5546\u5bb6\u5c06\u4ee4\u724c\u53d1\u9001\u5230\u4ee4\u724c\u670d\u52a1\u5668\u3002\u4ee4\u724c\u670d\u52a1\u5668\u786e\u8ba4\u5b83 \u5339\u914d\u5ba2\u6237\u7684\u4ee4\u724c\uff0c\u5e76\u6388\u6743\u5546\u5bb6\u9488\u5bf9 \u5ba2\u6237\u7684\u5361\u3002<var>2537446225198291<\/var><\/p>\n\n\n\n<p>Commerce Payments Tokenization API \u63a5\u53d7\u4fe1\u7528\u5361\u4fe1\u606f\u5e76\u4f7f\u7528\u5916\u90e8 \u901a\u8fc7\u5ba2\u6237\u7684 Salesforce \u7ec4\u7ec7\u914d\u7f6e\u7684\u652f\u4ed8\u7f51\u5173\uff0c\u7528\u4e8e\u5bf9\u5361\u8fdb\u884c\u4ee4\u724c\u5316 \u4fe1\u606f\u3002\u7136\u540e\uff0c\u5b83\u8fd4\u56de\u6807\u8bb0\u5316\u8868\u793a\u5f62\u5f0f\u3002\u7136\u540e\uff0cAPI \u5c06\u4ee4\u724c\u4fdd\u5b58\u5728 \u4e2d\u3002<samp>CardPaymentMethod<\/samp><\/p>\n\n\n\n<p>\u901a\u8fc7\u5411\u4ee5\u4e0b\u7ec8\u7ed3\u70b9\u53d1\u51fa POST \u8bf7\u6c42\u6765\u8c03\u7528\u6388\u6743\u64a4\u9500\u670d\u52a1\u3002<\/p>\n\n\n\n<p><strong>\u7aef\u70b9<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/commerce\/payments\/payment-method\/tokens\/<\/code><\/pre>\n\n\n\n<p>\u4ee4\u724c\u5316\u670d\u52a1\u63a5\u53d7\u6765\u81ea\u4ed8\u6b3e\u7684\u4ee5\u4e0b\u8bf7\u6c42\u53c2\u6570\uff0c\u5e76\u76f8\u5173 \u5b9e\u4f53\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\u53c2\u6570<\/th><th>\u5fc5\u586b<\/th><th>\u8be6<\/th><\/tr><\/thead><tbody><tr><td><code>cardPaymentMethod: { \"cardHolderName\":\"\", \"expiryMonth\":\"\", \"expiryYear\":\"\", \"startMonth\":\"\", \"startYear\":\"\", \"cvv\":\"\", \"cardNumber\":\"\", \"cardCategory\":\"\", \"cardType\":\"\", \"nickName\":\"\", \"cardHolderFirstName\":\"\", \"cardHolderLastName\":\"\", \"email\":\"\", \"comments\":\"\" }<\/code><\/td><td>\u5fc5\u586b<\/td><td>\u8981\u4ee4\u724c\u5316\u7684\u4fe1\u7528\u5361\u7684\u8be6\u7ec6\u4fe1\u606f\u3002<\/td><\/tr><tr><td>\u5e10\u6237 ID<\/td><td>\u81ea\u9009<\/td><td>\u6301\u5361\u4eba\u7684 Salesforce \u5e10\u6237 ID\u3002<\/td><\/tr><tr><td><code>\"address\":{ \"street\":\"\", \"city\":\"\", \"state\":\"\", \"country\":\"\", \"postalCode\":\"\", \"companyName\":\"\", }<\/code><\/td><td>\u81ea\u9009<\/td><td>\u62e5\u6709\u4fe1\u7528\u5361\u4ed8\u6b3e\u65b9\u5f0f\u7684\u5ba2\u6237\u7684\u5730\u5740\u4fe1\u606f \u4ee3\u5e01\u5316\u3002<\/td><\/tr><tr><td>paymentGatewayId<\/td><td>\u5fc5\u586b<\/td><td>\u4e0e\u4ee4\u724c\u5316\u670d\u52a1\u5668\u76f8\u5173\u7684\u5916\u90e8\u652f\u4ed8\u7f51\u5173\u3002<\/td><\/tr><tr><td>\u7535\u5b50\u90ae\u4ef6<\/td><td>\u81ea\u9009<\/td><td>\u6b3a\u8bc8\u53c2\u6570\u3002<\/td><\/tr><tr><td>ip\u5730\u5740<\/td><td>\u81ea\u9009<\/td><td>\u6b3a\u8bc8\u53c2\u6570\u3002<\/td><\/tr><tr><td>mac\u5730\u5740<\/td><td>\u81ea\u9009<\/td><td>\u6b3a\u8bc8\u53c2\u6570\u3002<\/td><\/tr><tr><td>\u7535\u8bdd<\/td><td>\u81ea\u9009<\/td><td>\u6b3a\u8bc8\u53c2\u6570\u3002<\/td><\/tr><tr><td>additionalData<\/td><td>\u81ea\u9009<\/td><td>\u7f51\u5173\u4ee4\u724c\u5316\u4fe1\u7528\u5361\u4ed8\u6b3e\u6240\u9700\u7684\u4efb\u4f55\u5176\u4ed6\u6570\u636e \u65b9\u6cd5\u3002<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u793a\u4f8b\u8bf7\u6c42\u548c\u54cd\u5e94<\/h2>\n\n\n\n<p>\u6b64\u793a\u4f8b\u8bf7\u6c42\u63d0\u4f9b\u5ba2\u6237\u7684\u4fe1\u7528\u5361\u4fe1\u606f\u4ee5\u8fdb\u884c\u4ee4\u724c\u5316\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n    \"cardPaymentMethod\": {\n        \"cardHolderName\":\"Carol Smith\",\n        \"expiryMonth\": \"05\",\n        \"expiryYear\": \"2025\", \n        \"startMonth\": \"\",\n        \"startYear\": \"\",\n        \"cvv\": \"000\",\n        \"cardNumber\": \"4111111111111111\",\n        \"cardCategory\": \"Credit\",\n        \"cardType\": \"Visa\",\n        \"nickName\": \"\",\n        \"cardHolderFirstName\": \"Carol\",\n        \"cardHolderLastName\": \"Smith\",\n        \"email\" : \"csmith@example.com\",\n        \"comments\" : \"\",\n        \"accountId\": \"000XXXXXXXX\"\n    },\n    \"address\":{\n        \"street\": \"128 1st Street\",\n        \"city\": \"San Francisco\",\n        \"state\": \"CA\",\n        \"country\": \"USA\",\n        \"postalCode\": \"94015\",\n        \"companyName\": \"Salesforce\"\n    },\n    \"paymentGatewayId\" : \"000XXXXXXXX\",\n    \"email\": \"\"\n    \"ipAddress\": \"\",\n    \"macAddress\": \"\",\n    \"phone\": \"\",\n   \n    \"additionalData\":{\n         \/\/add additional information if needed\n        \"key1\":\"value1\",\n        \"key2\":\"value2\",\n        \"key3\":\"value3\",\n        \"key4\":\"value4\",\n        \"key5\":\"value5\"\n    }\n}<\/code><\/pre>\n\n\n\n<p><strong>\u793a\u4f8b\u6210\u529f\u54cd\u5e94<\/strong><\/p>\n\n\n\n<p>\u6210\u529f\u7684\u4ee4\u724c\u5316\u54cd\u5e94\u4f1a\u66f4\u65b0\u4ed8\u6b3e\u65b9\u5f0f\uff0c\u5e76\u63d0\u4f9b\u4ee5\u4e0b\u4fe1\u606f \u7f51\u5173\u54cd\u5e94\u548c\u4efb\u4f55\u652f\u4ed8\u7f51\u5173\u65e5\u5fd7\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  \"paymentMethod\": {\n    \"id\": \"03OR0000000xxxxxxx\",\n    \"accountId\" : \"001xx000000xxxxxxx\",\n    \"status\" : \"Active\"\n  },\n  \"gatewayResponse\" : {\n    \"gatewayResultCode\": \"00\",\n    \"gatewayResultCodeDescription\": \"Transaction Normal\",\n    \"gatewayDate\": \"2020-12-08T04:03:20.000Z\",\n    \"gatewayAvsCode\" : \"7638788018713617\",\n    \"gatewayMessage\" : \"8313990738208498\",\n    \"salesforceResultCode\": \"Success\",\n    \"gatewayTokenEncrypted\" : \"SF701252\"\n  }\n  \"paymentGatewayLogs\" : &#91; {\n    \"createdDate\" : \"2020-12-08T04:03:20.000Z\",\n    \"gatewayResultCode\" : \"00\",\n    \"id\" : \"0XtR0000000xxxxxxx\",\n    \"interactionStatus\" : \"NoOp\"\n  } ],\n}<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u5176\u4ed6\u4ed8\u6b3e\u65b9\u5f0f<\/h1>\n\n\n\n<p>\u53e6\u4e00\u79cd\u4ed8\u6b3e\u65b9\u5f0f\u5141\u8bb8\u5ba2\u6237\u5b58\u50a8\u548c\u8868\u793a\u4ed8\u6b3e\u65b9\u5f0f \u672a\u7531\u5176\u4ed6\u9884\u5b9a\u4e49\u7684\u4ed8\u6b3e\u65b9\u5f0f\uff08\u5982 \u6216 \uff09\u8868\u793a\u7684\u4fe1\u606f\u3002\u66ff\u4ee3\u652f\u4ed8\u65b9\u5f0f\u7684\u5e38\u89c1\u793a\u4f8b\u5305\u62ec CashOnDeliver\u3001 Klarna \u548c\u76f4\u63a5\u501f\u8bb0\u3002API v51.0 \u548c \u540e\u3002<\/p>\n\n\n\n<p><samp>CardPaymentMethod<\/samp><samp>DigitalWallet<\/samp><\/p>\n\n\n\n<p>\u4e3a\u7ec4\u7ec7\u4e2d\u7684\u6bcf\u79cd\u66ff\u4ee3\u4ed8\u6b3e\u65b9\u5f0f\u521b\u5efa\u552f\u4e00\u7684\u8bb0\u5f55\u7c7b\u578b\u3002\u8fd9\u8fb9 \u6bcf\u79cd\u66ff\u4ee3\u4ed8\u6b3e\u65b9\u5f0f\u90fd\u53ef\u4ee5\u663e\u793a\u4e0d\u540c\u7684\u9009\u62e9\u5217\u8868\u503c\u548c\u9875\u9762\u5e03\u5c40 \u57fa\u4e8e\u65b9\u6cd5\u63d0\u4f9b\u7a0b\u5e8f\u548c\u7f51\u5173\u63d0\u4f9b\u7a0b\u5e8f\u7684\u8981\u6c42\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u6709\u4e00\u4e2a \u76f4\u63a5\u501f\u8bb0\u7684\u66ff\u4ee3\u4ed8\u6b3e\u65b9\u5f0f\u8bb0\u5f55\u7c7b\u578b\u548c\u73b0\u91d1\u652f\u4ed8\u7684\u5176\u4ed6\u8bb0\u5f55\u7c7b\u578b \u63d0\u4f9b\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u8fd8\u5efa\u8bae\u60a8\u4e3a\u6bcf\u79cd\u72ec\u7279\u7684\u66ff\u4ee3\u4ed8\u6b3e\u65b9\u5f0f\u8bb0\u5f55\u7c7b\u578b\u521b\u5efa\u4e00\u4e2a\u3002<samp>GtwyProviderPaymentMethodType<\/samp><\/p>\n\n\n\n<p>AlternativePaymentMethod \u9ed8\u8ba4\u542f\u7528\u4e86\u79c1\u6709\u5171\u4eab\u6a21\u578b\uff0c\u7528\u4e8e\u5185\u90e8\u548c \u5916\u90e8\u7528\u6237\u3002\u53ea\u6709\u8bb0\u5f55\u6240\u6709\u8005\u548c\u5177\u6709\u8f83\u9ad8\u6240\u6709\u6743\u7684\u7528\u6237\u624d\u5177\u6709\u201c\u8bfb\u53d6\u201d\u3001\u201c\u7f16\u8f91\u201d\u548c\u201c\u5220\u9664\u201d \u8bbf\u95ee\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f8b<\/h2>\n\n\n\n<p>\u5047\u8bbe\u60a8\u60f3\u4e3a GiroPay \u63d0\u4f9b\u53e6\u4e00\u79cd\u4ed8\u6b3e\u65b9\u5f0f\u3002\u9996\u5148\uff0c\u521b\u5efa\u8bb0\u5f55\u7c7b\u578b\u3002<\/p>\n\n\n\n<p><samp>AlternativePaymentMethod<\/samp><\/p>\n\n\n\n<p><strong>\u65b0\u589e\u529f\u80fd \u8bb0\u5f55\u7c7b\u578b<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/services\/data\/v51.0\/sobjects\/RecordType<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n \"Name\" : \"Giro Pay\",\n \"DeveloperName\" : \"GiroPay\",\n \"SobjectType\" : \"AlternativePaymentMethod\"\n}<\/code><\/pre>\n\n\n\n<p>\u4e0b\u4e00\u4e2a \u4e3a\u8bb0\u5f55\u7c7b\u578b\u521b\u5efa\u5907\u7528\u4ed8\u6b3e\u65b9\u5f0f\u8bb0\u5f55\u3002<samp>AlternativePaymentMethod<\/samp><\/p>\n\n\n\n<p><strong>\u65b0\u589e\u529f\u80fd AlternativePaymentMethod<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/services\/data\/v51.0\/sobjects\/AlternativePaymentMethod<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n \"ProcessingMode\": \"External\",\n \"status\":\"Active\",\n \"GatewayToken\":\"mHkDsh0oIA3mnWjo9UL\",\n\"NickName\" : \"MyGiroPay\",\n\"RecordTypeId\" : \"{record_type_id}\"\n}<\/code><\/pre>\n\n\n\n<p>\u60a8\u8fd8\u53ef\u4ee5\u521b\u5efa\u7f51\u5173\u63d0\u4f9b\u5546\u4ed8\u6b3e \u65b9\u6cd5\u7c7b\u578b\u3002<\/p>\n\n\n\n<p><strong>\u65b0\u589e\u529f\u80fd GtwyProvPaymentMethodType<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n \"PaymentGatewayProviderId\": \"XXXXXXXXXXXXXXX\",\n \"PaymentMethodType\":\"AlternativePaymentMethod\",\n \"GtwyProviderPaymentMethodType\" : \"PM_Giro\",\n \"DeveloperName\" : \"DevName\",\n \"MasterLabel\" : \"MasterLabel\",\n \"RecordTypeId\" : \"{record_type_id}\"\n}<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u5904\u7406\u4ed8\u6b3e<\/h1>\n\n\n\n<p>\u5728\u652f\u4ed8\u7f51\u5173\u4e2d\u5904\u7406\u4ed8\u6b3e\u3002<\/p>\n\n\n\n<p>\u8981\u8bbf\u95ee API\uff0c\u60a8\u9700\u8981 PaymentPlatform \u7ec4\u7ec7 \u8bb8\u53ef\u3002<\/p>\n\n\n\n<p><samp>commercepayments<\/samp><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u4ece\u00a0<samp>PaymentGatewayContext \u7c7b<\/samp>\u83b7\u53d6\u4ed8\u6b3e\u6355\u83b7\u8bf7\u6c42\u5bf9\u8c61\u3002<code>commercepayments.CaptureRequest = (commercepayments.CaptureRequest)gatewayContext.getPaymentRequest()<\/code><\/li>\n\n\n\n<li>\u8bbe\u7f6e HTTP \u8bf7\u6c42\u5bf9\u8c61\u3002<code>HttpRequest req = new HttpRequest(); req.setHeader('Content-Type', 'application\/json');<\/code><\/li>\n\n\n\n<li>\u4ece\u00a0<samp>CaptureRequest<\/samp>\u00a0\u5bf9\u8c61\u4e2d\u8bfb\u53d6\u53c2\u6570\u5e76\u51c6\u5907 HTTP \u8bf7\u6c42\u6b63\u6587\u3002<\/li>\n\n\n\n<li>\u4f7f\u7528\u00a0<samp>PaymentsHttp \u7c7b<\/samp>\u5bf9\u7f51\u5173\u8fdb\u884c HTTP \u8c03\u7528\u3002<code>commercepayments.PaymentsHttp http = new commercepayments.PaymentsHttp(); HttpResponse res = http.send(req);<\/code><\/li>\n\n\n\n<li>\u5206\u6790\u00a0<samp>httpResponse<\/samp>\u00a0\u5e76\u51c6\u5907\u00a0<samp>CaptureResponse<\/samp>\u00a0\u5bf9\u8c61\u3002<code>commercepayments.CaptureResponse captureResponse = new commercepayments.CaptureResponse(); captureResponse.setGatewayResultCode(\u201c\u201d); captureResponse.setGatewayResultCodeDescription(\u201c\u201d); captureResponse.setGatewayReferenceNumber(\u201c\u201d); captureResponse.setSalesforceResultCodeInfo(getSalesforceResultCodeInfo(commercepayments.SalesforceResultCode.SUCCESS.name())); captureResponse.setGatewayReferenceDetails(\u201c\u201d); captureResponse.setAmount(double.valueOf(100);<\/code><\/li>\n\n\n\n<li>\u8fd4\u56de&nbsp;<samp>captureResponse<\/samp>\u3002<\/li>\n<\/ol>\n\n\n\n<h1 class=\"wp-block-heading\">\u5904\u7406\u9000\u6b3e<\/h1>\n\n\n\n<p>\u5728\u652f\u4ed8\u7f51\u5173\u4e2d\u5904\u7406\u9000\u6b3e\u3002<\/p>\n\n\n\n<p>\u8981\u8bbf\u95ee API\uff0c\u60a8\u9700\u8981 PaymentPlatform \u7ec4\u7ec7\u6743\u9650\u3002<\/p>\n\n\n\n<p><samp>commercepayments<\/samp><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u4ece\u00a0<samp>PaymentGatewayContext \u7c7b<\/samp>\u4e2d\u83b7\u53d6\u5f15\u7528\u7684\u9000\u6b3e\u8bf7\u6c42\u5bf9\u8c61\u3002<code>commercepayments.ReferencedRefundRequest = (commercepayments.ReferencedRefundRequest)gatewayContext.getPaymentRequest();<\/code><\/li>\n\n\n\n<li>\u8bbe\u7f6e HTTP \u8bf7\u6c42\u5bf9\u8c61\u3002<code>HttpRequest req = new HttpRequest(); req.setHeader('Content-Type', 'application\/json');<\/code><\/li>\n\n\n\n<li>\u4ece\u00a0<samp>ReferencedRefundRequest\u00a0\u5bf9\u8c61<\/samp>\u4e2d\u8bfb\u53d6\u53c2\u6570\uff0c\u5e76\u51c6\u5907 HTTP \u8bf7\u6c42\u6b63\u6587\u3002<\/li>\n\n\n\n<li>\u4f7f\u7528<samp>PaymentsHttp \u7c7b<\/samp>\u5bf9\u7f51\u5173\u8fdb\u884c HTTP \u8c03\u7528\u3002<code>commercepayments.PaymentsHttp http = new commercepayments.PaymentsHttp(); HttpResponse res = http.send(req);<\/code><\/li>\n\n\n\n<li>\u5206\u6790\u00a0<samp>httpResponse<\/samp>\u00a0\u5e76\u51c6\u5907\u00a0<samp>ReferencedRefundResponse<\/samp>\u00a0\u5bf9\u8c61\u3002<code>commercepayments.ReferencedRefundResponse referencedRefundResponse = new commercepayments.ReferencedRefundResponse(); referencedRefundResponse.setGatewayResultCode(\u201c\u201d); referencedRefundResponse.setGatewayResultCodeDescription(\u201c\u201d); referencedRefundResponse.setGatewayReferenceNumber(\u201c\u201d); referencedRefundResponse.setSalesforceResultCodeInfo(getSalesforceResultCodeInfo(commercepayments.SalesforceResultCode.SUCCESS.name())); referencedRefundResponse.setGatewayReferenceDetails(\u201c\u201d); referencedRefundResponse.setAmount(double.valueOf(100);<\/code><\/li>\n\n\n\n<li>\u8fd4\u56de&nbsp;<samp>referencedRefundResponse<\/samp>\u3002<\/li>\n<\/ol>\n\n\n\n<h1 class=\"wp-block-heading\">\u5e42\u7b49\u6027\u51c6\u5219<\/h1>\n\n\n\n<p>\u5e42\u7b49\u6027\u8868\u793a\u652f\u4ed8\u7f51\u5173\u8bc6\u522b\u91cd\u590d\u8bf7\u6c42\u7684\u80fd\u529b \u9519\u8bef\u6216\u6076\u610f\u63d0\u4ea4\uff0c\u7136\u540e\u76f8\u5e94\u5730\u5904\u7406\u91cd\u590d\u8bf7\u6c42\u3002 \u4f7f\u7528\u5e42\u7b49\u7f51\u5173\u65f6\uff0c\u8bf7\u8003\u8651\u4ee5\u4e0b\u91cd\u8981\u51c6\u5219\u3002<\/p>\n\n\n\n<p>\u8981\u8bbf\u95ee API\uff0c\u60a8\u9700\u8981 PaymentPlatform \u7ec4\u7ec7\u6743\u9650\u3002<\/p>\n\n\n\n<p><samp>commercepayments<\/samp><\/p>\n\n\n\n<p>\u4ed8\u6b3e\u7f51\u5173\u9002\u914d\u5668\u7c7b\u94fe\u63a5\u5230 paymentGatewayProvider \u5bf9\u8c61\u8bb0\u5f55\u3002\u8239\u7ea7\u793e Payments \u4e3a\u81ea\u5df1\u7684\u670d\u52a1\u8bf7\u6c42\u63d0\u4f9b\u81ea\u5df1\u7684\u5e42\u7b49\u6027\u5c42\u3002\u6bcf\u7b14\u4ed8\u6b3e \u7f51\u5173\u8fd8\u53ef\u4ee5\u6307\u5b9a\u5b83\u4eec\u7684\u503c \u5728 paymentGatewayProvider \u4e2d \u5bf9\u8c61 \u8bb0\u5f55\u3002\u5982\u679c Salesforce CCS Payment API \u68c0\u6d4b\u5230\u91cd\u590d\u8bf7\u6c42\u548c\u7f51\u5173\u63d0\u4f9b\u5546 \u652f\u6301\u5e42\u7b49\u6027\uff0c\u8bf7\u6c42\u6b63\u6587\u7684\u53c2\u6570\u53d8\u4e3a .<samp>idempotencySupported<\/samp><samp>duplicate<\/samp><var>True<\/var><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>commercepayments.CaptureRequest request = \n(commercepayments.CaptureRequest)paymentGatewayContext.getPaymentRequest();\nBoolean isDuplicate = requestObject.duplicate<\/code><\/pre>\n\n\n\n<p>\u5e42\u7b49\u5bc6\u94a5\u53ef\u4ee5\u4ece\u8bf7\u6c42\u5bf9\u8c61\u4e2d\u83b7\u53d6\u3002<\/p>\n\n\n\n<p><samp>String idempotencyKey = request.idempotencyKey<\/samp><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">CommercePayments \u7684\u793a\u4f8b\u652f\u4ed8\u7f51\u5173\u5b9e\u65bd<\/h1>\n\n\n\n<p>\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a GitHub \u5b58\u50a8\u5e93\uff0c\u5176\u4e2d\u5305\u542b\u793a\u4f8b Payeezy \u4ed8\u6b3e\u7684\u4ee3\u7801\u793a\u4f8b \u5177\u6709 CommercePayments \u547d\u540d\u7a7a\u95f4\u7684\u7f51\u5173\u5b9e\u73b0\u3002\u5982\u679c\u9700\u8981\uff0c\u8bf7\u67e5\u770b\u793a\u4f8b\u4ee3\u7801 \u5e2e\u52a9\u914d\u7f6e\u652f\u4ed8\u7f51\u5173\u5b9e\u65bd\u3002<\/p>\n\n\n\n<p>\u67e5\u770b\u00a0CommercePayments Gateway \u53c2\u8003\u5b9e\u73b0\u4e2d\u7684\u4ee3\u7801\u793a\u4f8b\uff0c\u4e86\u89e3 Payeezy\u00a0\u5b58\u50a8\u5e93\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668<br \/>\n\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u4ee3\u8868\u4e86\u60a8\u7684\u652f\u4ed8\u5e73\u53f0\u4e4b\u95f4\u7684\u6865\u6881 Salesforce \u548c\u5916\u90e8\u652f\u4ed8\u7f51\u5173\u3002<\/p>\n","protected":false},"author":1,"featured_media":3703,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[199],"tags":[209],"class_list":["post-3702","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apex-","tag-commercepayments-"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>CommercePayments \u547d\u540d\u7a7a\u95f4\u7684\u7528\u4f8b - \u767d\u767d\u968f\u7b14<\/title>\n<meta name=\"description\" content=\"\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u4ee3\u8868\u4e86\u60a8\u7684\u652f\u4ed8\u5e73\u53f0\u4e4b\u95f4\u7684\u6865\u6881 Salesforce \u548c\u5916\u90e8\u652f\u4ed8\u7f51\u5173\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.ponybai.com\/?p=3702\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CommercePayments \u547d\u540d\u7a7a\u95f4\u7684\u7528\u4f8b - \u767d\u767d\u968f\u7b14\" \/>\n<meta property=\"og:description\" content=\"\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u4ee3\u8868\u4e86\u60a8\u7684\u652f\u4ed8\u5e73\u53f0\u4e4b\u95f4\u7684\u6865\u6881 Salesforce \u548c\u5916\u90e8\u652f\u4ed8\u7f51\u5173\u3002\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.ponybai.com\/?p=3702\" \/>\n<meta property=\"og:site_name\" content=\"\u767d\u767d\u968f\u7b14\" \/>\n<meta property=\"article:published_time\" content=\"2023-12-09T02:46:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-25T03:02:52+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.ponybai.com\/wp-content\/uploads\/2023\/11\/apex\u652f\u4ed8.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1319\" \/>\n\t<meta property=\"og:image:height\" content=\"183\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"ponybai\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"ponybai\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/www.ponybai.com\/?p=3702#article\",\"isPartOf\":{\"@id\":\"http:\/\/www.ponybai.com\/?p=3702\"},\"author\":{\"name\":\"ponybai\",\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883\"},\"headline\":\"CommercePayments \u547d\u540d\u7a7a\u95f4\u7684\u7528\u4f8b\",\"datePublished\":\"2023-12-09T02:46:23+00:00\",\"dateModified\":\"2023-11-25T03:02:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/www.ponybai.com\/?p=3702\"},\"wordCount\":419,\"publisher\":{\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883\"},\"keywords\":[\"CommercePayments \u547d\u540d\u7a7a\u95f4\"],\"articleSection\":[\"Apex \u5f00\u53d1\u4eba\u5458\u6307\u5357\"],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/www.ponybai.com\/?p=3702\",\"url\":\"http:\/\/www.ponybai.com\/?p=3702\",\"name\":\"CommercePayments \u547d\u540d\u7a7a\u95f4\u7684\u7528\u4f8b - \u767d\u767d\u968f\u7b14\",\"isPartOf\":{\"@id\":\"http:\/\/www.ponybai.com\/#website\"},\"datePublished\":\"2023-12-09T02:46:23+00:00\",\"dateModified\":\"2023-11-25T03:02:52+00:00\",\"description\":\"\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u4ee3\u8868\u4e86\u60a8\u7684\u652f\u4ed8\u5e73\u53f0\u4e4b\u95f4\u7684\u6865\u6881 Salesforce \u548c\u5916\u90e8\u652f\u4ed8\u7f51\u5173\u3002\",\"breadcrumb\":{\"@id\":\"http:\/\/www.ponybai.com\/?p=3702#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.ponybai.com\/?p=3702\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.ponybai.com\/?p=3702#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"http:\/\/www.ponybai.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CommercePayments \u547d\u540d\u7a7a\u95f4\u7684\u7528\u4f8b\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.ponybai.com\/#website\",\"url\":\"http:\/\/www.ponybai.com\/\",\"name\":\"\u767d\u767d\u968f\u7b14\",\"description\":\"Salesforce\u5b98\u65b9\u8bb2\u5e08\",\"publisher\":{\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.ponybai.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883\",\"name\":\"ponybai\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/www.ponybai.com\/wp-content\/uploads\/2025\/03\/cropped-Ihsans-WeChatQR.jpg\",\"contentUrl\":\"http:\/\/www.ponybai.com\/wp-content\/uploads\/2025\/03\/cropped-Ihsans-WeChatQR.jpg\",\"width\":248,\"height\":248,\"caption\":\"ponybai\"},\"logo\":{\"@id\":\"http:\/\/www.ponybai.com\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/121.37.188.161\"],\"url\":\"http:\/\/www.ponybai.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CommercePayments \u547d\u540d\u7a7a\u95f4\u7684\u7528\u4f8b - \u767d\u767d\u968f\u7b14","description":"\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u4ee3\u8868\u4e86\u60a8\u7684\u652f\u4ed8\u5e73\u53f0\u4e4b\u95f4\u7684\u6865\u6881 Salesforce \u548c\u5916\u90e8\u652f\u4ed8\u7f51\u5173\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.ponybai.com\/?p=3702","og_locale":"zh_CN","og_type":"article","og_title":"CommercePayments \u547d\u540d\u7a7a\u95f4\u7684\u7528\u4f8b - \u767d\u767d\u968f\u7b14","og_description":"\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u4ee3\u8868\u4e86\u60a8\u7684\u652f\u4ed8\u5e73\u53f0\u4e4b\u95f4\u7684\u6865\u6881 Salesforce \u548c\u5916\u90e8\u652f\u4ed8\u7f51\u5173\u3002","og_url":"http:\/\/www.ponybai.com\/?p=3702","og_site_name":"\u767d\u767d\u968f\u7b14","article_published_time":"2023-12-09T02:46:23+00:00","article_modified_time":"2023-11-25T03:02:52+00:00","og_image":[{"width":1319,"height":183,"url":"http:\/\/www.ponybai.com\/wp-content\/uploads\/2023\/11\/apex\u652f\u4ed8.png","type":"image\/png"}],"author":"ponybai","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"ponybai","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/www.ponybai.com\/?p=3702#article","isPartOf":{"@id":"http:\/\/www.ponybai.com\/?p=3702"},"author":{"name":"ponybai","@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883"},"headline":"CommercePayments \u547d\u540d\u7a7a\u95f4\u7684\u7528\u4f8b","datePublished":"2023-12-09T02:46:23+00:00","dateModified":"2023-11-25T03:02:52+00:00","mainEntityOfPage":{"@id":"http:\/\/www.ponybai.com\/?p=3702"},"wordCount":419,"publisher":{"@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883"},"keywords":["CommercePayments \u547d\u540d\u7a7a\u95f4"],"articleSection":["Apex \u5f00\u53d1\u4eba\u5458\u6307\u5357"],"inLanguage":"zh-Hans"},{"@type":"WebPage","@id":"http:\/\/www.ponybai.com\/?p=3702","url":"http:\/\/www.ponybai.com\/?p=3702","name":"CommercePayments \u547d\u540d\u7a7a\u95f4\u7684\u7528\u4f8b - \u767d\u767d\u968f\u7b14","isPartOf":{"@id":"http:\/\/www.ponybai.com\/#website"},"datePublished":"2023-12-09T02:46:23+00:00","dateModified":"2023-11-25T03:02:52+00:00","description":"\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u652f\u4ed8\u7f51\u5173\u9002\u914d\u5668\u4ee3\u8868\u4e86\u60a8\u7684\u652f\u4ed8\u5e73\u53f0\u4e4b\u95f4\u7684\u6865\u6881 Salesforce \u548c\u5916\u90e8\u652f\u4ed8\u7f51\u5173\u3002","breadcrumb":{"@id":"http:\/\/www.ponybai.com\/?p=3702#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.ponybai.com\/?p=3702"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/www.ponybai.com\/?p=3702#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"http:\/\/www.ponybai.com\/"},{"@type":"ListItem","position":2,"name":"CommercePayments \u547d\u540d\u7a7a\u95f4\u7684\u7528\u4f8b"}]},{"@type":"WebSite","@id":"http:\/\/www.ponybai.com\/#website","url":"http:\/\/www.ponybai.com\/","name":"\u767d\u767d\u968f\u7b14","description":"Salesforce\u5b98\u65b9\u8bb2\u5e08","publisher":{"@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.ponybai.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/935c7592c850c65e1e5eba4530dbf883","name":"ponybai","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/image\/","url":"http:\/\/www.ponybai.com\/wp-content\/uploads\/2025\/03\/cropped-Ihsans-WeChatQR.jpg","contentUrl":"http:\/\/www.ponybai.com\/wp-content\/uploads\/2025\/03\/cropped-Ihsans-WeChatQR.jpg","width":248,"height":248,"caption":"ponybai"},"logo":{"@id":"http:\/\/www.ponybai.com\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/121.37.188.161"],"url":"http:\/\/www.ponybai.com\/?author=1"}]}},"_links":{"self":[{"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/posts\/3702","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3702"}],"version-history":[{"count":1,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/posts\/3702\/revisions"}],"predecessor-version":[{"id":3704,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/posts\/3702\/revisions\/3704"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=\/wp\/v2\/media\/3703"}],"wp:attachment":[{"href":"http:\/\/www.ponybai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3702"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3702"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ponybai.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3702"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}