@tap-payments/apple-pay-button 1.0.1 → 1.0.2-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.
Files changed (38) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +240 -194
  3. package/build/@types/ApplePaySession.d.ts +67 -0
  4. package/build/@types/ApplePaySession.js +1 -0
  5. package/build/@types/index.d.ts +118 -73
  6. package/build/@types/index.js +1 -1
  7. package/build/api/app.service.d.ts +23 -11
  8. package/build/api/app.service.js +253 -217
  9. package/build/api/base.d.ts +9 -9
  10. package/build/api/base.js +45 -45
  11. package/build/api/httpClient.d.ts +8 -2
  12. package/build/api/httpClient.js +33 -16
  13. package/build/constants/index.d.ts +59 -26
  14. package/build/constants/index.js +59 -26
  15. package/build/features/ApplePayButton/ApplePayButton.css +10 -40
  16. package/build/features/ApplePayButton/ApplePayButton.d.ts +7 -6
  17. package/build/features/ApplePayButton/ApplePayButton.js +65 -51
  18. package/build/features/ApplePayButton/index.d.ts +3 -3
  19. package/build/features/ApplePayButton/index.js +2 -2
  20. package/build/hooks/index.d.ts +1 -1
  21. package/build/hooks/index.js +1 -1
  22. package/build/hooks/useApplePay.d.ts +10 -9
  23. package/build/hooks/useApplePay.js +342 -197
  24. package/build/hooks/useGetEvents.d.ts +4 -0
  25. package/build/hooks/useGetEvents.js +15 -0
  26. package/build/hooks/useScript.d.ts +1 -1
  27. package/build/hooks/useScript.js +39 -39
  28. package/build/index.d.ts +4 -4
  29. package/build/index.js +15 -9
  30. package/build/utils/config.d.ts +13 -9
  31. package/build/utils/config.js +76 -54
  32. package/build/utils/defaultValues.d.ts +32 -0
  33. package/build/utils/defaultValues.js +48 -0
  34. package/build/utils/html.d.ts +1 -1
  35. package/build/utils/html.js +9 -9
  36. package/build/utils/index.d.ts +1 -1
  37. package/build/utils/index.js +1 -1
  38. package/package.json +4 -2
@@ -1,73 +1,118 @@
1
- import { Scope, ButtonStyle, MerchantCapabilities, SupportedNetworks } from '../constants';
2
- export interface ApplePayRequestData {
3
- countryCode: string;
4
- currencyCode: string;
5
- merchantCapabilities: Array<typeof MerchantCapabilities[keyof typeof MerchantCapabilities]>;
6
- supportedNetworks: Array<typeof SupportedNetworks[keyof typeof SupportedNetworks]>;
7
- billingContact?: {
8
- phoneNumber: string;
9
- emailAddress: string;
10
- givenName: string;
11
- familyName: string;
12
- };
13
- total: {
14
- label: string;
15
- amount: number;
16
- };
17
- }
18
- export interface ApplePayButtonProps {
19
- publicKey: string;
20
- merchant: {
21
- id?: string;
22
- domain: string;
23
- };
24
- scope?: typeof Scope[keyof typeof Scope];
25
- supportedNetworks?: Array<typeof SupportedNetworks[keyof typeof SupportedNetworks]>;
26
- buttonStyle?: typeof ButtonStyle[keyof typeof ButtonStyle];
27
- billingContact?: {
28
- name: {
29
- first: string;
30
- middle?: string;
31
- last: string;
32
- };
33
- email: {
34
- address: string;
35
- };
36
- phone: {
37
- code: string;
38
- number: string;
39
- };
40
- };
41
- transaction: {
42
- amount: string;
43
- currency: string;
44
- };
45
- onCancel?: () => void;
46
- onError?: (error: any) => void;
47
- onSuccess?: (data: Record<string, any>) => Promise<void>;
48
- }
49
- export interface MerchantResponse {
50
- id: string;
51
- name: string;
52
- country_code: string;
53
- session_token: string;
54
- [other: string]: string;
55
- }
56
- export interface PaymentMethod {
57
- id: string;
58
- image: string;
59
- name: string;
60
- payment_type: string;
61
- supported_card_brands: Array<typeof SupportedNetworks[keyof typeof SupportedNetworks]>;
62
- supported_currencies: string[];
63
- }
64
- export interface PaymentOptionsResponse {
65
- id: string;
66
- country: string;
67
- currency: string;
68
- payment_methods: PaymentMethod[];
69
- }
70
- export interface ProfileResponse {
71
- merchant: MerchantResponse;
72
- payment_options: PaymentOptionsResponse;
73
- }
1
+ import { Scope, SupportedNetworks, ButtonType, Locale, Environment, ThemeMode, Edges } from '../constants';
2
+ import { ApplePayPaymentContact, ApplePayPaymentMethod, ApplePayShippingMethod, ApplePayUpdateData, RequiredShippingContactField } from './ApplePaySession';
3
+ export * from './ApplePaySession';
4
+ export interface Interface {
5
+ locale?: typeof Locale[keyof typeof Locale];
6
+ theme?: typeof ThemeMode[keyof typeof ThemeMode];
7
+ edges?: typeof Edges[keyof typeof Edges];
8
+ type?: typeof ButtonType[keyof typeof ButtonType];
9
+ }
10
+ export interface Customer {
11
+ id?: string;
12
+ name?: {
13
+ lang: typeof Locale[keyof typeof Locale];
14
+ first: string;
15
+ last: string;
16
+ middle?: string;
17
+ }[];
18
+ contact?: {
19
+ email?: string;
20
+ phone?: {
21
+ countryCode: string;
22
+ number: string;
23
+ };
24
+ };
25
+ shippingContactFields?: Array<RequiredShippingContactField>;
26
+ }
27
+ export interface Acceptance {
28
+ supportedBrands?: Array<typeof SupportedNetworks[keyof typeof SupportedNetworks]>;
29
+ supportedCards?: Array<string>;
30
+ supportedCardsWithAuthentications?: Array<string>;
31
+ supportsCouponCode?: boolean;
32
+ }
33
+ export interface Transaction {
34
+ amount: string;
35
+ currency: string;
36
+ couponCode?: string;
37
+ shipping?: ApplePayShippingMethod[];
38
+ }
39
+ export interface ApplePayButtonProps {
40
+ scope?: typeof Scope[keyof typeof Scope];
41
+ publicKey: string;
42
+ environment: typeof Environment[keyof typeof Environment];
43
+ merchant: {
44
+ id: string;
45
+ domain: string;
46
+ identifier?: string;
47
+ };
48
+ interface?: Interface;
49
+ customer?: Customer;
50
+ acceptance: Acceptance;
51
+ transaction: Transaction;
52
+ onCancel?: () => void;
53
+ onError?: (error: any) => void;
54
+ onSuccess?: (data: Record<string, any>) => Promise<void>;
55
+ onClick?: () => void;
56
+ onReady?: () => void;
57
+ onMerchantValidation?: (status: 'initiated' | 'completed' | 'error') => void;
58
+ onShippingContactSelected?: (shippingContact: ApplePayPaymentContact) => Promise<ApplePayUpdateData | void>;
59
+ onPaymentMethodSelected?: (paymentMethod: ApplePayPaymentMethod) => Promise<ApplePayUpdateData | void>;
60
+ onCouponChanged?: (couponCode: string) => Promise<ApplePayUpdateData | void>;
61
+ metaData?: MetaData;
62
+ debug?: boolean;
63
+ }
64
+ export interface MerchantResponse {
65
+ id: string;
66
+ name: string;
67
+ country_code: string;
68
+ session_token: string;
69
+ [other: string]: string;
70
+ }
71
+ export interface PaymentMethod {
72
+ id: string;
73
+ image: string;
74
+ name: string;
75
+ payment_type: string;
76
+ supported_card_brands: Array<typeof SupportedNetworks[keyof typeof SupportedNetworks]>;
77
+ supported_currencies: string[];
78
+ }
79
+ export interface PaymentOptionsResponse {
80
+ id: string;
81
+ country: string;
82
+ currency: string;
83
+ payment_methods: PaymentMethod[];
84
+ }
85
+ export interface MetaData {
86
+ merchant: MerchantResponse;
87
+ payment_options: PaymentOptionsResponse;
88
+ headers: Record<string, string>;
89
+ }
90
+ export interface CheckoutProfileRequest {
91
+ currency: string;
92
+ merchant_id: string;
93
+ total_amount: number;
94
+ order: {
95
+ amount: number;
96
+ currency: string;
97
+ customer?: {
98
+ id?: string;
99
+ email?: string;
100
+ first_name?: string;
101
+ last_name?: string;
102
+ phone?: {
103
+ country_code: string;
104
+ number: string;
105
+ };
106
+ };
107
+ items: {
108
+ quantity: number;
109
+ amount: number;
110
+ currency: string;
111
+ name: string;
112
+ requiresShipping: string;
113
+ }[];
114
+ merchant: {
115
+ id: string;
116
+ };
117
+ };
118
+ }
@@ -1 +1 @@
1
- export {};
1
+ export * from './ApplePaySession';
@@ -1,11 +1,23 @@
1
- import { MerchantResponse, ApplePayRequestData, ProfileResponse } from '../@types';
2
- import BaseService from './base';
3
- declare class APPService extends BaseService {
4
- constructor();
5
- init(publicKey: string, merchantId?: string): Promise<ProfileResponse>;
6
- appleSession(merchant: MerchantResponse, validationURL: string, merchantRegisteredDomain: string): Promise<any>;
7
- tapTokenization(applePaymentData: Record<string, string>, merchant: MerchantResponse): Promise<any>;
8
- createCharge(publicKey: string, merchant: MerchantResponse, request: ApplePayRequestData, cardToken: string): Promise<import("axios").AxiosResponse<any, any>>;
9
- }
10
- declare const appService: APPService;
11
- export default appService;
1
+ import { MerchantResponse, ApplePayButtonProps, CheckoutProfileRequest } from '../@types';
2
+ import BaseService from './base';
3
+ declare class APPService extends BaseService {
4
+ private baseUrl;
5
+ private env;
6
+ constructor();
7
+ setEnv(env: ApplePayButtonProps['environment']): void;
8
+ setBaseUrl(): void;
9
+ getHeaderPublicKey(): "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8AX++RtxPZFtns4XzXFlDIxPBh0umN4qRXZaKDIlb6a3MknaB7psJWmf2l+e4Cfh9b5tey/+rZqpQ065eXTZfGCAuBLt+fYLQBhLfjRpk8S6hlIzc1Kdjg65uqzMwcTd0p7I4KLwHk1I0oXzuEu53fU1LSZhWp4Mnd6wjVgXAsQIDAQAB\n-----END PUBLIC KEY-----" | "" | "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCi9W5jyTvA4Iwv3V5sfNQ7VdSz\n7WqwBbnWFbIUL/GjaaE93mvDv4zbgRSznHaHQPH6pxrMhMh0tV58njkvjHvQ/tvg\npwM8SemNPKEEAPl69tnMvCrJRPh2dWL3OHY8yCW4c38Hyx4fy56Zd5cdoVWfCReu\njCsvASLGz+cfRrj2swIDAQAB\n-----END PUBLIC KEY-----" | "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9hSRms7Ir1HmzdZxGXFYgmpi3\nez7VBFje0f8wwrxYS9oVoBtN4iAt0DOs3DbeuqtueI31wtpFVUMGg8W7R0SbtkZd\nGzszQNqt/wyqxpDC9q+97XdXwkWQFA72s76ud7eMXQlsWKsvgwhY+Ywzt0KlpNC3\nHj+N6UWFOYK98Xi+sQIDAQAB\n-----END PUBLIC KEY-----";
10
+ setBrowserHeaders({ locale, pk, domain }: {
11
+ locale: string;
12
+ pk: string;
13
+ domain: string;
14
+ }): Promise<void>;
15
+ checkoutProfile(request: CheckoutProfileRequest): Promise<{
16
+ merchant: any;
17
+ payment_options: any;
18
+ }>;
19
+ appleSession(merchant: MerchantResponse, validationURL: string, merchantRegisteredDomain: string, merchantIdentifier: string): Promise<any>;
20
+ tapTokenization(applePaymentData: Record<string, string>): Promise<any>;
21
+ }
22
+ declare const appService: APPService;
23
+ export default appService;