The Pay with Amazon Application by Mozu uses the Arc.js framework to create custom actions that enable the use of the Amazon Payments service on the Mozu platform. This app uses the Amazon Marketplace Web Service (MWS) API to connect Mozu with Amazon.
Note: The code in this repository is provided for reference purposes only. If you are a Mozu customer and want to enable Pay with Amazon functionality on your storefront, you can simply install the Pay with Amazon Application by Mozu from the Mozu App Marketplace and integrate the required theme changes.
This application is implemented using a hosted workflow that protects a merchant from having to share their AWS Secret Key. Amazon requires that merchants never share their Secret Key, and provides the MWS Authorization Token as an alternative method for third-party application developers to access a client’s MWS account. The merchant-flow branch of this repo shows an alternative implementation that in-house application developers can use.
In order to work with Arc.js, you'll need to have:
- A Developer Account at mozu.com
- Arc.js enabled on your Mozu tenant. (Contact your sales or professional services representative for more information.)
- NodeJS
- The following global NPM packages installed
yo
grunt-cli
generator-mozu-app
You can install all of the required NPM packages at once by running the following command in your Terminal (OS X) or Command Prompt (Windows):
npm i -g yo grunt-cli generator-mozu-app
-
First, clone this repository to a folder on your development machine:
$ git clone https://github.com/Mozu/PayWithAmazon.git Cloning into './PayWithAmazon'... done.
-
Log in to the Mozu Developer Center and create a new app. Call it "PayWithAmazon". Make a note of its Application Key.
-
Now you're prepared to generate your upload configuration! Have on hand:
- The application key for the app you just created
- Your Developer Center login
Got those? OK, in your
PayWithAmazon
directory you cloned from Git, run:
$ yo mozu-app --config
You will be prompted to enter all the necessary information.
-
Once that is complete, you should be able to run
npm install
:$ npm install
to download the necessary dependencies.
-
You're ready to sync! Run
grunt
:$ grunt
to upload the actions to Developer Center. Or, if you want grunt to detect when you change files and upload continuously as you work, run:
$ grunt watch
Now that you've uploaded the code to your PayWithAmazon app, it's ready to install in your sandbox!
- In Mozu Dev Center, go to Develop > Applications and double-click the app.
- On the app details page, click Install.
- Select your sandbox in the dialog that appears and click OK.
If the install process fails at this point, check with Mozu Support to make sure that the Arc.js framework is enabled for your sandbox.
In the sandbox where you installed the app, go to Settings > Payment & Checkout.
You should see a new option for PayWithAmazon. Enable the checkbox to view the Amazon configuration settings. Pay with Amazon requires the following default settings for the app to work:
- SellerId
- Client Id
- Application Id
- MWS Auth Token
- AWS Region
- Order Processing
These settings are defined in the following file in your application:
assets/src/domains/platform.applications/embedded.platform.applications.install.js
You can modify this file to add additional settings.
Installing and configuring the Pay with Amazon app enables you to accept payments via Amazon Payments. However, you still must enable Pay with Amazon functionality on your storefront so that customers can use it. Go to the PayWithAmazon-Theme repository and follow the instructions in the readme to merge Pay with Amazon functionality with your Mozu theme.
The following are the actions for which embedded.commerce.payments.action.performPaymentInteraction is invoked:
- CreatePayment
- AuthorizePayment
- CapturePayment
- CreditPayment
- DeclinePayment
- Rollback
- VoidPayment
After the payment interaction has been processed, one of the following states can be passed back to the system:
- Authorized
- Captured
- Declined
- Failed (set this state to terminate payment flow)
- Voided
- Credited
- New
- RolledBack