amzn/swa-sample-seller

Name: swa-sample-seller

Owner: Amazon

Description: Sample website demonstrating how to use LWA and SWA APIs

Created: 2016-08-17 22:27:58.0

Updated: 2017-06-03 06:52:16.0

Pushed: 2018-03-13 18:44:28.0

Homepage: null

Size: 576

Language: Java

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

WARNING

Subscribe with Amazon (SWA) Sample Seller

Sample Seller is a sample web application storefront that uses LWA and SWA APIs.

Screenshot of login page

Screenshot of subscriptions page

Before you start
Install dependencies
  1. Install Java Development Kit (JDK) 8.
  2. Verify installation by running javac from your terminal.
  3. Install Apache Maven.
  4. Verify installation by running mvn from your terminal.
Edit src/main/resources/config.json
  1. Retrieve your Client ID and Client Secret Key from the Technical Details of your product.
  2. Set clientId to your client ID.
  3. Set clientSecret to your client secret.
  4. Set detailPageUrl to the URL for the detail page of your product.
  5. Set port to an open port you want to serve Sample Seller on.
  6. Ex: 8444
  7. Set redirectUri to https://127.0.0.1:port/login
  8. Ex: https://127.0.0.1:8444/login
  9. In Sample Seller, we want LWA to redirect the user to the /login path so Sample Seller can query and display the user's subscriptions information.
  10. Set logoutRedirectUri to https://127.0.0.1:port.\
  11. Ex: https://127.0.0.1:8444
  12. In Sample Seller, we want to redirect the uselr to the landing page.
Configure your LWA application. [2.4]
  1. Sign into the App Console at http://login.amazon.com/manageApps.
  2. Select the LWA application associated with your SWA subscription.
  3. Expand the “Web Settings” tab.
  4. Add https://127.0.0.1:port to “Allowed JavaScript Origins”
  5. Ex: https://127.0.0.1:8444
  6. Add redirectUri to “Allowed Return URLs”.
  7. Ex: https://127.0.0.1:8444/login
Build Sample Seller
ath/to/repo    # Switch to the repo root directory.
package        # Build the program with Maven.
Run Sample Seller
  1. Run the JAR file to start the web application:

    ath/to/repo                                         # Switch to the repo root directory.
     -jar target/swa_sample_seller-1.0-SNAPSHOT.jar     # Run the JAR file.
    
  2. Visit the application at https://127.0.0.1:port

  3. Ex https://127.0.0.1:8444

Take a tour of Sample Seller
  1. Visit the index page at https://127.0.0.1:port.
  2. Ex: https://127.0.0.1:8444
  3. Click the Login with Swanly button.
  4. Click the LWA button and login with an Amazon account that has not purchased your subscription.
  5. Verify that you see a Subscribe Now button.
  6. Expand the Information for developers tab.
  7. Scroll to the bottom
  8. Verify that you do not see any ACTIVE subscriptions in the Subscriptions Response body.
  9. Logout.
  10. Click the LWA button and login with an Amazon account that has purchased your subscription.
  11. Verify that you see at least 1 ACTIVE subscriptions in the Subscriptions Response body.
View code snippets

SWA Sample Push Notification Endpoint

Sample Push Notification Endpoint is a collection of services running on Amazon Web Services (AWS) that implement an endpoint to catch SWA push notifications.

You do not have to use AWS to implement your endpoint. See the FAQ section for more information.

Setup Python
  1. Install Python 2 or Python 3 from https://www.python.org/downloads/

  2. Verify your installation by running python and pip from your terminal.

  3. Install the Python boto3 library:

    install boto3
    
Setup AWS
  1. Create an AWS account at https://aws.amazon.com/
  2. Create an IAM user named swa_sample_seller with the AdministratorAccess permission.
  3. See http://docs.aws.amazon.com/lambda/latest/dg/setting-up.html
  4. Make note of your access key ID and access key secret.
Edit src/main/resources/config.json
  1. Set awsAccessKeyId to your user's access key ID.
  2. Set awsSecretAccessKey to your user's secret access key.
  3. [Optional] Change awsResourcesName to a name of your choice.
    • Ex: sample_seller_resources
    • All AWS resources will be created with this name.
    • Use a name that will be easy to find in your AWS console.
  4. [Optional] Change awsRegionName
    • See http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html
Create a sample endpoint to catch push notifications
  1. Run:

    ath/to/repo
    on src/main/python/aws_create.py
    
  2. Make note of the endpoint printed out by the script.

  3. Ex: Your push notification endpoint is YOUR_ENDPOINT

Console output of running aws_create.py

Send a test notification [4.2.5]
  1. Visit https://sellercentral.amazon.com/swa/dashboard.
  2. Edit the Technical Details of your product.
  3. Continue to the Push Notifications page.
  4. Set the Enter your HTTPS endpoint field to YOUR_ENDPOINT
  5. Click Send Test Notification.
View the test notification
  1. In your DynamoDB dashboard, view the Table with the name of your awsResourcesName field.
  2. View the Items of the table.
  3. Verify that there is an entry for the test push notification you just sent.
View a real push notification
  1. Purchase / Renew / Cancel your subscription.
  2. View the table in your DynamoDB dashboard.
Delete your sample endpoint

Run:

ath/to/repo
on src/main/python/aws_delete.py

Console output of running aws_delete.py

View code snippets

FAQ


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.