开发者

amazon payment gateway

Am doing one project ,

For that my client asked amazon payment gateway ,

So now i started exploring amazon payment gateway ,

This is the first time am looking the amazon payment gateway ,

I have registered in amazon payment gateway,

Please tell me PHP CODE snippet for amazon payment gateway ,

开发者_C百科

Thanks


Amazon has different payment products. Checkout by Amazon is their usual product, but it works best for products that you actually ship by mail. SimplePay is probably best for electronic goods and services - which I discovered too late. Make sure you sign up for the right thing. :)

Here's the PHP code for a "Pay Now" button for one item using a POST form submission:

// Key from Amazon
$merchant_id = 'your_id';
$aws_access_key_id = 'your_access_key'; 
$aws_secret_access_key = 'your_secret_access_key';

// 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'] = $price;
$form['item_quantity_1'] = $quantity;
$form['item_sku_1'] = $sku;
$form['item_title_1'] = $item_name;
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!
$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 method="post" action="https://payments.amazon.com/checkout/' . $merchant_id . '">';
foreach ( $form as $key => $value ) {   
  $amazon_order_html .= '<input type="hidden" name="' . $key . '" value="' . $value . '" />';
}
$amazon_order_html .= '<input alt="Checkout with Amazon Payments" src="https://payments.amazon.com/gp/cba/button?ie=UTF8&color=orange&background=white&cartOwnerId=' . $merchant_id . '&size=large" type="image"></form>';

return $amazon_order_html;


For simple pay when account is created, user will be given a sandbox access in which you find the "Merchant code" at this URL : https://sandbox.simplepay.hu/admin/partner/account/id(partnerid)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜