@tap-payments/apple-pay-button 0.0.11-test → 0.0.12-test

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { Scope, ButtonStyle, MerchantCapabilities, SupportedNetworks } from '../constants';
1
+ import { Scope, ButtonStyle, MerchantCapabilities, SupportedNetworks, ButtonType, Locale } from '../constants';
2
2
  export interface ApplePayRequestData {
3
3
  countryCode: string;
4
4
  currencyCode: string;
@@ -47,6 +47,8 @@ export interface ApplePayButtonProps {
47
47
  onSuccess?: (data: Record<string, any>) => Promise<void>;
48
48
  onClick?: () => void;
49
49
  metaData?: ProfileResponse;
50
+ type?: typeof ButtonType[keyof typeof ButtonType];
51
+ locale?: typeof Locale[keyof typeof Locale];
50
52
  }
51
53
  export interface MerchantResponse {
52
54
  id: string;
@@ -7,6 +7,19 @@ export declare const ButtonStyle: {
7
7
  readonly White: "white";
8
8
  readonly WhiteOutline: "whiteOutline";
9
9
  };
10
+ export declare const Locale: {
11
+ readonly EN: "en";
12
+ readonly AR: "ar";
13
+ readonly FR: "fr";
14
+ };
15
+ export declare const ButtonType: {
16
+ readonly BOOK: "book";
17
+ readonly BUY: "buy";
18
+ readonly CHECK_OUT: "check-out";
19
+ readonly PAY: "pay";
20
+ readonly PLAIN: "plain";
21
+ readonly SUBSCRIBE: "subscribe";
22
+ };
10
23
  export declare const MerchantCapabilities: {
11
24
  readonly Supports3DS: "supports3DS";
12
25
  readonly SupportsCredit: "supportsCredit";
@@ -24,3 +37,4 @@ export declare const SupportedNetworks: {
24
37
  readonly Maestro: "maestro";
25
38
  };
26
39
  export declare const ApplePayVersion = 5;
40
+ export declare const ApplePaySDK = "https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js";
@@ -7,6 +7,19 @@ export var ButtonStyle = {
7
7
  White: 'white',
8
8
  WhiteOutline: 'whiteOutline'
9
9
  };
10
+ export var Locale = {
11
+ EN: 'en',
12
+ AR: 'ar',
13
+ FR: 'fr'
14
+ };
15
+ export var ButtonType = {
16
+ BOOK: 'book',
17
+ BUY: 'buy',
18
+ CHECK_OUT: 'check-out',
19
+ PAY: 'pay',
20
+ PLAIN: 'plain',
21
+ SUBSCRIBE: 'subscribe'
22
+ };
10
23
  export var MerchantCapabilities = {
11
24
  Supports3DS: 'supports3DS',
12
25
  SupportsCredit: 'supportsCredit',
@@ -24,3 +37,4 @@ export var SupportedNetworks = {
24
37
  Maestro: 'maestro'
25
38
  };
26
39
  export var ApplePayVersion = 5;
40
+ export var ApplePaySDK = 'https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js';
@@ -1,51 +1,7 @@
1
- .button-applepay-tap {
2
- appearance: none;
3
- border: none;
4
- cursor: pointer;
5
- -webkit-user-select: none;
6
- user-select: none;
7
- display: flex;
8
- position: relative;
9
- -webkit-box-pack: center;
10
- -ms-flex-pack: center;
11
- -webkit-justify-content: center;
12
- justify-content: center;
13
- -webkit-align-items: center;
14
- -webkit-box-align: center;
15
- -ms-flex-align: center;
16
- align-items: center;
17
- -webkit-margin-end: 8px;
18
- margin-inline-end: 8px;
19
- min-width: 96px;
20
- max-width: 300px;
21
- min-height: 40px;
22
- border-radius: 9px;
23
- background-color: white;
24
- width: 100%;
25
- }
26
-
27
- .button-applepay-tap:disabled {
28
- cursor: default;
29
- }
30
-
31
- .img-container {
32
- height: 24px;
33
- max-width: 80px;
34
- }
35
-
36
- .img-container img {
37
- height: 100%;
38
- width: 100%;
39
- transform: scale(1.5);
40
- filter: invert(0);
41
- }
42
-
43
- .whiteOutline {
44
- border: solid 1px gray;
45
- }
46
- .black {
47
- background-color: black;
48
- }
49
- .black .img-container img {
50
- filter: invert(1);
1
+ apple-pay-button {
2
+ display: block;
3
+ --apple-pay-button-width: 100%;
4
+ --apple-pay-button-height: 48px;
5
+ --apple-pay-button-border-radius: 5px;
6
+ --apple-pay-button-padding: 0px 0px;
51
7
  }
@@ -2,5 +2,12 @@
2
2
  import { ApplePayButtonProps } from '../../@types';
3
3
  import './ApplePayButton.css';
4
4
  export type { ApplePayButtonProps };
5
+ declare global {
6
+ namespace JSX {
7
+ interface IntrinsicElements {
8
+ 'apple-pay-button': unknown;
9
+ }
10
+ }
11
+ }
5
12
  export declare function ApplePayButton(props: ApplePayButtonProps): JSX.Element;
6
13
  export declare const renderApplePayButton: (props: ApplePayButtonProps, elementId: string) => any;
@@ -10,15 +10,17 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
- import React from 'react';
13
+ import * as React from 'react';
14
14
  import { createRoot } from 'react-dom/client';
15
15
  import { findOrCreateElementAndInject } from '../../utils';
16
16
  import { useApplePay } from '../../hooks/useApplePay';
17
- import { ButtonStyle, Scope } from '../../constants';
17
+ import { ApplePaySDK, ButtonStyle, ButtonType, Locale, Scope } from '../../constants';
18
18
  import './ApplePayButton.css';
19
+ import { useScript } from '../../hooks';
19
20
  var ApplePay = React.memo(function (_a) {
20
- var publicKey = _a.publicKey, merchant = _a.merchant, transaction = _a.transaction, billingContact = _a.billingContact, supportedNetworks = _a.supportedNetworks, onCancel = _a.onCancel, onError = _a.onError, onSuccess = _a.onSuccess, onClick = _a.onClick, _b = _a.scope, scope = _b === void 0 ? Scope.TapToken : _b, _c = _a.buttonStyle, buttonStyle = _c === void 0 ? ButtonStyle.WhiteOutline : _c, metaData = _a.metaData;
21
- var _d = useApplePay({
21
+ var publicKey = _a.publicKey, merchant = _a.merchant, transaction = _a.transaction, billingContact = _a.billingContact, supportedNetworks = _a.supportedNetworks, onCancel = _a.onCancel, onError = _a.onError, onSuccess = _a.onSuccess, onClick = _a.onClick, metaData = _a.metaData, _b = _a.scope, scope = _b === void 0 ? Scope.TapToken : _b, _c = _a.buttonStyle, buttonStyle = _c === void 0 ? ButtonStyle.WhiteOutline : _c, _d = _a.type, type = _d === void 0 ? ButtonType.PLAIN : _d, _e = _a.locale, locale = _e === void 0 ? Locale.EN : _e;
22
+ useScript(ApplePaySDK);
23
+ var _f = useApplePay({
22
24
  publicKey: publicKey,
23
25
  merchant: merchant,
24
26
  transaction: transaction,
@@ -29,11 +31,11 @@ var ApplePay = React.memo(function (_a) {
29
31
  onCancel: onCancel,
30
32
  scope: scope,
31
33
  metaData: metaData
32
- }), loading = _d.loading, onApplePayButtonClicked = _d.onApplePayButtonClicked, disabled = _d.disabled;
33
- return (_jsx("button", __assign({ className: "button-applepay-tap ".concat(buttonStyle), onClick: function () {
34
+ }), loading = _f.loading, onApplePayButtonClicked = _f.onApplePayButtonClicked, disabled = _f.disabled;
35
+ return (_jsx("apple-pay-button", { onClick: function () {
34
36
  onApplePayButtonClicked();
35
37
  onClick === null || onClick === void 0 ? void 0 : onClick();
36
- }, disabled: loading || disabled }, { children: _jsx("div", __assign({ className: 'img-container' }, { children: _jsx("img", { loading: 'eager', src: 'https://back-end.b-cdn.net/payment_methods/apple_pay.svg' }) })) })));
38
+ }, disabled: loading || disabled, buttonstyle: buttonStyle, type: type, locale: locale }));
37
39
  });
38
40
  export function ApplePayButton(props) {
39
41
  return _jsx(ApplePay, __assign({}, props));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/apple-pay-button",
3
- "version": "0.0.11-test",
3
+ "version": "0.0.12-test",
4
4
  "description": "Apple Pay Button React Component",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.js",