I’m working on adding Pay By Amazon to a site but have run into a problem. I need to create a signature (http://amazonpayments.s3.amazonaws.com/documents/Inline_Checkout_API_Reference_Guide_UK.pdf page 10) but I’m really stuck in how to actually do that. I’ve read so many pdf’s on how to create a signature but none of them seem to be any help. So far I’ve tried pasting this into the browser
but all I got was **<UnknownOperationException/>**
I also tried Amazon scratchpad but it didn’t have any options for ‘payments’, ‘purchase contract’ or ‘SetPurchaseItems’
I’d be extremely grateful if anybody could help me with this please as I’m now at a lose at to how to do this.
If it helps the full code for sending the order to amazon is:
I’m sorry I clicked on the wrong link and was still reading from the old document although are those new documents relevant to the UK? I can’t seem to see where it says the endpoint url for the UK
The references i can find via google say the signature of the cart is a HMAC hashing of the concatenated,urlencoded,querystringformatted contents of the cart with the SHA1 algorithm, base64 encoded.
So [FPHP]base64_encode[/FPHP] the string generated by [FPHP]hash_hmac[/FPHP] using the algorithm sha1 and your key.
I’m sorry but I still don’t quite understand how to do this. I’ve made a lot of progress but now keep getting a MalformedQueryString error. I’ve included the code for the ‘place order’ button as well as the error I’m getting.
[quote]SenderMalformedQueryStringAWSAccessKeyId= AWSKEYCODE&Action=SetPurchaseItems&PurchaseContractId=amzn1.contract.1.1.1.f8edab0979ddeca91a83eedecfaa4259&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2014-11-11T12:34:37&Version=2010-08-31&Signature=NWI5MWI1NWI0MzkzODAwMTlkOTFlOGI1ODAwMGYxYTk1MWZmZGQ3ZDA4M2IzMTI2Y2Y5YmU4ZmUxOGU2YTllYQ==&PurchaseItems.PurchaseItem.1.FulfillmentNetwork=MERCHANT&PurchaseItems.PurchaseItem.1.MerchantId=MERCHANTIDCODE&PurchaseItems.PurchaseItem.1.MerchantItemId=32&PurchaseItems.PurchaseItem.1.Title=LA+Whey+Gold+2.2kg&PurchaseItems.PurchaseItem.1.Quantity=1&PurchaseItems.PurchaseItem.1.UnitPrice.Amount=59.99&PurchaseItems.PurchaseItem.1.UnitPrice.CurrencyCode=GBP&PurchaseItems.PurchaseItem.1.Description=Option%3A+Banana&DeliveryMethod.ServiceLevel=None&DeliveryMethod.DisplayableShippingLabel=14.5%3D%3D20%3D%3D2&Shipping.Amount=14.50&Shipping.CurrencyCode=GBP is not valid; the value of a query string parameter may not contain a ‘=’ delimiter1e25fd55-699f-11e4-9d1b-55ab79da9df4
[/quote]
I removed that, but am still getting the same error. I think that the problem may be with the signature that’s generated. This is what’s generated Signature=NWI5MWI1NWI0MzkzODAwMTlkOTFlOGI1ODAwMGYxYTk1MWZmZGQ3ZDA4M2IzMTI2Y2Y5YmU4ZmUxOGU2YTllYQ==
If I remove the base64 encoding then I get this error The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method although the signature doesn’t have the two ‘==’ in it this time
If I remove it then I get the same error as before SignatureDoesNotMatch saying The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method
Try wrapping urlencode() around base64_encode() for Signature. The error is saying that = signs aren’t permitted in values. If those last two == are converted to %3D than that might be the fix.
Ok then what @StarLion mentioned before could be it. The Shipping Label has this value if you urldecode() it: 14.5==20==2. Try a value that wouldn’t have equal signs in it.