-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Abhishek Kumar
committed
Jul 31, 2024
1 parent
77ef94b
commit 72fd366
Showing
7 changed files
with
354 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Amazon\Pay\API; | ||
|
||
/* Interface class to showcase the public API methods for Amazon Pay */ | ||
|
||
interface AccountManagementClientInterface | ||
{ | ||
// ----------------------------------- Account Management APIs----------------------------------- | ||
|
||
/* Amazon Checkout v2 - Create Merchant Account | ||
* | ||
* Provide merchant info through this API to create loginable account for your merchant partners. Client should expect either a success message or a detailed error message based on data validation and fulfillment. | ||
* | ||
* @param payload - [String in JSON format] or [array] | ||
* @param headers - [array] - requires x-amz-pay-Idempotency-Key header | ||
*/ | ||
public function createMerchantAccount($payload, $headers); | ||
|
||
/* Amazon Checkout v2 - Update Amazon Pay Merchant Account | ||
* | ||
* Updates a merchant account and store for the given Amazon merchantAccountId. Partners are only able to update fields which do not change the legal business entity itself. | ||
* | ||
* @param merchantAccountId - [String] - Merchant Account ID | ||
* @param payload - [String in JSON format] or [array] | ||
* @param headers - [array] - requires x-amz-pay-authToken header | ||
*/ | ||
public function updateMerchantAccount($merchantAccountId, $payload, $headers); | ||
|
||
/* Amazon Checkout v2 - Claim Amazon Pay Merchant Account | ||
* | ||
* Initiates the merchant account claim process. Clients should expect a redirection response or a detailed error message based on data validation and fulfillment. | ||
* | ||
* @param merchantAccountId - [String] - Merchant Account ID | ||
* @param payload - [String in JSON format] or [array] | ||
* @optional headers - [indexed array of string key-value pairs] | ||
*/ | ||
public function claimMerchantAccount($merchantAccountId, $payload, $headers = null); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,6 +172,11 @@ Please contact your Amazon Pay Account Manager before using the In-Store API cal | |
* **updateAmazonPayAccount**($merchantAccountId, $payload, $headers = null) → PATCH to "$version/merchantAccounts/$merchantAccountId" | ||
* **deleteAmazonPayAccount**($merchantAccountId, $headers = null) → DELETE to "$version/merchantAccounts/$merchantAccountId" | ||
|
||
### Amazon Checkout v2 Account Management APIs | ||
* **createMerchantAccount**($payload, $headers) → POST to "$version/merchantAccounts" | ||
* **updateMerchantAccount**($merchantAccountId, $payload, $headers) → PATCH to "$version/merchantAccounts/$merchantAccountId" | ||
* **claimMerchantAccount**($merchantAccountId, $payload, $headers) → POST to "$version/merchantAccounts/$merchantAccountId/claim" | ||
|
||
# Using Convenience Functions | ||
|
||
Four quick steps are needed to make an API call: | ||
|
@@ -1441,4 +1446,288 @@ if ($result['status'] === 200) { | |
echo $e . "\n"; | ||
} | ||
?> | ||
``` | ||
# Sample codes for Account Management APIs | ||
For more details related to Account Management APIs, please refer to this [Integration Guide](https://developer.amazon.com/docs/amazon-pay-registration/jp-merchant-onboarding-and-account-management-APIs.html). | ||
|
||
## Amazon Checkout v2 Account Management APIs - createMerchantAccount API | ||
|
||
```php | ||
<?php | ||
include 'vendor/autoload.php'; | ||
require_once 'Amazon/Pay/API/Client.php'; | ||
|
||
$amazonpay_config = array( | ||
'public_key_id' => 'YOUR_PUBLIC_KEY_ID', | ||
'private_key' => 'keys/private.pem', | ||
'region' => 'JP', | ||
'algorithm' => 'AMZN-PAY-RSASSA-PSS-V2' | ||
); | ||
|
||
try { | ||
|
||
$payload = array( | ||
"uniqueReferenceId" => "Unique_Reference_Id", // Mandatory | ||
"ledgerCurrency" => "JPY", | ||
"businessInfo" => array( | ||
"email" => "[email protected]", | ||
"businessType" => "CORPORATE", | ||
"businessLegalName" => "密林コーヒー", | ||
"businessCategory" => "Beauty", | ||
"businessAddress" => array( | ||
"addressLine1" => "扇町4丁目5-1", | ||
"addressLine2" => "フルフィルメントセンタービル", | ||
"city" => "小田原市", | ||
"stateOrRegion" => "神奈川県", | ||
"postalCode" => "250-0001", | ||
"countryCode" => "JP", | ||
"phoneNumber" => array( | ||
"countryCode" => "81", | ||
"number" => "2062062061" | ||
) | ||
), | ||
"businessDisplayName" => "Abhi's Cafe", | ||
"annualSalesVolume" => array( | ||
"amount" => "100000", | ||
"currencyCode" => "JPY" | ||
), | ||
"countryOfEstablishment" => "JP", | ||
"customerSupportInformation" => array( | ||
"customerSupportEmail" => "[email protected]", | ||
"customerSupportPhoneNumber" => array( | ||
"countryCode" => "1", | ||
"number" => "1234567", | ||
"extension" => "123" | ||
) | ||
) | ||
), // Mandatory | ||
"beneficiaryOwners" => array( | ||
array( | ||
"personId" => "AO1", | ||
"personFullName" => "Abhishek Kumar", | ||
"residentialAddress" => array( | ||
"addressLine1" => "扇町4丁目5-1", | ||
"addressLine2" => "フルフィルメントセンタービル", | ||
"city" => "小田原市", | ||
"stateOrRegion" => "神奈川県", | ||
"postalCode" => "250-0001", | ||
"countryCode" => "JP", | ||
"phoneNumber" => array( | ||
"countryCode" => "81", | ||
"number" => "2062062061" | ||
) | ||
) | ||
), | ||
array( | ||
"personId" => "AO2", | ||
"personFullName" => "Rufus1 Rufus1", | ||
"residentialAddress" => array( | ||
"addressLine1" => "扇町4丁目5-1", | ||
"addressLine2" => "フルフィルメントセンタービル", | ||
"city" => "小田原市", | ||
"stateOrRegion" => "神奈川県", | ||
"postalCode" => "250-0001", | ||
"countryCode" => "JP", | ||
"phoneNumber" => array( | ||
"countryCode" => "81", | ||
"number" => "2062062061" | ||
) | ||
) | ||
) | ||
), // Mandatory | ||
"primaryContactPerson" => array( | ||
"personFullName" => "Abhishek Kumar" | ||
), // Optional | ||
"integrationInfo" => array( | ||
"ipnEndpointUrls" => array( | ||
"https://yourdomainname.com/ipnendpoint1", | ||
"https://yourdomainname.com/ipnendpoint2" | ||
) | ||
), // Optionals | ||
"stores" => array( | ||
array( | ||
"domainUrls" => array( | ||
"http://www.yourdomainname.com" | ||
), | ||
"storeName" => "Rufus's Cafe", | ||
"privacyPolicyUrl" => "http://www.yourdomainname.com/privacy", | ||
"storeStatus" => array( | ||
"state" => "Active", | ||
"reasonCode" => null | ||
) | ||
) | ||
), // Mandatory | ||
"merchantStatus" => array( | ||
"statusProvider" => "Ayden", | ||
"state" => "ACTIVE", | ||
"reasonCode" => null | ||
) // Mandatory | ||
); | ||
|
||
$headers = array('x-amz-pay-Idempotency-Key' => uniqid()); | ||
$client = new Amazon\Pay\API\Client($amazonpay_config); | ||
$result = $client->createMerchantAccount($payload, $headers); | ||
print_r($result); | ||
|
||
if ($result['status'] === 201) { | ||
// success | ||
$response = $result['response']; | ||
print_r($response); | ||
} else { | ||
// check the error | ||
echo 'status=' . $result['status'] . '; response=' . $result['response'] . "\n"; | ||
} | ||
} catch (\Exception $e) { | ||
// handle the exception | ||
echo $e . "\n"; | ||
} | ||
?> | ||
``` | ||
|
||
## Amazon Checkout v2 Account Management APIs - updateMerchantAccount API | ||
|
||
```php | ||
<?php | ||
include 'vendor/autoload.php'; | ||
require_once 'Amazon/Pay/API/Client.php'; | ||
|
||
$amazonpay_config = array( | ||
'public_key_id' => 'YOUR_PUBLIC_KEY_ID', | ||
'private_key' => 'keys/private.pem', | ||
'region' => 'JP', | ||
'algorithm' => 'AMZN-PAY-RSASSA-PSS-V2' | ||
); | ||
|
||
try { | ||
|
||
$payload = array( | ||
"uniqueReferenceId" => "String", // Mandatory | ||
"ownerAccountId" => "String", // Optional | ||
"businessInfo" => array( | ||
"email" => "String", // Mandatory | ||
"businessCategory" => "ENUM", // Mandatory | ||
"countryOfEstablishment" => "JP", // Mandatory (JP for Japan) | ||
"businessType" => "ENUM", // Mandatory (e.g., Corporate) | ||
"businessLegalName" => "String", // Mandatory | ||
"businessAddress" => array( | ||
"addressLine1" => "String", // Mandatory | ||
"addressLine2" => "String", // Optional | ||
"city" => "String", // Optional | ||
"stateOrRegion" => "String", // Optional | ||
"postalCode" => "String", // Mandatory | ||
"countryCode" => "String" // Mandatory | ||
), | ||
"businessDisplayName" => "String", // Mandatory | ||
"customerSupportInformation" => array( | ||
"customerSupportEmail" => "String", // Optional | ||
"customerSupportPhoneNumber" => array( | ||
"countryCode" => "String", // Mandatory | ||
"number" => "String", // Mandatory | ||
"extension" => "String" // Optional | ||
) | ||
), | ||
"annualSalesVolume" => array( | ||
"amount" => "String", // Mandatory | ||
"currencyCode" => "String" // Optional (ISO 4217) | ||
) // Optional | ||
), | ||
"primaryContactPerson" => array( | ||
"personFullName" => "String", // Mandatory | ||
"residentialAddress" => array( | ||
"addressLine1" => "String", // Mandatory | ||
"addressLine2" => "String", // Optional | ||
"city" => "String", // Optional | ||
"stateOrRegion" => "String", // Optional | ||
"postalCode" => "String", // Mandatory | ||
"countryCode" => "String" // Mandatory | ||
) // Optional | ||
), | ||
"beneficiaryOwners" => array( | ||
array( | ||
"personFullName" => "String", // Mandatory | ||
"residentialAddress" => array( | ||
"addressLine1" => "String", // Mandatory | ||
"addressLine2" => "String", // Optional | ||
"city" => "String", // Optional | ||
"stateOrRegion" => "String", // Optional | ||
"postalCode" => "String", // Mandatory | ||
"countryCode" => "String" // Mandatory | ||
) // Optional | ||
) | ||
), // Mandatory | ||
"defaultStore" => array( | ||
"domainUrls" => array("String"), // Mandatory | ||
"storeName" => "String", // Optional | ||
"privacyPolicyUrl" => "String", // Optional | ||
"storeStatus" => array( | ||
"state" => "ENUM", // Mandatory | ||
"reasonCode" => "ENUM" // Optional | ||
) // Optional | ||
), | ||
"integrationInfo" => array( | ||
"ipnEndpointUrl" => array("String") // Optional | ||
), | ||
"merchantStatus" => array( | ||
"statusProvider" => "String", // Optional (Mandatory if state is Active) | ||
"state" => "ENUM", // Mandatory | ||
"reasonCode" => "ENUM" // Optional | ||
) | ||
); | ||
|
||
$headers = array('x-amz-pay-authtoken' => 'other_merchant_super_secret_token'); // Mandatory | ||
$client = new Amazon\Pay\API\Client($amazonpay_config); | ||
$merchantAccountId = "YOUR_MERCHANT_ID"; | ||
$result = $client->updateMerchantAccount($merchantAccountId, $payload, $headers); | ||
|
||
if ($result['status'] === 200) { | ||
// success | ||
$response = $result['response']; | ||
} else { | ||
// check the error | ||
echo 'status=' . $result['status'] . '; response=' . $result['response'] . "\n"; | ||
} | ||
} catch (\Exception $e) { | ||
// handle the exception | ||
echo $e . "\n"; | ||
} | ||
?> | ||
``` | ||
|
||
## Amazon Checkout v2 Account Management APIs - claimMerchantAccount API | ||
|
||
```php | ||
<?php | ||
include 'vendor/autoload.php'; | ||
require_once 'Amazon/Pay/API/Client.php'; | ||
|
||
$amazonpay_config = array( | ||
'public_key_id' => 'YOUR_PUBLIC_KEY_ID', | ||
'private_key' => 'keys/private.pem', | ||
'region' => 'JP', | ||
'algorithm' => 'AMZN-PAY-RSASSA-PSS-V2' | ||
); | ||
|
||
try { | ||
|
||
$payload = array( | ||
"uniqueReferenceId" => "Unique_Reference_Id" // Mandatory | ||
); | ||
|
||
$headers = array('x-amz-pay-Idempotency-Key' => uniqid()); | ||
$client = new Amazon\Pay\API\Client($amazonpay_config); | ||
$merchantAccountId = "YOUR_MERCHANT_ID"; | ||
$result = $client->claimMerchantAccount($merchantAccountId, $payload, $headers = null); | ||
|
||
if ($result['status'] === 303) { | ||
// success | ||
$response = $result['response']; | ||
} else { | ||
// check the error | ||
echo 'status=' . $result['status'] . '; response=' . $result['response'] . "\n"; | ||
} | ||
} catch (\Exception $e) { | ||
// handle the exception | ||
echo $e . "\n"; | ||
} | ||
?> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.