1.0.17 • Published 2 months ago

@tap-payments/apple-pay-button v1.0.17

Weekly downloads
-
License
ISC
Repository
-
Last release
2 months ago

apple-pay-button

Handling Apple Pay button in React and vanilla JS

Install

This is a React module available through the npm registry. Installation is done using the npm install command:

npm install @tap-payments/apple-pay-button

---------------------------- OR -------------------------

yarn add @tap-payments/apple-pay-button

Examples

ES6

import React from 'react'
import { ApplePayButton, ButtonStyle, SupportedNetworks, Scope } from '@tap-payments/apple-pay-button'

const App = () => {
	return (
		<ApplePayButton
			// required (The public Key provided by Tap)
			publicKey={'pk_test_xxxxxxxxxxxxxxxzh'}
			// required
			merchant={{
				// required (The merchant domain name)
				domain: 'example.com',
				// optional (The merchant identifier provided by Tap)
				id: '1xxxxx8'
			}}
			// required
			transaction={{
				// required (The amount to be charged)
				amount: '12',
				// required (The currency of the amount)
				currency: 'KWD'
			}}
			// optional (The scope of the SDK and it can be one of these scopes:
			// [TapToken,AppleToken], by default it is TapToken)
			scope={Scope.TapToken}
			// optional (The supported networks for the Apple Pay button and it
			// can be one of these networks: [Mada,Visa,MasterCard], by default
			// we bring all the supported networks from tap merchant configuration)
			supportedNetworks={[SupportedNetworks.Mada, SupportedNetworks.Visa, SupportedNetworks.MasterCard]}
			// optional (The style of the Apple Pay button and it can be one of
			// these styles: [White,WhiteOutline,Black], by default it is WhiteOutline)
			buttonStyle={ButtonStyle.WhiteOutline}
			// optional (The billing contact information)
			billingContact={{
				// required
				email: {
					// required
					address: 'test@gmail.com'
				},
				// required
				name: {
					// required
					first: 'test',
					// required
					last: 'tester',
					// optional
					middle: 'test'
				},
				// required
				phone: {
					number: '10XXXXXX56',
					code: '+20'
				}
			}}
			// optional (A callback function that will be called when you cancel
			// the payment process)
			onCancel={() => console.log('cancelled')}
			// optional (A callback function that will be called when you have an error)
			onError={(err) => console.error(err)}
			// optional (A async function that will be called after creating the token
			// successfully)
			onSuccess={async (token) => {
				// do your stuff here...
				console.log(token)
			}}
		/>
	)
}

Vanilla JS

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>apple pay button</title>
		<link rel="stylesheet" href="https://apple-pay-button.b-cdn.net/build-0.0.8-test/main.css" />
		<script src="https://apple-pay-button.b-cdn.net/build-0.0.8-test/main.js"></script>
	</head>
	<body>
		<div id="apple-pay-button"></div>
		<script type="text/javascript">
			const { renderApplePayButton, ButtonStyle, Scope, SupportedNetworks } = window.TapSDKs
			renderApplePayButton(
				{
					// required
					publicKey: 'pk_test_xxxxxxxxxxxxxxxzh',
					// required
					merchant: {
						// required
						domain: 'example.com'
						// optional
						// id: '123...'
					},
					// required
					transaction: {
						// required
						currency: 'USD',
						// required
						amount: '100'
					},
					// optional
					scope: Scope.TapToken,
					// optional
					buttonStyle: ButtonStyle.WhiteOutline,
					// optional
					supportedNetworks: [SupportedNetworks.Visa, SupportedNetworks.MasterCard],
					// optional (The billing contact information)
					billingContact: {
						// required
						email: {
							// required
							address: 'test@gmail.com'
						},
						// required
						name: {
							// required
							first: 'test',
							// required
							last: 'tester',
							// optional
							middle: 'test'
						},
						// required
						phone: {
							number: '10XXXXXX56',
							code: '+20'
						}
					},
					// optional
					onCancel: () => {
						console.log('onCancel')
					},
					// optional
					onError: (error) => {
						console.log('onError', error)
					},
					// optional
					onSuccess: async (data) => {
						console.log('onSuccess', data)
					}
				},
				'apple-pay-button'
			)
		</script>
	</body>
</html>

Configurations

NameTypeR/ODescription
publicKeystringrequiredThe public Key provided by Tap
merchant.idstringoptionalThe merchant identifier provided by Tap
merchant.domainstringrequiredThe merchant domain name
transaction.amountstringrequiredThe amount to be charged
transaction.currencystringrequiredThe currency of the amount
scopeScopeoptionalThe scope of the SDK
supportedNetworksSupportedNetworks[]optionalThe supported networks for the Apple Pay button
buttonStyleButtonStyleoptionalThe style of the Apple Pay button
billingContactBillingContactoptionalThe billing contact information
onCancelfunctionoptionalA callback function that will be called when you cancel the process
onErrorfunctionoptionalA callback function that will be called when you have an error
onSuccessfunctionoptionalA async function that will be called after creating the token successfully
0.0.68-development

2 months ago

1.0.17

4 months ago

1.0.16

4 months ago

1.0.15

4 months ago

0.0.67-development

5 months ago

0.0.66-development

5 months ago

0.0.65-development

5 months ago

0.0.64-development

5 months ago

0.0.63-development

6 months ago

0.0.62-development

6 months ago

0.0.61-development

6 months ago

0.0.60-development

6 months ago

0.0.59-development

6 months ago

0.0.57-development

6 months ago

0.0.58-development

6 months ago

0.0.56-development

6 months ago

0.0.51-development

6 months ago

0.0.27-test

11 months ago

0.0.40-development

6 months ago

0.0.41-development

6 months ago

0.0.35-test

9 months ago

0.0.52-development

6 months ago

0.0.32-test

10 months ago

0.0.53-development

6 months ago

0.0.42-development

6 months ago

0.0.50-development

6 months ago

0.0.48-development

6 months ago

0.0.49-development

6 months ago

0.0.30-test

10 months ago

0.0.26-test

11 months ago

0.0.36-test

7 months ago

0.0.45-development

6 months ago

0.0.43-development

6 months ago

0.0.46-development

6 months ago

0.0.47-development

6 months ago

0.0.31-test

10 months ago

0.0.28-test

10 months ago

0.0.34-test

10 months ago

0.0.37-development

6 months ago

0.0.38-development

6 months ago

0.0.33-test

10 months ago

0.0.29-test

10 months ago

0.0.55-development

6 months ago

0.0.54-development

6 months ago

1.0.11

10 months ago

0.0.39-development

6 months ago

1.0.14

7 months ago

1.0.13

9 months ago

1.0.12

9 months ago

1.0.9

11 months ago

1.0.8

11 months ago

0.0.25-test

11 months ago

1.0.10

11 months ago

0.0.24-test

11 months ago

1.0.7

12 months ago

1.0.6

1 year ago

1.0.5

1 year ago

0.0.23-test

12 months ago

0.0.20-test

1 year ago

0.0.22-test

12 months ago

0.0.21-test

1 year ago

0.0.19-test

1 year ago

1.0.2

1 year ago

0.0.16-test

1 year ago

1.0.4

1 year ago

0.0.12-test

1 year ago

0.0.17-test

1 year ago

0.0.11-test

1 year ago

0.0.14-test

1 year ago

0.0.18-test

1 year ago

0.0.1

1 year ago

0.0.15-test

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.13-test

1 year ago

0.0.9-test

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.1-test

1 year ago

0.0.6-test

1 year ago

0.0.7-test

1 year ago

0.0.3-test

1 year ago

0.0.4-test

1 year ago

0.0.5-test

1 year ago

0.0.10-test

1 year ago

0.0.8-test

1 year ago

0.0.2-test

1 year ago

0.0.0-test

1 year ago