mobilyflow-react-native-sdk 0.0.1 → 0.0.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.
@@ -100,7 +100,7 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
100
100
  dependencies {
101
101
  implementation "com.facebook.react:react-android"
102
102
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
103
- implementation "com.mobilyflow:mobilyflow-android-sdk:0.0.3-beta3"
103
+ implementation "com.mobilyflow:mobilyflow-android-sdk:0.0.4"
104
104
  implementation "org.jetbrains.kotlinx:kotlinx-datetime:0.6.2"
105
105
  implementation "org.jetbrains.kotlin:kotlin-reflect"
106
106
  }
@@ -75,6 +75,10 @@ public abstract class NativeMobilyflowReactNativeSdkSpec extends ReactContextBas
75
75
  @DoNotStrip
76
76
  public abstract void openManageSubscription(String uuid, Promise promise);
77
77
 
78
+ @ReactMethod
79
+ @DoNotStrip
80
+ public abstract void openRefundDialog(String uuid, String transactionId, Promise promise);
81
+
78
82
  @ReactMethod
79
83
  @DoNotStrip
80
84
  public abstract void purchaseProduct(String uuid, String productId, @Nullable ReadableMap options, Promise promise);
@@ -62,6 +62,11 @@ static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI
62
62
  return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "openManageSubscription", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
63
63
  }
64
64
 
65
+ static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_openRefundDialog(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
66
+ static jmethodID cachedMethodId = nullptr;
67
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "openRefundDialog", "(Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
68
+ }
69
+
65
70
  static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_purchaseProduct(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
66
71
  static jmethodID cachedMethodId = nullptr;
67
72
  return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "purchaseProduct", "(Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
@@ -89,6 +94,7 @@ NativeMobilyflowReactNativeSdkSpecJSI::NativeMobilyflowReactNativeSdkSpecJSI(con
89
94
  methodMap_["getEntitlements"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getEntitlements};
90
95
  methodMap_["requestTransferOwnership"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_requestTransferOwnership};
91
96
  methodMap_["openManageSubscription"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_openManageSubscription};
97
+ methodMap_["openRefundDialog"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_openRefundDialog};
92
98
  methodMap_["purchaseProduct"] = MethodMetadata {3, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_purchaseProduct};
93
99
  methodMap_["sendDiagnotic"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_sendDiagnotic};
94
100
  methodMap_["getStoreCountry"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getStoreCountry};
@@ -81,6 +81,13 @@ static jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_openMa
81
81
  count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
82
82
  );
83
83
  }
84
+ static jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_openRefundDialog(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
85
+ return static_cast<NativeMobilyflowReactNativeSdkCxxSpecJSI *>(&turboModule)->openRefundDialog(
86
+ rt,
87
+ count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
88
+ count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt)
89
+ );
90
+ }
84
91
  static jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_purchaseProduct(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
85
92
  return static_cast<NativeMobilyflowReactNativeSdkCxxSpecJSI *>(&turboModule)->purchaseProduct(
86
93
  rt,
@@ -115,6 +122,7 @@ NativeMobilyflowReactNativeSdkCxxSpecJSI::NativeMobilyflowReactNativeSdkCxxSpecJ
115
122
  methodMap_["getEntitlements"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getEntitlements};
116
123
  methodMap_["requestTransferOwnership"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_requestTransferOwnership};
117
124
  methodMap_["openManageSubscription"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_openManageSubscription};
125
+ methodMap_["openRefundDialog"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_openRefundDialog};
118
126
  methodMap_["purchaseProduct"] = MethodMetadata {3, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_purchaseProduct};
119
127
  methodMap_["sendDiagnotic"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_sendDiagnotic};
120
128
  methodMap_["getStoreCountry"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getStoreCountry};
@@ -138,6 +138,7 @@ public:
138
138
  virtual jsi::Value getEntitlements(jsi::Runtime &rt, jsi::String uuid, jsi::Array productIds) = 0;
139
139
  virtual jsi::Value requestTransferOwnership(jsi::Runtime &rt, jsi::String uuid) = 0;
140
140
  virtual jsi::Value openManageSubscription(jsi::Runtime &rt, jsi::String uuid) = 0;
141
+ virtual jsi::Value openRefundDialog(jsi::Runtime &rt, jsi::String uuid, jsi::String transactionId) = 0;
141
142
  virtual jsi::Value purchaseProduct(jsi::Runtime &rt, jsi::String uuid, jsi::String productId, std::optional<jsi::Object> options) = 0;
142
143
  virtual void sendDiagnotic(jsi::Runtime &rt, jsi::String uuid) = 0;
143
144
  virtual jsi::Value getStoreCountry(jsi::Runtime &rt, jsi::String uuid) = 0;
@@ -251,6 +252,14 @@ private:
251
252
  return bridging::callFromJs<jsi::Value>(
252
253
  rt, &T::openManageSubscription, jsInvoker_, instance_, std::move(uuid));
253
254
  }
255
+ jsi::Value openRefundDialog(jsi::Runtime &rt, jsi::String uuid, jsi::String transactionId) override {
256
+ static_assert(
257
+ bridging::getParameterCount(&T::openRefundDialog) == 3,
258
+ "Expected openRefundDialog(...) to have 3 parameters");
259
+
260
+ return bridging::callFromJs<jsi::Value>(
261
+ rt, &T::openRefundDialog, jsInvoker_, instance_, std::move(uuid), std::move(transactionId));
262
+ }
254
263
  jsi::Value purchaseProduct(jsi::Runtime &rt, jsi::String uuid, jsi::String productId, std::optional<jsi::Object> options) override {
255
264
  static_assert(
256
265
  bridging::getParameterCount(&T::purchaseProduct) == 4,
@@ -127,6 +127,10 @@ class MobilyflowReactNativeSdkModule(reactContext: ReactApplicationContext) : Na
127
127
  }
128
128
  }
129
129
 
130
+ override fun openRefundDialog(uuid: String, transactionId: String, promise: Promise) {
131
+ promise.reject("-1", "Not implemented")
132
+ }
133
+
130
134
  override fun purchaseProduct(uuid: String, productId: String, options: ReadableMap?, promise: Promise) {
131
135
  try {
132
136
  if (reactApplicationContext.currentActivity == null) {
@@ -156,7 +160,8 @@ class MobilyflowReactNativeSdkModule(reactContext: ReactApplicationContext) : Na
156
160
  }
157
161
  }
158
162
 
159
- sdk.purchaseProduct(reactApplicationContext.currentActivity!!, product, purchaseOptions)
163
+ var status = sdk.purchaseProduct(reactApplicationContext.currentActivity!!, product, purchaseOptions)
164
+ promise.resolve(status)
160
165
  } catch (error: Exception) {
161
166
  throwError(error, promise)
162
167
  }
@@ -167,14 +172,7 @@ class MobilyflowReactNativeSdkModule(reactContext: ReactApplicationContext) : Na
167
172
  }
168
173
 
169
174
  override fun getStoreCountry(uuid: String, promise: Promise) {
170
- /*try {
171
- val status = _sdkInstances[uuid]!!.getS()
172
- promise.resolve(status.value)
173
- } catch (error: Exception) {
174
- throwError(error, promise)
175
- }*/
176
- // TODO
177
- return promise.resolve("FRA")
175
+ promise.reject("-1", "Not implemented")
178
176
  }
179
177
 
180
178
  companion object {
@@ -133,6 +133,13 @@ RCT_EXPORT_MODULE()
133
133
  }];
134
134
  }
135
135
 
136
+ - (void)openRefundDialog:(NSString *)uuid transactionId:(NSString *)transactionId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
137
+
138
+ [[self getInstance:uuid] openRefundDialogWithTransactionId:[transactionId longLongValue] completionHandler:^(BOOL result) {
139
+ resolve([NSNumber numberWithBool:result]);
140
+ }];
141
+ }
142
+
136
143
  - (void)purchaseProduct:(NSString *)uuid productId:(NSString *)productId options:(JS::NativeMobilyflowReactNativeSdk::PurchaseOptions &)options resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
137
144
 
138
145
  MobilyPurchaseSDK* sdk = [self getInstance:uuid];
@@ -77,6 +77,10 @@ namespace facebook::react {
77
77
  return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "openManageSubscription", @selector(openManageSubscription:resolve:reject:), args, count);
78
78
  }
79
79
 
80
+ static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_openRefundDialog(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
81
+ return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "openRefundDialog", @selector(openRefundDialog:transactionId:resolve:reject:), args, count);
82
+ }
83
+
80
84
  static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_purchaseProduct(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
81
85
  return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "purchaseProduct", @selector(purchaseProduct:productId:options:resolve:reject:), args, count);
82
86
  }
@@ -122,6 +126,9 @@ namespace facebook::react {
122
126
  methodMap_["openManageSubscription"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_openManageSubscription};
123
127
 
124
128
 
129
+ methodMap_["openRefundDialog"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_openRefundDialog};
130
+
131
+
125
132
  methodMap_["purchaseProduct"] = MethodMetadata {3, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_purchaseProduct};
126
133
  setMethodArgConversionSelector(@"purchaseProduct", 2, @"JS_NativeMobilyflowReactNativeSdk_PurchaseOptions:");
127
134
 
@@ -102,6 +102,10 @@ namespace JS {
102
102
  - (void)openManageSubscription:(NSString *)uuid
103
103
  resolve:(RCTPromiseResolveBlock)resolve
104
104
  reject:(RCTPromiseRejectBlock)reject;
105
+ - (void)openRefundDialog:(NSString *)uuid
106
+ transactionId:(NSString *)transactionId
107
+ resolve:(RCTPromiseResolveBlock)resolve
108
+ reject:(RCTPromiseRejectBlock)reject;
105
109
  - (void)purchaseProduct:(NSString *)uuid
106
110
  productId:(NSString *)productId
107
111
  options:(JS::NativeMobilyflowReactNativeSdk::PurchaseOptions &)options
@@ -81,6 +81,13 @@ static jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_openMa
81
81
  count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
82
82
  );
83
83
  }
84
+ static jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_openRefundDialog(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
85
+ return static_cast<NativeMobilyflowReactNativeSdkCxxSpecJSI *>(&turboModule)->openRefundDialog(
86
+ rt,
87
+ count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
88
+ count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt)
89
+ );
90
+ }
84
91
  static jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_purchaseProduct(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
85
92
  return static_cast<NativeMobilyflowReactNativeSdkCxxSpecJSI *>(&turboModule)->purchaseProduct(
86
93
  rt,
@@ -115,6 +122,7 @@ NativeMobilyflowReactNativeSdkCxxSpecJSI::NativeMobilyflowReactNativeSdkCxxSpecJ
115
122
  methodMap_["getEntitlements"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getEntitlements};
116
123
  methodMap_["requestTransferOwnership"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_requestTransferOwnership};
117
124
  methodMap_["openManageSubscription"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_openManageSubscription};
125
+ methodMap_["openRefundDialog"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_openRefundDialog};
118
126
  methodMap_["purchaseProduct"] = MethodMetadata {3, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_purchaseProduct};
119
127
  methodMap_["sendDiagnotic"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_sendDiagnotic};
120
128
  methodMap_["getStoreCountry"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getStoreCountry};
@@ -138,6 +138,7 @@ public:
138
138
  virtual jsi::Value getEntitlements(jsi::Runtime &rt, jsi::String uuid, jsi::Array productIds) = 0;
139
139
  virtual jsi::Value requestTransferOwnership(jsi::Runtime &rt, jsi::String uuid) = 0;
140
140
  virtual jsi::Value openManageSubscription(jsi::Runtime &rt, jsi::String uuid) = 0;
141
+ virtual jsi::Value openRefundDialog(jsi::Runtime &rt, jsi::String uuid, jsi::String transactionId) = 0;
141
142
  virtual jsi::Value purchaseProduct(jsi::Runtime &rt, jsi::String uuid, jsi::String productId, std::optional<jsi::Object> options) = 0;
142
143
  virtual void sendDiagnotic(jsi::Runtime &rt, jsi::String uuid) = 0;
143
144
  virtual jsi::Value getStoreCountry(jsi::Runtime &rt, jsi::String uuid) = 0;
@@ -251,6 +252,14 @@ private:
251
252
  return bridging::callFromJs<jsi::Value>(
252
253
  rt, &T::openManageSubscription, jsInvoker_, instance_, std::move(uuid));
253
254
  }
255
+ jsi::Value openRefundDialog(jsi::Runtime &rt, jsi::String uuid, jsi::String transactionId) override {
256
+ static_assert(
257
+ bridging::getParameterCount(&T::openRefundDialog) == 3,
258
+ "Expected openRefundDialog(...) to have 3 parameters");
259
+
260
+ return bridging::callFromJs<jsi::Value>(
261
+ rt, &T::openRefundDialog, jsInvoker_, instance_, std::move(uuid), std::move(transactionId));
262
+ }
254
263
  jsi::Value purchaseProduct(jsi::Runtime &rt, jsi::String uuid, jsi::String productId, std::optional<jsi::Object> options) override {
255
264
  static_assert(
256
265
  bridging::getParameterCount(&T::purchaseProduct) == 4,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobilyflow-react-native-sdk",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "MobilyFlow React Native SDK",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",
@@ -30,7 +30,7 @@ export interface Spec extends TurboModule {
30
30
 
31
31
  requestTransferOwnership(uuid: string): Promise<void>;
32
32
  openManageSubscription(uuid: string): Promise<void>;
33
- // openRefundDialog(uuid: string, transactionId: string): Promise<void>;
33
+ openRefundDialog(uuid: string, transactionId: string): Promise<boolean>;
34
34
 
35
35
  purchaseProduct(uuid: string, productId: string, options?: PurchaseOptions): Promise<WebhookStatus>;
36
36
 
@@ -38,9 +38,4 @@ export interface Spec extends TurboModule {
38
38
  getStoreCountry(uuid: string): Promise<string>;
39
39
  }
40
40
 
41
- // export default TurboModuleRegistry.getEnforcing<Spec>('MobilyflowReactNativeSdk');
42
- console.log('Before module');
43
- const module = TurboModuleRegistry.getEnforcing<Spec>('MobilyflowReactNativeSdk');
44
- console.log('after module ', module);
45
-
46
- export default module;
41
+ export default TurboModuleRegistry.getEnforcing<Spec>('MobilyflowReactNativeSdk');
@@ -1,5 +1,5 @@
1
1
  export enum ProductStatus {
2
2
  INVALID = 0,
3
- unavailable = 1,
4
- available = 2,
3
+ UNAVAILABLE = 1,
4
+ AVAILABLE = 2,
5
5
  }
package/src/index.tsx CHANGED
@@ -122,7 +122,17 @@ export class MobilyPurchaseSDK {
122
122
  }
123
123
  }
124
124
 
125
- // openRefundDialog(transactionId: string): Promise<void>;
125
+ async openRefundDialog(transactionId: string): Promise<boolean> {
126
+ if (RNPlatform.OS === 'android') {
127
+ throw new Error('openRefundDialog not implemented on Android');
128
+ } else {
129
+ try {
130
+ return await MobilyflowReactNativeSdk.openRefundDialog(this._uuid, transactionId);
131
+ } catch (error: any) {
132
+ throw this.throwError(error);
133
+ }
134
+ }
135
+ }
126
136
 
127
137
  async purchaseProduct(product: MobilyProduct, options?: PurchaseOptions): Promise<WebhookStatus> {
128
138
  try {
@@ -144,10 +154,14 @@ export class MobilyPurchaseSDK {
144
154
  }
145
155
 
146
156
  async getStoreCountry() {
147
- try {
148
- return await MobilyflowReactNativeSdk.getStoreCountry(this._uuid);
149
- } catch (error: any) {
150
- throw this.throwError(error);
157
+ if (RNPlatform.OS === 'android') {
158
+ throw new Error('getStoreCountry not implemented on Android');
159
+ } else {
160
+ try {
161
+ return await MobilyflowReactNativeSdk.getStoreCountry(this._uuid);
162
+ } catch (error: any) {
163
+ throw this.throwError(error);
164
+ }
151
165
  }
152
166
  }
153
167
  }