@onramper/onramper-react-native 1.2.0 → 1.2.2
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 +30 -0
- package/README.md +9 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64/OnramperSDK.framework/Info.plist +0 -0
- 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 +12 -1
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64/OnramperSDK.framework/OnramperSDK +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64/OnramperSDK.framework/OnramperSDK_OnramperSDK.bundle/Info.plist +0 -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 +2240 -2234
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/OnramperSDK.framework/Info.plist +0 -0
- 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 +12 -1
- 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 +12 -1
- 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/Info.plist +0 -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 +2240 -2234
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/OnramperSDK.framework.dSYM/Contents/Resources/Relocations/x86_64/OnramperSDK.yml +2206 -2200
- package/ios/HybridOnramperNitro.swift +12 -0
- package/lib/commonjs/OnramperClient.js +35 -1
- package/lib/commonjs/OnramperClient.js.map +1 -1
- package/lib/module/OnramperClient.js +35 -1
- package/lib/module/OnramperClient.js.map +1 -1
- package/lib/typescript/commonjs/src/OnramperClient.d.ts +5 -0
- package/lib/typescript/commonjs/src/OnramperClient.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/specs/OnramperNitro.nitro.d.ts +1 -0
- package/lib/typescript/commonjs/src/specs/OnramperNitro.nitro.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types.d.ts +2 -0
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
- package/lib/typescript/module/src/OnramperClient.d.ts +5 -0
- package/lib/typescript/module/src/OnramperClient.d.ts.map +1 -1
- package/lib/typescript/module/src/specs/OnramperNitro.nitro.d.ts +1 -0
- package/lib/typescript/module/src/specs/OnramperNitro.nitro.d.ts.map +1 -1
- package/lib/typescript/module/src/types.d.ts +2 -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 +7 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string_.swift +53 -0
- package/nitrogen/generated/ios/swift/HybridOnramperNitroSpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridOnramperNitroSpec_cxx.swift +22 -0
- package/nitrogen/generated/shared/c++/HybridOnramperNitroSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridOnramperNitroSpec.hpp +2 -0
- package/package.json +2 -2
- package/src/OnramperClient.ts +38 -1
- package/src/specs/OnramperNitro.nitro.ts +2 -0
- package/src/types.ts +2 -0
|
@@ -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 {
|
|
@@ -66,6 +67,7 @@ namespace margelo::nitro::onramper {
|
|
|
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.2.
|
|
3
|
+
"version": "1.2.2",
|
|
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": "754184c10a736e1db3292b592ca634ddbaa61dd01540b60610df4aa73a61de9a"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"react": ">=19.0.0",
|
package/src/OnramperClient.ts
CHANGED
|
@@ -30,12 +30,14 @@ export interface GetCheckoutRequirementsResult {
|
|
|
30
30
|
export class OnramperClient {
|
|
31
31
|
state: OnramperState = { kind: 'idle' };
|
|
32
32
|
lastError: OnramperError | null = null;
|
|
33
|
+
currentTransactionId: string | null = null;
|
|
33
34
|
|
|
34
35
|
// Each client owns its own native instance (and thus its own SDK client).
|
|
35
36
|
private readonly native = createOnramperNative();
|
|
36
37
|
|
|
37
38
|
private readonly stateListeners = new Set<(state: OnramperState) => void>();
|
|
38
39
|
private readonly eventListeners = new Set<(event: CheckoutEvent) => void>();
|
|
40
|
+
private readonly transactionIdListeners = new Set<(transactionId: string | null) => void>();
|
|
39
41
|
|
|
40
42
|
// Resolved when the constructor-issued configure() completes. Public methods
|
|
41
43
|
// that need the native client await this first.
|
|
@@ -50,12 +52,23 @@ export class OnramperClient {
|
|
|
50
52
|
for (const fn of this.stateListeners) fn(s);
|
|
51
53
|
});
|
|
52
54
|
|
|
53
|
-
// 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.
|
|
54
57
|
this.native.setEventListener((json) => {
|
|
55
58
|
const e = JSON.parse(json) as CheckoutEvent;
|
|
59
|
+
if (e.type === 'checkoutFinalized') {
|
|
60
|
+
this.updateCurrentTransactionId(e.response.onramperTransactionId);
|
|
61
|
+
}
|
|
56
62
|
for (const fn of this.eventListeners) fn(e);
|
|
57
63
|
});
|
|
58
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
|
+
|
|
59
72
|
// The SDK calls this when its session expires; return fresh credentials.
|
|
60
73
|
// Nitro stores the async callback natively and awaits it directly — no
|
|
61
74
|
// event round-trip needed.
|
|
@@ -82,6 +95,19 @@ export class OnramperClient {
|
|
|
82
95
|
this.configured.catch(() => undefined);
|
|
83
96
|
}
|
|
84
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
|
+
|
|
85
111
|
async initialize(creds: SessionCredentials): Promise<void> {
|
|
86
112
|
try {
|
|
87
113
|
await this.configured;
|
|
@@ -95,6 +121,7 @@ export class OnramperClient {
|
|
|
95
121
|
try {
|
|
96
122
|
await this.configured;
|
|
97
123
|
await this.native.reset();
|
|
124
|
+
this.updateCurrentTransactionId(null);
|
|
98
125
|
} catch (e: unknown) {
|
|
99
126
|
throw OnramperError.from(e);
|
|
100
127
|
}
|
|
@@ -110,6 +137,7 @@ export class OnramperClient {
|
|
|
110
137
|
try {
|
|
111
138
|
await this.configured;
|
|
112
139
|
await this.native.signOut();
|
|
140
|
+
this.updateCurrentTransactionId(null);
|
|
113
141
|
} catch (e: unknown) {
|
|
114
142
|
throw OnramperError.from(e);
|
|
115
143
|
}
|
|
@@ -166,6 +194,14 @@ export class OnramperClient {
|
|
|
166
194
|
};
|
|
167
195
|
}
|
|
168
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
|
+
|
|
169
205
|
/** Subscribe to a specific checkout event. Returns an unsubscribe function. */
|
|
170
206
|
addEventListener<K extends EventName>(name: K, fn: (e: EventPayload<K>) => void): () => void {
|
|
171
207
|
const wrapper = (e: CheckoutEvent) => {
|
|
@@ -181,6 +217,7 @@ export class OnramperClient {
|
|
|
181
217
|
destroy(): void {
|
|
182
218
|
this.stateListeners.clear();
|
|
183
219
|
this.eventListeners.clear();
|
|
220
|
+
this.transactionIdListeners.clear();
|
|
184
221
|
this.native.dispose();
|
|
185
222
|
}
|
|
186
223
|
}
|
|
@@ -52,6 +52,8 @@ export interface OnramperNitro extends HybridObject<{ ios: 'swift' }> {
|
|
|
52
52
|
// Single native callback per stream; the JS wrapper fans out to multiple listeners.
|
|
53
53
|
setStateListener(onState: (stateJson: string) => void): void;
|
|
54
54
|
setEventListener(onEvent: (eventJson: string) => void): void;
|
|
55
|
+
// Mirrors OnramperSDK.$currentTransactionId. `undefined` represents native nil.
|
|
56
|
+
setTransactionIdListener(onTransactionId: (transactionId: string | undefined) => void): void;
|
|
55
57
|
|
|
56
58
|
// The SDK's sessionExpirationHandler, as a stored async callback that returns
|
|
57
59
|
// fresh credentials. Replaces the Expo-era onSessionExpired/provide/fail dance.
|
package/src/types.ts
CHANGED
|
@@ -115,6 +115,8 @@ export interface HeadlessCheckoutData {
|
|
|
115
115
|
|
|
116
116
|
export interface CheckoutFinalizeResponse {
|
|
117
117
|
headlessCheckoutId: string;
|
|
118
|
+
/** Durable Onramper transaction identifier for support, reconciliation, and status lookups. */
|
|
119
|
+
onramperTransactionId: string;
|
|
118
120
|
headlessCheckoutData: HeadlessCheckoutData;
|
|
119
121
|
}
|
|
120
122
|
|