@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.
Files changed (203) hide show
  1. package/NitroPay.podspec +31 -0
  2. package/README.md +455 -0
  3. package/android/CMakeLists.txt +29 -0
  4. package/android/build.gradle +144 -0
  5. package/android/fix-prefab.gradle +51 -0
  6. package/android/gradle.properties +8 -0
  7. package/android/src/main/AndroidManifest.xml +2 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/margelo/nitro/pay/Constants.kt +49 -0
  10. package/android/src/main/java/com/margelo/nitro/pay/GooglePayButtonFactory.kt +95 -0
  11. package/android/src/main/java/com/margelo/nitro/pay/GooglePayRequestBuilder.kt +170 -0
  12. package/android/src/main/java/com/margelo/nitro/pay/HybridGooglePayButton.kt +146 -0
  13. package/android/src/main/java/com/margelo/nitro/pay/HybridPaymentHandler.kt +184 -0
  14. package/android/src/main/java/com/margelo/nitro/pay/NitroPayPackage.kt +26 -0
  15. package/android/src/main/java/com/margelo/nitro/pay/PaymentMapper.kt +89 -0
  16. package/app.plugin.js +1 -0
  17. package/ios/ApplePayButtonFactory.swift +53 -0
  18. package/ios/Bridge.h +8 -0
  19. package/ios/HybridApplePayButton.swift +60 -0
  20. package/ios/HybridPaymentHandler.swift +248 -0
  21. package/ios/PassKitTypeMapper.swift +192 -0
  22. package/lib/hooks/index.d.ts +7 -0
  23. package/lib/hooks/index.js +10 -0
  24. package/lib/hooks/usePaymentCheckout.d.ts +95 -0
  25. package/lib/hooks/usePaymentCheckout.js +183 -0
  26. package/lib/index.d.ts +10 -0
  27. package/lib/index.js +29 -0
  28. package/lib/plugin/index.d.ts +4 -0
  29. package/lib/plugin/index.js +10 -0
  30. package/lib/plugin/type.d.ts +4 -0
  31. package/lib/plugin/type.js +2 -0
  32. package/lib/plugin/withApplePay.d.ts +4 -0
  33. package/lib/plugin/withApplePay.js +32 -0
  34. package/lib/plugin/withGooglePay.d.ts +4 -0
  35. package/lib/plugin/withGooglePay.js +24 -0
  36. package/lib/specs/ApplePayButton.nitro.d.ts +13 -0
  37. package/lib/specs/ApplePayButton.nitro.js +2 -0
  38. package/lib/specs/GooglePayButton.nitro.d.ts +14 -0
  39. package/lib/specs/GooglePayButton.nitro.js +2 -0
  40. package/lib/specs/PaymentHandler.nitro.d.ts +10 -0
  41. package/lib/specs/PaymentHandler.nitro.js +2 -0
  42. package/lib/types/Contact.d.ts +51 -0
  43. package/lib/types/Contact.js +6 -0
  44. package/lib/types/Payment.d.ts +67 -0
  45. package/lib/types/Payment.js +6 -0
  46. package/lib/types/index.d.ts +2 -0
  47. package/lib/types/index.js +18 -0
  48. package/lib/utils/index.d.ts +4 -0
  49. package/lib/utils/index.js +20 -0
  50. package/lib/utils/paymentHelpers.d.ts +144 -0
  51. package/lib/utils/paymentHelpers.js +190 -0
  52. package/nitro.json +30 -0
  53. package/nitrogen/generated/.gitattributes +1 -0
  54. package/nitrogen/generated/android/NitroPay+autolinking.cmake +87 -0
  55. package/nitrogen/generated/android/NitroPay+autolinking.gradle +27 -0
  56. package/nitrogen/generated/android/NitroPayOnLoad.cpp +58 -0
  57. package/nitrogen/generated/android/NitroPayOnLoad.hpp +25 -0
  58. package/nitrogen/generated/android/c++/JCNContact.hpp +202 -0
  59. package/nitrogen/generated/android/c++/JCNContactType.hpp +59 -0
  60. package/nitrogen/generated/android/c++/JCNLabeledEmailAddress.hpp +62 -0
  61. package/nitrogen/generated/android/c++/JCNLabeledPhoneNumber.hpp +64 -0
  62. package/nitrogen/generated/android/c++/JCNLabeledPostalAddress.hpp +64 -0
  63. package/nitrogen/generated/android/c++/JCNPhoneNumber.hpp +57 -0
  64. package/nitrogen/generated/android/c++/JCNPostalAddress.hpp +78 -0
  65. package/nitrogen/generated/android/c++/JFunc_void.hpp +74 -0
  66. package/nitrogen/generated/android/c++/JGooglePayButtonTheme.hpp +59 -0
  67. package/nitrogen/generated/android/c++/JGooglePayButtonType.hpp +77 -0
  68. package/nitrogen/generated/android/c++/JGooglePayEnvironment.hpp +59 -0
  69. package/nitrogen/generated/android/c++/JHybridGooglePayButtonSpec.cpp +96 -0
  70. package/nitrogen/generated/android/c++/JHybridGooglePayButtonSpec.hpp +71 -0
  71. package/nitrogen/generated/android/c++/JHybridPaymentHandlerSpec.cpp +154 -0
  72. package/nitrogen/generated/android/c++/JHybridPaymentHandlerSpec.hpp +66 -0
  73. package/nitrogen/generated/android/c++/JPKSecureElementPass.hpp +96 -0
  74. package/nitrogen/generated/android/c++/JPassActivationState.hpp +68 -0
  75. package/nitrogen/generated/android/c++/JPayServiceStatus.hpp +61 -0
  76. package/nitrogen/generated/android/c++/JPaymentItem.hpp +67 -0
  77. package/nitrogen/generated/android/c++/JPaymentItemType.hpp +59 -0
  78. package/nitrogen/generated/android/c++/JPaymentMethod.hpp +97 -0
  79. package/nitrogen/generated/android/c++/JPaymentMethodType.hpp +68 -0
  80. package/nitrogen/generated/android/c++/JPaymentNetwork.hpp +86 -0
  81. package/nitrogen/generated/android/c++/JPaymentRequest.hpp +181 -0
  82. package/nitrogen/generated/android/c++/JPaymentResult.hpp +97 -0
  83. package/nitrogen/generated/android/c++/JPaymentToken.hpp +91 -0
  84. package/nitrogen/generated/android/c++/views/JHybridGooglePayButtonStateUpdater.cpp +68 -0
  85. package/nitrogen/generated/android/c++/views/JHybridGooglePayButtonStateUpdater.hpp +49 -0
  86. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/CNContact.kt +96 -0
  87. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/CNContactType.kt +21 -0
  88. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/CNLabeledEmailAddress.kt +39 -0
  89. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/CNLabeledPhoneNumber.kt +39 -0
  90. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/CNLabeledPostalAddress.kt +39 -0
  91. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/CNPhoneNumber.kt +36 -0
  92. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/CNPostalAddress.kt +51 -0
  93. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/Func_void.kt +80 -0
  94. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/GooglePayButtonTheme.kt +21 -0
  95. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/GooglePayButtonType.kt +27 -0
  96. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/GooglePayEnvironment.kt +21 -0
  97. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/HybridGooglePayButtonSpec.kt +80 -0
  98. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/HybridPaymentHandlerSpec.kt +61 -0
  99. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/NitroPayOnLoad.kt +35 -0
  100. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PKSecureElementPass.kt +63 -0
  101. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PassActivationState.kt +24 -0
  102. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PayServiceStatus.kt +39 -0
  103. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentItem.kt +42 -0
  104. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentItemType.kt +21 -0
  105. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentMethod.kt +48 -0
  106. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentMethodType.kt +24 -0
  107. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentNetwork.kt +30 -0
  108. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentRequest.kt +72 -0
  109. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentResult.kt +45 -0
  110. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentToken.kt +42 -0
  111. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/views/HybridGooglePayButtonManager.kt +50 -0
  112. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/views/HybridGooglePayButtonStateUpdater.kt +23 -0
  113. package/nitrogen/generated/ios/NitroPay+autolinking.rb +60 -0
  114. package/nitrogen/generated/ios/NitroPay-Swift-Cxx-Bridge.cpp +73 -0
  115. package/nitrogen/generated/ios/NitroPay-Swift-Cxx-Bridge.hpp +415 -0
  116. package/nitrogen/generated/ios/NitroPay-Swift-Cxx-Umbrella.hpp +116 -0
  117. package/nitrogen/generated/ios/NitroPayAutolinking.mm +41 -0
  118. package/nitrogen/generated/ios/NitroPayAutolinking.swift +40 -0
  119. package/nitrogen/generated/ios/c++/HybridApplePayButtonSpecSwift.cpp +11 -0
  120. package/nitrogen/generated/ios/c++/HybridApplePayButtonSpecSwift.hpp +92 -0
  121. package/nitrogen/generated/ios/c++/HybridPaymentHandlerSpecSwift.cpp +11 -0
  122. package/nitrogen/generated/ios/c++/HybridPaymentHandlerSpecSwift.hpp +148 -0
  123. package/nitrogen/generated/ios/c++/views/HybridApplePayButtonComponent.mm +106 -0
  124. package/nitrogen/generated/ios/swift/ApplePayButtonStyle.swift +44 -0
  125. package/nitrogen/generated/ios/swift/ApplePayButtonType.swift +84 -0
  126. package/nitrogen/generated/ios/swift/CNContact.swift +329 -0
  127. package/nitrogen/generated/ios/swift/CNContactType.swift +40 -0
  128. package/nitrogen/generated/ios/swift/CNLabeledEmailAddress.swift +65 -0
  129. package/nitrogen/generated/ios/swift/CNLabeledPhoneNumber.swift +65 -0
  130. package/nitrogen/generated/ios/swift/CNLabeledPostalAddress.swift +65 -0
  131. package/nitrogen/generated/ios/swift/CNPhoneNumber.swift +35 -0
  132. package/nitrogen/generated/ios/swift/CNPostalAddress.swift +204 -0
  133. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  134. package/nitrogen/generated/ios/swift/Func_void_PaymentResult.swift +47 -0
  135. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  136. package/nitrogen/generated/ios/swift/GooglePayEnvironment.swift +40 -0
  137. package/nitrogen/generated/ios/swift/HybridApplePayButtonSpec.swift +51 -0
  138. package/nitrogen/generated/ios/swift/HybridApplePayButtonSpec_cxx.swift +175 -0
  139. package/nitrogen/generated/ios/swift/HybridPaymentHandlerSpec.swift +52 -0
  140. package/nitrogen/generated/ios/swift/HybridPaymentHandlerSpec_cxx.swift +155 -0
  141. package/nitrogen/generated/ios/swift/PKSecureElementPass.swift +191 -0
  142. package/nitrogen/generated/ios/swift/PassActivationState.swift +52 -0
  143. package/nitrogen/generated/ios/swift/PayServiceStatus.swift +46 -0
  144. package/nitrogen/generated/ios/swift/PaymentItem.swift +57 -0
  145. package/nitrogen/generated/ios/swift/PaymentItemType.swift +40 -0
  146. package/nitrogen/generated/ios/swift/PaymentMethod.swift +134 -0
  147. package/nitrogen/generated/ios/swift/PaymentMethodType.swift +52 -0
  148. package/nitrogen/generated/ios/swift/PaymentNetwork.swift +76 -0
  149. package/nitrogen/generated/ios/swift/PaymentRequest.swift +341 -0
  150. package/nitrogen/generated/ios/swift/PaymentResult.swift +118 -0
  151. package/nitrogen/generated/ios/swift/PaymentToken.swift +57 -0
  152. package/nitrogen/generated/shared/c++/ApplePayButtonStyle.hpp +80 -0
  153. package/nitrogen/generated/shared/c++/ApplePayButtonType.hpp +120 -0
  154. package/nitrogen/generated/shared/c++/CNContact.hpp +168 -0
  155. package/nitrogen/generated/shared/c++/CNContactType.hpp +76 -0
  156. package/nitrogen/generated/shared/c++/CNLabeledEmailAddress.hpp +80 -0
  157. package/nitrogen/generated/shared/c++/CNLabeledPhoneNumber.hpp +82 -0
  158. package/nitrogen/generated/shared/c++/CNLabeledPostalAddress.hpp +82 -0
  159. package/nitrogen/generated/shared/c++/CNPhoneNumber.hpp +75 -0
  160. package/nitrogen/generated/shared/c++/CNPostalAddress.hpp +96 -0
  161. package/nitrogen/generated/shared/c++/GooglePayButtonTheme.hpp +76 -0
  162. package/nitrogen/generated/shared/c++/GooglePayButtonType.hpp +100 -0
  163. package/nitrogen/generated/shared/c++/GooglePayEnvironment.hpp +76 -0
  164. package/nitrogen/generated/shared/c++/HybridApplePayButtonSpec.cpp +26 -0
  165. package/nitrogen/generated/shared/c++/HybridApplePayButtonSpec.hpp +73 -0
  166. package/nitrogen/generated/shared/c++/HybridGooglePayButtonSpec.cpp +28 -0
  167. package/nitrogen/generated/shared/c++/HybridGooglePayButtonSpec.hpp +75 -0
  168. package/nitrogen/generated/shared/c++/HybridPaymentHandlerSpec.cpp +23 -0
  169. package/nitrogen/generated/shared/c++/HybridPaymentHandlerSpec.hpp +74 -0
  170. package/nitrogen/generated/shared/c++/PKSecureElementPass.hpp +114 -0
  171. package/nitrogen/generated/shared/c++/PassActivationState.hpp +88 -0
  172. package/nitrogen/generated/shared/c++/PayServiceStatus.hpp +79 -0
  173. package/nitrogen/generated/shared/c++/PaymentItem.hpp +85 -0
  174. package/nitrogen/generated/shared/c++/PaymentItemType.hpp +76 -0
  175. package/nitrogen/generated/shared/c++/PaymentMethod.hpp +103 -0
  176. package/nitrogen/generated/shared/c++/PaymentMethodType.hpp +88 -0
  177. package/nitrogen/generated/shared/c++/PaymentNetwork.hpp +112 -0
  178. package/nitrogen/generated/shared/c++/PaymentRequest.hpp +130 -0
  179. package/nitrogen/generated/shared/c++/PaymentResult.hpp +90 -0
  180. package/nitrogen/generated/shared/c++/PaymentToken.hpp +85 -0
  181. package/nitrogen/generated/shared/c++/views/HybridApplePayButtonComponent.cpp +111 -0
  182. package/nitrogen/generated/shared/c++/views/HybridApplePayButtonComponent.hpp +111 -0
  183. package/nitrogen/generated/shared/c++/views/HybridGooglePayButtonComponent.cpp +123 -0
  184. package/nitrogen/generated/shared/c++/views/HybridGooglePayButtonComponent.hpp +112 -0
  185. package/nitrogen/generated/shared/json/ApplePayButtonConfig.json +12 -0
  186. package/nitrogen/generated/shared/json/GooglePayButtonConfig.json +13 -0
  187. package/package.json +116 -0
  188. package/react-native.config.js +16 -0
  189. package/src/hooks/index.ts +12 -0
  190. package/src/hooks/usePaymentCheckout.ts +281 -0
  191. package/src/index.ts +32 -0
  192. package/src/plugin/index.ts +17 -0
  193. package/src/plugin/type.ts +4 -0
  194. package/src/plugin/withApplePay.ts +44 -0
  195. package/src/plugin/withGooglePay.ts +41 -0
  196. package/src/specs/ApplePayButton.nitro.ts +37 -0
  197. package/src/specs/GooglePayButton.nitro.ts +34 -0
  198. package/src/specs/PaymentHandler.nitro.ts +13 -0
  199. package/src/types/Contact.ts +58 -0
  200. package/src/types/Payment.ts +104 -0
  201. package/src/types/index.ts +2 -0
  202. package/src/utils/index.ts +5 -0
  203. package/src/utils/paymentHelpers.ts +215 -0
@@ -0,0 +1,111 @@
1
+ ///
2
+ /// HybridApplePayButtonComponent.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridApplePayButtonComponent.hpp"
9
+
10
+ #include <string>
11
+ #include <exception>
12
+ #include <utility>
13
+ #include <NitroModules/NitroDefines.hpp>
14
+ #include <NitroModules/JSIConverter.hpp>
15
+ #include <react/renderer/core/RawValue.h>
16
+ #include <react/renderer/core/ShadowNode.h>
17
+ #include <react/renderer/core/ComponentDescriptor.h>
18
+ #include <react/renderer/components/view/ViewProps.h>
19
+
20
+ namespace margelo::nitro::pay::views {
21
+
22
+ extern const char HybridApplePayButtonComponentName[] = "ApplePayButton";
23
+
24
+ HybridApplePayButtonProps::HybridApplePayButtonProps(const react::PropsParserContext& context,
25
+ const HybridApplePayButtonProps& sourceProps,
26
+ const react::RawProps& rawProps):
27
+ react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
28
+ buttonType([&]() -> CachedProp<ApplePayButtonType> {
29
+ try {
30
+ const react::RawValue* rawValue = rawProps.at("buttonType", nullptr, nullptr);
31
+ if (rawValue == nullptr) return sourceProps.buttonType;
32
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
33
+ return CachedProp<ApplePayButtonType>::fromRawValue(*runtime, value, sourceProps.buttonType);
34
+ } catch (const std::exception& exc) {
35
+ throw std::runtime_error(std::string("ApplePayButton.buttonType: ") + exc.what());
36
+ }
37
+ }()),
38
+ buttonStyle([&]() -> CachedProp<ApplePayButtonStyle> {
39
+ try {
40
+ const react::RawValue* rawValue = rawProps.at("buttonStyle", nullptr, nullptr);
41
+ if (rawValue == nullptr) return sourceProps.buttonStyle;
42
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
43
+ return CachedProp<ApplePayButtonStyle>::fromRawValue(*runtime, value, sourceProps.buttonStyle);
44
+ } catch (const std::exception& exc) {
45
+ throw std::runtime_error(std::string("ApplePayButton.buttonStyle: ") + exc.what());
46
+ }
47
+ }()),
48
+ onPress([&]() -> CachedProp<std::optional<std::function<void()>>> {
49
+ try {
50
+ const react::RawValue* rawValue = rawProps.at("onPress", nullptr, nullptr);
51
+ if (rawValue == nullptr) return sourceProps.onPress;
52
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
53
+ return CachedProp<std::optional<std::function<void()>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, "f"), sourceProps.onPress);
54
+ } catch (const std::exception& exc) {
55
+ throw std::runtime_error(std::string("ApplePayButton.onPress: ") + exc.what());
56
+ }
57
+ }()),
58
+ hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridApplePayButtonSpec>& /* ref */)>>> {
59
+ try {
60
+ const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
61
+ if (rawValue == nullptr) return sourceProps.hybridRef;
62
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
63
+ return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridApplePayButtonSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, "f"), sourceProps.hybridRef);
64
+ } catch (const std::exception& exc) {
65
+ throw std::runtime_error(std::string("ApplePayButton.hybridRef: ") + exc.what());
66
+ }
67
+ }()) { }
68
+
69
+ HybridApplePayButtonProps::HybridApplePayButtonProps(const HybridApplePayButtonProps& other):
70
+ react::ViewProps(),
71
+ buttonType(other.buttonType),
72
+ buttonStyle(other.buttonStyle),
73
+ onPress(other.onPress),
74
+ hybridRef(other.hybridRef) { }
75
+
76
+ bool HybridApplePayButtonProps::filterObjectKeys(const std::string& propName) {
77
+ switch (hashString(propName)) {
78
+ case hashString("buttonType"): return true;
79
+ case hashString("buttonStyle"): return true;
80
+ case hashString("onPress"): return true;
81
+ case hashString("hybridRef"): return true;
82
+ default: return false;
83
+ }
84
+ }
85
+
86
+ HybridApplePayButtonComponentDescriptor::HybridApplePayButtonComponentDescriptor(const react::ComponentDescriptorParameters& parameters)
87
+ : ConcreteComponentDescriptor(parameters,
88
+ react::RawPropsParser(/* enableJsiParser */ true)) {}
89
+
90
+ std::shared_ptr<const react::Props> HybridApplePayButtonComponentDescriptor::cloneProps(const react::PropsParserContext& context,
91
+ const std::shared_ptr<const react::Props>& props,
92
+ react::RawProps rawProps) const {
93
+ // 1. Prepare raw props parser
94
+ rawProps.parse(rawPropsParser_);
95
+ // 2. Copy props with Nitro's cached copy constructor
96
+ return HybridApplePayButtonShadowNode::Props(context, /* & */ rawProps, props);
97
+ }
98
+
99
+ #ifdef ANDROID
100
+ void HybridApplePayButtonComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
101
+ // This is called immediately after `ShadowNode` is created, cloned or in progress.
102
+ // On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
103
+ auto& concreteShadowNode = dynamic_cast<HybridApplePayButtonShadowNode&>(shadowNode);
104
+ const HybridApplePayButtonProps& props = concreteShadowNode.getConcreteProps();
105
+ HybridApplePayButtonState state;
106
+ state.setProps(props);
107
+ concreteShadowNode.setStateData(std::move(state));
108
+ }
109
+ #endif
110
+
111
+ } // namespace margelo::nitro::pay::views
@@ -0,0 +1,111 @@
1
+ ///
2
+ /// HybridApplePayButtonComponent.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <optional>
11
+ #include <NitroModules/NitroDefines.hpp>
12
+ #include <NitroModules/NitroHash.hpp>
13
+ #include <NitroModules/CachedProp.hpp>
14
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
15
+ #include <react/renderer/core/PropsParserContext.h>
16
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
17
+ #include <react/renderer/components/view/ViewProps.h>
18
+
19
+ #include "ApplePayButtonType.hpp"
20
+ #include "ApplePayButtonStyle.hpp"
21
+ #include <functional>
22
+ #include <optional>
23
+ #include <memory>
24
+ #include "HybridApplePayButtonSpec.hpp"
25
+
26
+ namespace margelo::nitro::pay::views {
27
+
28
+ using namespace facebook;
29
+
30
+ /**
31
+ * The name of the actual native View.
32
+ */
33
+ extern const char HybridApplePayButtonComponentName[];
34
+
35
+ /**
36
+ * Props for the "ApplePayButton" View.
37
+ */
38
+ class HybridApplePayButtonProps final: public react::ViewProps {
39
+ public:
40
+ HybridApplePayButtonProps() = default;
41
+ HybridApplePayButtonProps(const HybridApplePayButtonProps&);
42
+ HybridApplePayButtonProps(const react::PropsParserContext& context,
43
+ const HybridApplePayButtonProps& sourceProps,
44
+ const react::RawProps& rawProps);
45
+
46
+ public:
47
+ CachedProp<ApplePayButtonType> buttonType;
48
+ CachedProp<ApplePayButtonStyle> buttonStyle;
49
+ CachedProp<std::optional<std::function<void()>>> onPress;
50
+ CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridApplePayButtonSpec>& /* ref */)>>> hybridRef;
51
+
52
+ private:
53
+ static bool filterObjectKeys(const std::string& propName);
54
+ };
55
+
56
+ /**
57
+ * State for the "ApplePayButton" View.
58
+ */
59
+ class HybridApplePayButtonState final {
60
+ public:
61
+ HybridApplePayButtonState() = default;
62
+
63
+ public:
64
+ void setProps(const HybridApplePayButtonProps& props) { _props.emplace(props); }
65
+ const std::optional<HybridApplePayButtonProps>& getProps() const { return _props; }
66
+
67
+ public:
68
+ #ifdef ANDROID
69
+ HybridApplePayButtonState(const HybridApplePayButtonState& /* previousState */, folly::dynamic /* data */) {}
70
+ folly::dynamic getDynamic() const {
71
+ throw std::runtime_error("HybridApplePayButtonState does not support folly!");
72
+ }
73
+ react::MapBuffer getMapBuffer() const {
74
+ throw std::runtime_error("HybridApplePayButtonState does not support MapBuffer!");
75
+ };
76
+ #endif
77
+
78
+ private:
79
+ std::optional<HybridApplePayButtonProps> _props;
80
+ };
81
+
82
+ /**
83
+ * The Shadow Node for the "ApplePayButton" View.
84
+ */
85
+ using HybridApplePayButtonShadowNode = react::ConcreteViewShadowNode<HybridApplePayButtonComponentName /* "HybridApplePayButton" */,
86
+ HybridApplePayButtonProps /* custom props */,
87
+ react::ViewEventEmitter /* default */,
88
+ HybridApplePayButtonState /* custom state */>;
89
+
90
+ /**
91
+ * The Component Descriptor for the "ApplePayButton" View.
92
+ */
93
+ class HybridApplePayButtonComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridApplePayButtonShadowNode> {
94
+ public:
95
+ HybridApplePayButtonComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
96
+
97
+ public:
98
+ /**
99
+ * A faster path for cloning props - reuses the caching logic from `HybridApplePayButtonProps`.
100
+ */
101
+ std::shared_ptr<const react::Props> cloneProps(const react::PropsParserContext& context,
102
+ const std::shared_ptr<const react::Props>& props,
103
+ react::RawProps rawProps) const override;
104
+ #ifdef ANDROID
105
+ void adopt(react::ShadowNode& shadowNode) const override;
106
+ #endif
107
+ };
108
+
109
+ /* The actual view for "ApplePayButton" needs to be implemented in platform-specific code. */
110
+
111
+ } // namespace margelo::nitro::pay::views
@@ -0,0 +1,123 @@
1
+ ///
2
+ /// HybridGooglePayButtonComponent.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridGooglePayButtonComponent.hpp"
9
+
10
+ #include <string>
11
+ #include <exception>
12
+ #include <utility>
13
+ #include <NitroModules/NitroDefines.hpp>
14
+ #include <NitroModules/JSIConverter.hpp>
15
+ #include <react/renderer/core/RawValue.h>
16
+ #include <react/renderer/core/ShadowNode.h>
17
+ #include <react/renderer/core/ComponentDescriptor.h>
18
+ #include <react/renderer/components/view/ViewProps.h>
19
+
20
+ namespace margelo::nitro::pay::views {
21
+
22
+ extern const char HybridGooglePayButtonComponentName[] = "GooglePayButton";
23
+
24
+ HybridGooglePayButtonProps::HybridGooglePayButtonProps(const react::PropsParserContext& context,
25
+ const HybridGooglePayButtonProps& sourceProps,
26
+ const react::RawProps& rawProps):
27
+ react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
28
+ buttonType([&]() -> CachedProp<GooglePayButtonType> {
29
+ try {
30
+ const react::RawValue* rawValue = rawProps.at("buttonType", nullptr, nullptr);
31
+ if (rawValue == nullptr) return sourceProps.buttonType;
32
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
33
+ return CachedProp<GooglePayButtonType>::fromRawValue(*runtime, value, sourceProps.buttonType);
34
+ } catch (const std::exception& exc) {
35
+ throw std::runtime_error(std::string("GooglePayButton.buttonType: ") + exc.what());
36
+ }
37
+ }()),
38
+ theme([&]() -> CachedProp<GooglePayButtonTheme> {
39
+ try {
40
+ const react::RawValue* rawValue = rawProps.at("theme", nullptr, nullptr);
41
+ if (rawValue == nullptr) return sourceProps.theme;
42
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
43
+ return CachedProp<GooglePayButtonTheme>::fromRawValue(*runtime, value, sourceProps.theme);
44
+ } catch (const std::exception& exc) {
45
+ throw std::runtime_error(std::string("GooglePayButton.theme: ") + exc.what());
46
+ }
47
+ }()),
48
+ radius([&]() -> CachedProp<std::optional<double>> {
49
+ try {
50
+ const react::RawValue* rawValue = rawProps.at("radius", nullptr, nullptr);
51
+ if (rawValue == nullptr) return sourceProps.radius;
52
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
53
+ return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.radius);
54
+ } catch (const std::exception& exc) {
55
+ throw std::runtime_error(std::string("GooglePayButton.radius: ") + exc.what());
56
+ }
57
+ }()),
58
+ onPress([&]() -> CachedProp<std::optional<std::function<void()>>> {
59
+ try {
60
+ const react::RawValue* rawValue = rawProps.at("onPress", nullptr, nullptr);
61
+ if (rawValue == nullptr) return sourceProps.onPress;
62
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
63
+ return CachedProp<std::optional<std::function<void()>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, "f"), sourceProps.onPress);
64
+ } catch (const std::exception& exc) {
65
+ throw std::runtime_error(std::string("GooglePayButton.onPress: ") + exc.what());
66
+ }
67
+ }()),
68
+ hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridGooglePayButtonSpec>& /* ref */)>>> {
69
+ try {
70
+ const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
71
+ if (rawValue == nullptr) return sourceProps.hybridRef;
72
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
73
+ return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridGooglePayButtonSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, "f"), sourceProps.hybridRef);
74
+ } catch (const std::exception& exc) {
75
+ throw std::runtime_error(std::string("GooglePayButton.hybridRef: ") + exc.what());
76
+ }
77
+ }()) { }
78
+
79
+ HybridGooglePayButtonProps::HybridGooglePayButtonProps(const HybridGooglePayButtonProps& other):
80
+ react::ViewProps(),
81
+ buttonType(other.buttonType),
82
+ theme(other.theme),
83
+ radius(other.radius),
84
+ onPress(other.onPress),
85
+ hybridRef(other.hybridRef) { }
86
+
87
+ bool HybridGooglePayButtonProps::filterObjectKeys(const std::string& propName) {
88
+ switch (hashString(propName)) {
89
+ case hashString("buttonType"): return true;
90
+ case hashString("theme"): return true;
91
+ case hashString("radius"): return true;
92
+ case hashString("onPress"): return true;
93
+ case hashString("hybridRef"): return true;
94
+ default: return false;
95
+ }
96
+ }
97
+
98
+ HybridGooglePayButtonComponentDescriptor::HybridGooglePayButtonComponentDescriptor(const react::ComponentDescriptorParameters& parameters)
99
+ : ConcreteComponentDescriptor(parameters,
100
+ react::RawPropsParser(/* enableJsiParser */ true)) {}
101
+
102
+ std::shared_ptr<const react::Props> HybridGooglePayButtonComponentDescriptor::cloneProps(const react::PropsParserContext& context,
103
+ const std::shared_ptr<const react::Props>& props,
104
+ react::RawProps rawProps) const {
105
+ // 1. Prepare raw props parser
106
+ rawProps.parse(rawPropsParser_);
107
+ // 2. Copy props with Nitro's cached copy constructor
108
+ return HybridGooglePayButtonShadowNode::Props(context, /* & */ rawProps, props);
109
+ }
110
+
111
+ #ifdef ANDROID
112
+ void HybridGooglePayButtonComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
113
+ // This is called immediately after `ShadowNode` is created, cloned or in progress.
114
+ // On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
115
+ auto& concreteShadowNode = dynamic_cast<HybridGooglePayButtonShadowNode&>(shadowNode);
116
+ const HybridGooglePayButtonProps& props = concreteShadowNode.getConcreteProps();
117
+ HybridGooglePayButtonState state;
118
+ state.setProps(props);
119
+ concreteShadowNode.setStateData(std::move(state));
120
+ }
121
+ #endif
122
+
123
+ } // namespace margelo::nitro::pay::views
@@ -0,0 +1,112 @@
1
+ ///
2
+ /// HybridGooglePayButtonComponent.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <optional>
11
+ #include <NitroModules/NitroDefines.hpp>
12
+ #include <NitroModules/NitroHash.hpp>
13
+ #include <NitroModules/CachedProp.hpp>
14
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
15
+ #include <react/renderer/core/PropsParserContext.h>
16
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
17
+ #include <react/renderer/components/view/ViewProps.h>
18
+
19
+ #include "GooglePayButtonType.hpp"
20
+ #include "GooglePayButtonTheme.hpp"
21
+ #include <optional>
22
+ #include <functional>
23
+ #include <memory>
24
+ #include "HybridGooglePayButtonSpec.hpp"
25
+
26
+ namespace margelo::nitro::pay::views {
27
+
28
+ using namespace facebook;
29
+
30
+ /**
31
+ * The name of the actual native View.
32
+ */
33
+ extern const char HybridGooglePayButtonComponentName[];
34
+
35
+ /**
36
+ * Props for the "GooglePayButton" View.
37
+ */
38
+ class HybridGooglePayButtonProps final: public react::ViewProps {
39
+ public:
40
+ HybridGooglePayButtonProps() = default;
41
+ HybridGooglePayButtonProps(const HybridGooglePayButtonProps&);
42
+ HybridGooglePayButtonProps(const react::PropsParserContext& context,
43
+ const HybridGooglePayButtonProps& sourceProps,
44
+ const react::RawProps& rawProps);
45
+
46
+ public:
47
+ CachedProp<GooglePayButtonType> buttonType;
48
+ CachedProp<GooglePayButtonTheme> theme;
49
+ CachedProp<std::optional<double>> radius;
50
+ CachedProp<std::optional<std::function<void()>>> onPress;
51
+ CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridGooglePayButtonSpec>& /* ref */)>>> hybridRef;
52
+
53
+ private:
54
+ static bool filterObjectKeys(const std::string& propName);
55
+ };
56
+
57
+ /**
58
+ * State for the "GooglePayButton" View.
59
+ */
60
+ class HybridGooglePayButtonState final {
61
+ public:
62
+ HybridGooglePayButtonState() = default;
63
+
64
+ public:
65
+ void setProps(const HybridGooglePayButtonProps& props) { _props.emplace(props); }
66
+ const std::optional<HybridGooglePayButtonProps>& getProps() const { return _props; }
67
+
68
+ public:
69
+ #ifdef ANDROID
70
+ HybridGooglePayButtonState(const HybridGooglePayButtonState& /* previousState */, folly::dynamic /* data */) {}
71
+ folly::dynamic getDynamic() const {
72
+ throw std::runtime_error("HybridGooglePayButtonState does not support folly!");
73
+ }
74
+ react::MapBuffer getMapBuffer() const {
75
+ throw std::runtime_error("HybridGooglePayButtonState does not support MapBuffer!");
76
+ };
77
+ #endif
78
+
79
+ private:
80
+ std::optional<HybridGooglePayButtonProps> _props;
81
+ };
82
+
83
+ /**
84
+ * The Shadow Node for the "GooglePayButton" View.
85
+ */
86
+ using HybridGooglePayButtonShadowNode = react::ConcreteViewShadowNode<HybridGooglePayButtonComponentName /* "HybridGooglePayButton" */,
87
+ HybridGooglePayButtonProps /* custom props */,
88
+ react::ViewEventEmitter /* default */,
89
+ HybridGooglePayButtonState /* custom state */>;
90
+
91
+ /**
92
+ * The Component Descriptor for the "GooglePayButton" View.
93
+ */
94
+ class HybridGooglePayButtonComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridGooglePayButtonShadowNode> {
95
+ public:
96
+ HybridGooglePayButtonComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
97
+
98
+ public:
99
+ /**
100
+ * A faster path for cloning props - reuses the caching logic from `HybridGooglePayButtonProps`.
101
+ */
102
+ std::shared_ptr<const react::Props> cloneProps(const react::PropsParserContext& context,
103
+ const std::shared_ptr<const react::Props>& props,
104
+ react::RawProps rawProps) const override;
105
+ #ifdef ANDROID
106
+ void adopt(react::ShadowNode& shadowNode) const override;
107
+ #endif
108
+ };
109
+
110
+ /* The actual view for "GooglePayButton" needs to be implemented in platform-specific code. */
111
+
112
+ } // namespace margelo::nitro::pay::views
@@ -0,0 +1,12 @@
1
+ {
2
+ "uiViewClassName": "ApplePayButton",
3
+ "supportsRawText": false,
4
+ "bubblingEventTypes": {},
5
+ "directEventTypes": {},
6
+ "validAttributes": {
7
+ "buttonType": true,
8
+ "buttonStyle": true,
9
+ "onPress": true,
10
+ "hybridRef": true
11
+ }
12
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "uiViewClassName": "GooglePayButton",
3
+ "supportsRawText": false,
4
+ "bubblingEventTypes": {},
5
+ "directEventTypes": {},
6
+ "validAttributes": {
7
+ "buttonType": true,
8
+ "theme": true,
9
+ "radius": true,
10
+ "onPress": true,
11
+ "hybridRef": true
12
+ }
13
+ }
package/package.json ADDED
@@ -0,0 +1,116 @@
1
+ {
2
+ "name": "@gmisoftware/react-native-pay",
3
+ "version": "0.0.4",
4
+ "author": "gmi.software",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/gmi-software/react-native-pay.git"
8
+ },
9
+ "main": "lib/index",
10
+ "module": "lib/index",
11
+ "dependencies": {
12
+ "expo": "^53.0.0"
13
+ },
14
+ "devDependencies": {
15
+ "@react-native/eslint-config": "0.82.0",
16
+ "@types/jest": "^29.5.12",
17
+ "@types/react": "^19.1.03",
18
+ "eslint": "^8.57.0",
19
+ "eslint-config-prettier": "^9.1.0",
20
+ "eslint-plugin-prettier": "^5.2.1",
21
+ "nitrogen": "*",
22
+ "prettier": "^3.3.3",
23
+ "typescript": "^5.8.3"
24
+ },
25
+ "peerDependencies": {
26
+ "react": "*",
27
+ "react-native": "*",
28
+ "react-native-nitro-modules": ">=0.31.4",
29
+ "expo": ">=53.0.0"
30
+ },
31
+ "bugs": {
32
+ "url": "https://github.com/gmi-software/react-native-pay/issues"
33
+ },
34
+ "description": "Pay for iOS and Android with React Native Pay",
35
+ "eslintConfig": {
36
+ "root": true,
37
+ "extends": [
38
+ "@react-native",
39
+ "prettier"
40
+ ],
41
+ "plugins": [
42
+ "prettier"
43
+ ],
44
+ "rules": {
45
+ "prettier/prettier": [
46
+ "warn",
47
+ {
48
+ "quoteProps": "consistent",
49
+ "singleQuote": true,
50
+ "tabWidth": 2,
51
+ "trailingComma": "es5",
52
+ "useTabs": false
53
+ }
54
+ ]
55
+ }
56
+ },
57
+ "eslintIgnore": [
58
+ "node_modules/",
59
+ "lib/"
60
+ ],
61
+ "files": [
62
+ "src",
63
+ "react-native.config.js",
64
+ "lib",
65
+ "nitrogen",
66
+ "android/build.gradle",
67
+ "android/gradle.properties",
68
+ "android/fix-prefab.gradle",
69
+ "android/CMakeLists.txt",
70
+ "android/src",
71
+ "ios/**/*.h",
72
+ "ios/**/*.m",
73
+ "ios/**/*.mm",
74
+ "ios/**/*.cpp",
75
+ "ios/**/*.swift",
76
+ "app.plugin.js",
77
+ "nitro.json",
78
+ "*.podspec",
79
+ "README.md"
80
+ ],
81
+ "homepage": "https://github.com/gmi-software/react-native-pay#readme",
82
+ "keywords": [
83
+ "react-native",
84
+ "react-native-pay",
85
+ "apple-pay",
86
+ "google-pay",
87
+ "payment",
88
+ "checkout",
89
+ "typescript",
90
+ "javascript"
91
+ ],
92
+ "license": "MIT",
93
+ "prettier": {
94
+ "quoteProps": "consistent",
95
+ "singleQuote": true,
96
+ "tabWidth": 2,
97
+ "trailingComma": "es5",
98
+ "useTabs": false,
99
+ "semi": false
100
+ },
101
+ "publishConfig": {
102
+ "registry": "https://registry.npmjs.org/"
103
+ },
104
+ "react-native": "src/index",
105
+ "scripts": {
106
+ "postinstall": "tsc || exit 0;",
107
+ "typecheck": "tsc --noEmit",
108
+ "clean": "rm -rf android/build node_modules/**/android/build lib",
109
+ "lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
110
+ "lint-ci": "eslint \"**/*.{js,ts,tsx}\" -f @jamesacarr/github-actions",
111
+ "typescript": "tsc",
112
+ "specs": "typescript && nitrogen --logLevel=\"debug\""
113
+ },
114
+ "source": "src/index",
115
+ "types": "lib/index.d.ts"
116
+ }
@@ -0,0 +1,16 @@
1
+ // https://github.com/react-native-community/cli/blob/main/docs/dependencies.md
2
+
3
+ module.exports = {
4
+ dependency: {
5
+ platforms: {
6
+ /**
7
+ * @type {import('@react-native-community/cli-types').IOSDependencyParams}
8
+ */
9
+ ios: {},
10
+ /**
11
+ * @type {import('@react-native-community/cli-types').AndroidDependencyParams}
12
+ */
13
+ android: {},
14
+ },
15
+ },
16
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * React hooks for payment operations
3
+ *
4
+ * @module hooks
5
+ */
6
+
7
+ export { usePaymentCheckout } from './usePaymentCheckout'
8
+
9
+ export type {
10
+ UsePaymentCheckoutConfig,
11
+ UsePaymentCheckoutReturn,
12
+ } from './usePaymentCheckout'