嗨,我正在尝试将 adyen 支付网关集成到我的项目中。我使用了以下 PHP SDK Adyen PHP SDK
我已按照 sdk 中提到的步骤生成客户端加密并将这些加密值传递给服务器端以执行付款。但是我遇到了一条错误消息“无法解密数据”
以下是我的示例代码,
前端 :
<script type="text/javascript" src="https://test.adyen.com/hpp/cse/js/MY_LIBRARY_TOKEN.shtml"></script>
<form method="POST" id="adyen-encrypted-form">
<input placeholder="number" type="text" size="20" data-encrypted-name="number" value="2223520443560010" />
<input placeholder="holderName" type="text" size="20" data-encrypted-name="holderName" value="Ashok" />
<input placeholder="expiryMonth" type="text" size="2" data-encrypted-name="expiryMonth" value="10" />
<input placeholder="expiryYear" type="text" size="4" data-encrypted-name="expiryYear" value="2020" />
<input placeholder="cvc" type="text" size="4" data-encrypted-name="cvc" value="737" />
<input type="hidden" value="<?php echo date('Y-m-d\TH:i:sO'); ?>" data-encrypted-name="generationtime"/>
<input type="submit" value="Pay"/>
</form>
<script>
// The form element to encrypt.
var form = document.getElementById('adyen-encrypted-form');
var options = {};
// Bind encryption options to the form.
var encryptedBlobFieldName = "myFieldName";
options.name = encryptedBlobFieldName;
options.onsubmit = function(e) {
var encryptedData = form.elements[encryptedBlobFieldName].value;
// Encrypted form detials
console.log(encryptedData);
e.preventDefault();
};
var result = adyen.createEncryptedForm(form, options);
</script>
正如我在表单中填充的那样,我从上面的提交操作中获得了带有测试处理的加密值。(即) 加密数据
服务器代码:
$client = new \Adyen\Client();
$client->setApplicationName("Adyen PHP Api Library Example");
$client->setUsername("WS_USERNAME");
$client->setPassword("WS_USER_PASSWORD");
$client->setEnvironment(\Adyen\Environment::TEST);
$service = new \Adyen\Service\Payment($client);
$result = $service->authorise($params);
以下是我传递给授权方法的值,
Array(
[amount] => Array
(
[value] => 19
[currency] => GBP
)
[reference] => payment-test
[merchantAccount] => MERCHANT_ACCOUNT_CODE
[additionalData] => Array
(
[card.encrypted.json] => 'ENCRYPTED_DATA_FROM_FRONT_END'
)
)
我不确定我在做什么错,从服务器端我收到一个错误,因为无法解密数据。请协助我解决此问题