3

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

任何一个请给我建议。

4

2 回答 2

6

要扩展 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 库来执行授权调用。要为以后保存详细信息,请包括shopperEmail, shopperReference(这是您为购物者指定的 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" : "wyldstallyns@email.com",
  "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" : "wyldstallyns@email.com",
  "shopperReference" : "shopperref123456",
  "recurring" : {
    "contract" : "RECURRING"
  }
}'

$params = json_decode($json, true);

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

希望这会有所帮助。也可以查看循环文档

于 2017-04-28T21:54:23.573 回答
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
于 2016-11-17T22:06:16.127 回答