amzn / amzn/amazon-pay-api-sdk-php

Testing Amazon Pay button on localhost:

Open
#32 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
51
Forks
33
PR merge metrics
No merged PRs in 30d

Description

To download the **private key** two methods are recommended here:

**Method 1:**
Using the following keys on windows 10 creates ---BEGIN OPENSSH PRIVATE KEY --- file as mentioned in the index page.

ssh-keygen -t rsa -b 2048 -f private.pem
ssh-keygen -f private.pem -e -m PKCS8 > public.pub

**Method 2**
Using https://sellercentral-europe.amazon.com/external-payments/amazon-pay/integration-central 'Create Api Keys', downloads the private key automatically in the left hand corner of the browser eg. AmazonPay_SANDBOX-AGQNBBAR7LO44CKBVHJWB4AB.
This file is a ---BEGIN PRIVATE KEY --- file ie. without the OPENSSH and the RSA.

I was initially getting an invalid Signature error as follows with Method 1: (Security keys have been adjusted)

![image](https://user-images.githubusercontent.com/8538339/205497096-287a2c8f-e6c8-4431-88fe-49cf2c002319.png)

I am now getting an invalid Login exception as follows with Method 2 thankfully using my live amazon account before I progress to the sandbox.

My question is ... when I begin hosting my website, what type of private key file ie. OPENSSH / RSA / BLANK should I use. It would appear that the `ssh-keygen -t rsa -b 2048 -f private.pem` is not generating a suitable file.

Under the API\Client generateButtonSignature function, I php echoed the $hashedButtonRequest variable in the controller before signing and the view output did in fact match my merchant details. So it would appear the culprit is the file that was generated by the `ssh-keygen -t rsa -b 2048 -f private.pem`.

After creating a test buyer on sellercentral using a different email address, I logged into payments.amazon.co.uk using this buyers email address and successfully received the following page.

![image](https://user-images.githubusercontent.com/8538339/205509284-6af4e053-6e14-4f27-b7f0-f57629b305f4.png)

.

Contributor guide

Open the contributing guide

Research direction

Start with API\Client generateButtonSignature and the controller/view path where the hashed button request is echoed. Reproduce the reported invalid Signature and invalid Login results with the two key-generation methods, then verify which private-key format the SDK accepts and confirm a successful sandbox flow.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, payments
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.