-
Notifications
You must be signed in to change notification settings - Fork 0
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
Tony Cordova
committed
May 1, 2019
1 parent
b0ed271
commit 5824e37
Showing
5 changed files
with
109 additions
and
88 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 |
---|---|---|
@@ -1,11 +1,35 @@ | ||
{ | ||
"deploy_settings": { | ||
"default": { | ||
"skill_id": "", | ||
"skill_id": "amzn1.ask.skill.7b00fd1c-b906-4dc6-8d9c-c4cbe1ef69fc", | ||
"was_cloned": false, | ||
"merge": { | ||
"manifest": {} | ||
}, | ||
"resources": { | ||
"manifest": { | ||
"eTag": "3517b94184e7b2fce7b7f48ab23b2b92" | ||
}, | ||
"interactionModel": { | ||
"en-US": { | ||
"eTag": "18f1e29eab906e15a7e9db8f36fb48c4" | ||
} | ||
}, | ||
"lambda": [ | ||
{ | ||
"alexaUsage": [ | ||
"custom/default" | ||
], | ||
"arn": "arn:aws:lambda:us-east-1:859669077786:function:no-nicks", | ||
"awsRegion": "us-east-1", | ||
"codeUri": "lambda/custom", | ||
"functionName": "no-nicks", | ||
"handler": "index.handler", | ||
"revisionId": "ef2f82bd-b5c9-4052-9be9-cfed3fe6eddb", | ||
"runtime": "nodejs8.10" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/** | ||
To run the skill, the minimum values you need configure are: sellerId, sandboxCustomerEmailId, and bucketName | ||
To run this skill, the minimum values you need configure are in INIT: bucketName, sandboxCustomerEmailId, and sellerId | ||
A detailed list of attribute descriptions can be found here: | ||
https://developer.amazon.com/docs/amazon-pay/amazon-pay-apis-for-alexa.html | ||
|
@@ -9,38 +9,42 @@ | |
|
||
const utilities = require( 'utilities' ); | ||
|
||
// Setup & Charge Payload attributes | ||
const GENERAL = { | ||
VERSION: '2.0', // Required; | ||
needAmazonShippingAddress: true, // Optional; Must be boolean | ||
// You must specify these values to run this skill | ||
const INIT = { | ||
bucketName: 'no-nicks', // Required; Used for skill state management | ||
sandboxCustomerEmailId: '[email protected]', // Required*; If sandboxMode equals true; | ||
sellerId: 'AVX6ERM5QT1ZB', // Required; Amazon Pay seller ID | ||
}; | ||
|
||
// These attributes are used globally across US, EU, and JP | ||
const GLOBAL = { | ||
amount: '0.01', // Required; Max $150,000.00 USD; Intentionally set to $.01 in the demo for testing purposes | ||
paymentAction: 'AuthorizeAndCapture', // Required; 'Authorize' or 'AuthorizeAndCapture' | ||
sandboxMode: true, // Required*; Must be true for sandbox testing; Must be false to submit to certification & production | ||
version: '2', // Required; | ||
setupType: 'SetupAmazonPayRequest', // Required; | ||
chargeType: 'ChargeAmazonPayRequest', // Required; | ||
needAmazonShippingAddress: true, // Optional; Must be boolean | ||
transactionTimeout: 0, // Optional; The default and recommended value for Alexa transactions is 0 | ||
bucketName: 'INSERT-YOUR-S3-BUCKET-NAME' // Required; Used for skill state management | ||
}; | ||
|
||
// These attributes will change based on your region ( US, EU, or JP ) | ||
const REGIONAL = { | ||
'en-US': { | ||
sellerId: 'INSERT-YOUR-AMAZON-PAY-SELLER-ID', // Required; Amazon Pay seller ID | ||
checkoutLanguage: 'en_US', // Optional; US must be en_US | ||
countryOfEstablishment: 'US', // Required; | ||
ledgerCurrency: 'USD', // Required; | ||
sandboxMode: true, // Optional; Must be false for certification & production; Must be true for sandbox testing | ||
sandboxCustomerEmailId: 'INSERT-YOUR-SANDBOX-EMAIL-ADDRESS', // Optional; Required if sandboxMode equals true; Must setup Amazon Pay test account first | ||
sellerAuthorizationNote: utilities.getSimulationString( '' ), // Optional; Max 255 chars | ||
softDescriptor: 'No Nicks', // Optional; Max 16 chars; This value is visible on customers credit card statements | ||
amount: '0.01', // Required; Max $150,000.00 USD; Intentionally set to $.01 in the demo for testing purposes. | ||
currencyCode: 'USD', // Required; | ||
|
||
// SELLER ORDER ATTRIBUTES | ||
ledgerCurrency: 'USD', // Required; | ||
checkoutLanguage: 'en_US', // Optional; US must be en_US | ||
customInformation: '', // Optional; Max 1024 chars | ||
sellerAuthorizationNote: utilities.getSimulationString( '' ), // Optional; Max 255 chars; In sandbox mode you can pass simulation strings. See utilities.js | ||
sellerNote: 'Thanks for shaving with No Nicks', // Optional; Max 1024 chars, visible on confirmation mails to buyers | ||
sellerStoreName: 'No Nicks', // Optional; Documentation calls this out as storeName not sellerStoreName | ||
softDescriptor: 'No Nicks', // Optional; Max 16 chars; This value is visible on customers credit card statements | ||
} | ||
}; | ||
|
||
/** | ||
The following strings DO NOT interact with Amazon Pay | ||
They are here to augment the skill | ||
The following strings DO NOT interact with Amazon Pay, they are here to augment the skill | ||
Order Summary, Order Confirmation, Cancel and Refund Custom Intents are required for certification: | ||
https://developer.amazon.com/docs/amazon-pay/certify-skill-with-amazon-pay.html | ||
|
@@ -110,7 +114,6 @@ const REGIONAL = { | |
The following strings are used to output errors to test the skill | ||
**/ | ||
|
||
|
||
// ERROR RESPONSE STRINGS | ||
const scope = 'payments:autopay_consent'; // Required; Used request permissions for Amazon Pay | ||
const enablePermission = 'To make purchases in this skill, you need to enable Amazon Pay and turn on voice purchasing. To help, I sent a card to your Alexa app.'; | ||
|
@@ -126,8 +129,10 @@ const REGIONAL = { | |
|
||
|
||
module.exports = { | ||
'GENERAL': GENERAL, | ||
'REGIONAL': REGIONAL, | ||
// PAYLOAD ATTRIBUTES | ||
'INIT': INIT, | ||
'GLOBAL': GLOBAL, | ||
'REGIONAL': REGIONAL, | ||
|
||
// INTENT RESPONSE STRINGS | ||
'launchRequestWelcomeTitle': launchRequestWelcomeTitle, | ||
|
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 |
---|---|---|
|
@@ -9,4 +9,4 @@ | |
"ask-sdk-core": "^2.4.0", | ||
"ask-sdk-s3-persistence-adapter": "^2.4.0" | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,84 +1,76 @@ | ||
const utilities = require( 'utilities' ); | ||
let config = require( 'config' ); | ||
const utilities = require( 'utilities' ); | ||
const config = require( 'config' ); | ||
const initConfig = config.INIT; | ||
const globalConfig = config.GLOBAL; | ||
|
||
const setupPayloadVersioning = { | ||
type: 'SetupAmazonPayRequest', | ||
version: '2' | ||
}; | ||
function setupPayload( language ) { | ||
const regionalConfig = config.REGIONAL[ language ]; | ||
|
||
const processPayloadVersioning = { | ||
type: 'ChargeAmazonPayRequest', | ||
version: '2' | ||
}; | ||
|
||
var setupPayload = function( language ) { | ||
console.log( language ); | ||
const regionalConfig = config.REGIONAL[ language ]; | ||
const generalConfig = config.GENERAL; | ||
var payload = { | ||
'@type': setupPayloadVersioning.type, | ||
'@version': setupPayloadVersioning.version, | ||
'sellerId': regionalConfig.sellerId, | ||
'countryOfEstablishment': regionalConfig.countryOfEstablishment, | ||
'ledgerCurrency': regionalConfig.ledgerCurrency, | ||
'checkoutLanguage': language, | ||
'sandboxCustomerEmailId': regionalConfig.sandboxCustomerEmailId, | ||
'sandboxMode': regionalConfig.sandboxMode, | ||
'needAmazonShippingAddress': generalConfig.needAmazonShippingAddress, | ||
let payload = { | ||
'@type': globalConfig.setupType, | ||
'@version': globalConfig.version, | ||
'sellerId': initConfig.sellerId, | ||
'countryOfEstablishment': regionalConfig.countryOfEstablishment, | ||
'ledgerCurrency': regionalConfig.ledgerCurrency, | ||
'checkoutLanguage': language, | ||
'sandboxCustomerEmailId': initConfig.sandboxCustomerEmailId, | ||
'sandboxMode': globalConfig.sandboxMode, | ||
'needAmazonShippingAddress': globalConfig.needAmazonShippingAddress, | ||
'billingAgreementAttributes': { | ||
'@type': 'BillingAgreementAttributes', | ||
'@version': '2', | ||
'sellerNote': regionalConfig.sellerNote, | ||
'platformId': generalConfig.platformId, | ||
'@type': 'BillingAgreementAttributes', | ||
'@version': globalConfig.version, | ||
'sellerNote': regionalConfig.sellerNote, | ||
'platformId': globalConfig.platformId, | ||
'sellerBillingAgreementAttributes': { | ||
'@type': 'SellerBillingAgreementAttributes', | ||
'@version': '2', | ||
//'sellerBillingAgreementId': SOME RANDOM STRING, | ||
'storeName': generalConfig.sellerStoreName, | ||
'customInformation': regionalConfig.customInformation | ||
'@type': 'SellerBillingAgreementAttributes', | ||
'@version': globalConfig.version, | ||
'sellerBillingAgreementId': utilities.generateRandomString( 6 ), | ||
'storeName': globalConfig.sellerStoreName, | ||
'customInformation': regionalConfig.customInformation | ||
} | ||
} | ||
}; | ||
|
||
return payload; | ||
}; | ||
var chargePayload = function( billingAgreementId, authorizationReferenceId, sellerOrderId, amount, language ) { | ||
} | ||
|
||
function chargePayload ( billingAgreementId, authorizationReferenceId, sellerOrderId, amount, language ) { | ||
const regionalConfig = config.REGIONAL[ language ]; | ||
|
||
const regionalConfig = config.REGIONAL[ language ]; | ||
const generalConfig = config.GENERAL; | ||
var payload = { | ||
'@type': processPayloadVersioning.type, | ||
'@version': processPayloadVersioning.version, | ||
'sellerId': regionalConfig.sellerId, | ||
'billingAgreementId': billingAgreementId, | ||
'paymentAction': generalConfig.paymentAction, | ||
let payload = { | ||
'@type': globalConfig.chargeType, | ||
'@version': globalConfig.version, | ||
'sellerId': initConfig.sellerId, | ||
'billingAgreementId': billingAgreementId, | ||
'paymentAction': globalConfig.paymentAction, | ||
'authorizeAttributes': { | ||
'@type': 'AuthorizeAttributes', | ||
'@version': '2', | ||
'authorizationReferenceId': authorizationReferenceId, | ||
'@version': globalConfig.version, | ||
'authorizationReferenceId': authorizationReferenceId, | ||
'authorizationAmount': { | ||
'@type': 'Price', | ||
'@version': '2', | ||
'amount': amount.toString( ), | ||
'currencyCode': regionalConfig.ledgerCurrency | ||
'@type': 'Price', | ||
'@version': globalConfig.version, | ||
'amount': amount, | ||
'currencyCode': regionalConfig.ledgerCurrency | ||
}, | ||
'transactionTimeout': generalConfig.transactionTimeout, | ||
'sellerAuthorizationNote': regionalConfig.sellerAuthorizationNote, // util.getSimulationString('AmazonRejected'), | ||
'softDescriptor': regionalConfig.softDescriptor | ||
'transactionTimeout': globalConfig.transactionTimeout, | ||
'sellerAuthorizationNote': regionalConfig.sellerAuthorizationNote, | ||
'softDescriptor': regionalConfig.softDescriptor | ||
}, | ||
'sellerOrderAttributes': { | ||
'@type': 'SellerOrderAttributes', | ||
'@version': '2', | ||
// 'sellerOrderId': sellerOrderId, | ||
'storeName': regionalConfig.sellerStoreName, | ||
'customInformation': regionalConfig.customInformation, | ||
'sellerNote': regionalConfig.sellerNote | ||
'@type': 'SellerOrderAttributes', | ||
'@version': globalConfig.version, | ||
'sellerOrderId': sellerOrderId, | ||
'storeName': regionalConfig.sellerStoreName, | ||
'customInformation': regionalConfig.customInformation, | ||
'sellerNote': regionalConfig.sellerNote | ||
} | ||
}; | ||
|
||
return payload; | ||
}; | ||
} | ||
|
||
module.exports = { | ||
'setupPayload': setupPayload, | ||
'chargePayload': chargePayload | ||
'setupPayload': setupPayload, | ||
'chargePayload': chargePayload | ||
}; |