Martin Costello
Martin Costello

Reputation: 10862

Integrating Apple Pay JS Into A Website

I'm looking into integrating Apple Pay into a website using the new Apple Pay JS SDK. The documentation is currently pretty minimal, concerning just the API declarations and how to instantiate a new ApplePaySession object.

Is there any example code available yet, or has anyone actually implemented this themselves yet, showing the typical API integration flow for a web application?

The only examples I've been able to find anything for all appear to be for third-party payment providers' own SDK integrations of Apple Pay.

Upvotes: 29

Views: 31042

Answers (3)

Martin Costello
Martin Costello

Reputation: 10862

The integration I've been working on has now finally been released, and there's a blog post I've written to go along with it as well as a GitHub project with an example integration using ASP.NET Core.

I hope others doing an Apple Pay JS integration themselves find it useful.

Upvotes: 8

Stu Cartwright
Stu Cartwright

Reputation: 376

I've published end-to-end ApplePayJS example code on github here

https://github.com/norfolkmustard/ApplePayJS

It uses PHP for the server-side part, needed for the initial vendor validation to begin the transaction. The rest is in javascript.

ApplePayJS != cash in the bank, just a means of getting a tokenised credit card from a customer. You hand that card number off to a third-party payment processor like stripe.com, braintreepayments.com, authorize.net

Cheers

Upvotes: 34

Eugene Hauptmann
Eugene Hauptmann

Reputation: 1279

The stable release will be available this fall probably.

First thing you want to do is to ensure that API is available in your browser:

if(ApplePaySession)
   ApplePaySession.canMakePayments()

Then the transaction itself:

var request = {
  countryCode: 'US',
  currencyCode: 'USD',
  supportedNetworks: ['visa', 'masterCard'],
  merchantCapabilities: ['supports3DS'],
  total: { label: 'Your Label', amount: '10.00' },
}
var session = new ApplePaySession(1, request);

This is from official website how to get it started: https://developer.apple.com/reference/applepayjs/applepaysession

After you have the session, you can control it: enter image description here

And you can listen to events, and change your flow based on it: enter image description here

I'm working on the integration between Apple Pay JS and Stripe API right now, so I'll release draft version to GitHub this summer.

Upvotes: 9

Related Questions