akandaurov / react-native-apple-payment

Apple Pay for React Native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-native-apple-payment

Apple Pay implementation for React Native (Only IOS)

img1 img2 img3

Installation

yarn add react-native-apple-payment

cd ios && pod install

Usage

Types

type Network = 'Visa' | 'MasterCard' | 'AmEx';

export type SupportedNetworks = Network[];

export interface MethodData {
    countryCode: string;
    currencyCode: string;
    supportedNetworks: SupportedNetworks;
    merchantIdentifier: string;
}

export interface Detail {
    label: string;
    amount: number;
}

export interface DetailsData {
    items?: Detail[];
    total: Detail;
}

export type ApplePayResponse = {
    paymentData: string;
    paymentMethod: {
        displayName: string;
        network: string;
        type: string;
    };
};

Code

import ApplePay, { MethodData, DetailsData, ApplePayResponse } from "react-native-apple-payment";

const payment = new ApplePay(method as MethodData, details as DetailsData);

const canMakePayment: boolean = await payment.canMakePayments()

const paymentResponse: ApplePayResponse = await payment.initApplePay()

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

About

Apple Pay for React Native

License:MIT License


Languages

Language:Ruby 33.0%Language:Swift 26.8%Language:Objective-C 17.8%Language:JavaScript 13.5%Language:TypeScript 8.2%Language:C 0.7%