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

任何人请给我建议。

最佳答案

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

Adyen使用购物者概念,将其用作存储已保存的详细信息的存储桶。此shopperReference由您定义,并且可以根据此ID存储支持重复收费的任何付款方式。

要存储信用卡,首先您需要使用CSE(客户端加密)接受卡的详细信息。在将卡详细信息提交到您自己的服务器之前,这将在客户端的浏览器上对其进行加密,并使您可以完全控制输入字段的外观。这是一个示例表格:

<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属性的所有字段将被删除,并替换为单个adyen-encrypted-data。从这里,您的php服务器可以使用我们提供的php api library执行授权调用。要保存以后的详细信息,请包括shopperEmailshopperReference(这是您为购物者指定的ID)和recurring.contract。定期合同价值通常为RECURRING。请确保存储pspReference供以后使用,因为它将用于匹配已保存的详细信息。

$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" : "[email protected]",
  "shopperReference" : "shopperref123456",
  "recurring" : {
    "contract" : "RECURRING"
  }
}'

$params = json_decode($json, true);

$result = $service->authorise($params);
$pspReference = $result.pspReference;


收到AUTHORISED的结果后,可以执行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进行将来的收费。

$service = new Service\Payment($client);

$json = '{
  "amount": {
    "value": 999,
    "currency": "USD"
  },
  "reference": "recurring-test",
  "merchantAccount": "[YOUR MERCHANT ACCOUNT]",
  "selectedRecurringDetailReference":' . $recurringToken . '
  "shopperEmail" : "[email protected]",
  "shopperReference" : "shopperref123456",
  "recurring" : {
    "contract" : "RECURRING"
  }
}'

$params = json_decode($json, true);

$result = $service->authorise($params);


希望这会有所帮助。还要检查Recurring Documentation

10-08 14:13