php - Amazon Pay 授权引用 ID

标签 php amazon-web-services aws-sdk amazon-pay

我将亚马逊支付集成到我的网站中,并按照 Amazon Pay SDK Simple Checkout 的说明进行操作。 。到目前为止一切正常,但在last step代码示例显示我需要一个授权引用 ID。

namespace AmazonPay;

session_start();

// Create the parameters array
$requestParameters = array();

// Refer to GetDetails.php where the Amazon Order Reference ID was set
$requestParameters['amazon_order_reference_id'] = 'AMAZON_ORDER_REFERENCE_ID';

// Confirm the order by making the ConfirmOrderReference API call
$response = $client->confirmOrderReference($requestParameters);

$responsearray['confirm'] = json_decode($response->toJson());

// If the API call was a success make the Authorize API call
if($client->success)
{
$requestParameters['authorization_amount'] = '175.00';
##################################################
############ WHERE DO I GET THIS? ################
$requestParameters['authorization_reference_id'] = 'Your Unique Reference Id';
$requestParameters['seller_authorization_note'] = 'Authorizing payment';
$requestParameters['transaction_timeout'] = 0;

$response = $client->authorize($requestParameters);
$responsearray['authorize'] = json_decode($response->toJson());
}

// If the Authorize API call was a success, make the Capture API call when you are ready to capture             
for the order (for example when the order has been dispatched)
if($client->success)
{
$requestParameters['amazon_authorization_id'] = 'Parse the Authorize Response for this id';
$requestParameters['capture_amount'] = '175.00';
$requestParameters['currency_code'] = 'USD';
$requestParameters['capture_reference_id'] = 'Your Unique Reference Id';

$response = $client->capture($requestParameters);
$responsearray['capture'] = json_decode($response->toJson());
}

// Echo the Json encoded array for the Ajax success
echo json_encode($responsearray);

如上所示,需要设置“authorization_reference_id”。但我不知道如何得到它。我之前对“设置新订单”的回复中没有这个内容。它也不包含在“confirmOrderReference”响应中。我是否错过了这里的某些内容或者代码示例不完整?

$requestParameters['authorization_reference_id'] = 'Your Unique Reference Id';

感谢您的帮助

最佳答案

authorization_reference_id is given by you 。它应该是独一无二的。

您可以使用 PHP 中的 uniqid 内置函数来生成它。对于每个请求,它都必须是唯一的。

$requestParameters['authorization_reference_id'] = uniqid();

关于php - Amazon Pay 授权引用 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60196024/

相关文章:

php - 使 :command not defined in Laravel 5. 1.7

php - 在 PHP 中生成 GnuPG 对

python - AWS lambda在每次调用时更新sts角色非常耗时

amazon-web-services - 具有另一个对象列表的对象的 DynamoDB Mapper 注释

php - 使用 session 显示/隐藏 div (php)

php - 如何添加 if 语句以排除特定的空行

amazon-web-services - Openstack 仪表板给出错误 "Error: Unable to retrieve usage information"

amazon-web-services - 运行时出错 : Property validation failure: [Value of property {/Targets/0/Values} does not match type {Array}]

laravel - 如何使用 AWS SNS 在 Laravel 中发送推送通知并在 Android 和 iOS 设备中使用默认声音?

java - 无法使用 AES 服务器端加密将对象上传到 S3