Skip to content
No description, website, or topics provided.
TypeScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
__tests__
docs
examples
libs
.gitignore
.npmignore
README.md
package-lock.json
package.json
tsconfig.json
yarn.lock

README.md

@ask-utils/amazon-pay

Getting Started

$ npm i -S @ask-utils/amazon-pay

// If you using typescript
$ npm i -D @ask-utils/amazon-pay

Example

Setup API

const AMAZONPay = require('@ask-utils/amazon-pay')
const SellerOrderAttributes = AMAZONPay.Setup.BillingAgreementBuilder
  .setPlatFormId('My id')
  .setSellerNote('my note')
  .setSellerBillingAgreementId('agreement id')
  .setSellerNote('My store')
  .setCustomInformation('custom info')
const setupPayload = AMAZONPay.Setup.PayloadBuilder
  .setSellerId('my seller id')
  .setCountryOfEstablishment('country')
  .setLedgerCurrency('ledger currency')
  .setCheckoutLanguage('checkout lang')
  .withAmazonShippingAddress(true)
  .isSandboxMode(true)
  .setSandboxCustomerEmailId('email')
  .updateBillingAgreement(SellerOrderAttributes)
const payload = setupPayload.getPayload()
console.log(JSON.stringify(payload))


{
  "@type": "SetupAmazonPayRequest",
  "@version": "v2",
  "sellerId": "my seller id",
  "countryOfEstablishment": "country",
  "ledgerCurrency": "ledger currency",
  "checkoutLanguage": "checkout lang",
  "needAmazonShippingAddress": true,
  "sandboxMode": true,
  "sandboxCustomerEmailId": "email",
  "billingAgreementAttributes": {
    "@type": "BillingAgreementAttributes",
    "@version": "2",
    "platformId": "My id",
    "sellerNote": "My store",
    "sellerBillingAgreementAttributes": {
      "@type": "SellerBillingAgreementAttributes",
      "@version": "2",
      "sellerBillingAgreementId": "agreement id",
      "customInformation": "custom info"
    }
  }
}

Charge API

const AMAZONPay = require('@ask-utils/amazon-pay')

const authorizeAttributes = AMAZONPay.Charge.AuthorizeAttributesBuilder
  .setReferenceId('MyReference ID')
  .setCurrencyCode('USD')
  .setAmount('500')
const sellerOrderAttribtes = AMAZONPay.Charge.SellerOrderAttributesBuilder
  .setSellerOrderId('my seller id')
  .setStoreName('Example store')
const payload = AMAZONPay.Charge.PayloadBuilder
  .setSellerId('my-seller-id')
  .setBillingAgreementId('agreement-id')
  .updateAuthorizeAttributes(authorizeAttributes)
  .updateSellerOrderAttributes(sellerOrderAttribtes)
  .getPayload()

console.log(payload)

{
  "@type": "ChargeAmazonPayRequest",
  "@version": "2",
  "sellerId": "my-seller-id",
  "billingAgreementId": "agreement-id",
  "paymentAction": "AuthorizeAndCapture",
  "authorizeAttributes": {
    "@type": "AuthorizeAttributes",
    "@version": "2",
    "authorizationReferenceId": "MyReference ID",
    "authorizationAmount": {
      "@type": "Price",
      "@version": "2",
      "amount": "500",
      "currencyCode": "USD"
    }
  },
  "sellerOrderAttributes": {
    "@type": "SellerOrderAttributes",
    "@version": "2",
    "sellerOrderId": "my seller id",
    "storeName": "Example store"
  }
}

Testing

$ yarn test

or

$ yarn test -- --watch

Contributing

Getting started

$ git clone git@github.com:ask-utils/ask-utils-for-amazon-pay.git
$ cd ask-utils-for-amazon-pay
$ yarn install
$ yarn run build

Before making a Pull Request

$ git checkout -b YOUR_TOPIC_BRANCH
$ yarn test
$ git add ./
$ git commit -m "YOUR UPDATE DESCRIPTION"
You can’t perform that action at this time.