@onramper/onramper-react-native 1.1.1 → 1.2.1
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/CHANGELOG.md +54 -0
- package/README.md +11 -0
- package/ios/Frameworks/OnramperSDK.xcframework/Info.plist +5 -5
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64/OnramperSDK.framework/Modules/OnramperSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64/OnramperSDK.framework/Modules/OnramperSDK.swiftmodule/arm64-apple-ios.swiftinterface +25 -2
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64/OnramperSDK.framework/OnramperSDK +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64/OnramperSDK.framework/OnramperSDK_OnramperSDK.bundle/PrivacyInfo.xcprivacy +36 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64/OnramperSDK.framework/PrivacyInfo.xcprivacy +36 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64/dSYMs/OnramperSDK.framework.dSYM/Contents/Resources/DWARF/OnramperSDK +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64/dSYMs/OnramperSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/OnramperSDK.yml +2684 -2578
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/OnramperSDK.framework/Modules/OnramperSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/OnramperSDK.framework/Modules/OnramperSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +25 -2
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/OnramperSDK.framework/Modules/OnramperSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/OnramperSDK.framework/Modules/OnramperSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +25 -2
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/OnramperSDK.framework/OnramperSDK +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/OnramperSDK.framework/OnramperSDK_OnramperSDK.bundle/PrivacyInfo.xcprivacy +36 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/OnramperSDK.framework/PrivacyInfo.xcprivacy +36 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/OnramperSDK.framework.dSYM/Contents/Resources/DWARF/OnramperSDK +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/OnramperSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/OnramperSDK.yml +2684 -2578
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/OnramperSDK.framework.dSYM/Contents/Resources/Relocations/x86_64/OnramperSDK.yml +2651 -2545
- package/ios/HybridOnramperNitro.swift +32 -4
- package/ios/OnramperCheckoutBridge.swift +33 -0
- package/lib/commonjs/OnramperClient.js +47 -3
- package/lib/commonjs/OnramperClient.js.map +1 -1
- package/lib/module/OnramperClient.js +47 -3
- package/lib/module/OnramperClient.js.map +1 -1
- package/lib/typescript/commonjs/src/OnramperClient.d.ts +17 -2
- package/lib/typescript/commonjs/src/OnramperClient.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +1 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/specs/OnramperNitro.nitro.d.ts +2 -1
- package/lib/typescript/commonjs/src/specs/OnramperNitro.nitro.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types.d.ts +9 -0
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
- package/lib/typescript/module/src/OnramperClient.d.ts +17 -2
- package/lib/typescript/module/src/OnramperClient.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +1 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/specs/OnramperNitro.nitro.d.ts +2 -1
- package/lib/typescript/module/src/specs/OnramperNitro.nitro.d.ts.map +1 -1
- package/lib/typescript/module/src/types.d.ts +9 -0
- package/lib/typescript/module/src/types.d.ts.map +1 -1
- package/nitrogen/generated/ios/OnramperReactNative-Swift-Cxx-Bridge.cpp +8 -0
- package/nitrogen/generated/ios/OnramperReactNative-Swift-Cxx-Bridge.hpp +38 -0
- package/nitrogen/generated/ios/OnramperReactNative-Swift-Cxx-Umbrella.hpp +1 -0
- package/nitrogen/generated/ios/c++/HybridOnramperNitroSpecSwift.hpp +9 -2
- package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string_.swift +53 -0
- package/nitrogen/generated/ios/swift/HybridOnramperNitroSpec.swift +2 -1
- package/nitrogen/generated/ios/swift/HybridOnramperNitroSpec_cxx.swift +24 -2
- package/nitrogen/generated/shared/c++/HybridOnramperNitroSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridOnramperNitroSpec.hpp +3 -1
- package/package.json +2 -2
- package/src/OnramperClient.ts +55 -2
- package/src/index.ts +1 -0
- package/src/specs/OnramperNitro.nitro.ts +7 -2
- package/src/types.ts +27 -0
|
@@ -4,6 +4,6 @@ export { OnramperCheckoutButtonView } from './OnramperCheckoutButtonView.js';
|
|
|
4
4
|
export type { OnramperCheckoutButtonViewProps } from './OnramperCheckoutButtonView.js';
|
|
5
5
|
export { OnramperError } from './errors.js';
|
|
6
6
|
export type { OnramperErrorCode, OnramperErrorPayload } from './errors.js';
|
|
7
|
-
export type { CheckoutButtonStyle, CheckoutFinalizeResponse, CheckoutRequest, CheckoutPaymentType, CheckoutRequirement, HeadlessCheckoutData, OnramperConfiguration, OnramperEnvironment, OnramperLogLevel, OnramperState, OnramperTheme, QuoteResponse, RenderType, ReverificationField, SessionCredentials, ToSItem, TransactionType, UserInfoField, UserInfoFieldType, WalletInfo, } from './types.js';
|
|
7
|
+
export type { CheckoutButtonStyle, CheckoutFinalizeResponse, CheckoutRequest, CheckoutPaymentType, CheckoutRequirement, HeadlessCheckoutData, OnramperConfiguration, OnramperEnvironment, OnramperLogLevel, OnramperState, OnramperTheme, OnramperUserPrefill, QuoteResponse, RenderType, ReverificationField, SessionCredentials, ToSItem, TransactionType, UserInfoField, UserInfoFieldType, WalletInfo, } from './types.js';
|
|
8
8
|
export type { CheckoutEvent, EventName, EventPayload } from './events.js';
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAkB,CAAC;AAClD,YAAY,EAAE,6BAA6B,EAAE,MAAM,qBAAkB,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAA8B,CAAC;AAC1E,YAAY,EAAE,+BAA+B,EAAE,MAAM,iCAA8B,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,aAAU,CAAC;AACzC,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,aAAU,CAAC;AACxE,YAAY,EACV,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,aAAa,EACb,UAAU,EACV,mBAAmB,EACnB,kBAAkB,EAClB,OAAO,EACP,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,UAAU,GACX,MAAM,YAAS,CAAC;AACjB,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAkB,CAAC;AAClD,YAAY,EAAE,6BAA6B,EAAE,MAAM,qBAAkB,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAA8B,CAAC;AAC1E,YAAY,EAAE,+BAA+B,EAAE,MAAM,iCAA8B,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,aAAU,CAAC;AACzC,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,aAAU,CAAC;AACxE,YAAY,EACV,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,mBAAmB,EACnB,kBAAkB,EAClB,OAAO,EACP,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,UAAU,GACX,MAAM,YAAS,CAAC;AACjB,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAU,CAAC"}
|
|
@@ -30,10 +30,11 @@ export interface OnramperNitro extends HybridObject<{
|
|
|
30
30
|
initialize(sessionId: string, sessionToken: string): Promise<void>;
|
|
31
31
|
reset(): Promise<void>;
|
|
32
32
|
signOut(): Promise<void>;
|
|
33
|
-
getCheckoutRequirements(requestJson: string, styleJson: string): Promise<PreparedIntentResult>;
|
|
33
|
+
getCheckoutRequirements(requestJson: string, prefillJson: string, styleJson: string): Promise<PreparedIntentResult>;
|
|
34
34
|
cancelPreparedIntent(intentHandle: string): Promise<void>;
|
|
35
35
|
setStateListener(onState: (stateJson: string) => void): void;
|
|
36
36
|
setEventListener(onEvent: (eventJson: string) => void): void;
|
|
37
|
+
setTransactionIdListener(onTransactionId: (transactionId: string | undefined) => void): void;
|
|
37
38
|
setSessionExpirationHandler(handler: () => Promise<NitroSessionCredentials>): void;
|
|
38
39
|
}
|
|
39
40
|
//# sourceMappingURL=OnramperNitro.nitro.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OnramperNitro.nitro.d.ts","sourceRoot":"","sources":["../../../../../src/specs/OnramperNitro.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI/D,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAID,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB;AAID,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAc,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,OAAO,CAAA;CAAE,CAAC;IACnE,SAAS,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"OnramperNitro.nitro.d.ts","sourceRoot":"","sources":["../../../../../src/specs/OnramperNitro.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI/D,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAA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AG,IAAI,CAAC;CAKpF"}
|
|
@@ -49,6 +49,13 @@ export interface QuoteResponse {
|
|
|
49
49
|
transactionFee: number;
|
|
50
50
|
recommendations?: string[];
|
|
51
51
|
}
|
|
52
|
+
export interface OnramperUserPrefill {
|
|
53
|
+
email?: string;
|
|
54
|
+
firstName?: string;
|
|
55
|
+
lastName?: string;
|
|
56
|
+
/** E.164 format, e.g. `+3712345678`. Always a candidate — the user still verifies it. */
|
|
57
|
+
phoneNumber?: string;
|
|
58
|
+
}
|
|
52
59
|
export interface CheckoutButtonStyle {
|
|
53
60
|
backgroundColor?: string;
|
|
54
61
|
foregroundColor?: string;
|
|
@@ -63,6 +70,8 @@ export interface HeadlessCheckoutData {
|
|
|
63
70
|
}
|
|
64
71
|
export interface CheckoutFinalizeResponse {
|
|
65
72
|
headlessCheckoutId: string;
|
|
73
|
+
/** Durable Onramper transaction identifier for support, reconciliation, and status lookups. */
|
|
74
|
+
onramperTransactionId: string;
|
|
66
75
|
headlessCheckoutData: HeadlessCheckoutData;
|
|
67
76
|
}
|
|
68
77
|
export type CheckoutRequirement = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAU,CAAC;AAErD,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG,YAAY,CAAC;AAC/D,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAClE,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAExD,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,MAAM,CAAC;AAE7C,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,M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@@ -63,6 +63,14 @@ namespace margelo::nitro::onramper::bridge::swift {
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
// pragma MARK: std::function<void(const std::optional<std::string>& /* transactionId */)>
|
|
67
|
+
Func_void_std__optional_std__string_ create_Func_void_std__optional_std__string_(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
68
|
+
auto swiftClosure = OnramperReactNative::Func_void_std__optional_std__string_::fromUnsafe(swiftClosureWrapper);
|
|
69
|
+
return [swiftClosure = std::move(swiftClosure)](const std::optional<std::string>& transactionId) mutable -> void {
|
|
70
|
+
swiftClosure.call(transactionId);
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
66
74
|
// pragma MARK: std::function<void(const NitroSessionCredentials& /* result */)>
|
|
67
75
|
Func_void_NitroSessionCredentials create_Func_void_NitroSessionCredentials(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
68
76
|
auto swiftClosure = OnramperReactNative::Func_void_NitroSessionCredentials::fromUnsafe(swiftClosureWrapper);
|
|
@@ -34,6 +34,7 @@ namespace OnramperReactNative { class HybridOnramperNitroSpec_cxx; }
|
|
|
34
34
|
#include <exception>
|
|
35
35
|
#include <functional>
|
|
36
36
|
#include <memory>
|
|
37
|
+
#include <optional>
|
|
37
38
|
#include <string>
|
|
38
39
|
|
|
39
40
|
/**
|
|
@@ -166,6 +167,43 @@ namespace margelo::nitro::onramper::bridge::swift {
|
|
|
166
167
|
return Func_void_std__string_Wrapper(std::move(value));
|
|
167
168
|
}
|
|
168
169
|
|
|
170
|
+
// pragma MARK: std::optional<std::string>
|
|
171
|
+
/**
|
|
172
|
+
* Specialized version of `std::optional<std::string>`.
|
|
173
|
+
*/
|
|
174
|
+
using std__optional_std__string_ = std::optional<std::string>;
|
|
175
|
+
inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) noexcept {
|
|
176
|
+
return std::optional<std::string>(value);
|
|
177
|
+
}
|
|
178
|
+
inline bool has_value_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
179
|
+
return optional.has_value();
|
|
180
|
+
}
|
|
181
|
+
inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
182
|
+
return optional.value();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// pragma MARK: std::function<void(const std::optional<std::string>& /* transactionId */)>
|
|
186
|
+
/**
|
|
187
|
+
* Specialized version of `std::function<void(const std::optional<std::string>&)>`.
|
|
188
|
+
*/
|
|
189
|
+
using Func_void_std__optional_std__string_ = std::function<void(const std::optional<std::string>& /* transactionId */)>;
|
|
190
|
+
/**
|
|
191
|
+
* Wrapper class for a `std::function<void(const std::optional<std::string>& / * transactionId * /)>`, this can be used from Swift.
|
|
192
|
+
*/
|
|
193
|
+
class Func_void_std__optional_std__string__Wrapper final {
|
|
194
|
+
public:
|
|
195
|
+
explicit Func_void_std__optional_std__string__Wrapper(std::function<void(const std::optional<std::string>& /* transactionId */)>&& func): _function(std::make_unique<std::function<void(const std::optional<std::string>& /* transactionId */)>>(std::move(func))) {}
|
|
196
|
+
inline void call(std::optional<std::string> transactionId) const noexcept {
|
|
197
|
+
_function->operator()(transactionId);
|
|
198
|
+
}
|
|
199
|
+
private:
|
|
200
|
+
std::unique_ptr<std::function<void(const std::optional<std::string>& /* transactionId */)>> _function;
|
|
201
|
+
} SWIFT_NONCOPYABLE;
|
|
202
|
+
Func_void_std__optional_std__string_ create_Func_void_std__optional_std__string_(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
203
|
+
inline Func_void_std__optional_std__string__Wrapper wrap_Func_void_std__optional_std__string_(Func_void_std__optional_std__string_ value) noexcept {
|
|
204
|
+
return Func_void_std__optional_std__string__Wrapper(std::move(value));
|
|
205
|
+
}
|
|
206
|
+
|
|
169
207
|
// pragma MARK: std::shared_ptr<Promise<NitroSessionCredentials>>
|
|
170
208
|
/**
|
|
171
209
|
* Specialized version of `std::shared_ptr<Promise<NitroSessionCredentials>>`.
|
|
@@ -24,6 +24,7 @@ namespace margelo::nitro::onramper { struct NitroSessionCredentials; }
|
|
|
24
24
|
#include <string>
|
|
25
25
|
#include "PreparedIntentResult.hpp"
|
|
26
26
|
#include <functional>
|
|
27
|
+
#include <optional>
|
|
27
28
|
#include "NitroSessionCredentials.hpp"
|
|
28
29
|
|
|
29
30
|
#include "OnramperReactNative-Swift-Cxx-Umbrella.hpp"
|
|
@@ -108,8 +109,8 @@ namespace margelo::nitro::onramper {
|
|
|
108
109
|
auto __value = std::move(__result.value());
|
|
109
110
|
return __value;
|
|
110
111
|
}
|
|
111
|
-
inline std::shared_ptr<Promise<PreparedIntentResult>> getCheckoutRequirements(const std::string& requestJson, const std::string& styleJson) override {
|
|
112
|
-
auto __result = _swiftPart.getCheckoutRequirements(requestJson, styleJson);
|
|
112
|
+
inline std::shared_ptr<Promise<PreparedIntentResult>> getCheckoutRequirements(const std::string& requestJson, const std::string& prefillJson, const std::string& styleJson) override {
|
|
113
|
+
auto __result = _swiftPart.getCheckoutRequirements(requestJson, prefillJson, styleJson);
|
|
113
114
|
if (__result.hasError()) [[unlikely]] {
|
|
114
115
|
std::rethrow_exception(__result.error());
|
|
115
116
|
}
|
|
@@ -136,6 +137,12 @@ namespace margelo::nitro::onramper {
|
|
|
136
137
|
std::rethrow_exception(__result.error());
|
|
137
138
|
}
|
|
138
139
|
}
|
|
140
|
+
inline void setTransactionIdListener(const std::function<void(const std::optional<std::string>& /* transactionId */)>& onTransactionId) override {
|
|
141
|
+
auto __result = _swiftPart.setTransactionIdListener(onTransactionId);
|
|
142
|
+
if (__result.hasError()) [[unlikely]] {
|
|
143
|
+
std::rethrow_exception(__result.error());
|
|
144
|
+
}
|
|
145
|
+
}
|
|
139
146
|
inline void setSessionExpirationHandler(const std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<NitroSessionCredentials>>>>()>& handler) override {
|
|
140
147
|
auto __result = _swiftPart.setSessionExpirationHandler(handler);
|
|
141
148
|
if (__result.hasError()) [[unlikely]] {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__optional_std__string_.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a Swift `(_ transactionId: String?) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_std__optional_std__string_ {
|
|
15
|
+
public typealias bridge = margelo.nitro.onramper.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ transactionId: String?) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ transactionId: String?) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(transactionId: bridge.std__optional_std__string_) -> Void {
|
|
25
|
+
self.closure({ () -> String? in
|
|
26
|
+
if bridge.has_value_std__optional_std__string_(transactionId) {
|
|
27
|
+
let __unwrapped = bridge.get_std__optional_std__string_(transactionId)
|
|
28
|
+
return String(__unwrapped)
|
|
29
|
+
} else {
|
|
30
|
+
return nil
|
|
31
|
+
}
|
|
32
|
+
}())
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
37
|
+
* This acquires one additional strong reference on the object!
|
|
38
|
+
*/
|
|
39
|
+
@inline(__always)
|
|
40
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
41
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Casts an unsafe pointer to a `Func_void_std__optional_std__string_`.
|
|
46
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__optional_std__string_>`.
|
|
47
|
+
* This removes one strong reference from the object!
|
|
48
|
+
*/
|
|
49
|
+
@inline(__always)
|
|
50
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__optional_std__string_ {
|
|
51
|
+
return Unmanaged<Func_void_std__optional_std__string_>.fromOpaque(pointer).takeRetainedValue()
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -17,10 +17,11 @@ public protocol HybridOnramperNitroSpec_protocol: HybridObject {
|
|
|
17
17
|
func initialize(sessionId: String, sessionToken: String) throws -> Promise<Void>
|
|
18
18
|
func reset() throws -> Promise<Void>
|
|
19
19
|
func signOut() throws -> Promise<Void>
|
|
20
|
-
func getCheckoutRequirements(requestJson: String, styleJson: String) throws -> Promise<PreparedIntentResult>
|
|
20
|
+
func getCheckoutRequirements(requestJson: String, prefillJson: String, styleJson: String) throws -> Promise<PreparedIntentResult>
|
|
21
21
|
func cancelPreparedIntent(intentHandle: String) throws -> Promise<Void>
|
|
22
22
|
func setStateListener(onState: @escaping (_ stateJson: String) -> Void) throws -> Void
|
|
23
23
|
func setEventListener(onEvent: @escaping (_ eventJson: String) -> Void) throws -> Void
|
|
24
|
+
func setTransactionIdListener(onTransactionId: @escaping (_ transactionId: String?) -> Void) throws -> Void
|
|
24
25
|
func setSessionExpirationHandler(handler: @escaping () -> Promise<Promise<NitroSessionCredentials>>) throws -> Void
|
|
25
26
|
}
|
|
26
27
|
|
|
@@ -201,9 +201,9 @@ open class HybridOnramperNitroSpec_cxx {
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
@inline(__always)
|
|
204
|
-
public final func getCheckoutRequirements(requestJson: std.string, styleJson: std.string) -> bridge.Result_std__shared_ptr_Promise_PreparedIntentResult___ {
|
|
204
|
+
public final func getCheckoutRequirements(requestJson: std.string, prefillJson: std.string, styleJson: std.string) -> bridge.Result_std__shared_ptr_Promise_PreparedIntentResult___ {
|
|
205
205
|
do {
|
|
206
|
-
let __result = try self.__implementation.getCheckoutRequirements(requestJson: String(requestJson), styleJson: String(styleJson))
|
|
206
|
+
let __result = try self.__implementation.getCheckoutRequirements(requestJson: String(requestJson), prefillJson: String(prefillJson), styleJson: String(styleJson))
|
|
207
207
|
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_PreparedIntentResult__ in
|
|
208
208
|
let __promise = bridge.create_std__shared_ptr_Promise_PreparedIntentResult__()
|
|
209
209
|
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_PreparedIntentResult__(__promise)
|
|
@@ -270,6 +270,28 @@ open class HybridOnramperNitroSpec_cxx {
|
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
+
@inline(__always)
|
|
274
|
+
public final func setTransactionIdListener(onTransactionId: bridge.Func_void_std__optional_std__string_) -> bridge.Result_void_ {
|
|
275
|
+
do {
|
|
276
|
+
try self.__implementation.setTransactionIdListener(onTransactionId: { () -> (String?) -> Void in
|
|
277
|
+
let __wrappedFunction = bridge.wrap_Func_void_std__optional_std__string_(onTransactionId)
|
|
278
|
+
return { (__transactionId: String?) -> Void in
|
|
279
|
+
__wrappedFunction.call({ () -> bridge.std__optional_std__string_ in
|
|
280
|
+
if let __unwrappedValue = __transactionId {
|
|
281
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
282
|
+
} else {
|
|
283
|
+
return .init()
|
|
284
|
+
}
|
|
285
|
+
}())
|
|
286
|
+
}
|
|
287
|
+
}())
|
|
288
|
+
return bridge.create_Result_void_()
|
|
289
|
+
} catch (let __error) {
|
|
290
|
+
let __exceptionPtr = __error.toCpp()
|
|
291
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
273
295
|
@inline(__always)
|
|
274
296
|
public final func setSessionExpirationHandler(handler: bridge.Func_std__shared_ptr_Promise_std__shared_ptr_Promise_NitroSessionCredentials____) -> bridge.Result_void_ {
|
|
275
297
|
do {
|
|
@@ -22,6 +22,7 @@ namespace margelo::nitro::onramper {
|
|
|
22
22
|
prototype.registerHybridMethod("cancelPreparedIntent", &HybridOnramperNitroSpec::cancelPreparedIntent);
|
|
23
23
|
prototype.registerHybridMethod("setStateListener", &HybridOnramperNitroSpec::setStateListener);
|
|
24
24
|
prototype.registerHybridMethod("setEventListener", &HybridOnramperNitroSpec::setEventListener);
|
|
25
|
+
prototype.registerHybridMethod("setTransactionIdListener", &HybridOnramperNitroSpec::setTransactionIdListener);
|
|
25
26
|
prototype.registerHybridMethod("setSessionExpirationHandler", &HybridOnramperNitroSpec::setSessionExpirationHandler);
|
|
26
27
|
});
|
|
27
28
|
}
|
|
@@ -25,6 +25,7 @@ namespace margelo::nitro::onramper { struct NitroSessionCredentials; }
|
|
|
25
25
|
#include <string>
|
|
26
26
|
#include "PreparedIntentResult.hpp"
|
|
27
27
|
#include <functional>
|
|
28
|
+
#include <optional>
|
|
28
29
|
#include "NitroSessionCredentials.hpp"
|
|
29
30
|
|
|
30
31
|
namespace margelo::nitro::onramper {
|
|
@@ -62,10 +63,11 @@ namespace margelo::nitro::onramper {
|
|
|
62
63
|
virtual std::shared_ptr<Promise<void>> initialize(const std::string& sessionId, const std::string& sessionToken) = 0;
|
|
63
64
|
virtual std::shared_ptr<Promise<void>> reset() = 0;
|
|
64
65
|
virtual std::shared_ptr<Promise<void>> signOut() = 0;
|
|
65
|
-
virtual std::shared_ptr<Promise<PreparedIntentResult>> getCheckoutRequirements(const std::string& requestJson, const std::string& styleJson) = 0;
|
|
66
|
+
virtual std::shared_ptr<Promise<PreparedIntentResult>> getCheckoutRequirements(const std::string& requestJson, const std::string& prefillJson, const std::string& styleJson) = 0;
|
|
66
67
|
virtual std::shared_ptr<Promise<void>> cancelPreparedIntent(const std::string& intentHandle) = 0;
|
|
67
68
|
virtual void setStateListener(const std::function<void(const std::string& /* stateJson */)>& onState) = 0;
|
|
68
69
|
virtual void setEventListener(const std::function<void(const std::string& /* eventJson */)>& onEvent) = 0;
|
|
70
|
+
virtual void setTransactionIdListener(const std::function<void(const std::optional<std::string>& /* transactionId */)>& onTransactionId) = 0;
|
|
69
71
|
virtual void setSessionExpirationHandler(const std::function<std::shared_ptr<Promise<std::shared_ptr<Promise<NitroSessionCredentials>>>>()>& handler) = 0;
|
|
70
72
|
|
|
71
73
|
protected:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onramper/onramper-react-native",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "React Native wrapper for the Onramper iOS SDK",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/module/index.js",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"license": "Apache-2.0",
|
|
65
65
|
"homepage": "https://github.com/onramper/onramper-react-native#readme",
|
|
66
66
|
"onramperSDK": {
|
|
67
|
-
"checksum": "
|
|
67
|
+
"checksum": "305cca364bb24bb5ec964488e1dc815a9a63c734a989482080cbc02993ec7f6b"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"react": ">=19.0.0",
|
package/src/OnramperClient.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
CheckoutRequest,
|
|
10
10
|
OnramperConfiguration,
|
|
11
11
|
OnramperState,
|
|
12
|
+
OnramperUserPrefill,
|
|
12
13
|
QuoteResponse,
|
|
13
14
|
SessionCredentials,
|
|
14
15
|
} from './types';
|
|
@@ -29,12 +30,14 @@ export interface GetCheckoutRequirementsResult {
|
|
|
29
30
|
export class OnramperClient {
|
|
30
31
|
state: OnramperState = { kind: 'idle' };
|
|
31
32
|
lastError: OnramperError | null = null;
|
|
33
|
+
currentTransactionId: string | null = null;
|
|
32
34
|
|
|
33
35
|
// Each client owns its own native instance (and thus its own SDK client).
|
|
34
36
|
private readonly native = createOnramperNative();
|
|
35
37
|
|
|
36
38
|
private readonly stateListeners = new Set<(state: OnramperState) => void>();
|
|
37
39
|
private readonly eventListeners = new Set<(event: CheckoutEvent) => void>();
|
|
40
|
+
private readonly transactionIdListeners = new Set<(transactionId: string | null) => void>();
|
|
38
41
|
|
|
39
42
|
// Resolved when the constructor-issued configure() completes. Public methods
|
|
40
43
|
// that need the native client await this first.
|
|
@@ -49,12 +52,23 @@ export class OnramperClient {
|
|
|
49
52
|
for (const fn of this.stateListeners) fn(s);
|
|
50
53
|
});
|
|
51
54
|
|
|
52
|
-
// Single native checkout-event callback →
|
|
55
|
+
// Single native checkout-event callback → keep the transaction ID mirror
|
|
56
|
+
// synchronized at finalization, then fan out to checkout listeners.
|
|
53
57
|
this.native.setEventListener((json) => {
|
|
54
58
|
const e = JSON.parse(json) as CheckoutEvent;
|
|
59
|
+
if (e.type === 'checkoutFinalized') {
|
|
60
|
+
this.updateCurrentTransactionId(e.response.onramperTransactionId);
|
|
61
|
+
}
|
|
55
62
|
for (const fn of this.eventListeners) fn(e);
|
|
56
63
|
});
|
|
57
64
|
|
|
65
|
+
this.native.setTransactionIdListener((transactionId) => {
|
|
66
|
+
// The SDK transiently publishes nil while re-preparing after the payment
|
|
67
|
+
// sheet is dismissed. The finalized transaction ID remains durable across
|
|
68
|
+
// that attempt change; only explicit reset()/signOut() clear the JS mirror.
|
|
69
|
+
if (transactionId !== undefined) this.updateCurrentTransactionId(transactionId);
|
|
70
|
+
});
|
|
71
|
+
|
|
58
72
|
// The SDK calls this when its session expires; return fresh credentials.
|
|
59
73
|
// Nitro stores the async callback natively and awaits it directly — no
|
|
60
74
|
// event round-trip needed.
|
|
@@ -81,6 +95,19 @@ export class OnramperClient {
|
|
|
81
95
|
this.configured.catch(() => undefined);
|
|
82
96
|
}
|
|
83
97
|
|
|
98
|
+
private updateCurrentTransactionId(next: string | null): void {
|
|
99
|
+
if (next === this.currentTransactionId) return;
|
|
100
|
+
|
|
101
|
+
this.currentTransactionId = next;
|
|
102
|
+
for (const fn of [...this.transactionIdListeners]) {
|
|
103
|
+
try {
|
|
104
|
+
fn(next);
|
|
105
|
+
} catch (error: unknown) {
|
|
106
|
+
console.error('Onramper transaction ID listener threw:', error);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
84
111
|
async initialize(creds: SessionCredentials): Promise<void> {
|
|
85
112
|
try {
|
|
86
113
|
await this.configured;
|
|
@@ -94,6 +121,7 @@ export class OnramperClient {
|
|
|
94
121
|
try {
|
|
95
122
|
await this.configured;
|
|
96
123
|
await this.native.reset();
|
|
124
|
+
this.updateCurrentTransactionId(null);
|
|
97
125
|
} catch (e: unknown) {
|
|
98
126
|
throw OnramperError.from(e);
|
|
99
127
|
}
|
|
@@ -109,6 +137,7 @@ export class OnramperClient {
|
|
|
109
137
|
try {
|
|
110
138
|
await this.configured;
|
|
111
139
|
await this.native.signOut();
|
|
140
|
+
this.updateCurrentTransactionId(null);
|
|
112
141
|
} catch (e: unknown) {
|
|
113
142
|
throw OnramperError.from(e);
|
|
114
143
|
}
|
|
@@ -118,14 +147,29 @@ export class OnramperClient {
|
|
|
118
147
|
* Fetches checkout requirements + quote and returns a native checkout button
|
|
119
148
|
* to render plus the quote. The button handles login / finalize / webview
|
|
120
149
|
* internally; outcomes surface via the event stream (`addEventListener`).
|
|
150
|
+
*
|
|
151
|
+
* Pass `prefill` to pre-populate the OnramperID sign-in and additional-info
|
|
152
|
+
* screens with values you already know about the user. It is best-effort and
|
|
153
|
+
* never blocks sign-in — there is no error to handle. Note the caveat on
|
|
154
|
+
* `OnramperUserPrefill.email` before supplying it.
|
|
155
|
+
*
|
|
156
|
+
* `prefill` trails `buttonStyle` here, unlike the Swift
|
|
157
|
+
* `getCheckoutRequirements(_:prefill:buttonStyle:)` where argument labels make
|
|
158
|
+
* the middle position free: appending it keeps every existing JS call site
|
|
159
|
+
* working unchanged.
|
|
121
160
|
*/
|
|
122
161
|
async getCheckoutRequirements(
|
|
123
162
|
request: CheckoutRequest,
|
|
124
163
|
buttonStyle: CheckoutButtonStyle = {},
|
|
164
|
+
prefill: OnramperUserPrefill = {},
|
|
125
165
|
): Promise<GetCheckoutRequirementsResult> {
|
|
126
166
|
try {
|
|
127
167
|
await this.configured;
|
|
128
|
-
const result = await this.native.getCheckoutRequirements(
|
|
168
|
+
const result = await this.native.getCheckoutRequirements(
|
|
169
|
+
JSON.stringify(request),
|
|
170
|
+
JSON.stringify(prefill),
|
|
171
|
+
JSON.stringify(buttonStyle),
|
|
172
|
+
);
|
|
129
173
|
const quote = JSON.parse(result.quoteJson) as QuoteResponse;
|
|
130
174
|
const button = createElement(OnramperCheckoutButtonView, {
|
|
131
175
|
intentHandle: result.intentHandle,
|
|
@@ -150,6 +194,14 @@ export class OnramperClient {
|
|
|
150
194
|
};
|
|
151
195
|
}
|
|
152
196
|
|
|
197
|
+
/** Subscribe to the durable Onramper transaction ID. Successful reset/signOut publish null. */
|
|
198
|
+
addTransactionIdListener(fn: (transactionId: string | null) => void): () => void {
|
|
199
|
+
this.transactionIdListeners.add(fn);
|
|
200
|
+
return () => {
|
|
201
|
+
this.transactionIdListeners.delete(fn);
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
153
205
|
/** Subscribe to a specific checkout event. Returns an unsubscribe function. */
|
|
154
206
|
addEventListener<K extends EventName>(name: K, fn: (e: EventPayload<K>) => void): () => void {
|
|
155
207
|
const wrapper = (e: CheckoutEvent) => {
|
|
@@ -165,6 +217,7 @@ export class OnramperClient {
|
|
|
165
217
|
destroy(): void {
|
|
166
218
|
this.stateListeners.clear();
|
|
167
219
|
this.eventListeners.clear();
|
|
220
|
+
this.transactionIdListeners.clear();
|
|
168
221
|
this.native.dispose();
|
|
169
222
|
}
|
|
170
223
|
}
|
package/src/index.ts
CHANGED
|
@@ -42,13 +42,18 @@ export interface OnramperNitro extends HybridObject<{ ios: 'swift' }> {
|
|
|
42
42
|
// Fetches checkout requirements + quote, stores the SDK's SwiftUI checkout
|
|
43
43
|
// button under a handle, and returns the handle + JSON-encoded quote. The
|
|
44
44
|
// OnramperCheckoutButton Nitro view renders the stored button by handle.
|
|
45
|
-
// `requestJson` is a JSON CheckoutRequest; `
|
|
46
|
-
|
|
45
|
+
// `requestJson` is a JSON CheckoutRequest; `prefillJson` a JSON
|
|
46
|
+
// OnramperUserPrefill (`{}` when the caller supplied none); `styleJson` a JSON
|
|
47
|
+
// CheckoutButtonStyle. Argument order mirrors the SDK's
|
|
48
|
+
// `getCheckoutRequirements(_:prefill:buttonStyle:)`.
|
|
49
|
+
getCheckoutRequirements(requestJson: string, prefillJson: string, styleJson: string): Promise<PreparedIntentResult>;
|
|
47
50
|
cancelPreparedIntent(intentHandle: string): Promise<void>;
|
|
48
51
|
|
|
49
52
|
// Single native callback per stream; the JS wrapper fans out to multiple listeners.
|
|
50
53
|
setStateListener(onState: (stateJson: string) => void): void;
|
|
51
54
|
setEventListener(onEvent: (eventJson: string) => void): void;
|
|
55
|
+
// Mirrors OnramperSDK.$currentTransactionId. `undefined` represents native nil.
|
|
56
|
+
setTransactionIdListener(onTransactionId: (transactionId: string | undefined) => void): void;
|
|
52
57
|
|
|
53
58
|
// The SDK's sessionExpirationHandler, as a stored async callback that returns
|
|
54
59
|
// fresh credentials. Replaces the Expo-era onSessionExpired/provide/fail dance.
|
package/src/types.ts
CHANGED
|
@@ -69,6 +69,31 @@ export interface QuoteResponse {
|
|
|
69
69
|
recommendations?: string[];
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
// Mirrors Swift `OnramperUserPrefill`. Values you already know about the user,
|
|
73
|
+
// used to pre-populate the OnramperID sign-in and additional-info screens.
|
|
74
|
+
// Every field is optional — supply only what you know.
|
|
75
|
+
//
|
|
76
|
+
// Prefill is **best-effort and never blocks sign-in**: if it can't be applied,
|
|
77
|
+
// the login flow opens without it. Nothing surfaces to your app, and there is
|
|
78
|
+
// no error to handle.
|
|
79
|
+
//
|
|
80
|
+
// `email` is the *binding identity*, not merely another prefilled value. When
|
|
81
|
+
// it matches the account that signs in, the remaining values may be applied
|
|
82
|
+
// automatically; when it does not match, the whole prefill is dropped — which
|
|
83
|
+
// is strictly worse than omitting `email`, where the values are still offered
|
|
84
|
+
// to the user for confirmation. Supply it only when you're confident it's the
|
|
85
|
+
// address the user will sign in with.
|
|
86
|
+
//
|
|
87
|
+
// Prefill is enabled per integration — talk to your Onramper representative
|
|
88
|
+
// before relying on it.
|
|
89
|
+
export interface OnramperUserPrefill {
|
|
90
|
+
email?: string;
|
|
91
|
+
firstName?: string;
|
|
92
|
+
lastName?: string;
|
|
93
|
+
/** E.164 format, e.g. `+3712345678`. Always a candidate — the user still verifies it. */
|
|
94
|
+
phoneNumber?: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
72
97
|
export interface CheckoutButtonStyle {
|
|
73
98
|
backgroundColor?: string; // hex #RRGGBB or #RRGGBBAA
|
|
74
99
|
foregroundColor?: string;
|
|
@@ -90,6 +115,8 @@ export interface HeadlessCheckoutData {
|
|
|
90
115
|
|
|
91
116
|
export interface CheckoutFinalizeResponse {
|
|
92
117
|
headlessCheckoutId: string;
|
|
118
|
+
/** Durable Onramper transaction identifier for support, reconciliation, and status lookups. */
|
|
119
|
+
onramperTransactionId: string;
|
|
93
120
|
headlessCheckoutData: HeadlessCheckoutData;
|
|
94
121
|
}
|
|
95
122
|
|