Adyen付款:保存卡令牌,稍后通过令牌

时间:2016-11-11 08:49:32

标签: php adyen

可以允许adyen保留信用卡详细信息,并根据令牌或客户ID而不是信用卡信息向客户付款。 我检查了adyen标记化方法,我找不到任何用于标记化方法的api文档(类似于条带化支付)。

任何人请建议我。

2 个答案:

答案 0 :(得分:5)

要扩展uselight的答案,您绝对可以对卡片详细信息进行标记。

Adyen使用购物者概念作为存储桶来存储已保存的详细信息。此$_POST['player_ids']由您定义,任何支持定期费用的付款方式都可以存储在此ID中。

要存储信用卡,首先您需要使用CSE(客户端加密)接受卡详细信息。这将在客户端浏览器上将卡详细信息加密,然后再将其提交给您自己的服务器,并允许您完全控制输入字段的外观。以下是一个示例表单:

shopperReference

具有<script type="text/javascript" src="https://test.adyen.com/hpp/cse/js/adyen.encrypt.js"></script> <form method="POST" action="payment-request-handler.php" id="adyen-encrypted-form"> <input type="text" size="20" data-encrypted-name="number"/> <input type="text" size="20" data-encrypted-name="holderName"/> <input type="text" size="2" data-encrypted-name="expiryMonth"/> <input type="text" size="4" data-encrypted-name="expiryYear"/> <input type="text" size="4" data-encrypted-name="cvc"/> <input type="hidden" value="[generate this timestamp server side]" data-encrypted-name="generationtime"/> <input type="submit" value="Pay"/> </form> <script> // The form element to encrypt. var form = document.getElementById('adyen-encrypted-form'); // See https://github.com/Adyen/CSE-JS/blob/master/Options.md for details on the options to use. var options = {}; // Bind encryption options to the form. adyen.createEncryptedForm(form, options); </script> 属性的所有字段都将被删除,并替换为单个data-encrypted-name。从这里,您的php服务器可以使用我们提供的php api library来执行授权调用。要保存详细信息,请添加adyen-encrypted-datashopperEmail(您为购物者指定的ID)和shopperReference。经常性合同价值通常为recurring.contract。请务必稍后存储pspReference,因为这将用于匹配保存的详细信息。

RECURRING

收到AUTHORIZED的结果后,您可以执行$client = new \Adyen\Client(); $client->setApplicationName("Adyen PHP Api Library Example"); $client->setUsername("[YOUR USERNAME]"); $client->setPassword("[YOUR PASSWORD]"); $client->setEnvironment(\Adyen\Environment::TEST); $service = new Service\Payment($client); $json = '{ "amount": { "value": 999, "currency": "USD" }, "reference": "payment-test", "merchantAccount": "[YOUR MERCHANT ACCOUNT]", "additionalData": { "card.encrypted.json": ' . $_POST['adyen-encrypted-data'] . ' }, "shopperEmail" : "wyldstallyns@email.com", "shopperReference" : "shopperref123456", "recurring" : { "contract" : "RECURRING" } }' $params = json_decode($json, true); $result = $service->authorise($params); $pspReference = $result.pspReference; 的查找,以通过shopperReference电话获取用于定期收费的令牌。

listRecurringDetails

您使用此$service = new Service\Recurring($client); $recurring = array('contract' => \Adyen\Contract::RECURRING); $params = array('merchantAccount' => '[Your Merchant Account]', 'recurring' => $recurring, 'shopperReference' => 'shopperref123456' ); $result = $service->listRecurringDetails($params); $recurringToken = ''; foreach($result['details'] as $detail) { if($detail['RecurringDetail']['firstPspReference'] == $pspReference) { $recurringToken = $detail['RecurringDetail']['recurringDetailReference']; } } 执行将来的费用。

recurringDetailReference

希望这很有帮助。查看Recurring Documentation

答案 1 :(得分:1)

您似乎正在寻找定期付款。如果是这样,您可能希望这样做,通过客户端加密传递卡详细信息:

curl -u "ws@Company.YourCompany":"YourWsPassword" \
 -H "Content-Type: application/json" \
 -X POST --data \
 '{
     "additionalData": {
        "card.encrypted.json":"adyenjs_0_1_4p1$..."
     },
     "amount" : {
         "value" : 20000,
         "currency" : "EUR"
     },
     "reference" : "Your Reference Here",
     "merchantAccount" : "TestMerchant",
     "shopperEmail" : "s.hopper@test.com",
     "shopperReference" : "Simon Hopper",
     "recurring" : {
        "contract" : "RECURRING"
     }
 }' \
 https://pal-test.adyen.com/pal/servlet/Payment/v18/authorise

要在以后使用这些详细信息,您应该只提交以下数据:

curl -u "ws@Company.YourCompany":"YourWsPassword" \
 -H "Content-Type: application/json" \
 -X POST --data \
 '{
     "amount" : {
         "value" : 20000,
         "currency" : "EUR"
     },
     "reference" : "Your Reference Here",
     "merchantAccount" : "TestMerchant",
     "shopperEmail" : "s.hopper@test.com",
     "shopperReference" : "Simon Hopper",
     "selectedRecurringDetailReference" : "LATEST",
     "shopperInteraction" : "ContAuth",
     "recurring" : {
        "contract" : "RECURRING"
     }
 }' \
 https://pal-test.adyen.com/pal/servlet/Payment/v18/authorise