Hi,I need help developing a basic Amazon Payments VirtueMart 1.0.12 payment module, my knowledge of PHP is limited & this is what I have now:
<formaction="
https://authorize.payments.amazon.com/pba/paypipeline"method="post" />
<input type="hidden"name="immediateReturn" value="0" />
<input type="hidden"name="amount" value="USD <?php printf("%.2f",
$db->f("order_total"))?>"/>
<input type="hidden"name="signature" value="Generate the signature as described inthe integration guide" >
<input type="hidden"name="description" value="Product Description Here" />
<input type="hidden"name="amazonPaymentsAccountId" value="Put your Amazon Payments Account Id here as describedin the integration guide" />
<input type="hidden"name="accessKey" value="Put your accessKey here as described inthe integration guide" />
<input type="hidden"name="returnUrl" value="
http://yourwebsite.com/confirmed"/>
<input type="hidden"name="referenceId" value="<?php printf("%08d",$db->f("order_id")); ?>" />
<input type="hidden"name="abandonUrl" value="
http://yourwebsite.com/cancel"/>
<input type="image" src="
https://authorize.payments.amazon.com/pba/images/amazonPaymentsButton.jpg"border="0" />
</form>
How do I getvirtuemart to automatically generate a signature as described here:
http://docs.amazonwebservices.com/AmazonFPS/2007-01-08/PayNowWidgetImplementationGuide/<?
#PHP Sample Code for creatinga 'Pay Now' widget
#To use this sample, replacethe values of $accessKey and $secretKey with the values for youraccount
require_once'Crypt/HMAC.php'; #see
http://pear.php.net/package/Crypt_HMAC require_once'HTTP/Request.php'; #see
http://pear.php.net/package/HTTP_Request $accessKey ="<insert-your-access-key-here>";
$secretKey = "<insert-your-secret-key-here>";
functiongetPayNowButtonForm($amount, $description, $referenceId,
$immediateReturn, $returnUrl,$abandonUrl) {
global $accessKey;
$formHiddenInputs['accessKey'] = $accessKey;
$formHiddenInputs['amount'] =$amount;
$formHiddenInputs['description'] = $description;
if ($referenceId)$formHiddenInputs['referenceId'] = $referenceId;
if ($immediateReturn)$formHiddenInputs['immediateReturn'] = $immediateReturn;
if ($returnUrl)$formHiddenInputs['returnUrl'] = $returnUrl;
if ($abandonUrl)$formHiddenInputs['abandonUrl'] = $abandonUrl;
ksort($formHiddenInputs);
$stringToSign ="";
foreach ($formHiddenInputs as$formHiddenInputName => $formHiddenInputValue) {
$stringToSign = $stringToSign. $formHiddenInputName . $formHiddenInputValue;
}
$formHiddenInputs['signature'] = getSignature($stringToSign,$secretKey);
$form = "<formaction=\"
https://authorize.payments.amazon.com/pba/paypipeline\"method=\"post\">\n";
foreach ($formHiddenInputs as$formHiddenInputName => $formHiddenInputValue) {
$form = $form ."<input type=\"hidden\"name=\"$formHiddenInputName\"value=\"$formHiddenInputValue\" />\n";
}
$form = $form ."<input type=\"image\" src=\"
https://authorize.payments.amazon.com/pba/images/amazonPaymentsButton.jpg\"border=\"0\" alt=\"Pay Using Amazon\"/>\n";
$form = $form ."</form>\n";
return $form;
}
functiongetSignature($stringToSign) {
global $secretKey;
$hmac = newCrypt_HMAC($secretKey,"sha1");
$binary_hmac =pack("H40", $hmac->hash(trim($stringToSign)));
returnbase64_encode($binary_hmac);
}
?>
<html>
<body>
<?=getPayNowButtonForm("USD1.00", "e-Card", "i123n", "1", "
http://yourwebsite.com/return.html",
"
http://yourwebsite.com/abandon.htm")?>
</body>
</html>
Pastedfrom <
http://docs.amazonwebservices.com/AmazonFPS/2007-01-08/PayNowWidgetImplementationGuide/generatesig.html>