Pay With Amazon

I’m working on adding Pay By Amazon to a site but have run into a problem. I think is quite easy to sort, but I’m not sure how. Each item has to have the prefix “PurchaseItems.PurchaseItem.” and then a number. How do I change that for each product so for the first product it would be PurchaseItems.PurchaseItem.1 the second would be PurchaseItems.PurchaseItem.2 etc?

The full code is:

<form action="https://payments.amazon.co.uk/cba/api/purchasecontract/" method="get">
<input type="hidden" name="Action" value="SetPurchaseItems" />
<input type="hidden" name="AWSAccessKeyId" value="SAMPLE" />
<input type="hidden" name="PurchaseContractId" value="<?php echo $_GET['purchaseContractId']; ?>" />
<?php foreach( $order_line as $key=>$value ) { ?>
<input type="hidden" name="PurchaseItems.PurchaseItem.1.FulfillmentNetwork" value="MERCHANT" />
<input type="hidden" name="PurchaseItems.PurchaseItem.1.MerchantId" value="SAMPLE" />
<input type="hidden" name="PurchaseItems.PurchaseItem.1.MerchantItemId" value="<?php echo $products_all[$value['product_id']]['id'] ?>" />
<input type="hidden" name="PurchaseItems.PurchaseItem.1.Quantity" value="<?php echo $value['product_qty'] ?>" />
<input type="hidden" name="PurchaseItems.PurchaseItem.1.Title" value="<?php echo htmldisplay( $products_all[$value['product_id']]['name'] ) ?>" />
<?php if( count( $value['detail'] ) ) { ?>
<?php if( is_array( $product_detail ) ) { foreach( $product_detail as $key2=>$value2 ) { if( isset( $value['detail'][$key2] ) ) { ?>
<input type="hidden" name="PurchaseItems.PurchaseItem.1.Description" value="Option: <?php echo htmldisplay( $value2['name'] ) ?>" /><?php } } ?>
<input type="hidden" name="PurchaseItems.PurchaseItem.1.UnitPrice.Amount" value="<?php if( $value['price_total']<0.01 ) { echo "00.00"; } else { echo (number_format( $value['price_total']/$value['product_qty']*$companydetails['exchange'],2 )); } ?>" />
<input type="hidden" name="PurchaseItems.PurchaseItem.1.UnitPrice.CurrencyCode" value="<?php echo htmldisplay( $companydetails['currency_iso']); ?>" />
<input type="hidden" name="PurchaseItems.PurchaseItem.1.URL" value="product/<?php echo $products_all[$value['product_id']]['linkword'] ?>" />
<?php } } } ?>
<input type="hidden" name="SignatureSignature" value="SAMPLE" />
<input type="hidden" name="SignatureMethod" value="METHOD" />
<input type="hidden" name="SignatureVersion" value="SIGNATUREVERSION" />
<input type="hidden" name="Timestamp" value="TIMESTAMP" />
<input type="hidden" name="Version" value="VERSION" />
<input type="submit" class="input_button input_red" value="Complete order" />
</form>

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.