我正在尝试创建亚马逊结帐的基本实现。此代码取自我的控制器。
public function amazAction()
{
// Key from Amazon
$merchant_id = 'xxxxx';
$aws_access_key_id = 'xxxxx';
$aws_secret_access_key = 'xxxxx';
// Set up cart
$form['aws_access_key_id'] = $aws_access_key_id;
$form['currency_code'] = 'USD';
$form['item_merchant_id_1'] = $merchant_id;
$form['item_price_1'] = 10;
$form['item_quantity_1'] = 1;
$form['item_sku_1'] = 11;
$form['item_title_1'] = test;
ksort($form);
// Encode order as string and calculate signature
$order = '';
foreach ($form as $key => $value) {
$order .= $key . "=" . rawurlencode($value) . "&";
}
$form['merchant_signature'] = base64_encode(hash_hmac('sha1', $order, $aws_secret_access_key, true));
// Return string with Amazon javascript and HTML form
// Assumes you already have jQuery loaded elsewhere on page
// URL's link to live site, not sandbox!
$this->view->amazon_order_html = '<script type="text/javascript" src="https://images-na.ssl-images-amazon.com/images/G/01/cba/js/widget/widget.js"></script>
<form target="_blank" method="post" action="https://payments-sandbox.amazon.com/checkout/' . $merchant_id . '">';
foreach ( $form as $key => $value ) {
$this->view->amazon_order_html .= '<input type="hidden" name="' . $key . '" value="' . $value . '" />';
}
$this->view->amazon_order_html .= '<input alt="Checkout with Amazon Payments" src="https://payments-sandbox.amazon.com/gp/cba/button?ie=UTF8&color=orange&background=white&cartOwnerId=' . $merchant_id . '&size=large" type="image"></form>';
}
当我运行此页面时,我从亚马逊收到以下错误
很抱歉,这个订单有问题。请联系 商家直接协助完成此订单。
如何修复此错误?此外,我需要知道如何在隐藏字段中传递折扣价,运费名称和运费的金额?
请提供关于此的建议
答案 0 :(得分:1)
如需发货,请尝试添加可输出以下内容的内容:
<input type="hidden" name="shipping_method_price_per_shipment_amount_1" value="0.00" />
<input type="hidden" name="shipping_method_price_per_unit_rate_1" value="0.00" />
<input type="hidden" name="shipping_method_price_type_1" value="weight_based" />
<input type="hidden" name="shipping_method_region_1" value="world_all" />
<input type="hidden" name="shipping_method_service_level_1" value="standard" />
根据您的代码,您应该能够添加类似的内容(根据需要进行更改):
$form['shipping_method_price_per_shipment_amount_1'] = 0.00;
$form['shipping_method_price_per_unit_rate_1'] = 0.00;
$form['shipping_method_price_type_1'] = 'weight_based';
$form['shipping_method_region_1'] = 'world_all';
$form['shipping_method_service_level_1'] = 'standard';
我希望这对你有用......