Code Monkey home page Code Monkey logo

applepayjssample's Introduction

Apple Pay JS Example Integration

This repository contains a sample implementation of Apple Pay JS using ASP.NET Core written in C# and JavaScript.

Overview

Apple Pay JS is a way of accepting Apple Pay in websites using Safari in either iOS 10 and macOS for users who have a TouchID compatible device.

This example integration shows a minimal sample of how to integrate Apple Pay into a webpage to obtain an Apple Pay token that can be used to capture funds for a user for goods and services.

The key components to look at for the implementation are:

  • src\ApplePayJS\Views\Home\Index.cshtml - The view that renders the Apple Pay button.
  • src\ApplePayJS\wwwroot\css\site.css - The CSS used to style the Apple Pay button.
  • src\ApplePayJS\wwwroot\js\site.js - The JavaScript that performs the majority of the Apple Pay functionality.
  • src\ApplePayJS\Controllers\HomeController.cs - The controller that performs the POST to the Apple Pay service to verify a merchant session.

Setup

To setup the repository to run the sample, perform the steps below:

  1. Fork this repository.
  2. Clone the repository from your fork to your local machine: git clone https://github.com/{username}/ApplePayJSSample.git
  3. Follow the steps to obtain your Apple Pay Merchant ID, Payment Processing Certificate, Domain Verification file and Merchant Identity Certificate if you do not already have them.
  4. Place the Domain Verification file (apple-developer-merchantid-domain-association) in the src\ApplePayJS\wwwroot\.well-known folder.
  5. Generate a .pfx file from your Merchant Identity Certificate (merchant_id.cer, which is the public key) and the Certificate Signing Request (your_file_name.csr, which is the private key) that you used to generate it.
  6. Either add your .pfx file to the root of the application in src\ApplePayJS (but not in the wwwroot folder) or install it into the local certificate store.
  7. Update the Apple touch icon (src\ApplePayJS\wwwroot\apple-touch-icon.png) and favicon (src\ApplePayJS\wwwroot\favicon.ico) to your own designs.
  8. Configure the following settings as appropriate in either your environment variables or in src\ApplePayJS\appsettings.json: * ApplePay:StoreName * ApplePay:UseCertificateStore * ApplePay:MerchantCertificateThumbprint or ApplePay:MerchantCertificateFileName
  9. Configure the following setting in either your environment variables, your user secrets or in src\ApplePayJS\appsettings.json (not recommended) if loading the .pfx file from disk (i.e. ApplePay:UseCertificateStore=false): * ApplePay:MerchantCertificatePassword
  10. Deploy the application to the hosting environment for the domain where you wish to use Apple Pay JS.
  11. Verify the domain in the Apple Developer Portal.

You should now be able to perform Apple Pay JS transactions on the deployed application.

Feedback

Any feedback or issues can be added to the issues for this project in GitHub.

License

This project is licensed under the Apache 2.0 license.

External Links

applepayjssample's People

Contributors

martincostello avatar

Watchers

Mathieu Agee avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.