@primer-io/react-native 0.12.4 → 0.15.0
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.
- package/android/build.gradle +2 -2
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/primerioreactnative/PrimerRN.kt +191 -152
- package/android/src/main/java/com/primerioreactnative/PrimerRNEventListener.kt +131 -86
- package/android/src/main/java/com/primerioreactnative/datamodels/PrimerErrorRN.kt +3 -2
- package/android/src/main/java/com/primerioreactnative/datamodels/PrimerEventsRN.kt +11 -0
- package/android/src/main/java/com/primerioreactnative/utils/ErrorHelper.kt +11 -0
- package/android/src/main/java/com/primerioreactnative/utils/PrimerImplementedRNCallbacks.kt +14 -0
- package/ios/DataModels/PrimerErrorRN.swift +32 -2
- package/ios/RNTPrimer.m +43 -0
- package/ios/RNTPrimer.swift +394 -0
- package/ios/ReactNative-Bridging-Header.h +1 -9
- package/ios/ReactNative.xcodeproj/project.pbxproj +44 -0
- package/lib/commonjs/Primer.js +221 -209
- package/lib/commonjs/Primer.js.map +1 -1
- package/lib/commonjs/RNPrimer.js +145 -0
- package/lib/commonjs/RNPrimer.js.map +1 -0
- package/lib/commonjs/index.js +1 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/primer-intent.js.map +1 -1
- package/lib/commonjs/models/utils/redirectScheme.js +4 -0
- package/lib/commonjs/models/utils/redirectScheme.js.map +1 -0
- package/lib/module/Primer.js +203 -209
- package/lib/module/Primer.js.map +1 -1
- package/lib/module/RNPrimer.js +136 -0
- package/lib/module/RNPrimer.js.map +1 -0
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/primer-intent.js.map +1 -1
- package/lib/module/models/utils/redirectScheme.js +2 -0
- package/lib/module/models/utils/redirectScheme.js.map +1 -0
- package/lib/typescript/Primer.d.ts +13 -0
- package/lib/typescript/RNPrimer.d.ts +24 -0
- package/lib/typescript/models/primer-callbacks.d.ts +7 -9
- package/lib/typescript/models/primer-config.d.ts +16 -13
- package/lib/typescript/models/primer-intent.d.ts +1 -1
- package/lib/typescript/models/primer-request.d.ts +2 -12
- package/lib/typescript/models/primer-settings.d.ts +3 -5
- package/lib/typescript/models/primer.d.ts +4 -4
- package/lib/typescript/models/utils/redirectScheme.d.ts +3 -0
- package/package.json +4 -1
- package/primer-io-react-native.podspec +2 -3
- package/src/Primer.ts +227 -176
- package/src/RNPrimer.ts +170 -0
- package/src/index.tsx +1 -0
- package/src/models/primer-callbacks.ts +9 -27
- package/src/models/primer-config.ts +23 -20
- package/src/models/primer-intent.ts +1 -1
- package/src/models/primer-request.ts +2 -16
- package/src/models/primer-settings.ts +3 -5
- package/src/models/primer.ts +5 -5
- package/src/models/utils/redirectScheme.ts +5 -0
- package/ios/PrimerRN+PrimerDelegate.swift +0 -147
- package/ios/PrimerRN.swift +0 -166
- package/ios/ReactNative.m +0 -34
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["RNPrimer.ts"],"names":["NativePrimer","NativeModules","eventEmitter","NativeEventEmitter","RNPrimer","addListener","eventType","listener","removeListener","removeAllListenersForEvent","removeAllListeners","configure","settings","theme","Promise","resolve","reject","configureWithSettings","JSON","stringify","configureWithTheme","err","showUniversalCheckout","clientToken","showUniversalCheckoutWithClientToken","showVaultManager","showPaymentMethod","paymentMethodType","intent","handleNewClientToken","handleError","handleSuccess","setImplementedRNCallbacks","implementedRNCallbacks","dispose"],"mappings":";;;;;;;AAAA;;AAIA,MAAM;AAAEA,EAAAA;AAAF,IAAmBC,0BAAzB;AACA,MAAMC,YAAY,GAAG,IAAIC,+BAAJ,CAAuBH,YAAvB,CAArB;AAkBA,MAAMI,QAAQ,GAAG;AACf;AACA;AACA;AACAC,EAAAA,WAAW,EAAE,CAACC,SAAD,EAAuBC,QAAvB,KAA6D;AACxEL,IAAAA,YAAY,CAACG,WAAb,CAAyBC,SAAzB,EAAoCC,QAApC;AACD,GANc;AAQfC,EAAAA,cAAc,E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hB,KAA2B;AAC5C,UAAI;AACF,cAAMhB,YAAY,CAACgC,yBAAb,CAAuCd,IAAI,CAACC,SAAL,CAAec,sBAAf,CAAvC,CAAN;AACAlB,QAAAA,OAAO;AACR,OAHD,CAGE,OAAOM,GAAP,EAAY;AACZL,QAAAA,MAAM,CAACK,GAAD,CAAN;AACD;AACF,KAPM,CAAP;AAQD,GA3Ic;AA6Ifa,EAAAA,OAAO,EAAE,MAAY,CAEpB;AA/Ic,CAAjB;eAkJe9B,Q","sourcesContent":["import { NativeEventEmitter, NativeModules } from 'react-native';\nimport type { PrimerSettings } from './models/primer-settings';\nimport type { PrimerTheme } from './models/primer-theme';\n\nconst { NativePrimer } = NativeModules;\nconst eventEmitter = new NativeEventEmitter(NativePrimer);\n\ntype EventType =\n | 'onClientTokenCallback'\n | 'onClientSessionActions'\n | 'onTokenizeSuccessCallback'\n | 'onVaultSuccess'\n | 'onResumeSuccess'\n | 'onCheckoutDismissed'\n | 'onError'\n | 'detectImplementedRNCallbacks';\n\nexport interface IPrimerError {\n errorId: string\n errorDescription?: string\n recoverySuggestion?: string\n}\n\nconst RNPrimer = {\n ///////////////////////////////////////////\n // Event Emitter\n ///////////////////////////////////////////\n addListener: (eventType: EventType, listener: (...args: any[]) => any) => {\n eventEmitter.addListener(eventType, listener);\n },\n\n removeListener: (eventType: EventType, listener: (...args: any[]) => any) => {\n eventEmitter.removeListener(eventType, listener);\n },\n\n removeAllListenersForEvent(eventType: EventType) {\n eventEmitter.removeAllListeners(eventType);\n },\n\n removeAllListeners() {\n eventEmitter.removeAllListeners('onClientTokenCallback');\n eventEmitter.removeAllListeners('onClientSessionActions');\n eventEmitter.removeAllListeners('onTokenizeSuccessCallback');\n eventEmitter.removeAllListeners('onResumeSuccess');\n eventEmitter.removeAllListeners('onCheckoutDismissed');\n eventEmitter.removeAllListeners('onError');\n eventEmitter.removeAllListeners('detectImplementedRNCallbacks');\n },\n\n ///////////////////////////////////////////\n // Native API\n ///////////////////////////////////////////\n configure: (\n settings: PrimerSettings | null,\n theme: PrimerTheme | null\n ): Promise<void> => {\n return new Promise(async (resolve, reject) => {\n try {\n if (settings === null && theme === null) {\n // Do nothing, SDK will use default settings and theme.\n } else if (settings && theme === null) {\n await NativePrimer.configureWithSettings(JSON.stringify(settings));\n } else if (settings === null && theme) {\n await NativePrimer.configureWithTheme(JSON.stringify(theme));\n } else {\n await NativePrimer.configureWithSettings(JSON.stringify(settings));\n await NativePrimer.configureWithTheme(JSON.stringify(theme));\n }\n resolve();\n } catch (err) {\n reject(err);\n }\n });\n },\n\n showUniversalCheckout: (clientToken: string | undefined): Promise<void> => {\n return new Promise(async (resolve, reject) => {\n try {\n if (clientToken) {\n await NativePrimer.showUniversalCheckoutWithClientToken(clientToken);\n } else {\n await NativePrimer.showUniversalCheckout();\n }\n resolve();\n } catch (err) {\n reject(err);\n }\n });\n },\n\n showVaultManager: (clientToken: string | undefined): Promise<void> => {\n return new Promise(async (resolve, reject) => {\n try {\n if (clientToken) {\n await NativePrimer.showVaultManager(clientToken);\n } else {\n await NativePrimer.showVaultManager();\n }\n resolve();\n } catch (err) {\n reject(err);\n }\n });\n },\n\n showPaymentMethod: (\n clientToken: string,\n paymentMethodType: string,\n intent: \"checkout\" | \"vault\"\n ): Promise<void> => {\n return new Promise(async (resolve, reject) => {\n try {\n await NativePrimer.showPaymentMethod(clientToken, paymentMethodType, intent);\n resolve();\n } catch (err) {\n reject(err);\n }\n });\n },\n\n handleNewClientToken: (clientToken: string | undefined): Promise<void> => {\n return new Promise(async (resolve, reject) => {\n try {\n await NativePrimer.handleNewClientToken(clientToken);\n resolve();\n } catch (err) {\n reject(err);\n }\n });\n },\n\n handleError: (err: IPrimerError): Promise<void> => {\n return new Promise(async (resolve, reject) => {\n try {\n await NativePrimer.handleError(JSON.stringify(err));\n resolve();\n } catch (err) {\n reject(err);\n }\n });\n },\n\n handleSuccess: (): Promise<void> => {\n return new Promise(async (resolve, reject) => {\n try {\n await NativePrimer.handleSuccess();\n resolve();\n } catch (err) {\n reject(err);\n }\n });\n },\n\n setImplementedRNCallbacks: (implementedRNCallbacks: any): Promise<void> => {\n return new Promise(async (resolve, reject) => {\n try {\n await NativePrimer.setImplementedRNCallbacks(JSON.stringify(implementedRNCallbacks));\n resolve();\n } catch (err) {\n reject(err);\n }\n });\n },\n\n dispose: (): void => {\n\n }\n};\n\nexport default RNPrimer;\n"]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["Primer","PrimerNativeMapping"],"mappings":";;;;;;;AACA;;AAEA,MAAMA,MAAe,GAAGC,2BAAxB","sourcesContent":["import type { IPrimer } from './models/primer';\nimport { PrimerNativeMapping } from './Primer';\n\nconst Primer: IPrimer = PrimerNativeMapping;\n\nexport { Primer };\n"]}
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["Primer","PrimerNativeMapping"],"mappings":";;;;;;;AACA;;AACA;AAEA,MAAMA,MAAe,GAAGC,2BAAxB","sourcesContent":["import type { IPrimer } from './models/primer';\nimport { PrimerNativeMapping } from './Primer';\n// import type { IPrimerConfig as PrimerConfig } from './models/primer-config';\n\nconst Primer: IPrimer = PrimerNativeMapping;\n\nexport { Primer };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["primer-intent.ts"],"names":["paymentMethods"],"mappings":";;AAAA,MAAMA,cAAc,GAAG,CACrB,cADqB,EAErB,cAFqB,EAGrB,eAHqB,EAIrB,aAJqB,EAKrB,iBALqB,EAMrB,cANqB,EAOrB,eAPqB,EAQrB,aARqB,EASrB,aATqB,EAUrB,OAVqB,EAWrB,WAXqB,EAYrB,OAZqB,EAarB,qBAbqB,EAcrB,cAdqB,EAerB,kBAfqB,EAgBrB,gBAhBqB,EAiBrB,iBAjBqB,EAkBrB,YAlBqB,EAmBrB,YAnBqB,EAoBrB,QApBqB,EAqBrB,QArBqB,EAsBrB,mBAtBqB,EAuBrB,cAvBqB,EAwBrB,mBAxBqB,EAyBrB,gBAzBqB,EA0BrB,cA1BqB,EA2BrB,iBA3BqB,EA4BrB,cA5BqB,EA6BrB,QA7BqB,EA8BrB,cA9BqB,CAAvB","sourcesContent":["const paymentMethods = [\n 'ADYEN_ALIPAY',\n 'ADYEN_DOTPAY',\n 'ADYEN_GIROPAY',\n 'ADYEN_IDEAL',\n 'ADYEN_MOBILEPAY',\n 'ADYEN_SOFORT',\n 'ADYEN_TRUSTLY',\n 'ADYEN_TWINT',\n 'ADYEN_VIPPS',\n 'APAYA',\n 'APPLE_PAY',\n 'ATOME',\n 'BUCKAROO_BANCONTACT',\n 'BUCKAROO_EPS',\n 'BUCKAROO_GIROPAY',\n 'BUCKAROO_IDEAL',\n 'BUCKAROO_SOFORT',\n 'GOCARDLESS',\n 'GOOGLE_PAY',\n 'HOOLAH',\n 'KLARNA',\n 'MOLLIE_BANCONTACT',\n 'MOLLIE_IDEAL',\n 'PAY_NL_BANCONTACT',\n 'PAY_NL_GIROPAY',\n 'PAY_NL_IDEAL',\n 'PAY_NL_PAYCONIQ',\n 'PAYMENT_CARD',\n 'PAYPAL',\n 'XFERS_PAYNOW',\n] as const;\n\nexport type SinglePrimerPaymentMethod = typeof paymentMethods[number];\nexport interface AnyPrimerPaymentMethodIntent {\n vault: boolean;\n paymentMethod:
|
|
1
|
+
{"version":3,"sources":["primer-intent.ts"],"names":["paymentMethods"],"mappings":";;AAAA,MAAMA,cAAc,GAAG,CACrB,cADqB,EAErB,cAFqB,EAGrB,eAHqB,EAIrB,aAJqB,EAKrB,iBALqB,EAMrB,cANqB,EAOrB,eAPqB,EAQrB,aARqB,EASrB,aATqB,EAUrB,OAVqB,EAWrB,WAXqB,EAYrB,OAZqB,EAarB,qBAbqB,EAcrB,cAdqB,EAerB,kBAfqB,EAgBrB,gBAhBqB,EAiBrB,iBAjBqB,EAkBrB,YAlBqB,EAmBrB,YAnBqB,EAoBrB,QApBqB,EAqBrB,QArBqB,EAsBrB,mBAtBqB,EAuBrB,cAvBqB,EAwBrB,mBAxBqB,EAyBrB,gBAzBqB,EA0BrB,cA1BqB,EA2BrB,iBA3BqB,EA4BrB,cA5BqB,EA6BrB,QA7BqB,EA8BrB,cA9BqB,CAAvB","sourcesContent":["const paymentMethods = [\n 'ADYEN_ALIPAY',\n 'ADYEN_DOTPAY',\n 'ADYEN_GIROPAY',\n 'ADYEN_IDEAL',\n 'ADYEN_MOBILEPAY',\n 'ADYEN_SOFORT',\n 'ADYEN_TRUSTLY',\n 'ADYEN_TWINT',\n 'ADYEN_VIPPS',\n 'APAYA',\n 'APPLE_PAY',\n 'ATOME',\n 'BUCKAROO_BANCONTACT',\n 'BUCKAROO_EPS',\n 'BUCKAROO_GIROPAY',\n 'BUCKAROO_IDEAL',\n 'BUCKAROO_SOFORT',\n 'GOCARDLESS',\n 'GOOGLE_PAY',\n 'HOOLAH',\n 'KLARNA',\n 'MOLLIE_BANCONTACT',\n 'MOLLIE_IDEAL',\n 'PAY_NL_BANCONTACT',\n 'PAY_NL_GIROPAY',\n 'PAY_NL_IDEAL',\n 'PAY_NL_PAYCONIQ',\n 'PAYMENT_CARD',\n 'PAYPAL',\n 'XFERS_PAYNOW',\n] as const;\n\nexport type SinglePrimerPaymentMethod = typeof paymentMethods[number];\nexport interface AnyPrimerPaymentMethodIntent {\n vault: boolean;\n paymentMethod: SinglePrimerPaymentMethod;\n}\n\nexport type PrimerPaymentMethodIntent = ISinglePrimerPaymentMethodIntent;\n\ninterface ISinglePrimerPaymentMethodIntent {\n vault: boolean;\n paymentMethod: SinglePrimerPaymentMethod;\n}\n\nexport type PrimerIntent =\n | ISinglePrimerPaymentMethodIntent\n | AnyPrimerPaymentMethodIntent;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["redirectScheme.ts"],"names":["redirectSchemes"],"mappings":";;AAAA,IAAIA,eAAe,GAAG,CAClB,QADkB,CAAtB","sourcesContent":["var redirectSchemes = [\n 'primer'\n] as const;\n\nexport type RedirectScheme = typeof redirectSchemes[number];\n"]}
|
package/lib/module/Primer.js
CHANGED
|
@@ -1,224 +1,218 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import RNPrimer from './RNPrimer';
|
|
2
|
+
const resumeHandler = {
|
|
3
|
+
handleNewClientToken: async clientToken => {
|
|
4
|
+
try {
|
|
5
|
+
await RNPrimer.handleNewClientToken(clientToken);
|
|
6
|
+
} catch (err) {
|
|
7
|
+
let primerError;
|
|
8
|
+
|
|
9
|
+
if (err instanceof Error) {
|
|
10
|
+
primerError = {
|
|
11
|
+
errorId: "react-native-bridge",
|
|
12
|
+
errorDescription: err.message
|
|
13
|
+
};
|
|
14
|
+
} else {
|
|
15
|
+
primerError = {
|
|
16
|
+
errorId: "react-native-bridge",
|
|
17
|
+
errorDescription: "unknown error"
|
|
18
|
+
};
|
|
19
|
+
}
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
vault: true,
|
|
19
|
-
paymentMethod: 'Any'
|
|
20
|
-
});
|
|
21
|
-
configure(config);
|
|
22
|
-
NativeModule.initialize(token);
|
|
21
|
+
await RNPrimer.handleError(primerError);
|
|
22
|
+
}
|
|
23
23
|
},
|
|
24
|
+
handleError: async err => {
|
|
25
|
+
try {
|
|
26
|
+
const primerError = {
|
|
27
|
+
errorId: "react-native",
|
|
28
|
+
errorDescription: err.message
|
|
29
|
+
};
|
|
30
|
+
await RNPrimer.handleError(primerError);
|
|
31
|
+
} catch (err) {
|
|
32
|
+
let primerError;
|
|
33
|
+
|
|
34
|
+
if (err instanceof Error) {
|
|
35
|
+
primerError = {
|
|
36
|
+
errorId: "react-native-bridge",
|
|
37
|
+
errorDescription: err.message
|
|
38
|
+
};
|
|
39
|
+
} else {
|
|
40
|
+
primerError = {
|
|
41
|
+
errorId: "react-native-bridge",
|
|
42
|
+
errorDescription: "unknown error"
|
|
43
|
+
};
|
|
44
|
+
}
|
|
24
45
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
configure(config);
|
|
28
|
-
NativeModule.initialize(token);
|
|
46
|
+
await RNPrimer.handleError(primerError);
|
|
47
|
+
}
|
|
29
48
|
},
|
|
49
|
+
handleSuccess: async () => {
|
|
50
|
+
try {
|
|
51
|
+
await RNPrimer.handleSuccess();
|
|
52
|
+
} catch (err) {
|
|
53
|
+
let primerError;
|
|
54
|
+
|
|
55
|
+
if (err instanceof Error) {
|
|
56
|
+
primerError = {
|
|
57
|
+
errorId: "react-native-bridge",
|
|
58
|
+
errorDescription: err.message
|
|
59
|
+
};
|
|
60
|
+
} else {
|
|
61
|
+
primerError = {
|
|
62
|
+
errorId: "react-native-bridge",
|
|
63
|
+
errorDescription: "unknown error"
|
|
64
|
+
};
|
|
65
|
+
}
|
|
30
66
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// configure(config);
|
|
34
|
-
// NativeModule.fetchSavedPaymentInstruments(token);
|
|
35
|
-
// },
|
|
36
|
-
dispose() {
|
|
37
|
-
NativeModule.dispose();
|
|
67
|
+
await RNPrimer.handleError(primerError);
|
|
68
|
+
}
|
|
38
69
|
}
|
|
39
|
-
|
|
40
70
|
};
|
|
71
|
+
export const PrimerNativeMapping = {
|
|
72
|
+
showUniversalCheckout(clientToken, config) {
|
|
73
|
+
RNPrimer.removeAllListeners();
|
|
74
|
+
|
|
75
|
+
if (config.settings || config.theme) {
|
|
76
|
+
RNPrimer.configure(config.settings || null, config.theme || null);
|
|
77
|
+
let implementedRNCallbacks = {
|
|
78
|
+
// isClientTokenCallbackImplemented: (config.onClientTokenCallback !== undefined),
|
|
79
|
+
isTokenAddedToVaultImplemented: config.onTokenAddedToVault !== undefined,
|
|
80
|
+
isOnResumeSuccessImplemented: config.onResumeSuccess !== undefined,
|
|
81
|
+
isOnResumeErrorImplemented: config.onError !== undefined,
|
|
82
|
+
isOnCheckoutDismissedImplemented: config.onDismiss !== undefined,
|
|
83
|
+
isCheckoutFailedImplemented: config.onError !== undefined,
|
|
84
|
+
isClientSessionActionsImplemented: config.onClientSessionActions !== undefined
|
|
85
|
+
};
|
|
86
|
+
RNPrimer.setImplementedRNCallbacks(implementedRNCallbacks).then(() => {
|
|
87
|
+
RNPrimer.addListener('onClientSessionActions', data => {
|
|
88
|
+
const clientSessionActions = data;
|
|
89
|
+
|
|
90
|
+
if (config.onClientSessionActions) {
|
|
91
|
+
config.onClientSessionActions(clientSessionActions, resumeHandler);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
RNPrimer.addListener('onTokenizeSuccessCallback', data => {
|
|
95
|
+
const paymentInstrumentToken = data;
|
|
41
96
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
configureOnVaultSuccess(config.onTokenAddedToVault);
|
|
46
|
-
configureOnDismiss(config.onDismiss);
|
|
47
|
-
configureOnError(config.onError);
|
|
48
|
-
configureOnTokenizeSuccess(config.onTokenizeSuccess);
|
|
49
|
-
configureOnClientSessionActions(config.onClientSessionActions);
|
|
50
|
-
configureOnResumeSuccess(config.onResumeSuccess);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function configureSettings(settings = {}) {
|
|
54
|
-
const data = JSON.stringify(settings);
|
|
55
|
-
NativeModule.configureSettings(data);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function configureTheme(theme = {}) {
|
|
59
|
-
const data = JSON.stringify(theme);
|
|
60
|
-
NativeModule.configureTheme(data);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function configureIntent(intent = {
|
|
64
|
-
vault: false,
|
|
65
|
-
paymentMethod: 'Any'
|
|
66
|
-
}) {
|
|
67
|
-
const data = JSON.stringify(intent);
|
|
68
|
-
NativeModule.configureIntent(data);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function resume(request) {
|
|
72
|
-
const data = JSON.stringify(request);
|
|
73
|
-
NativeModule.resume(data);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function configureOnTokenizeSuccess(callback = (_, __) => {}) {
|
|
77
|
-
NativeModule.configureOnTokenizeSuccess(data => {
|
|
78
|
-
try {
|
|
79
|
-
const parsedData = JSON.parse(data);
|
|
80
|
-
callback(parsedData, {
|
|
81
|
-
handleError: error => resume({
|
|
82
|
-
error,
|
|
83
|
-
token: null
|
|
84
|
-
}),
|
|
85
|
-
handleSuccess: () => resume({
|
|
86
|
-
error: null,
|
|
87
|
-
token: null
|
|
88
|
-
}),
|
|
89
|
-
handleNewClientToken: token => resume({
|
|
90
|
-
error: null,
|
|
91
|
-
token
|
|
92
|
-
}),
|
|
93
|
-
// deprecated
|
|
94
|
-
resumeWithError: error => resume({
|
|
95
|
-
error,
|
|
96
|
-
token: null
|
|
97
|
-
}),
|
|
98
|
-
resumeWithSuccess: token => resume({
|
|
99
|
-
error: null,
|
|
100
|
-
token
|
|
101
|
-
})
|
|
102
|
-
});
|
|
103
|
-
} catch (e) {
|
|
104
|
-
console.log('failed to parse json', e);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function actionResume(request) {
|
|
110
|
-
const data = JSON.stringify(request);
|
|
111
|
-
NativeModule.actionResume(data);
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Call @method configureOnClientSessionActions on the native bridge, passing
|
|
115
|
-
* in a callback that the native side will call every time a client session
|
|
116
|
-
* action is triggered.
|
|
117
|
-
*/
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
function configureOnClientSessionActions(callback) // defined by integrating developer.
|
|
121
|
-
{
|
|
122
|
-
NativeModule.configureOnClientSessionActions(data => {
|
|
123
|
-
try {
|
|
124
|
-
// parse the client session action JSON string.
|
|
125
|
-
const parsedData = JSON.parse(data);
|
|
126
|
-
|
|
127
|
-
if (!callback) {
|
|
128
|
-
/**
|
|
129
|
-
* if @param callback is undefined immediately call the native bridge
|
|
130
|
-
* and resume with null values. This will resume the SDK flow without
|
|
131
|
-
* triggering extra configuration API fetch calls.
|
|
132
|
-
*/
|
|
133
|
-
actionResume({
|
|
134
|
-
error: null,
|
|
135
|
-
token: null
|
|
97
|
+
if (config.onTokenizeSuccess) {
|
|
98
|
+
config.onTokenizeSuccess(paymentInstrumentToken, resumeHandler);
|
|
99
|
+
}
|
|
136
100
|
});
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
handleSuccess: () => actionResume({
|
|
149
|
-
error: null,
|
|
150
|
-
token: null
|
|
151
|
-
}),
|
|
152
|
-
handleNewClientToken: token => actionResume({
|
|
153
|
-
error: null,
|
|
154
|
-
token
|
|
155
|
-
}),
|
|
156
|
-
// deprecated, remove in next major version update.
|
|
157
|
-
resumeWithError: error => actionResume({
|
|
158
|
-
error,
|
|
159
|
-
token: null
|
|
160
|
-
}),
|
|
161
|
-
resumeWithSuccess: token => actionResume({
|
|
162
|
-
error: null,
|
|
163
|
-
token
|
|
164
|
-
})
|
|
101
|
+
RNPrimer.addListener('onResumeSuccess', data => {
|
|
102
|
+
const resumeToken = data.resumeToken;
|
|
103
|
+
|
|
104
|
+
if (config.onResumeSuccess) {
|
|
105
|
+
config.onResumeSuccess(resumeToken, resumeHandler);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
RNPrimer.addListener('onCheckoutDismissed', _ => {
|
|
109
|
+
if (config.onDismiss) {
|
|
110
|
+
config.onDismiss();
|
|
111
|
+
}
|
|
165
112
|
});
|
|
166
|
-
|
|
113
|
+
RNPrimer.addListener('onError', data => {
|
|
114
|
+
const err = data.error;
|
|
167
115
|
|
|
116
|
+
if (config.onError) {
|
|
117
|
+
config.onError(err, resumeHandler);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
RNPrimer.showUniversalCheckout(clientToken);
|
|
121
|
+
}).catch(err => {
|
|
122
|
+
console.error(err);
|
|
123
|
+
});
|
|
124
|
+
} // RNPrimer.addListener('onClientTokenCallback', _ => {
|
|
125
|
+
// if (config.onClientTokenCallback) {
|
|
126
|
+
// config.onClientTokenCallback(resumeHandler);
|
|
127
|
+
// }
|
|
128
|
+
// });
|
|
168
129
|
|
|
169
|
-
|
|
170
|
-
} catch (e) {
|
|
171
|
-
// log error if the client session action JSON string cannot be parsed (this should never happen!).
|
|
172
|
-
console.error('[OnClientSessionActions]', 'failed to parse json', e);
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
}
|
|
130
|
+
},
|
|
176
131
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
132
|
+
showVaultManager(clientToken, config) {
|
|
133
|
+
RNPrimer.removeAllListeners();
|
|
134
|
+
|
|
135
|
+
if (config.settings || config.theme) {
|
|
136
|
+
RNPrimer.configure(config.settings || null, config.theme || null);
|
|
137
|
+
let implementedRNCallbacks = {
|
|
138
|
+
// isClientTokenCallbackImplemented: (config.onClientTokenCallback !== undefined),
|
|
139
|
+
isTokenAddedToVaultImplemented: config.onTokenAddedToVault !== undefined,
|
|
140
|
+
isOnResumeSuccessImplemented: config.onResumeSuccess !== undefined,
|
|
141
|
+
isOnResumeErrorImplemented: config.onError !== undefined,
|
|
142
|
+
isOnCheckoutDismissedImplemented: config.onDismiss !== undefined,
|
|
143
|
+
isCheckoutFailedImplemented: config.onError !== undefined,
|
|
144
|
+
isClientSessionActionsImplemented: config.onClientSessionActions !== undefined
|
|
145
|
+
};
|
|
146
|
+
RNPrimer.setImplementedRNCallbacks(implementedRNCallbacks);
|
|
147
|
+
} // RNPrimer.addListener('onClientTokenCallback', _ => {
|
|
148
|
+
// if (config.onClientTokenCallback) {
|
|
149
|
+
// config.onClientTokenCallback(resumeHandler);
|
|
150
|
+
// }
|
|
151
|
+
// });
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
RNPrimer.addListener('onClientSessionActions', data => {
|
|
155
|
+
const clientSessionActions = data;
|
|
156
|
+
|
|
157
|
+
if (config.onClientSessionActions) {
|
|
158
|
+
config.onClientSessionActions(clientSessionActions, resumeHandler);
|
|
159
|
+
} else {
|
|
160
|
+
RNPrimer.handleSuccess();
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
RNPrimer.addListener('onTokenizeSuccessCallback', data => {
|
|
164
|
+
const paymentInstrumentToken = data;
|
|
165
|
+
|
|
166
|
+
if (config.onTokenizeSuccess) {
|
|
167
|
+
config.onTokenizeSuccess(paymentInstrumentToken, resumeHandler);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
RNPrimer.addListener('onResumeSuccess', data => {
|
|
171
|
+
const resumeToken = data.resumeToken;
|
|
172
|
+
|
|
173
|
+
if (config.onResumeSuccess) {
|
|
174
|
+
config.onResumeSuccess(resumeToken, resumeHandler);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
RNPrimer.addListener('onCheckoutDismissed', () => {
|
|
178
|
+
if (config.onDismiss) {
|
|
179
|
+
config.onDismiss();
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
RNPrimer.addListener('onError', data => {
|
|
183
|
+
const err = data.error;
|
|
184
|
+
|
|
185
|
+
if (config.onError) {
|
|
186
|
+
config.onError(err, resumeHandler);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
RNPrimer.showVaultManager(clientToken);
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
showPaymentMethod(clientToken, intent, config) {
|
|
193
|
+
RNPrimer.removeAllListeners();
|
|
194
|
+
|
|
195
|
+
if (config.settings || config.theme) {
|
|
196
|
+
RNPrimer.configure(config.settings || null, config.theme || null);
|
|
205
197
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
198
|
+
|
|
199
|
+
let implementedRNCallbacks = {
|
|
200
|
+
// isClientTokenCallbackImplemented: (config.onClientTokenCallback !== undefined),
|
|
201
|
+
isTokenAddedToVaultImplemented: config.onTokenAddedToVault !== undefined,
|
|
202
|
+
isOnResumeSuccessImplemented: config.onResumeSuccess !== undefined,
|
|
203
|
+
isOnResumeErrorImplemented: config.onError !== undefined,
|
|
204
|
+
isOnCheckoutDismissedImplemented: config.onDismiss !== undefined,
|
|
205
|
+
isCheckoutFailedImplemented: config.onError !== undefined,
|
|
206
|
+
isClientSessionActionsImplemented: config.onClientSessionActions !== undefined
|
|
207
|
+
};
|
|
208
|
+
RNPrimer.setImplementedRNCallbacks(implementedRNCallbacks);
|
|
209
|
+
RNPrimer.showPaymentMethod(clientToken, intent.paymentMethod, intent.vault === true ? "vault" : "checkout");
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
dispose() {
|
|
213
|
+
RNPrimer.removeAllListeners();
|
|
214
|
+
RNPrimer.dispose();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
};
|
|
224
218
|
//# sourceMappingURL=Primer.js.map
|
package/lib/module/Primer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Primer.ts"],"names":["NativeModules","parseCallback","PrimerRN","NativeModule","PrimerNativeMapping","showUniversalCheckout","token","config","configureIntent","vault","paymentMethod","configure","initialize","showVaultManager","showPaymentMethod","intent","dispose","configureTheme","theme","configureSettings","settings","configureOnVaultSuccess","onTokenAddedToVault","configureOnDismiss","onDismiss","configureOnError","onError","configureOnTokenizeSuccess","onTokenizeSuccess","configureOnClientSessionActions","onClientSessionActions","configureOnResumeSuccess","onResumeSuccess","data","JSON","stringify","resume","request","callback","_","__","parsedData","parse","handleError","error","handleSuccess","handleNewClientToken","resumeWithError","resumeWithSuccess","e","console","log","actionResume","paymentMethodToken","configureOnPrimerError"],"mappings":"AAAA,SAASA,aAAT,QAA8B,cAA9B;AAmBA,SAASC,aAAT,QAA8B,SAA9B;AAEA,MAAM;AAAEC,EAAAA,QAAQ,EAAEC;AAAZ,IAA6BH,aAAnC;AAEA,OAAO,MAAMI,mBAA4B,GAAG;AAC1CC,EAAAA,qBAAqB,CAACC,KAAD,EAAgBC,MAAhB,EAA4C;AAC/DC,IAAAA,eAAe,CAAC;AAAEC,MAAAA,KAAK,EAAE,KAAT;AAAgBC,MAAAA,aAAa,EAAE;AAA/B,KAAD,CAAf;AACAC,IAAAA,SAAS,CAACJ,MAAD,CAAT;AACAJ,IAAAA,YAAY,CAACS,UAAb,CAAwBN,KAAxB;AACD,GALyC;;AAO1CO,EAAAA,gBAAgB,CAACP,KAAD,EAAgBC,MAAhB,EAA4C;AAC1DC,IAAAA,eAAe,CAAC;AAAEC,MAAAA,KAAK,EAAE,IAAT;AAAeC,MAAAA,aAAa,EAAE;AAA9B,KAAD,CAAf;AACAC,IAAAA,SAAS,CAACJ,MAAD,CAAT;AACAJ,IAAAA,YAAY,CAACS,UAAb,CAAwBN,KAAxB;AACD,GAXyC;;AAa1CQ,EAAAA,iBAAiB,CACfR,KADe,EAEfS,MAFe,EAGfR,MAHe,EAIT;AACNC,IAAAA,eAAe,CAACO,MAAD,CAAf;AACAJ,IAAAA,SAAS,CAACJ,MAAD,CAAT;AACAJ,IAAAA,YAAY,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AAe;AAClDhC,IAAAA,aAAa,CAAyBgC,IAAzB,EAA+BK,QAA/B,CAAb;AACD,GAFD;AAGD;;AAED,SAASf,kBAAT,CAA4Be,QAA2B,GAAG,MAAM,CAAE,CAAlE,EAAoE;AAClEnC,EAAAA,YAAY,CAACoB,kBAAb,CAAiCgB,CAAD,IAAYD,QAAQ,EAApD;AACD;;AAED,SAASb,gBAAT,CAA0Ba,QAA+B,GAAIC,CAAD,IAAO,CAAE,CAArE,EAAuE;AACrEpC,EAAAA,YAAY,CAACmD,sBAAb,CAAqCrB,IAAD,IAAe;AACjDhC,IAAAA,aAAa,CAAcgC,IAAd,EAAoBK,QAApB,CAAb;AACD,GAFD;AAGD","sourcesContent":["import { NativeModules } from 'react-native';\nimport type { ClientSessionActionsRequest } from './models/client-session-actions-request';\nimport type { PaymentInstrumentToken } from './models/payment-instrument-token';\nimport type { IPrimer } from './models/primer';\nimport type {\n OnClientSessionActionsCallback,\n OnDismissCallback,\n OnPrimerErrorCallback,\n OnTokenAddedToVaultCallback,\n OnTokenizeSuccessCallback,\n} from './models/primer-callbacks';\nimport type { PrimerConfig } from './models/primer-config';\nimport type { PrimerError } from './models/primer-error';\nimport type {\n PrimerIntent,\n PrimerPaymentMethodIntent,\n} from './models/primer-intent';\nimport type { PrimerSettings } from './models/primer-settings';\nimport type { PrimerTheme } from './models/primer-theme';\nimport { parseCallback } from './utils';\n\nconst { PrimerRN: NativeModule } = NativeModules;\n\nexport const PrimerNativeMapping: IPrimer = {\n showUniversalCheckout(token: String, config: PrimerConfig): void {\n configureIntent({ vault: false, paymentMethod: 'Any' });\n configure(config);\n NativeModule.initialize(token);\n },\n\n showVaultManager(token: String, config: PrimerConfig): void {\n configureIntent({ vault: true, paymentMethod: 'Any' });\n configure(config);\n NativeModule.initialize(token);\n },\n\n showPaymentMethod(\n token: String,\n intent: PrimerPaymentMethodIntent,\n config: PrimerConfig\n ): void {\n configureIntent(intent);\n configure(config);\n NativeModule.initialize(token);\n },\n\n // todo: refactor\n // fetchSavedPaymentInstruments(token: String, config: PrimerConfig): void {\n // configure(config);\n // NativeModule.fetchSavedPaymentInstruments(token);\n // },\n\n dispose(): void {\n NativeModule.dispose();\n },\n};\n\nfunction configure(config: PrimerConfig): void {\n configureTheme(config.theme);\n configureSettings(config.settings);\n configureOnVaultSuccess(config.onTokenAddedToVault);\n configureOnDismiss(config.onDismiss);\n configureOnError(config.onError);\n configureOnTokenizeSuccess(config.onTokenizeSuccess);\n configureOnClientSessionActions(config.onClientSessionActions);\n configureOnResumeSuccess(config.onResumeSuccess);\n}\n\nfunction configureSettings(settings: PrimerSettings = {}): void {\n const data = JSON.stringify(settings);\n NativeModule.configureSettings(data);\n}\n\nfunction configureTheme(theme: PrimerTheme = {}): void {\n const data = JSON.stringify(theme);\n NativeModule.configureTheme(data);\n}\n\nfunction configureIntent(\n intent: PrimerIntent = { vault: false, paymentMethod: 'Any' }\n): void {\n const data = JSON.stringify(intent);\n NativeModule.configureIntent(data);\n}\n\nfunction resume(request: ResumeRequest) {\n const data = JSON.stringify(request);\n NativeModule.resume(data);\n}\n\nfunction configureOnTokenizeSuccess(\n callback: OnTokenizeSuccessCallback = (_, __) => {}\n) {\n NativeModule.configureOnTokenizeSuccess((data: any) => {\n try {\n const parsedData = JSON.parse(data) as PaymentInstrumentToken;\n callback(parsedData, {\n handleError: (error) => resume({ error, token: null }),\n handleSuccess: () => resume({ error: null, token: null }),\n handleNewClientToken: (token) => resume({ error: null, token }),\n // deprecated\n resumeWithError: (error) => resume({ error, token: null }),\n resumeWithSuccess: (token) => resume({ error: null, token }),\n });\n } catch (e) {\n console.log('failed to parse json', e);\n }\n });\n}\n\nfunction actionResume(request: ResumeRequest) {\n const data = JSON.stringify(request);\n NativeModule.actionResume(data);\n}\n\n/**\n * Call @method configureOnClientSessionActions on the native bridge, passing\n * in a callback that the native side will call every time a client session\n * action is triggered.\n */\nfunction configureOnClientSessionActions(\n callback?: OnClientSessionActionsCallback // defined by integrating developer.\n) {\n NativeModule.configureOnClientSessionActions((data: any) => {\n try {\n // parse the client session action JSON string.\n const parsedData = JSON.parse(data) as ClientSessionActionsRequest;\n\n if (!callback) {\n /**\n * if @param callback is undefined immediately call the native bridge\n * and resume with null values. This will resume the SDK flow without\n * triggering extra configuration API fetch calls.\n */\n actionResume({ error: null, token: null });\n } else {\n /**\n * send the parsed data back to the developer through the defined callback.\n * The developer will determine how to resume the flow using one of the provided\n * resume handlers.\n */\n callback(parsedData, {\n handleError: (error) => actionResume({ error, token: null }),\n handleSuccess: () => actionResume({ error: null, token: null }),\n handleNewClientToken: (token) => actionResume({ error: null, token }),\n // deprecated, remove in next major version update.\n resumeWithError: (error) => actionResume({ error, token: null }),\n resumeWithSuccess: (token) => actionResume({ error: null, token }),\n });\n }\n\n // reset the client session action callback (native bridge callbacks are disposed once they're invoked).\n configureOnClientSessionActions(callback);\n } catch (e) {\n // log error if the client session action JSON string cannot be parsed (this should never happen!).\n console.error('[OnClientSessionActions]', 'failed to parse json', e);\n }\n });\n}\n\nfunction configureOnResumeSuccess(\n callback: OnTokenizeSuccessCallback = (_, __) => {}\n) {\n NativeModule.configureOnResumeSuccess((paymentMethodToken: any) => {\n try {\n callback(paymentMethodToken, {\n handleError: (error) => resume({ error, token: null }),\n handleSuccess: () => resume({ error: null, token: null }),\n handleNewClientToken: (token) => resume({ error: null, token }),\n // deprecated\n resumeWithError: (error) => resume({ error, token: null }),\n resumeWithSuccess: (token) => resume({ error: null, token }),\n });\n } catch (e) {\n console.log('failed to parse json', e);\n }\n });\n}\n\nfunction configureOnVaultSuccess(\n callback: OnTokenAddedToVaultCallback = (_) => {}\n) {\n NativeModule.configureOnVaultSuccess((data: any) => {\n parseCallback<PaymentInstrumentToken>(data, callback);\n });\n}\n\nfunction configureOnDismiss(callback: OnDismissCallback = () => {}) {\n NativeModule.configureOnDismiss((_: any) => callback());\n}\n\nfunction configureOnError(callback: OnPrimerErrorCallback = (_) => {}) {\n NativeModule.configureOnPrimerError((data: any) => {\n parseCallback<PrimerError>(data, callback);\n });\n}\n\ninterface ResumeRequest {\n error: string | null;\n token: string | null;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["Primer.ts"],"names":["RNPrimer","resumeHandler","handleNewClientToken","clientToken","err","primerError","Error","errorId","errorDescription","message","handleError","handleSuccess","PrimerNativeMapping","showUniversalCheckout","config","removeAllListeners","settings","theme","configure","implementedRNCallbacks","isTokenAddedToVaultImplemented","onTokenAddedToVault","undefined","isOnResumeSuccessImplemented","onResumeSuccess","isOnResumeErrorImplemented","onError","isOnCheckoutDismissedImplemented","onDismiss","isCheckoutFailedImplemented","isClientSessionActionsImplemented","onClientSessionActions","setImplementedRNCallbacks","then","addListener","data","clientSessionActions","paymentInstrumentToken","onTokenizeSuccess","resumeToken","_","error","catch","console","showVaultManager","showPaymentMethod","intent","paymentMethod","vault","dispose"],"mappings":"AAKA,OAAOA,QAAP,MAAuC,YAAvC;AAEA,MAAMC,aAAkC,GAAG;AACzCC,EAAAA,oBAAoB,EAAE,MAAOC,WAAP,IAAuB;AAC3C,QAAI;AACF,YAAMH,QAAQ,CAACE,oBAAT,CAA8BC,WAA9B,CAAN;AACD,KAFD,CAEE,OAAOC,GAAP,EAAY;AACZ,UAAIC,WAAJ;;AACA,UAAID,GAAG,YAAYE,KAAnB,EAA0B;AACxBD,QAAAA,WAAW,GAAG;AACZE,UAAAA,OAAO,EAAE,qBADG;AAEZC,UAAAA,gBAAgB,EAAEJ,GAAG,CAACK;AAFV,SAAd;AAID,OALD,MAKO;AACLJ,QAAAA,WAAW,GAAG;AACZE,UAAAA,OAAO,EAAE,qBADG;AAEZC,UAAAA,gBAAgB,EAAE;AAFN,SAAd;AAID;;AACD,YAAMR,QAAQ,CAACU,WAAT,CAAqBL,WAArB,CAAN;AACD;AACF,GAnBwC;AAoBzCK,EAAAA,WAAW,EAAE,MAAON,GAAP,IAAe;AAC1B,QAAI;AACF,YAAMC,WAAyB,GAAG;AAChCE,QAAAA,OAAO,EAAE,cADuB;AAEhCC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,kBAAT;AACAf,IAAAA,QAAQ,CAACiD,OAAT;AACD;;AAhKyC,CAArC","sourcesContent":["import type { PaymentInstrumentToken } from './models/payment-instrument-token';\nimport type { IPrimer } from './models/primer';\nimport type { IPrimerConfig } from './models/primer-config';\nimport type { PrimerPaymentMethodIntent } from './models/primer-intent';\nimport type { PrimerResumeHandler } from './models/primer-request';\nimport RNPrimer, { IPrimerError } from './RNPrimer';\n\nconst resumeHandler: PrimerResumeHandler = {\n handleNewClientToken: async (clientToken) => {\n try {\n await RNPrimer.handleNewClientToken(clientToken);\n } catch (err) {\n let primerError: IPrimerError;\n if (err instanceof Error) {\n primerError = {\n errorId: \"react-native-bridge\",\n errorDescription: err.message\n }\n } else {\n primerError = {\n errorId: \"react-native-bridge\",\n errorDescription: \"unknown error\"\n }\n }\n await RNPrimer.handleError(primerError);\n }\n },\n handleError: async (err) => {\n try {\n const primerError: IPrimerError = {\n errorId: \"react-native\",\n errorDescription: err.message\n }\n await RNPrimer.handleError(primerError);\n } catch (err) {\n let primerError: IPrimerError;\n if (err instanceof Error) {\n primerError = {\n errorId: \"react-native-bridge\",\n errorDescription: err.message\n }\n } else {\n primerError = {\n errorId: \"react-native-bridge\",\n errorDescription: \"unknown error\"\n }\n }\n await RNPrimer.handleError(primerError);\n }\n },\n handleSuccess: async () => {\n try {\n await RNPrimer.handleSuccess();\n } catch (err) {\n let primerError: IPrimerError;\n if (err instanceof Error) {\n primerError = {\n errorId: \"react-native-bridge\",\n errorDescription: err.message\n }\n } else {\n primerError = {\n errorId: \"react-native-bridge\",\n errorDescription: \"unknown error\"\n }\n }\n await RNPrimer.handleError(primerError);\n }\n }\n}\n\nexport interface IClientSessionAction {\n type:\n | 'SELECT_PAYMENT_METHOD'\n | 'UNSELECT_PAYMENT_METHOD'\n | 'SET_BILLING_ADDRESS';\n params?: IActionParams;\n}\n\ninterface IActionParams {\n billingAddress: Record<string, string | null>;\n paymentMethodType?: string;\n binData?: IBinData;\n}\n\ninterface IBinData {\n network: string;\n}\n\nexport const PrimerNativeMapping: IPrimer = {\n\n showUniversalCheckout(clientToken: string, config: IPrimerConfig): void {\n RNPrimer.removeAllListeners();\n\n if (config.settings || config.theme) {\n RNPrimer.configure(config.settings || null, config.theme || null);\n\n let implementedRNCallbacks: any = {\n // isClientTokenCallbackImplemented: (config.onClientTokenCallback !== undefined),\n isTokenAddedToVaultImplemented: (config.onTokenAddedToVault !== undefined),\n isOnResumeSuccessImplemented: (config.onResumeSuccess !== undefined),\n isOnResumeErrorImplemented: (config.onError !== undefined),\n isOnCheckoutDismissedImplemented: (config.onDismiss !== undefined),\n isCheckoutFailedImplemented: (config.onError !== undefined),\n isClientSessionActionsImplemented: (config.onClientSessionActions !== undefined)\n };\n\n RNPrimer.setImplementedRNCallbacks(implementedRNCallbacks)\n .then(() => {\n RNPrimer.addListener('onClientSessionActions', data => {\n const clientSessionActions: IClientSessionAction[] = data;\n if (config.onClientSessionActions) {\n config.onClientSessionActions(clientSessionActions, resumeHandler);\n }\n });\n\n RNPrimer.addListener('onTokenizeSuccessCallback', data => {\n const paymentInstrumentToken: PaymentInstrumentToken = data;\n if (config.onTokenizeSuccess) {\n config.onTokenizeSuccess(paymentInstrumentToken, resumeHandler);\n }\n });\n\n RNPrimer.addListener('onResumeSuccess', data => {\n const resumeToken: string = data.resumeToken;\n if (config.onResumeSuccess) {\n config.onResumeSuccess(resumeToken, resumeHandler);\n }\n });\n\n RNPrimer.addListener('onCheckoutDismissed', _ => {\n if (config.onDismiss) {\n config.onDismiss();\n }\n });\n\n RNPrimer.addListener('onError', data => {\n const err: IPrimerError = data.error;\n if (config.onError) {\n config.onError(err, resumeHandler);\n }\n });\n\n RNPrimer.showUniversalCheckout(clientToken);\n })\n .catch( err => {\n console.error(err);\n })\n }\n\n // RNPrimer.addListener('onClientTokenCallback', _ => {\n // if (config.onClientTokenCallback) {\n // config.onClientTokenCallback(resumeHandler);\n // }\n // });\n },\n\n showVaultManager(clientToken: string, config: IPrimerConfig): void {\n RNPrimer.removeAllListeners();\n\n if (config.settings || config.theme) {\n RNPrimer.configure(config.settings || null, config.theme || null);\n\n let implementedRNCallbacks: any = {\n // isClientTokenCallbackImplemented: (config.onClientTokenCallback !== undefined),\n isTokenAddedToVaultImplemented: (config.onTokenAddedToVault !== undefined),\n isOnResumeSuccessImplemented: (config.onResumeSuccess !== undefined),\n isOnResumeErrorImplemented: (config.onError !== undefined),\n isOnCheckoutDismissedImplemented: (config.onDismiss !== undefined),\n isCheckoutFailedImplemented: (config.onError !== undefined),\n isClientSessionActionsImplemented: (config.onClientSessionActions !== undefined)\n };\n\n RNPrimer.setImplementedRNCallbacks(implementedRNCallbacks);\n }\n\n // RNPrimer.addListener('onClientTokenCallback', _ => {\n // if (config.onClientTokenCallback) {\n // config.onClientTokenCallback(resumeHandler);\n // }\n // });\n\n RNPrimer.addListener('onClientSessionActions', data => {\n const clientSessionActions: IClientSessionAction[] = data;\n if (config.onClientSessionActions) {\n config.onClientSessionActions(clientSessionActions, resumeHandler);\n } else {\n RNPrimer.handleSuccess();\n }\n });\n\n RNPrimer.addListener('onTokenizeSuccessCallback', data => {\n const paymentInstrumentToken: PaymentInstrumentToken = data;\n if (config.onTokenizeSuccess) {\n config.onTokenizeSuccess(paymentInstrumentToken, resumeHandler);\n }\n });\n\n RNPrimer.addListener('onResumeSuccess', data => {\n const resumeToken: string = data.resumeToken;\n if (config.onResumeSuccess) {\n config.onResumeSuccess(resumeToken, resumeHandler);\n }\n });\n\n RNPrimer.addListener('onCheckoutDismissed', () => {\n if (config.onDismiss) {\n config.onDismiss();\n }\n });\n\n RNPrimer.addListener('onError', data => {\n const err: IPrimerError = data.error;\n if (config.onError) {\n config.onError(err, resumeHandler);\n }\n });\n\n RNPrimer.showVaultManager(clientToken);\n },\n\n showPaymentMethod(\n clientToken: string,\n intent: PrimerPaymentMethodIntent,\n config: IPrimerConfig\n ): void {\n RNPrimer.removeAllListeners();\n\n if (config.settings || config.theme) {\n RNPrimer.configure(config.settings || null, config.theme || null);\n }\n\n let implementedRNCallbacks: any = {\n // isClientTokenCallbackImplemented: (config.onClientTokenCallback !== undefined),\n isTokenAddedToVaultImplemented: (config.onTokenAddedToVault !== undefined),\n isOnResumeSuccessImplemented: (config.onResumeSuccess !== undefined),\n isOnResumeErrorImplemented: (config.onError !== undefined),\n isOnCheckoutDismissedImplemented: (config.onDismiss !== undefined),\n isCheckoutFailedImplemented: (config.onError !== undefined),\n isClientSessionActionsImplemented: (config.onClientSessionActions !== undefined)\n };\n\n RNPrimer.setImplementedRNCallbacks(implementedRNCallbacks);\n RNPrimer.showPaymentMethod(clientToken, intent.paymentMethod, intent.vault === true ? \"vault\" : \"checkout\");\n },\n\n dispose(): void {\n RNPrimer.removeAllListeners();\n RNPrimer.dispose();\n },\n\n};\n"]}
|