Craft Commerce payment method using Amazon Pay

I’ve been doing some work recently with Craft CMS, and its ecommerce plugin Craft Commerce.  Although Craft is still up-and-coming, it’s doing quite well.  The community is great, and I love working with it.  Craft itself is quite extensible, and Commerce is progressing in that aspect.  A recent project called for a lot of customization of Commerce, and I ended up creating quite a few plugins to handle third-party integrations.

One such instance was to integrate Amazon Pay as a new payment method in Commerce.  This had not been done by anyone else to this point, and more than a few clients/developers had asked if someone knew of an existing solution.  After a lot of work, I completed the plugin, and I am making it available for purchase here.

How It Works

There are actually two parts to Amazon Pay. The first is using Login With Amazon to have the customer authenticate with their Amazon account, and the second is using Amazon Pay itself to handle shipping address and payment method selection and, finally, process their payment. In Craft Commerce, there are several ways that payment methods can be used. They can work via forms directly on your site, redirect off-site(think PayPal). The plugin I created keeps the customer on-site.

Amazon Pay Button Sample

The pay button displayed on the cart page. Upon click, customers log in to their Amazon account and are redirected to the payment page to complete their purchase. All of this happens on site.

On the cart page, the customer is presented with the Amazon Pay button as an available payment method. When click, this button creates a popup that authenticates the user and logs them in to their Amazon account. Next, the customer is redirected to a custom page that displays Amazon Pay “widgets”. These widgets let the customer choose from their saved shipping addresses and credit cards stored in their Amazon account. When they’ve selected from both, they click “Pay Now”, and their order is processed. Commerce uses Omnipay to abstract payment methods, so the actual processing code is straightforward.

Amazon Pay Page

These widgets are used by the customer to complete their purchase on your site. After the customer pays, they are redirected to the standard receipt page for Craft Commerce.

Plugin Settings

To offer Amazon Pay to your customers, go to https://pay.amazon.com/us/ to sign up. Once you’ve been accepted, you’ll need to log in to Seller Central to retrieve credentials for this plugin. You need values for Login With Amazon and Amazon Pay. For the initial release, there are additional plugin settings for the Amazon Pay button type, color, and size. There’s also an option to block international payments.

What’s Next?

I’d like to add options for Commerce customer creation and email handling. If after purchasing you need any assistance installing or configuring the plugin or require specific customizations made to it, please contact me.

About

Web Developer

4 Comments

Add Your Thoughts

Your email address will not be published. Required fields are marked *