{"_id":"@amazonpay/amazon-pay-alexa-utils","_rev":"3-ad88c7d95d6dfd88cb4ba2424866ea60","name":"@amazonpay/amazon-pay-alexa-utils","dist-tags":{"latest":"1.3.2"},"versions":{"1.3.1":{"name":"@amazonpay/amazon-pay-alexa-utils","version":"1.3.1","description":"Convenience utilities to simplify Amazon Pay for Alexa Skills functionality","main":"lib/AmazonPay.js","types":"lib/AmazonPay.d.ts","scripts":{"build":"tsc","test":"jest --config jestconfig.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json"},"repository":{"type":"git","url":"git+https://github.com/alexa/amazon-pay-alexa-utils-for-nodejs.git"},"bugs":{"url":"https://github.com/alexa/amazon-pay-alexa-utils-for-nodejs/issues"},"author":{"name":"Daniel Neu"},"license":"Apache-2.0","private":false,"devDependencies":{"@types/jest":"^25.1.4","@types/node":"^13.9.1","ask-sdk":"^2.6.0","ask-sdk-model":"^1.18.0","jest":"^25.1.0","prettier":"^1.18.2","ts-jest":"^25.2.1","tslint":"^6.1.0","tslint-config-prettier":"^1.18.0","typescript":"^3.5.3"},"dependencies":{"https":"^1.0.0"},"gitHead":"2d47d3685eba8ef4e48ffd8e312a05660ab06479","homepage":"https://github.com/alexa/amazon-pay-alexa-utils-for-nodejs#readme","_id":"@amazonpay/amazon-pay-alexa-utils@1.3.1","_npmVersion":"5.6.0","_nodeVersion":"8.10.0","_npmUser":{"name":"amazonpay","email":"amazon-pay-sdk@amazon.com"},"dist":{"integrity":"sha512-sHvw+SgT918EQEw/iX4DjWfeuWZnjGsuGZMww9xrTNBJ+y41vqKBYvreGJhdr7hcPvrBnp+Pe+BAinesnmTFXA==","shasum":"777acb9ac630d9a10948ba11de03cfec8b913b78","tarball":"https://registry.npmjs.org/@amazonpay/amazon-pay-alexa-utils/-/amazon-pay-alexa-utils-1.3.1.tgz","fileCount":44,"unpackedSize":87432,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJec5msCRA9TVsSAnZWagAAbNQP/2kNeXtBrk6RY/qnJVwZ\nn/nRzdUP69tCjsdWiKUbpg9sUFvG+mxnR3em+9Y8g8BGiJH3ws6VjrC3BD92\nrA1/w1B342iDcFFvJGWrYulreZeo4qsAPzPyIOLJsGhSbVsunp2UNUcGTlmq\nhV41tbKAE3qkC/bgYml3bUH/R6lR9KuXcmUyltjZBhhkOi2tP1UoFpBCtl2E\nSkrRRCb1XUa1Ty9uw8Z+wIYWkNL/yM6pHcyVYwzM8emYcuw+9Nr6Hh5WaxPB\nV8z5lkJ7pU3XDjT2ZUkZCFXKTzhwCul4GSi0dSRFJbLUC/TB/Y46CxLxeH9L\nzCCjFalvpcuku9V50fEyyLBG/f1iO6c7mco5XDU1VUaZawaB6dvdbfiC83Qq\npVeVSlkGeh5GFzKwoQth1+8B6s4F3tNK/GPhspmGhX1Y6u+NU0N9swOvHZpG\n9yNg0umzSifRvOVnInSnbSITlXHuqEck4B9lRKZof7Tf1EcH/cHwMUi8qaWi\nwDfK4Yzj2ZzRpXpNQKSHzB6WOS3J3P8no/ASFwBdENAS2h5gdq73bhwYOhhW\n/C3Bk+rRSJ8XqQzTukynf3+asVWP2NLm/hgNXjoY14fVGfAONJgvtsh46jhg\n+/p4b1EQO16I22d1E6DuF8KjDkgg+XE6mdNHOcFuWIyvR/3USfZh+IVVSWwq\nbIxr\r\n=Ur0/\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDOQm+/6V2wyxmmBf/RPNpabJ96cjAa4Z/Uu0ICvRaY8wIgcKsDFslqSGOTmlSp9Beq6xZ1BWJ7UMdmi1/mXjKwyNI="}]},"maintainers":[{"name":"amazonpay","email":"amazon-pay-sdk@amazon.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/amazon-pay-alexa-utils_1.3.1_1584634284077_0.035223607478715335"},"_hasShrinkwrap":false,"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"1.3.2":{"name":"@amazonpay/amazon-pay-alexa-utils","version":"1.3.2","description":"Convenience utilities to simplify Amazon Pay for Alexa Skills functionality","main":"lib/AmazonPay.js","types":"lib/AmazonPay.d.ts","scripts":{"build":"tsc","test":"jest --config jestconfig.json","format":"prettier --write \"src/**/*.ts\" \"src/**/*.js\"","lint":"tslint -p tsconfig.json"},"repository":{"type":"git","url":"git+https://github.com/alexa/amazon-pay-alexa-utils-for-nodejs.git"},"bugs":{"url":"https://github.com/alexa/amazon-pay-alexa-utils-for-nodejs/issues"},"author":{"name":"Daniel Neu"},"license":"Apache-2.0","private":false,"devDependencies":{"@types/jest":"^25.1.4","@types/node":"^13.9.1","ask-sdk":"^2.6.0","ask-sdk-model":"^1.18.0","jest":"^25.1.0","prettier":"^1.18.2","ts-jest":"^25.2.1","tslint":"^6.1.0","tslint-config-prettier":"^1.18.0","typescript":"^3.5.3"},"dependencies":{"https":"^1.0.0"},"gitHead":"e1a2adeae414c9cb6f951bf6134a6d1c8bcb1f87","homepage":"https://github.com/alexa/amazon-pay-alexa-utils-for-nodejs#readme","_id":"@amazonpay/amazon-pay-alexa-utils@1.3.2","_npmVersion":"5.6.0","_nodeVersion":"8.10.0","_npmUser":{"name":"amazonpay","email":"amazon-pay-sdk@amazon.com"},"dist":{"integrity":"sha512-tDm1ZE29HjaYz9orazpxwP/FrHUeMVzvs8gRt6GzkZjvHxl0Okd4XW9uVmGypu/l82+zG812YuOOLGsuXCybnw==","shasum":"87ad6a4840906fcc7ec722a5915ece94ac60e122","tarball":"https://registry.npmjs.org/@amazonpay/amazon-pay-alexa-utils/-/amazon-pay-alexa-utils-1.3.2.tgz","fileCount":44,"unpackedSize":87435,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/xZrCRA9TVsSAnZWagAAhDYP+wauPRJGSpGHhD5I5d4x\nvI6+uC907G+ldeUei1cLZTCHzjDaGlrvQkwpptopblCxZYcG3TQAnVjeePUe\nJiJaT9ytqwcW8HVCVS+Vy+ZP9ghhl0VAmTS42otjhHMiiic4BgBQP9QagGrR\nRgFhoQ/JX2oC5DO8DmoXr0SRr475V4R9F5ZFlJrEToX/W9IB8htm6R1Tf+UH\njbLBL9VIuuUMtlWrDQFkfSIbyok9+8u+pFw9P2Z8SKW0T0BLR+ZovrT1cbM7\nV2lOpE/cLJ/AgTOaGxn36VKDPrLyDyIeZlUv8Y2lf29FFMCHlzUwVDH4ALwU\nxgmm7RvYS91uSKaMqEMwK7VtlT8l08aqwrmqH9DMPrjcId08fvBM6qe7VnYV\neI9JwMR08a5ujQeEQMuWj/36oiwgP8SyaujNJd11knXS5uMct2SBQR1oPbQ8\nOrHIlTCpst+6Tb1wfkM79pFGw/VjwWIrR8kyv14PufTEtBe+GD0MypY4+Sg0\nD1hiAGy4Rpsk6qlrMYEEd31LuAM1d7n7TlYw3yB2229QPf5G0ZMFlyoz1QsK\ncmkevDqVpaHTA20hOeaFHC/XWEb2TQecSlWzkACmDyLcIMPHRYKHsWrbDVpI\n/lmsh9guddTNXunzVmD3k4FtHBTUnWGbWph8Ij3M7zUdEbAOsZJa3O31neSO\nhl9C\r\n=bu+F\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF8ON1TWoYJYnH0z/8H3104nLzJkYwL8NffqheQE0CqVAiAlY9bC3HbcdpuPWbx5ect1rKEQFAQlDrqL+/l/wpOUCA=="}]},"maintainers":[{"name":"amazonpay","email":"amazon-pay-sdk@amazon.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/amazon-pay-alexa-utils_1.3.2_1593775723407_0.704680559162439"},"_hasShrinkwrap":false,"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."}},"time":{"created":"2020-03-19T16:11:23.837Z","1.3.1":"2020-03-19T16:11:24.269Z","modified":"2022-12-21T08:27:43.813Z","1.3.2":"2020-07-03T11:28:43.491Z"},"maintainers":[{"name":"amazonpay","email":"amazon-pay-sdk@amazon.com"}],"description":"Convenience utilities to simplify Amazon Pay for Alexa Skills functionality","homepage":"https://github.com/alexa/amazon-pay-alexa-utils-for-nodejs#readme","repository":{"type":"git","url":"git+https://github.com/alexa/amazon-pay-alexa-utils-for-nodejs.git"},"author":{"name":"Daniel Neu"},"bugs":{"url":"https://github.com/alexa/amazon-pay-alexa-utils-for-nodejs/issues"},"license":"Apache-2.0","readme":"# amazonpay-alexa-utils\r\n\r\n<p align=\"center\">\r\n  <img src=\"https://m.media-amazon.com/images/G/01/mobile-apps/dex/avs/docs/ux/branding/mark1._TTH_.png\">\r\n  <br/>\r\n  <h1 align=\"center\">Amazon Pay Alexa Utils for Node.js</h1>\r\n  <p align=\"center\"><a href=\"https://travis-ci.org/alexa/amazon-pay-alexa-utils-for-nodejs\"><img src=\"https://travis-ci.org/alexa/amazon-pay-alexa-utils-for-nodejs.svg?branch=master\"></a></p>\r\n</p>\r\n\r\nThe Amazon Pay Alexa Utils package simplifies creating Amazon Pay related payloads and Directives for skills created with the ASK SDK v2 for Node.js.\r\nIt also offers the Amazon Pay specific APIs to retrieve Buyer Ids and Shipping Addresses and supports with a simple way to handle permissions.\r\n\r\nTo install it into your project, simply execute `npm i @amazonpay/amazon-pay-alexa-utils --save`\r\n\r\n## Setup API\r\n\r\nBuild payloads for setup operations the easy way -  no need to know the payload structure. The builder will take care to give you the right format.\r\n\r\n\r\nLearn more about the [Amazon Pay Setup API](https://developer.amazon.com/de/docs/amazon-pay/amazon-pay-apis-for-alexa.html#setup)\r\n\r\n```javascript\r\nconst AmazonPay = require('@amazonpay/amazon-pay-alexa-utils');\r\n\r\nconst payload = AmazonPay.setupPayload(/*version*/ '2')\r\n    .withSellerId('ABCD1234ADS')\r\n    .withCountryOfEstablishment('DE')\r\n    .withLedgerCurrency('EUR')\r\n    .withCheckoutLanguage('en_GB')\r\n    .withBillingAgreementType('MerchantInitiatedTransaction')\r\n    .withSubscriptionAmount('19.99')\r\n    .withSubscriptionCurrency('EUR')\r\n    .withCustomInformation('so custom')\r\n    .withPlatformId('ABCDE')\r\n    .withSellerBillingAgreementId('12345')\r\n    .withSellerNote('my note')\r\n    .withStoreName('my store')\r\n    .shippingNeeded(true)\r\n    .onSandbox({'eMail': 'mysandbox@email.test'}))\r\n    .build();\r\n\r\nconsole.log(JSON.stringify(payload))\r\n\r\n\r\n{  \r\n    \"@type\":\"SetupAmazonPayRequest\",\r\n    \"@version\":\"2\",\r\n    \"countryOfEstablishment\":\"DE\",\r\n    \"ledgerCurrency\":\"EUR\",\r\n    \"needAmazonShippingAddress\":true,\r\n    \"sellerId\":\"ABCD1234ADS\",\r\n    \"sandboxCustomerEmailId\":\"mysandbox@email.test\",\r\n    \"sandboxMode\":true,\r\n    \"checkoutLanguage\":\"en_GB\",\r\n    \"billingAgreementAttributes\":{  \r\n        \"@type\":\"BillingAgreementAttributes\",\r\n        \"@version\":\"2\",\r\n        \"sellerNote\":\"my note\",\r\n        \"platformId\":\"ABCDE\",\r\n        \"billingAgreementType\":\"MerchantInitiatedTransaction\",\r\n        \"subscriptionAmount\":{\r\n            \"@type\":\"Price\",\r\n            \"@version\":\"2\",\r\n            \"amount\":\"19.99\",\r\n            \"currencyCode\":\"EUR\"\r\n        },\r\n        \"sellerBillingAgreementAttributes\":{  \r\n            \"@type\":\"SellerBillingAgreementAttributes\",\r\n            \"@version\":\"2\",\r\n            \"storeName\":\"my store\",\r\n            \"customInformation\":\"so custom\",\r\n            \"sellerBillingAgreementId\":\"12345\"\r\n        }\r\n    }\r\n} \r\n```\r\n\r\n## Charge API\r\n\r\nBuild payloads for charge operations the easy way -  no need to know the payload structure. The builder will take care to give you the right format.\r\n\r\n\r\nLearn more about the [Amazon Pay Charge API](https://developer.amazon.com/de/docs/amazon-pay/amazon-pay-apis-for-alexa.html#charge)\r\n\r\n```javascript\r\nconst AmazonPay = require('@amazonpay/amazon-pay-alexa-utils');\r\n\r\nconst payload = AmazonPay.chargePayload(/* version */ '2')\r\n    .withSellerId('ABCD1234ADS')\r\n    .withBillingAgreementId('B02-12345-12345')\r\n    .withPaymentAction('AUTHORIZEANDCAPTURE')\r\n    .withAuthorizationReferenceId('ref')\r\n    .withAmount('50')\r\n    .withCurrency('EUR')\r\n    .withTransactionTimeout('0')\r\n    .withSellerAuthorizationNote('my auth note')\r\n    .withSoftDescriptor('my store - Alexa skill')\r\n    .withSellerOrderId('12345')\r\n    .withStoreName('my store')\r\n    .withCustomInformation('so custom')\r\n    .withSellerNote('my note')\r\n    .build();\r\n\r\nconsole.log(JSON.stringify(payload))\r\n\r\n{\r\n    '@type': 'ChargeAmazonPayRequest',\r\n    '@version': '2',\r\n    'billingAgreementId': 'B02-12345-12345',\r\n    'paymentAction': 'AUTHORIZEANDCAPTURE',\r\n    'sellerId': 'ABCD1234ADS',\r\n    'authorizeAttributes': {\r\n      '@type': 'AuthorizeAttributes',\r\n      '@version': '2',\r\n      'authorizationReferenceId': 'ref',\r\n      'authorizationAmount': {\r\n        '@type': 'Price',\r\n        '@version': '2',\r\n        'amount': '50',\r\n        'currencyCode': 'EUR',\r\n      },\r\n      'sellerAuthorizationNote': 'my auth note',\r\n      'softDescriptor': 'my store - Alexa skill',\r\n      'transactionTimeout': '0',\r\n    },\r\n    'sellerOrderAttributes': {\r\n      '@type': 'SellerOrderAttributes',\r\n      '@version': '2',\r\n      'customInformation': 'so custom',\r\n      'sellerNote': 'my note',\r\n      'sellerOrderId': '12345',\r\n      'storeName': 'my store',\r\n    },\r\n  }\r\n```\r\n\r\n## Directives\r\n\r\nDirectives allow you to execute Amazon Pay operations. Just pass in the right payload and the DirectiveBuilder will hand you the correct directive to execute.\r\n\r\n### Setup\r\n\r\n```javascript\r\nconst AmazonPay = require('@amazonpay/amazon-pay-alexa-utils');\r\n\r\nconst payloadBuilder = AmazonPay.setupPayload(/* version */ '2')\r\n    .withSellerId('ABCD1234ADS')\r\n    .withCountryOfEstablishment('DE')\r\n    .withLedgerCurrency('EUR');\r\n\r\nconst directive = AmazonPay\r\n    .setupDirective(payloadBuilder, 'token')\r\n    .build();\r\n\r\nconsole.log(JSON.stringify(directive));\r\n\r\n    {\r\n      \"name\": \"Setup\",\r\n      \"payload\": {\r\n        \"@type\": \"SetupAmazonPayRequest\",\r\n        \"@version\": \"2\",\r\n        \"countryOfEstablishment\": \"DE\",\r\n        \"ledgerCurrency\": \"EUR\",\r\n        \"needAmazonShippingAddress\": false,\r\n        \"sellerId\": \"ABCD1234ADS\"\r\n      },\r\n      \"token\": \"token\",\r\n      \"type\": \"Connections.SendRequest\"\r\n    }\r\n\r\n\r\n```\r\n\r\n### Charge\r\n\r\n```javascript\r\nconst AmazonPay = require('@amazonpay/amazon-pay-alexa-utils');\r\n\r\nconst payloadBuilder = AmazonPay.chargePayload(/* version */ '2')\r\n    .withSellerId('ABCD1234ADS')\r\n    .withBillingAgreementId('B02-12345-12345')\r\n    .withAmount('50')\r\n    .withCurrency('EUR')\r\n    .withAuthorizationReferenceId('ref')\r\n    .withPaymentAction('AUTHORIZE');\r\n\r\nconst directive = AmazonPay\r\n    .chargeDirective(payloadBuilder, 'token')\r\n    .build();\r\n\r\n    console.log(JSON.stringify(directive));\r\n\r\n    {\r\n      \"name\": \"Charge\",\r\n      \"payload\": {\r\n        \"@type\": \"ChargeAmazonPayRequest\",\r\n        \"@version\": \"2\",\r\n        \"billingAgreementId\": \"B02-12345-12345\",\r\n        \"paymentAction\": \"AUTHORIZE\",\r\n        \"sellerId\": \"ABCD1234ADS\",\r\n        \"authorizeAttributes\": {\r\n          \"@type\": \"AuthorizeAttributes\",\r\n          \"@version\": \"2\",\r\n          \"authorizationAmount\": {\r\n            \"@type\": \"Price\",\r\n            \"@version\": \"2\",\r\n            \"amount\": \"50\",\r\n            \"currencyCode\": \"EUR\"\r\n          },\r\n          \"authorizationReferenceId\": \"ref\"\r\n        }\r\n      },\r\n      \"token\": \"token\",\r\n      \"type\": \"Connections.SendRequest\"\r\n    }\r\n\r\n```\r\n\r\n## Permissions\r\n\r\n### Get Permission Status\r\n\r\nKnowing if a customer has accepted Amazon Pay permissions is essential. The following method makes this job as easy as possible for you.\r\n\r\n```javascript\r\nconst AmazonPay = require('@amazonpay/amazon-pay-alexa-utils');\r\n\r\nconst permissionIsGranted = AmazonPay.isAmazonPayPermissionGranted(handlerInput.requestEnvelope);\r\n\r\n```\r\n\r\n\r\n### Ask For Permissions - send card and prompt\r\n```javascript\r\nconst AmazonPay = require('@amazonpay/amazon-pay-alexa-utils');\r\n\r\nconst response = AmazonPay.askForPermissionCard('Spoken message to ask for permission enablement')\r\n  .withAdditionalPermissions(['alexa::profile:email:read', 'alexa::profile:name:read'])\r\n  .send(handlerInput.responseBuilder);\r\n```\r\n\r\n## Amazon Pay Buyer Address API\r\n\r\nAmazon Pay helps you fulfilling your orders seamlessly, by - among others - offering delivery address data via the Amazon Pay payment objects. Sometimes, this is too late in the flow to personalize the experience.\r\nThe Amazon Pay Buyer Address API was introduced to help you out. Retrieve the default shipping address of the current buyer via a simple GET request whenever you need it.\r\n\r\nPlease check for granted Amazon Pay permissions first.\r\n\r\nLearn more about the [Amazon Pay Buyer Address API](https://developer.amazon.com/de/docs/amazon-pay/amazon-pay-apis-for-alexa.html#buyer_address).\r\n```javascript\r\n  const AmazonPay = require('@amazonpay/amazon-pay-alexa-utils');\r\n\r\n  async handle: {\r\n  ...\r\n\r\n  // use this to have the current locale decide for the region to use\r\n  const buyerAddress = await AmazonPay.getBuyerAddress(requestEnvelope, sellerId);\r\n  \r\n  // if you want to specify the region yourself\r\n  const buyerAddress = await AmazonPay.getBuyerAddressForRegion(requestEnvelope, region, sellerId);\r\n  ...\r\n  \r\n  // if you want to test in sandbox mode\r\n  const buyerAddress = await AmazonPay.getBuyerAddress(requestEnvelope, sellerId, 'sandbox', 'mysandbox@email.test');\r\n  \r\n  }\r\n```\r\n\r\n## Amazon Pay Buyer Id\r\n\r\nThe Amazon Pay Buyer Id allows you to personalize the experience immediately for Amazon Pay customers already known to you - without asking them to link accounts.\r\nThe Id is static, even if a customer deactivated the skill in the past and is consistent across channels.\r\nUse this simple abstraction to retrieve it.\r\n\r\nPlease check for granted Amazon Pay permission first.\r\n\r\nLearn more about the [Amazon Pay Buyer Id API](https://developer.amazon.com/de/docs/amazon-pay/amazon-pay-apis-for-alexa.html#buyer_id).\r\n```javascript\r\n  const AmazonPay = require('@amazonpay/amazon-pay-alexa-utils');\r\n\r\n  async handle: {\r\n  ...\r\n\r\n  // use this to have the current locale decide for the region to use\r\n  const buyerId = await AmazonPay.getBuyerId(requestEnvelope);\r\n  \r\n  // if you want to specify the region yourself\r\n  const buyerId = await AmazonPay.getBuyerIdForRegion(requestEnvelope, region);\r\n  ...\r\n  }\r\n```","readmeFilename":"README.md"}