@gmisoftware/react-native-pay 0.0.4
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/NitroPay.podspec +31 -0
- package/README.md +455 -0
- package/android/CMakeLists.txt +29 -0
- package/android/build.gradle +144 -0
- package/android/fix-prefab.gradle +51 -0
- package/android/gradle.properties +8 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/pay/Constants.kt +49 -0
- package/android/src/main/java/com/margelo/nitro/pay/GooglePayButtonFactory.kt +95 -0
- package/android/src/main/java/com/margelo/nitro/pay/GooglePayRequestBuilder.kt +170 -0
- package/android/src/main/java/com/margelo/nitro/pay/HybridGooglePayButton.kt +146 -0
- package/android/src/main/java/com/margelo/nitro/pay/HybridPaymentHandler.kt +184 -0
- package/android/src/main/java/com/margelo/nitro/pay/NitroPayPackage.kt +26 -0
- package/android/src/main/java/com/margelo/nitro/pay/PaymentMapper.kt +89 -0
- package/app.plugin.js +1 -0
- package/ios/ApplePayButtonFactory.swift +53 -0
- package/ios/Bridge.h +8 -0
- package/ios/HybridApplePayButton.swift +60 -0
- package/ios/HybridPaymentHandler.swift +248 -0
- package/ios/PassKitTypeMapper.swift +192 -0
- package/lib/hooks/index.d.ts +7 -0
- package/lib/hooks/index.js +10 -0
- package/lib/hooks/usePaymentCheckout.d.ts +95 -0
- package/lib/hooks/usePaymentCheckout.js +183 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +29 -0
- package/lib/plugin/index.d.ts +4 -0
- package/lib/plugin/index.js +10 -0
- package/lib/plugin/type.d.ts +4 -0
- package/lib/plugin/type.js +2 -0
- package/lib/plugin/withApplePay.d.ts +4 -0
- package/lib/plugin/withApplePay.js +32 -0
- package/lib/plugin/withGooglePay.d.ts +4 -0
- package/lib/plugin/withGooglePay.js +24 -0
- package/lib/specs/ApplePayButton.nitro.d.ts +13 -0
- package/lib/specs/ApplePayButton.nitro.js +2 -0
- package/lib/specs/GooglePayButton.nitro.d.ts +14 -0
- package/lib/specs/GooglePayButton.nitro.js +2 -0
- package/lib/specs/PaymentHandler.nitro.d.ts +10 -0
- package/lib/specs/PaymentHandler.nitro.js +2 -0
- package/lib/types/Contact.d.ts +51 -0
- package/lib/types/Contact.js +6 -0
- package/lib/types/Payment.d.ts +67 -0
- package/lib/types/Payment.js +6 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.js +18 -0
- package/lib/utils/index.d.ts +4 -0
- package/lib/utils/index.js +20 -0
- package/lib/utils/paymentHelpers.d.ts +144 -0
- package/lib/utils/paymentHelpers.js +190 -0
- package/nitro.json +30 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroPay+autolinking.cmake +87 -0
- package/nitrogen/generated/android/NitroPay+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroPayOnLoad.cpp +58 -0
- package/nitrogen/generated/android/NitroPayOnLoad.hpp +25 -0
- package/nitrogen/generated/android/c++/JCNContact.hpp +202 -0
- package/nitrogen/generated/android/c++/JCNContactType.hpp +59 -0
- package/nitrogen/generated/android/c++/JCNLabeledEmailAddress.hpp +62 -0
- package/nitrogen/generated/android/c++/JCNLabeledPhoneNumber.hpp +64 -0
- package/nitrogen/generated/android/c++/JCNLabeledPostalAddress.hpp +64 -0
- package/nitrogen/generated/android/c++/JCNPhoneNumber.hpp +57 -0
- package/nitrogen/generated/android/c++/JCNPostalAddress.hpp +78 -0
- package/nitrogen/generated/android/c++/JFunc_void.hpp +74 -0
- package/nitrogen/generated/android/c++/JGooglePayButtonTheme.hpp +59 -0
- package/nitrogen/generated/android/c++/JGooglePayButtonType.hpp +77 -0
- package/nitrogen/generated/android/c++/JGooglePayEnvironment.hpp +59 -0
- package/nitrogen/generated/android/c++/JHybridGooglePayButtonSpec.cpp +96 -0
- package/nitrogen/generated/android/c++/JHybridGooglePayButtonSpec.hpp +71 -0
- package/nitrogen/generated/android/c++/JHybridPaymentHandlerSpec.cpp +154 -0
- package/nitrogen/generated/android/c++/JHybridPaymentHandlerSpec.hpp +66 -0
- package/nitrogen/generated/android/c++/JPKSecureElementPass.hpp +96 -0
- package/nitrogen/generated/android/c++/JPassActivationState.hpp +68 -0
- package/nitrogen/generated/android/c++/JPayServiceStatus.hpp +61 -0
- package/nitrogen/generated/android/c++/JPaymentItem.hpp +67 -0
- package/nitrogen/generated/android/c++/JPaymentItemType.hpp +59 -0
- package/nitrogen/generated/android/c++/JPaymentMethod.hpp +97 -0
- package/nitrogen/generated/android/c++/JPaymentMethodType.hpp +68 -0
- package/nitrogen/generated/android/c++/JPaymentNetwork.hpp +86 -0
- package/nitrogen/generated/android/c++/JPaymentRequest.hpp +181 -0
- package/nitrogen/generated/android/c++/JPaymentResult.hpp +97 -0
- package/nitrogen/generated/android/c++/JPaymentToken.hpp +91 -0
- package/nitrogen/generated/android/c++/views/JHybridGooglePayButtonStateUpdater.cpp +68 -0
- package/nitrogen/generated/android/c++/views/JHybridGooglePayButtonStateUpdater.hpp +49 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/CNContact.kt +96 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/CNContactType.kt +21 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/CNLabeledEmailAddress.kt +39 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/CNLabeledPhoneNumber.kt +39 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/CNLabeledPostalAddress.kt +39 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/CNPhoneNumber.kt +36 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/CNPostalAddress.kt +51 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/Func_void.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/GooglePayButtonTheme.kt +21 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/GooglePayButtonType.kt +27 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/GooglePayEnvironment.kt +21 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/HybridGooglePayButtonSpec.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/HybridPaymentHandlerSpec.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/NitroPayOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PKSecureElementPass.kt +63 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PassActivationState.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PayServiceStatus.kt +39 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentItem.kt +42 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentItemType.kt +21 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentMethod.kt +48 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentMethodType.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentNetwork.kt +30 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentRequest.kt +72 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentResult.kt +45 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentToken.kt +42 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/views/HybridGooglePayButtonManager.kt +50 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/views/HybridGooglePayButtonStateUpdater.kt +23 -0
- package/nitrogen/generated/ios/NitroPay+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroPay-Swift-Cxx-Bridge.cpp +73 -0
- package/nitrogen/generated/ios/NitroPay-Swift-Cxx-Bridge.hpp +415 -0
- package/nitrogen/generated/ios/NitroPay-Swift-Cxx-Umbrella.hpp +116 -0
- package/nitrogen/generated/ios/NitroPayAutolinking.mm +41 -0
- package/nitrogen/generated/ios/NitroPayAutolinking.swift +40 -0
- package/nitrogen/generated/ios/c++/HybridApplePayButtonSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridApplePayButtonSpecSwift.hpp +92 -0
- package/nitrogen/generated/ios/c++/HybridPaymentHandlerSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridPaymentHandlerSpecSwift.hpp +148 -0
- package/nitrogen/generated/ios/c++/views/HybridApplePayButtonComponent.mm +106 -0
- package/nitrogen/generated/ios/swift/ApplePayButtonStyle.swift +44 -0
- package/nitrogen/generated/ios/swift/ApplePayButtonType.swift +84 -0
- package/nitrogen/generated/ios/swift/CNContact.swift +329 -0
- package/nitrogen/generated/ios/swift/CNContactType.swift +40 -0
- package/nitrogen/generated/ios/swift/CNLabeledEmailAddress.swift +65 -0
- package/nitrogen/generated/ios/swift/CNLabeledPhoneNumber.swift +65 -0
- package/nitrogen/generated/ios/swift/CNLabeledPostalAddress.swift +65 -0
- package/nitrogen/generated/ios/swift/CNPhoneNumber.swift +35 -0
- package/nitrogen/generated/ios/swift/CNPostalAddress.swift +204 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_PaymentResult.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/GooglePayEnvironment.swift +40 -0
- package/nitrogen/generated/ios/swift/HybridApplePayButtonSpec.swift +51 -0
- package/nitrogen/generated/ios/swift/HybridApplePayButtonSpec_cxx.swift +175 -0
- package/nitrogen/generated/ios/swift/HybridPaymentHandlerSpec.swift +52 -0
- package/nitrogen/generated/ios/swift/HybridPaymentHandlerSpec_cxx.swift +155 -0
- package/nitrogen/generated/ios/swift/PKSecureElementPass.swift +191 -0
- package/nitrogen/generated/ios/swift/PassActivationState.swift +52 -0
- package/nitrogen/generated/ios/swift/PayServiceStatus.swift +46 -0
- package/nitrogen/generated/ios/swift/PaymentItem.swift +57 -0
- package/nitrogen/generated/ios/swift/PaymentItemType.swift +40 -0
- package/nitrogen/generated/ios/swift/PaymentMethod.swift +134 -0
- package/nitrogen/generated/ios/swift/PaymentMethodType.swift +52 -0
- package/nitrogen/generated/ios/swift/PaymentNetwork.swift +76 -0
- package/nitrogen/generated/ios/swift/PaymentRequest.swift +341 -0
- package/nitrogen/generated/ios/swift/PaymentResult.swift +118 -0
- package/nitrogen/generated/ios/swift/PaymentToken.swift +57 -0
- package/nitrogen/generated/shared/c++/ApplePayButtonStyle.hpp +80 -0
- package/nitrogen/generated/shared/c++/ApplePayButtonType.hpp +120 -0
- package/nitrogen/generated/shared/c++/CNContact.hpp +168 -0
- package/nitrogen/generated/shared/c++/CNContactType.hpp +76 -0
- package/nitrogen/generated/shared/c++/CNLabeledEmailAddress.hpp +80 -0
- package/nitrogen/generated/shared/c++/CNLabeledPhoneNumber.hpp +82 -0
- package/nitrogen/generated/shared/c++/CNLabeledPostalAddress.hpp +82 -0
- package/nitrogen/generated/shared/c++/CNPhoneNumber.hpp +75 -0
- package/nitrogen/generated/shared/c++/CNPostalAddress.hpp +96 -0
- package/nitrogen/generated/shared/c++/GooglePayButtonTheme.hpp +76 -0
- package/nitrogen/generated/shared/c++/GooglePayButtonType.hpp +100 -0
- package/nitrogen/generated/shared/c++/GooglePayEnvironment.hpp +76 -0
- package/nitrogen/generated/shared/c++/HybridApplePayButtonSpec.cpp +26 -0
- package/nitrogen/generated/shared/c++/HybridApplePayButtonSpec.hpp +73 -0
- package/nitrogen/generated/shared/c++/HybridGooglePayButtonSpec.cpp +28 -0
- package/nitrogen/generated/shared/c++/HybridGooglePayButtonSpec.hpp +75 -0
- package/nitrogen/generated/shared/c++/HybridPaymentHandlerSpec.cpp +23 -0
- package/nitrogen/generated/shared/c++/HybridPaymentHandlerSpec.hpp +74 -0
- package/nitrogen/generated/shared/c++/PKSecureElementPass.hpp +114 -0
- package/nitrogen/generated/shared/c++/PassActivationState.hpp +88 -0
- package/nitrogen/generated/shared/c++/PayServiceStatus.hpp +79 -0
- package/nitrogen/generated/shared/c++/PaymentItem.hpp +85 -0
- package/nitrogen/generated/shared/c++/PaymentItemType.hpp +76 -0
- package/nitrogen/generated/shared/c++/PaymentMethod.hpp +103 -0
- package/nitrogen/generated/shared/c++/PaymentMethodType.hpp +88 -0
- package/nitrogen/generated/shared/c++/PaymentNetwork.hpp +112 -0
- package/nitrogen/generated/shared/c++/PaymentRequest.hpp +130 -0
- package/nitrogen/generated/shared/c++/PaymentResult.hpp +90 -0
- package/nitrogen/generated/shared/c++/PaymentToken.hpp +85 -0
- package/nitrogen/generated/shared/c++/views/HybridApplePayButtonComponent.cpp +111 -0
- package/nitrogen/generated/shared/c++/views/HybridApplePayButtonComponent.hpp +111 -0
- package/nitrogen/generated/shared/c++/views/HybridGooglePayButtonComponent.cpp +123 -0
- package/nitrogen/generated/shared/c++/views/HybridGooglePayButtonComponent.hpp +112 -0
- package/nitrogen/generated/shared/json/ApplePayButtonConfig.json +12 -0
- package/nitrogen/generated/shared/json/GooglePayButtonConfig.json +13 -0
- package/package.json +116 -0
- package/react-native.config.js +16 -0
- package/src/hooks/index.ts +12 -0
- package/src/hooks/usePaymentCheckout.ts +281 -0
- package/src/index.ts +32 -0
- package/src/plugin/index.ts +17 -0
- package/src/plugin/type.ts +4 -0
- package/src/plugin/withApplePay.ts +44 -0
- package/src/plugin/withGooglePay.ts +41 -0
- package/src/specs/ApplePayButton.nitro.ts +37 -0
- package/src/specs/GooglePayButton.nitro.ts +34 -0
- package/src/specs/PaymentHandler.nitro.ts +13 -0
- package/src/types/Contact.ts +58 -0
- package/src/types/Payment.ts +104 -0
- package/src/types/index.ts +2 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/paymentHelpers.ts +215 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { PaymentRequest, PaymentResult, PaymentItem, GooglePayEnvironment } from '../types';
|
|
2
|
+
export interface UsePaymentCheckoutConfig {
|
|
3
|
+
merchantIdentifier: string;
|
|
4
|
+
countryCode?: string;
|
|
5
|
+
currencyCode?: string;
|
|
6
|
+
supportedNetworks?: string[];
|
|
7
|
+
merchantCapabilities?: string[];
|
|
8
|
+
googlePayEnvironment?: GooglePayEnvironment;
|
|
9
|
+
googlePayGateway?: string;
|
|
10
|
+
googlePayGatewayMerchantId?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface UsePaymentCheckoutReturn {
|
|
13
|
+
canMakePayments: boolean;
|
|
14
|
+
canSetupCards: boolean;
|
|
15
|
+
isCheckingStatus: boolean;
|
|
16
|
+
items: PaymentItem[];
|
|
17
|
+
total: number;
|
|
18
|
+
addItem: (label: string, amount: number, type?: 'final' | 'pending') => void;
|
|
19
|
+
addItems: (items: Array<{
|
|
20
|
+
label: string;
|
|
21
|
+
amount: number;
|
|
22
|
+
type?: 'final' | 'pending';
|
|
23
|
+
}>) => void;
|
|
24
|
+
removeItem: (index: number) => void;
|
|
25
|
+
updateItem: (index: number, updates: Partial<PaymentItem>) => void;
|
|
26
|
+
clearItems: () => void;
|
|
27
|
+
startPayment: () => Promise<PaymentResult | null>;
|
|
28
|
+
isProcessing: boolean;
|
|
29
|
+
result: PaymentResult | null;
|
|
30
|
+
error: Error | null;
|
|
31
|
+
reset: () => void;
|
|
32
|
+
paymentRequest: PaymentRequest;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* All-in-one hook for payment checkout flow
|
|
36
|
+
*
|
|
37
|
+
* Handles:
|
|
38
|
+
* - Payment availability checking
|
|
39
|
+
* - Shopping cart management
|
|
40
|
+
* - Payment processing
|
|
41
|
+
* - State management
|
|
42
|
+
*
|
|
43
|
+
* @param config - Payment configuration
|
|
44
|
+
* @returns Complete payment checkout interface
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* function CheckoutScreen() {
|
|
49
|
+
* const {
|
|
50
|
+
* canMakePayments,
|
|
51
|
+
* items,
|
|
52
|
+
* total,
|
|
53
|
+
* addItem,
|
|
54
|
+
* addItems,
|
|
55
|
+
* removeItem,
|
|
56
|
+
* startPayment,
|
|
57
|
+
* isProcessing,
|
|
58
|
+
* error,
|
|
59
|
+
* } = usePaymentCheckout({
|
|
60
|
+
* merchantIdentifier: 'merchant.com.example',
|
|
61
|
+
* currencyCode: 'USD',
|
|
62
|
+
* countryCode: 'US',
|
|
63
|
+
* })
|
|
64
|
+
*
|
|
65
|
+
* // Add single item
|
|
66
|
+
* const handleAddOne = () => addItem('Coffee', 4.99)
|
|
67
|
+
*
|
|
68
|
+
* // Add multiple items at once
|
|
69
|
+
* const handleAddCart = () => addItems([
|
|
70
|
+
* { label: 'Coffee', amount: 4.99 },
|
|
71
|
+
* { label: 'Sandwich', amount: 8.99 },
|
|
72
|
+
* { label: 'Tax', amount: 1.20, type: 'final' }
|
|
73
|
+
* ])
|
|
74
|
+
*
|
|
75
|
+
* if (!canMakePayments) {
|
|
76
|
+
* return <Text>Payment not available</Text>
|
|
77
|
+
* }
|
|
78
|
+
*
|
|
79
|
+
* return (
|
|
80
|
+
* <>
|
|
81
|
+
* <Button title="Add Coffee" onPress={handleAddOne} />
|
|
82
|
+
* <Button title="Add Cart" onPress={handleAddCart} />
|
|
83
|
+
* <Text>Total: ${total.toFixed(2)}</Text>
|
|
84
|
+
* {isProcessing ? (
|
|
85
|
+
* <ActivityIndicator />
|
|
86
|
+
* ) : (
|
|
87
|
+
* <ApplePayButton onPress={startPayment} />
|
|
88
|
+
* )}
|
|
89
|
+
* {error && <Text>Error: {error.message}</Text>}
|
|
90
|
+
* </>
|
|
91
|
+
* )
|
|
92
|
+
* }
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare function usePaymentCheckout(config: UsePaymentCheckoutConfig): UsePaymentCheckoutReturn;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePaymentCheckout = usePaymentCheckout;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const react_native_nitro_modules_1 = require("react-native-nitro-modules");
|
|
6
|
+
const HybridPaymentHandler = react_native_nitro_modules_1.NitroModules.createHybridObject('PaymentHandler');
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
/**
|
|
9
|
+
* All-in-one hook for payment checkout flow
|
|
10
|
+
*
|
|
11
|
+
* Handles:
|
|
12
|
+
* - Payment availability checking
|
|
13
|
+
* - Shopping cart management
|
|
14
|
+
* - Payment processing
|
|
15
|
+
* - State management
|
|
16
|
+
*
|
|
17
|
+
* @param config - Payment configuration
|
|
18
|
+
* @returns Complete payment checkout interface
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* function CheckoutScreen() {
|
|
23
|
+
* const {
|
|
24
|
+
* canMakePayments,
|
|
25
|
+
* items,
|
|
26
|
+
* total,
|
|
27
|
+
* addItem,
|
|
28
|
+
* addItems,
|
|
29
|
+
* removeItem,
|
|
30
|
+
* startPayment,
|
|
31
|
+
* isProcessing,
|
|
32
|
+
* error,
|
|
33
|
+
* } = usePaymentCheckout({
|
|
34
|
+
* merchantIdentifier: 'merchant.com.example',
|
|
35
|
+
* currencyCode: 'USD',
|
|
36
|
+
* countryCode: 'US',
|
|
37
|
+
* })
|
|
38
|
+
*
|
|
39
|
+
* // Add single item
|
|
40
|
+
* const handleAddOne = () => addItem('Coffee', 4.99)
|
|
41
|
+
*
|
|
42
|
+
* // Add multiple items at once
|
|
43
|
+
* const handleAddCart = () => addItems([
|
|
44
|
+
* { label: 'Coffee', amount: 4.99 },
|
|
45
|
+
* { label: 'Sandwich', amount: 8.99 },
|
|
46
|
+
* { label: 'Tax', amount: 1.20, type: 'final' }
|
|
47
|
+
* ])
|
|
48
|
+
*
|
|
49
|
+
* if (!canMakePayments) {
|
|
50
|
+
* return <Text>Payment not available</Text>
|
|
51
|
+
* }
|
|
52
|
+
*
|
|
53
|
+
* return (
|
|
54
|
+
* <>
|
|
55
|
+
* <Button title="Add Coffee" onPress={handleAddOne} />
|
|
56
|
+
* <Button title="Add Cart" onPress={handleAddCart} />
|
|
57
|
+
* <Text>Total: ${total.toFixed(2)}</Text>
|
|
58
|
+
* {isProcessing ? (
|
|
59
|
+
* <ActivityIndicator />
|
|
60
|
+
* ) : (
|
|
61
|
+
* <ApplePayButton onPress={startPayment} />
|
|
62
|
+
* )}
|
|
63
|
+
* {error && <Text>Error: {error.message}</Text>}
|
|
64
|
+
* </>
|
|
65
|
+
* )
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
function usePaymentCheckout(config) {
|
|
70
|
+
// Payment status state
|
|
71
|
+
const [status, setStatus] = (0, react_1.useState)(null);
|
|
72
|
+
const [isCheckingStatus, setIsCheckingStatus] = (0, react_1.useState)(true);
|
|
73
|
+
// Cart state
|
|
74
|
+
const [items, setItems] = (0, react_1.useState)([]);
|
|
75
|
+
// Payment state
|
|
76
|
+
const [isProcessing, setIsProcessing] = (0, react_1.useState)(false);
|
|
77
|
+
const [result, setResult] = (0, react_1.useState)(null);
|
|
78
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
79
|
+
// Check payment status on mount
|
|
80
|
+
(0, react_1.useEffect)(() => {
|
|
81
|
+
try {
|
|
82
|
+
const paymentStatus = HybridPaymentHandler.payServiceStatus();
|
|
83
|
+
setStatus(paymentStatus);
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
console.error('Failed to check payment status:', err);
|
|
87
|
+
setStatus({ canMakePayments: false, canSetupCards: false });
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
setIsCheckingStatus(false);
|
|
91
|
+
}
|
|
92
|
+
}, []);
|
|
93
|
+
// Calculate total
|
|
94
|
+
const total = (0, react_1.useMemo)(() => (0, utils_1.calculateTotal)(items), [items]);
|
|
95
|
+
// Build payment request
|
|
96
|
+
const paymentRequest = (0, react_1.useMemo)(() => {
|
|
97
|
+
const { merchantIdentifier, countryCode = 'US', currencyCode = 'USD', supportedNetworks = ['visa', 'mastercard', 'amex', 'discover'], merchantCapabilities = ['3DS'], googlePayEnvironment, googlePayGateway, googlePayGatewayMerchantId, } = config;
|
|
98
|
+
return {
|
|
99
|
+
merchantIdentifier,
|
|
100
|
+
countryCode,
|
|
101
|
+
currencyCode,
|
|
102
|
+
supportedNetworks,
|
|
103
|
+
merchantCapabilities,
|
|
104
|
+
paymentItems: items.length > 0 ? items : [(0, utils_1.createPaymentItem)('Total', 0, 'final')],
|
|
105
|
+
googlePayEnvironment,
|
|
106
|
+
googlePayGateway,
|
|
107
|
+
googlePayGatewayMerchantId,
|
|
108
|
+
};
|
|
109
|
+
}, [config, items]);
|
|
110
|
+
// Cart operations
|
|
111
|
+
const addItem = (0, react_1.useCallback)((label, amount, type = 'final') => {
|
|
112
|
+
const item = (0, utils_1.createPaymentItem)(label, amount, type);
|
|
113
|
+
setItems((prev) => [...prev, item]);
|
|
114
|
+
}, []);
|
|
115
|
+
const addItems = (0, react_1.useCallback)((itemsToAdd) => {
|
|
116
|
+
const newItems = itemsToAdd.map((item) => (0, utils_1.createPaymentItem)(item.label, item.amount, item.type || 'final'));
|
|
117
|
+
setItems((prev) => [...prev, ...newItems]);
|
|
118
|
+
}, []);
|
|
119
|
+
const removeItem = (0, react_1.useCallback)((index) => {
|
|
120
|
+
setItems((prev) => prev.filter((_, i) => i !== index));
|
|
121
|
+
}, []);
|
|
122
|
+
const updateItem = (0, react_1.useCallback)((index, updates) => {
|
|
123
|
+
setItems((prev) => prev.map((item, i) => (i === index ? { ...item, ...updates } : item)));
|
|
124
|
+
}, []);
|
|
125
|
+
const clearItems = (0, react_1.useCallback)(() => {
|
|
126
|
+
setItems([]);
|
|
127
|
+
}, []);
|
|
128
|
+
// Start payment
|
|
129
|
+
const startPayment = (0, react_1.useCallback)(async () => {
|
|
130
|
+
if (items.length === 0) {
|
|
131
|
+
const emptyCartError = new Error('Cart is empty');
|
|
132
|
+
setError(emptyCartError);
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
setIsProcessing(true);
|
|
136
|
+
setResult(null);
|
|
137
|
+
setError(null);
|
|
138
|
+
try {
|
|
139
|
+
const paymentResult = await HybridPaymentHandler.startPayment(paymentRequest);
|
|
140
|
+
setResult(paymentResult);
|
|
141
|
+
if (!paymentResult.success) {
|
|
142
|
+
setError(new Error(paymentResult.error || 'Payment failed'));
|
|
143
|
+
}
|
|
144
|
+
return paymentResult;
|
|
145
|
+
}
|
|
146
|
+
catch (err) {
|
|
147
|
+
const paymentError = err instanceof Error ? err : new Error('Payment processing failed');
|
|
148
|
+
setError(paymentError);
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
finally {
|
|
152
|
+
setIsProcessing(false);
|
|
153
|
+
}
|
|
154
|
+
}, [items, paymentRequest]);
|
|
155
|
+
// Reset all state
|
|
156
|
+
const reset = (0, react_1.useCallback)(() => {
|
|
157
|
+
setIsProcessing(false);
|
|
158
|
+
setResult(null);
|
|
159
|
+
setError(null);
|
|
160
|
+
}, []);
|
|
161
|
+
return {
|
|
162
|
+
// Status
|
|
163
|
+
canMakePayments: status?.canMakePayments ?? false,
|
|
164
|
+
canSetupCards: status?.canSetupCards ?? false,
|
|
165
|
+
isCheckingStatus,
|
|
166
|
+
// Cart
|
|
167
|
+
items,
|
|
168
|
+
total,
|
|
169
|
+
addItem,
|
|
170
|
+
addItems,
|
|
171
|
+
removeItem,
|
|
172
|
+
updateItem,
|
|
173
|
+
clearItems,
|
|
174
|
+
// Payment
|
|
175
|
+
startPayment,
|
|
176
|
+
isProcessing,
|
|
177
|
+
result,
|
|
178
|
+
error,
|
|
179
|
+
// Utilities
|
|
180
|
+
reset,
|
|
181
|
+
paymentRequest,
|
|
182
|
+
};
|
|
183
|
+
}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ApplePayButtonProps, ApplePayButtonMethods } from './specs/ApplePayButton.nitro';
|
|
2
|
+
import type { GooglePayButtonProps, GooglePayButtonMethods } from './specs/GooglePayButton.nitro';
|
|
3
|
+
import type { PaymentHandler } from './specs/PaymentHandler.nitro';
|
|
4
|
+
export declare const HybridPaymentHandler: PaymentHandler;
|
|
5
|
+
export type { PaymentHandler } from './specs/PaymentHandler.nitro';
|
|
6
|
+
export declare const ApplePayButton: import("react-native-nitro-modules").ReactNativeView<ApplePayButtonProps, ApplePayButtonMethods>;
|
|
7
|
+
export declare const GooglePayButton: import("react-native-nitro-modules").ReactNativeView<GooglePayButtonProps, GooglePayButtonMethods>;
|
|
8
|
+
export * from './types';
|
|
9
|
+
export * from './utils';
|
|
10
|
+
export * from './hooks';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.GooglePayButton = exports.ApplePayButton = exports.HybridPaymentHandler = void 0;
|
|
21
|
+
const react_native_nitro_modules_1 = require("react-native-nitro-modules");
|
|
22
|
+
exports.HybridPaymentHandler = react_native_nitro_modules_1.NitroModules.createHybridObject('PaymentHandler');
|
|
23
|
+
const ApplePayButtonConfig_json_1 = __importDefault(require("../nitrogen/generated/shared/json/ApplePayButtonConfig.json"));
|
|
24
|
+
const GooglePayButtonConfig_json_1 = __importDefault(require("../nitrogen/generated/shared/json/GooglePayButtonConfig.json"));
|
|
25
|
+
exports.ApplePayButton = (0, react_native_nitro_modules_1.getHostComponent)('ApplePayButton', () => ApplePayButtonConfig_json_1.default);
|
|
26
|
+
exports.GooglePayButton = (0, react_native_nitro_modules_1.getHostComponent)('GooglePayButton', () => GooglePayButtonConfig_json_1.default);
|
|
27
|
+
__exportStar(require("./types"), exports);
|
|
28
|
+
__exportStar(require("./utils"), exports);
|
|
29
|
+
__exportStar(require("./hooks"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const withApplePay_1 = require("./withApplePay");
|
|
4
|
+
const withGooglePay_1 = require("./withGooglePay");
|
|
5
|
+
const withReactNativePay = (config, props) => {
|
|
6
|
+
config = (0, withGooglePay_1.withGooglePay)(config, props);
|
|
7
|
+
config = (0, withApplePay_1.withApplePay)(config, props);
|
|
8
|
+
return config;
|
|
9
|
+
};
|
|
10
|
+
exports.default = withReactNativePay;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type ConfigPlugin } from 'expo/config-plugins';
|
|
2
|
+
import type { ReactNativePayPluginProps } from './type';
|
|
3
|
+
export declare function setApplePayEntitlement(merchantIdentifiers: string | string[], entitlements: Record<string, any>): Record<string, any>;
|
|
4
|
+
export declare const withApplePay: ConfigPlugin<ReactNativePayPluginProps>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withApplePay = void 0;
|
|
4
|
+
exports.setApplePayEntitlement = setApplePayEntitlement;
|
|
5
|
+
const config_plugins_1 = require("expo/config-plugins");
|
|
6
|
+
function setApplePayEntitlement(merchantIdentifiers, entitlements) {
|
|
7
|
+
const key = 'com.apple.developer.in-app-payments';
|
|
8
|
+
const merchants = entitlements[key] ?? [];
|
|
9
|
+
if (!Array.isArray(merchantIdentifiers)) {
|
|
10
|
+
merchantIdentifiers = [merchantIdentifiers];
|
|
11
|
+
}
|
|
12
|
+
for (const id of merchantIdentifiers) {
|
|
13
|
+
if (id && !merchants.includes(id)) {
|
|
14
|
+
merchants.push(id);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (merchants.length) {
|
|
18
|
+
entitlements[key] = merchants;
|
|
19
|
+
}
|
|
20
|
+
return entitlements;
|
|
21
|
+
}
|
|
22
|
+
const withApplePay = (expoConfig, { merchantIdentifier }) => {
|
|
23
|
+
// If merchantIdentifier is not passed Apple Pay won't be initialize
|
|
24
|
+
if (!merchantIdentifier) {
|
|
25
|
+
return expoConfig;
|
|
26
|
+
}
|
|
27
|
+
return (0, config_plugins_1.withEntitlementsPlist)(expoConfig, (config) => {
|
|
28
|
+
config.modResults = setApplePayEntitlement(merchantIdentifier, config.modResults);
|
|
29
|
+
return config;
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
exports.withApplePay = withApplePay;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AndroidConfig, type ConfigPlugin } from 'expo/config-plugins';
|
|
2
|
+
import type { ReactNativePayPluginProps } from './type';
|
|
3
|
+
export declare const withGooglePay: ConfigPlugin<ReactNativePayPluginProps>;
|
|
4
|
+
export declare function setGooglePayMetaData(enabled: boolean, modResults: AndroidConfig.Manifest.AndroidManifest): AndroidConfig.Manifest.AndroidManifest;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withGooglePay = void 0;
|
|
4
|
+
exports.setGooglePayMetaData = setGooglePayMetaData;
|
|
5
|
+
const config_plugins_1 = require("expo/config-plugins");
|
|
6
|
+
const { addMetaDataItemToMainApplication, getMainApplicationOrThrow, removeMetaDataItemFromMainApplication, } = config_plugins_1.AndroidConfig.Manifest;
|
|
7
|
+
const withGooglePay = (expoConfig, { enableGooglePay = false }) => {
|
|
8
|
+
return (0, config_plugins_1.withAndroidManifest)(expoConfig, (config) => {
|
|
9
|
+
config.modResults = setGooglePayMetaData(enableGooglePay, config.modResults);
|
|
10
|
+
return config;
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
exports.withGooglePay = withGooglePay;
|
|
14
|
+
function setGooglePayMetaData(enabled, modResults) {
|
|
15
|
+
const GOOGLE_PAY_META_NAME = 'com.google.android.gms.wallet.api.enabled';
|
|
16
|
+
const mainApplication = getMainApplicationOrThrow(modResults);
|
|
17
|
+
if (enabled) {
|
|
18
|
+
addMetaDataItemToMainApplication(mainApplication, GOOGLE_PAY_META_NAME, 'true');
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
removeMetaDataItemFromMainApplication(mainApplication, GOOGLE_PAY_META_NAME);
|
|
22
|
+
}
|
|
23
|
+
return modResults;
|
|
24
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HybridView, HybridViewProps, HybridViewMethods } from 'react-native-nitro-modules';
|
|
2
|
+
export type ApplePayButtonType = 'buy' | 'setUp' | 'book' | 'donate' | 'continue' | 'reload' | 'addMoney' | 'topUp' | 'order' | 'rent' | 'support' | 'contribute' | 'tip';
|
|
3
|
+
export type ApplePayButtonStyle = 'white' | 'whiteOutline' | 'black';
|
|
4
|
+
export interface ApplePayButtonProps extends HybridViewProps {
|
|
5
|
+
buttonType: ApplePayButtonType;
|
|
6
|
+
buttonStyle: ApplePayButtonStyle;
|
|
7
|
+
onPress?: () => void;
|
|
8
|
+
}
|
|
9
|
+
export interface ApplePayButtonMethods extends HybridViewMethods {
|
|
10
|
+
}
|
|
11
|
+
export type ApplePayButton = HybridView<ApplePayButtonProps, ApplePayButtonMethods, {
|
|
12
|
+
ios: 'swift';
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HybridView, HybridViewProps, HybridViewMethods } from 'react-native-nitro-modules';
|
|
2
|
+
export type GooglePayButtonType = 'buy' | 'book' | 'checkout' | 'donate' | 'order' | 'pay' | 'subscribe' | 'plain';
|
|
3
|
+
export type GooglePayButtonTheme = 'dark' | 'light';
|
|
4
|
+
export interface GooglePayButtonProps extends HybridViewProps {
|
|
5
|
+
buttonType: GooglePayButtonType;
|
|
6
|
+
theme: GooglePayButtonTheme;
|
|
7
|
+
radius?: number;
|
|
8
|
+
onPress?: () => void;
|
|
9
|
+
}
|
|
10
|
+
export interface GooglePayButtonMethods extends HybridViewMethods {
|
|
11
|
+
}
|
|
12
|
+
export type GooglePayButton = HybridView<GooglePayButtonProps, GooglePayButtonMethods, {
|
|
13
|
+
android: 'kotlin';
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
import type { PayServiceStatus, PaymentRequest, PaymentResult } from '../types/Payment';
|
|
3
|
+
export interface PaymentHandler extends HybridObject<{
|
|
4
|
+
ios: 'swift';
|
|
5
|
+
android: 'kotlin';
|
|
6
|
+
}> {
|
|
7
|
+
payServiceStatus(): PayServiceStatus;
|
|
8
|
+
startPayment(request: PaymentRequest): Promise<PaymentResult>;
|
|
9
|
+
canMakePayments(usingNetworks: string[]): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contact types based on CNContact from Contacts framework
|
|
3
|
+
* @see https://developer.apple.com/documentation/contacts/cncontact
|
|
4
|
+
*/
|
|
5
|
+
export type CNContactType = 'person' | 'organization';
|
|
6
|
+
export interface CNPhoneNumber {
|
|
7
|
+
stringValue: string;
|
|
8
|
+
}
|
|
9
|
+
export interface CNPostalAddress {
|
|
10
|
+
street?: string;
|
|
11
|
+
city?: string;
|
|
12
|
+
state?: string;
|
|
13
|
+
postalCode?: string;
|
|
14
|
+
country?: string;
|
|
15
|
+
isoCountryCode?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface CNLabeledPhoneNumber {
|
|
18
|
+
label?: string;
|
|
19
|
+
value: CNPhoneNumber;
|
|
20
|
+
}
|
|
21
|
+
export interface CNLabeledEmailAddress {
|
|
22
|
+
label?: string;
|
|
23
|
+
value: string;
|
|
24
|
+
}
|
|
25
|
+
export interface CNLabeledPostalAddress {
|
|
26
|
+
label?: string;
|
|
27
|
+
value: CNPostalAddress;
|
|
28
|
+
}
|
|
29
|
+
export interface CNContact {
|
|
30
|
+
identifier: string;
|
|
31
|
+
contactType: CNContactType;
|
|
32
|
+
namePrefix: string;
|
|
33
|
+
givenName: string;
|
|
34
|
+
middleName: string;
|
|
35
|
+
familyName: string;
|
|
36
|
+
previousFamilyName: string;
|
|
37
|
+
nameSuffix: string;
|
|
38
|
+
nickname: string;
|
|
39
|
+
organizationName: string;
|
|
40
|
+
departmentName: string;
|
|
41
|
+
jobTitle: string;
|
|
42
|
+
phoneticGivenName: string;
|
|
43
|
+
phoneticMiddleName: string;
|
|
44
|
+
phoneticFamilyName: string;
|
|
45
|
+
phoneticOrganizationName?: string;
|
|
46
|
+
note: string;
|
|
47
|
+
imageDataAvailable?: boolean;
|
|
48
|
+
phoneNumbers: CNLabeledPhoneNumber[];
|
|
49
|
+
emailAddresses: CNLabeledEmailAddress[];
|
|
50
|
+
postalAddresses: CNLabeledPostalAddress[];
|
|
51
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payment types based on PassKit framework
|
|
3
|
+
* @see https://developer.apple.com/documentation/passkit
|
|
4
|
+
*/
|
|
5
|
+
import type { CNContact } from './Contact';
|
|
6
|
+
export type PaymentItemType = 'final' | 'pending';
|
|
7
|
+
export type PaymentMethodType = 'unknown' | 'debit' | 'credit' | 'prepaid' | 'store';
|
|
8
|
+
export type PaymentNetwork = 'visa' | 'mastercard' | 'amex' | 'discover' | 'jcb' | 'maestro' | 'electron' | 'elo' | 'idcredit' | 'interac' | 'privateLabel';
|
|
9
|
+
export type PassActivationState = 'activated' | 'requiresActivation' | 'activating' | 'suspended' | 'deactivated';
|
|
10
|
+
export type GooglePayEnvironment = 'TEST' | 'PRODUCTION';
|
|
11
|
+
export interface PKPass {
|
|
12
|
+
passTypeIdentifier: string;
|
|
13
|
+
serialNumber: string;
|
|
14
|
+
organizationName?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface PKSecureElementPass extends PKPass {
|
|
17
|
+
primaryAccountIdentifier: string;
|
|
18
|
+
primaryAccountNumberSuffix: string;
|
|
19
|
+
deviceAccountIdentifier: string;
|
|
20
|
+
deviceAccountNumberSuffix: string;
|
|
21
|
+
passActivationState: PassActivationState;
|
|
22
|
+
devicePassIdentifier?: string;
|
|
23
|
+
pairedTerminalIdentifier?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface PaymentItem {
|
|
26
|
+
label: string;
|
|
27
|
+
amount: number;
|
|
28
|
+
type: PaymentItemType;
|
|
29
|
+
}
|
|
30
|
+
export interface PaymentMethod {
|
|
31
|
+
displayName?: string;
|
|
32
|
+
network?: PaymentNetwork;
|
|
33
|
+
type: PaymentMethodType;
|
|
34
|
+
secureElementPass?: PKSecureElementPass;
|
|
35
|
+
billingAddress?: CNContact;
|
|
36
|
+
}
|
|
37
|
+
export interface PaymentToken {
|
|
38
|
+
paymentMethod: PaymentMethod;
|
|
39
|
+
transactionIdentifier: string;
|
|
40
|
+
paymentData: string;
|
|
41
|
+
}
|
|
42
|
+
export interface PaymentRequest {
|
|
43
|
+
merchantIdentifier: string;
|
|
44
|
+
countryCode: string;
|
|
45
|
+
currencyCode: string;
|
|
46
|
+
paymentItems: PaymentItem[];
|
|
47
|
+
merchantCapabilities: string[];
|
|
48
|
+
supportedNetworks: string[];
|
|
49
|
+
shippingType?: string;
|
|
50
|
+
shippingMethods?: PaymentItem[];
|
|
51
|
+
billingContactRequired?: boolean;
|
|
52
|
+
shippingContactRequired?: boolean;
|
|
53
|
+
googlePayEnvironment?: GooglePayEnvironment;
|
|
54
|
+
googlePayGateway?: string;
|
|
55
|
+
googlePayGatewayMerchantId?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface PaymentResult {
|
|
58
|
+
success: boolean;
|
|
59
|
+
transactionId?: string;
|
|
60
|
+
token?: PaymentToken;
|
|
61
|
+
error?: string;
|
|
62
|
+
}
|
|
63
|
+
export interface PayServiceStatus {
|
|
64
|
+
canMakePayments: boolean;
|
|
65
|
+
canSetupCards: boolean;
|
|
66
|
+
}
|
|
67
|
+
export type ApplePayStatus = PayServiceStatus;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Contact"), exports);
|
|
18
|
+
__exportStar(require("./Payment"), exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Utility functions for react-native-pay
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
__exportStar(require("./paymentHelpers"), exports);
|