Giter Site home page Giter Site logo

javorosas / react-native-apay Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sorokin0andrey/react-native-apay

0.0 0.0 0.0 2.76 MB

React Native bridge for Apple Pay

JavaScript 22.99% Ruby 12.96% Objective-C 39.34% Java 5.83% TypeScript 10.30% Starlark 8.57%

react-native-apay's Introduction

react-native-apay

react-native version npm npm (tag)

Accept Payments with Apple Pay for React Native apps.


Getting started

$ yarn add react-native-apay

Linking

>= 0.60

Autolinking will just do the job.

< 0.60

Mostly automatic installation

$ react-native link react-native-apay

CocoaPods

Link using Cocoapods by adding this to your Podfile:

pod 'RNApplePay', :path => '../node_modules/react-native-apay'

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-apay and add RNApplePay.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNApplePay.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Usage

import { ApplePay } from 'react-native-apay';

const requestData = {
  merchantIdentifier: 'merchant.com.example',
  supportedNetworks: ['mastercard', 'visa'],
  countryCode: 'US',
  currencyCode: 'USD',
  paymentSummaryItems: [
    {
      label: 'Item label',
      amount: '100.00',
    },
  ],
}

// Check if ApplePay is available
if (ApplePay.canMakePayments) {
  ApplePay.requestPayment(requestData)
    .then((paymentData) => {
      console.log(paymentData);
      // Simulate a request to the gateway
      setTimeout(() => {
        // Show status to user ApplePay.SUCCESS || ApplePay.FAILURE
        ApplePay.complete(ApplePay.SUCCESS)
          .then(() => {
            console.log('completed');
            // do something
          });
      }, 1000);
    });
};

Demo

You can run the demo by cloning the project and running:

$ yarn demo

react-native-apay's People

Contributors

sorokin0andrey avatar isokolovskii avatar thorsteinsson avatar dependabot[bot] avatar matwming 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.