Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Cordova committed Mar 21, 2019
1 parent f923296 commit 2e03af4
Show file tree
Hide file tree
Showing 17 changed files with 1,987 additions and 3 deletions.
20 changes: 20 additions & 0 deletions .ask/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"deploy_settings": {
"default": {
"skill_id": "",
"was_cloned": false,
"merge": {
"manifest": {
"apis": {
"custom": {
"endpoint": {
"uri": "demo-store-amazon-pay"
}
}
}
}
}
}
}
}
a
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
/lambda/custom/node_modules
53 changes: 50 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,54 @@
## Amazon Pay Demo Store for Alexa
# Build An Alexa Skill with Amazon Pay - Demo Store
Do you currently sell goods or services on other channels but want to expand to Alexa to reach new and existing customers? Good news, with [Amazon Pay](https://developer.amazon.com/alexa-skills-kit/make-money/amazon-pay), you can offer a seamless voice purchasing experience to your customers, allowing them to purchase real-world goods and services via Alexa - without having to leave the voice experience.

This custom skill is a demo store that showcases how to use Amazon Pay with your shopping experiences on Alexa.

## What You Will Need
Before you start working on this skill, you will need to create the following accounts:
* [Amazon Developer Account](http://developer.amazon.com/alexa)
* [Amazon Web Services Account](http://aws.amazon.com/)
* [Amazon Pay Merchant Account](https://pay.amazon.com/us)
* [Amazon Pay Sandbox Test Account](https://www.youtube.com/watch?v=m5teEFRZB8A)

## Setting Up the Demo
This repository contains the interaction model and skill code. It is structured to make it easy to deploy if you have the [ASK CLI](https://developer.amazon.com/docs/smapi/quick-start-alexa-skills-kit-command-line-interface.html) already setup. If you would like to use the Alexa Developer Console, you can follow the steps outlined in the [Hello World](https://github.com/alexa/skill-sample-nodejs-hello-world) example, substituting the [Model](./models/en-US.json) and the [skill code](./lambda/custom/index.js) when called for. In addition, you will need to configure the additional supporting javascript files found in the custom folder.

1. Clone repository and navigate the demo's root folder ( lambda/custom ).
1. Open [config.js](./lambda/custom/config.js) and update values `bucketName`, `sellerId`, and `sandboxCustomerEmailId`
* the `bucketName` is the name of your [S3](https://aws.amazon.com/s3/) bucket.
* the `sellerId` is your Amazon Pay Seller Id. You can find that [here](https://youtu.be/oHp4Hv5_MBA?t=38)
* the `sandboxCustomerEmailId` is the email address of the Amazon Pay sandbox test account you created in Seller Central. Instructions [here](https://www.youtube.com/watch?v=m5teEFRZB8A).
1. Give your skill permission to use your Amazon Pay account. You can do that [here](https://sellercentral.amazon.com/external-payments/integration/alexa/). The documentation is [here](https://developer.amazon.com/docs/amazon-pay/integrate-skill-with-amazon-pay-v2.html).
1. Enable the skill using the Alexa app. Be sure to click Settings to show the permissions page if you do not see it. Provide permission to use Amazon Pay.

## Running the Demo
Launch the demo by saying, 'Alexa, open No Nicks'. If you receive an error, proceed to the [troubleshooting section](#troubleshooting).

## Troubleshooting

If you are encountering issues with your skill, double check that you have completed the following:

1. Confirm that your Seller Central account is in good standing by selecting the Production environment and verify there are no errors on your account.
1. Check the correct skill was linked in Sandbox using in Seller Central.
1. Verify your sandbox test user was created in Seller Central.
1. Verify Amazon Pay permissions are enabled for your skill under Build > Permissions > Amazon Pay.
1. Verify the config.js contains the appropriate values for `bucketName`, `sellerId`, and `sandboxCustomerEmailId`.
1. Verify the correct skill Id is used in your Lambda function.
1. Enable your skill in your Alexa App
1. Consent and give permissions to Amazon Pay in your Alexa App
1. Enable Voice Purchasing in your Alexa App ( with or without the voice code ).

All other errors and decline handling can be found here: https://developer.amazon.com/docs/amazon-pay/payment-declines-and-processing-errors.html

## Resources
* [Amazon Pay Alexa Documentation](https://developer.amazon.com/docs/amazon-pay/amazon-pay-overview.html)
* [Amazon Pay Certification Requirements](https://developer.amazon.com/docs/amazon-pay/certify-skill-with-amazon-pay.html)
* [Official Alexa Skills Kit SDK for Node.js](https://ask-sdk-for-nodejs.readthedocs.io/en/latest/) - The Official Node.js SDK Documentation
* [Official Alexa Skills Kit Documentation](https://developer.amazon.com/docs/ask-overviews/build-skills-with-the-alexa-skills-kit.html) - Official Alexa Skills Kit Documentation
* [Amazon Developer Forums](https://forums.developer.amazon.com/spaces/423/index.html) - Join the conversation!
* [Amazon Pay Help Guide](https://pay.amazon.com/us/help)

This demo store showcases how to integrate Amazon Pay into your shopping experiences on Alexa.

## License

This library is licensed under the Amazon Software License.
This library is licensed under the Amazon Software License.
53 changes: 53 additions & 0 deletions hooks/post_new_hook.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Powershell script for ask-cli post-new hook for Node.js
# Script Usage: post_new_hook.ps1 <SKILL_NAME> <DO_DEBUG> <TARGET>

# SKILL_NAME is the preformatted name passed from the CLI, after removing special characters.
# DO_DEBUG is boolean value for debug logging

# Run this script one level outside of the skill root folder

# The script does the following:
# - Run "npm install" in each sourceDir in skill.json

param(
[string] $SKILL_NAME,
[bool] $DO_DEBUG = $False
)

if ($DO_DEBUG) {
Write-Output "###########################"
Write-Output "###### post-new hook ######"
Write-Output "###########################"
}

function install_dependencies ($CWD, $SOURCE_DIR) {
$INSTALL_PATH = $SKILL_NAME + "\" +$SOURCE_DIR
Set-Location $INSTALL_PATH
Invoke-Expression "npm install" 2>&1 | Out-Null
$EXEC_RESULT = $?
Set-Location $CWD
return $EXEC_RESULT
}

$SKILL_FILE_PATH = $SKILL_NAME + "\skill.json"
$ALL_SOURCE_DIRS = Get-Content -Path $SKILL_FILE_PATH | select-string -Pattern "sourceDir" -CaseSensitive
Foreach ($SOURCE_DIR in $ALL_SOURCE_DIRS) {
$FILTER_SOURCE_DIR = $SOURCE_DIR -replace "`"", "" -replace "\s", "" -replace ",","" -replace "sourceDir:", ""
$CWD = (Get-Location).Path
if (install_dependencies $CWD $FILTER_SOURCE_DIR) {
if ($DO_DEBUG) {
Write-Output "Codebase ($FILTER_SOURCE_DIR) built successfully."
}
} else {
if ($DO_DEBUG) {
Write-Output "There was a problem installing dependencies for ($FILTER_SOURCE_DIR)."
}
exit 1
}
}

if ($DO_DEBUG) {
Write-Output "###########################"
}

exit 0
42 changes: 42 additions & 0 deletions hooks/post_new_hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
# Shell script for ask-cli post-new hook for Node.js
# Script Usage: post_new_hook.sh <SKILL_NAME> <DO_DEBUG> <TARGET>

# SKILL_NAME is the preformatted name passed from the CLI, after removing special characters.
# DO_DEBUG is boolean value for debug logging

# Run this script one level outside of the skill root folder

# The script does the following:
# - Run "npm install" in each sourceDir in skill.json

SKILL_NAME=$1
DO_DEBUG=${2:-false}

if [ $DO_DEBUG == false ]
then
exec > /dev/null 2>&1
fi

install_dependencies() {
npm install --prefix "$SKILL_NAME/$1" >/dev/null 2>&1
return $?
}

echo "###########################"
echo "###### post-new hook ######"
echo "###########################"

grep "sourceDir" $SKILL_NAME/skill.json | cut -d: -f2 | sed 's/"//g' | sed 's/,//g' | while read -r SOURCE_DIR; do
if install_dependencies $SOURCE_DIR; then
echo "Codebase ($SOURCE_DIR) built successfully."
else
echo "There was a problem installing dependencies for ($SOURCE_DIR)."
exit 1
fi
done
echo "###########################"

exit 0


54 changes: 54 additions & 0 deletions hooks/pre_deploy_hook.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Powershell script for ask-cli pre-deploy hook for Node.js
# Script Usage: pre_deploy_hook.ps1 <SKILL_NAME> <DO_DEBUG> <TARGET>

# SKILL_NAME is the preformatted name passed from the CLI, after removing special characters.
# DO_DEBUG is boolean value for debug logging
# TARGET is the deploy TARGET provided to the CLI. (eg: all, skill, lambda etc.)

# Run this script under the skill root folder

# The script does the following:
# - Run "npm install" in each sourceDir in skill.json

param(
[string] $SKILL_NAME,
[bool] $DO_DEBUG = $False,
[string] $TARGET = "all"
)

function install_dependencies ($CWD, $SOURCE_DIR) {
Set-Location $SOURCE_DIR
Invoke-Expression "npm install" 2>&1 | Out-Null
$EXEC_RESULT = $?
Set-Location $CWD
return $EXEC_RESULT
}

if ($DO_DEBUG) {
Write-Output "###########################"
Write-Output "##### pre-deploy hook #####"
Write-Output "###########################"
}

if ($TARGET -eq "all" -Or $TARGET -eq "lambda") {
$ALL_SOURCE_DIRS = Get-Content -Path "skill.json" | select-string -Pattern "sourceDir" -CaseSensitive
Foreach ($SOURCE_DIR in $ALL_SOURCE_DIRS) {
$FILTER_SOURCE_DIR = $SOURCE_DIR -replace "`"", "" -replace "\s", "" -replace ",","" -replace "sourceDir:", ""
$CWD = (Get-Location).Path
if (install_dependencies $CWD $FILTER_SOURCE_DIR) {
if ($DO_DEBUG) {
Write-Output "Codebase ($FILTER_SOURCE_DIR) built successfully."
}
} else {
if ($DO_DEBUG) {
Write-Output "There was a problem installing dependencies for ($FILTER_SOURCE_DIR)."
}
exit 1
}
}
if ($DO_DEBUG) {
Write-Output "###########################"
}
}

exit 0
45 changes: 45 additions & 0 deletions hooks/pre_deploy_hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
# Shell script for ask-cli pre-deploy hook for Node.js
# Script Usage: pre_deploy_hook.sh <SKILL_NAME> <DO_DEBUG> <TARGET>

# SKILL_NAME is the preformatted name passed from the CLI, after removing special characters.
# DO_DEBUG is boolean value for debug logging
# TARGET is the deploy TARGET provided to the CLI. (eg: all, skill, lambda etc.)

# Run this script under skill root folder

# The script does the following:
# - Run "npm install" in each sourceDir in skill.json

SKILL_NAME=$1
DO_DEBUG=${2:-false}
TARGET=${3:-"all"}

if [ $DO_DEBUG == false ]
then
exec > /dev/null 2>&1
fi

install_dependencies() {
npm install --prefix "$1" >/dev/null 2>&1
return $?
}

echo "###########################"
echo "##### pre-deploy hook #####"
echo "###########################"

if [[ $TARGET == "all" || $TARGET == "lambda" ]]; then
grep "sourceDir" ./skill.json | cut -d: -f2 | sed 's/"//g' | sed 's/,//g' | while read -r SOURCE_DIR; do
if install_dependencies $SOURCE_DIR; then
echo "Codebase ($SOURCE_DIR) built successfully."
else
echo "There was a problem installing dependencies for ($SOURCE_DIR)."
exit 1
fi
done
echo "###########################"
fi

exit 0

Loading

0 comments on commit 2e03af4

Please sign in to comment.