payme-mini-app 0.1.3 → 0.1.5

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.
@@ -74,7 +74,7 @@ dependencies {
74
74
  //noinspection GradleDynamicVersion
75
75
  implementation "com.facebook.react:react-native"
76
76
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
77
- implementation 'com.github.PayME-Miniapp:native-android:0.0.20'
77
+ implementation 'com.github.PayME-Miniapp:native-android:0.0.21'
78
78
  }
79
79
 
80
80
  if (isNewArchitectureEnabled()) {
@@ -17,10 +17,29 @@ class RNPayMEMiniAppModule(reactContext: ReactApplicationContext) :
17
17
 
18
18
  private val eventNames = arrayListOf("onResponse", "onError")
19
19
 
20
+ private var listenerCount = 0
21
+
22
+ @ReactMethod
23
+ fun addListener(eventName: String) {
24
+ if (listenerCount == 0) {
25
+ // Set up any upstream listeners or background tasks as necessary
26
+ }
27
+
28
+ listenerCount += 1
29
+ }
30
+
31
+ @ReactMethod
32
+ fun removeListeners(count: Int) {
33
+ listenerCount -= count
34
+ if (listenerCount == 0) {
35
+ // Remove upstream listeners, stop unnecessary background tasks
36
+ }
37
+ }
38
+
20
39
  @ReactMethod
21
- fun initPayME(appId: String, publicKey: String, privateKey: String) {
40
+ fun initPayME(appId: String, publicKey: String, privateKey: String, env: String) {
22
41
  payMEMiniApp = PayMEMiniApp(
23
- currentActivity as Context, appId, publicKey, privateKey
42
+ currentActivity as Context, appId, publicKey, privateKey, getEnv(env)
24
43
  )
25
44
  }
26
45
 
@@ -33,7 +52,6 @@ class RNPayMEMiniAppModule(reactContext: ReactApplicationContext) :
33
52
  val transactionId = data?.getString("transactionId")
34
53
  val note = data?.getString("note")
35
54
  val ipnUrl = data?.getString("ipnUrl")
36
- val env = data?.getString("env") ?: ""
37
55
  var paymentData: PaymentData? = null
38
56
  if (amount != null && transactionId != null) {
39
57
  paymentData = PaymentData(transactionId, amount, note, ipnUrl)
@@ -42,7 +60,6 @@ class RNPayMEMiniAppModule(reactContext: ReactApplicationContext) :
42
60
  OpenMiniAppData(
43
61
  getActionOpenMiniApp(action),
44
62
  phone,
45
- env = getEnv(env),
46
63
  paymentData = paymentData
47
64
  )
48
65
  payMEMiniApp?.openMiniApp(
@@ -3,7 +3,7 @@
3
3
 
4
4
  @interface RCT_EXTERN_MODULE(RNPayMEMiniApp, RCTEventEmitter)
5
5
 
6
- RCT_EXTERN_METHOD(initPayME:(NSString*)appId publicKey:(NSString)publicKey privateKey:(NSString)privateKey)
6
+ RCT_EXTERN_METHOD(initPayME:(NSString*)appId publicKey:(NSString)publicKey privateKey:(NSString)privateKey env:(NSString)env)
7
7
  RCT_EXTERN_METHOD(open:(NSString*)type param:(NSDictionary)param)
8
8
 
9
9
  + (BOOL)requiresMainQueueSetup
@@ -4,15 +4,15 @@ import PayMEMiniApp
4
4
  class RNPayMEMiniApp: RCTEventEmitter, PayMEDelegate {
5
5
  var payme: PayME!
6
6
 
7
- @objc func initPayME(_ appId: String, publicKey: String, privateKey: String) {
7
+ @objc func initPayME(_ appId: String, publicKey: String, privateKey: String, env: String) {
8
8
  DispatchQueue.main.sync {
9
- PayMEConfig.instance.env = .local
9
+ PayMEConfig.instance.env = (env == "SANDBOX") ? .sbx : .prod
10
10
  self.payme = PayME(key: PayMEKey(appId: appId, publicKey: publicKey, privateKey: privateKey))
11
11
  self.payme.delegate = self
12
12
  }
13
13
  }
14
14
 
15
- @objc func open(_ type: String = "modal", param: NSDictionary) {
15
+ @objc func open(_ type: String, param: NSDictionary) {
16
16
  let openAction: PayMEAction = {
17
17
  switch param["action"] as? String {
18
18
  case "PAYME": return PayMEAction.PayME
@@ -34,13 +34,7 @@ class RNPayMEMiniApp: RCTEventEmitter, PayMEDelegate {
34
34
 
35
35
  DispatchQueue.main.sync {
36
36
  let RNVC = UIApplication.shared.delegate?.window??.rootViewController
37
- if (type == "screen") {
38
- guard let navigationController = RNVC as? UINavigationController else { return }
39
- navigationController.pushViewController(self.payme, animated: true)
40
- // payme.open()
41
- } else {
42
- self.payme.open(with: PayMEOpeningParam(action: openAction, phone: param["phone"] as! String, data: openData), from: RNVC)
43
- }
37
+ self.payme.open(with: PayMEOpeningParam(action: openAction, phone: param["phone"] as! String, data: openData), from: RNVC)
44
38
  }
45
39
  }
46
40
 
@@ -8,8 +8,8 @@ exports.init = init;
8
8
  exports.open = open;
9
9
  var _reactNative = require("react-native");
10
10
  const RNPayMEMiniApp = _reactNative.NativeModules.RNPayMEMiniApp;
11
- function init(appId, publicKey, privateKey) {
12
- return RNPayMEMiniApp.initPayME(appId, publicKey, privateKey);
11
+ function init(appId, publicKey, privateKey, env) {
12
+ return RNPayMEMiniApp.initPayME(appId, publicKey, privateKey, env);
13
13
  }
14
14
  function open(type, openingParam) {
15
15
  return RNPayMEMiniApp.open(type, openingParam);
@@ -1 +1 @@
1
- {"version":3,"names":["RNPayMEMiniApp","NativeModules","init","appId","publicKey","privateKey","initPayME","open","type","openingParam","PayMEMiniAppEvents","NativeEventEmitter"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;AAAA;AAGA,MAAMA,cAAc,GAAGC,0BAAa,CAACD,cAAc;AAE5C,SAASE,IAAI,CAACC,KAAa,EAAEC,SAAiB,EAAEC,UAAkB,EAAE;EACzE,OAAOL,cAAc,CAACM,SAAS,CAACH,KAAK,EAAEC,SAAS,EAAEC,UAAU,CAAC;AAC/D;AAEO,SAASE,IAAI,CAACC,IAAY,EAAEC,YAA+B,EAAE;EAClE,OAAOT,cAAc,CAACO,IAAI,CAACC,IAAI,EAAEC,YAAY,CAAC;AAChD;AAEO,MAAMC,kBAAkB,GAAG,IAAIC,+BAAkB,CAACX,cAAc,CAAC;AAAC"}
1
+ {"version":3,"names":["RNPayMEMiniApp","NativeModules","init","appId","publicKey","privateKey","env","initPayME","open","type","openingParam","PayMEMiniAppEvents","NativeEventEmitter"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;AAAA;AAGA,MAAMA,cAAc,GAAGC,0BAAa,CAACD,cAAc;AAE5C,SAASE,IAAI,CAClBC,KAAa,EACbC,SAAiB,EACjBC,UAAkB,EAClBC,GAAa,EACb;EACA,OAAON,cAAc,CAACO,SAAS,CAACJ,KAAK,EAAEC,SAAS,EAAEC,UAAU,EAAEC,GAAG,CAAC;AACpE;AAEO,SAASE,IAAI,CAACC,IAAY,EAAEC,YAA+B,EAAE;EAClE,OAAOV,cAAc,CAACQ,IAAI,CAACC,IAAI,EAAEC,YAAY,CAAC;AAChD;AAEO,MAAMC,kBAAkB,GAAG,IAAIC,+BAAkB,CAACZ,cAAc,CAAC;AAAC"}
@@ -1,7 +1,7 @@
1
1
  import { NativeEventEmitter, NativeModules } from 'react-native';
2
2
  const RNPayMEMiniApp = NativeModules.RNPayMEMiniApp;
3
- export function init(appId, publicKey, privateKey) {
4
- return RNPayMEMiniApp.initPayME(appId, publicKey, privateKey);
3
+ export function init(appId, publicKey, privateKey, env) {
4
+ return RNPayMEMiniApp.initPayME(appId, publicKey, privateKey, env);
5
5
  }
6
6
  export function open(type, openingParam) {
7
7
  return RNPayMEMiniApp.open(type, openingParam);
@@ -1 +1 @@
1
- {"version":3,"names":["NativeEventEmitter","NativeModules","RNPayMEMiniApp","init","appId","publicKey","privateKey","initPayME","open","type","openingParam","PayMEMiniAppEvents"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAGhE,MAAMC,cAAc,GAAGD,aAAa,CAACC,cAAc;AAEnD,OAAO,SAASC,IAAI,CAACC,KAAa,EAAEC,SAAiB,EAAEC,UAAkB,EAAE;EACzE,OAAOJ,cAAc,CAACK,SAAS,CAACH,KAAK,EAAEC,SAAS,EAAEC,UAAU,CAAC;AAC/D;AAEA,OAAO,SAASE,IAAI,CAACC,IAAY,EAAEC,YAA+B,EAAE;EAClE,OAAOR,cAAc,CAACM,IAAI,CAACC,IAAI,EAAEC,YAAY,CAAC;AAChD;AAEA,OAAO,MAAMC,kBAAkB,GAAG,IAAIX,kBAAkB,CAACE,cAAc,CAAC"}
1
+ {"version":3,"names":["NativeEventEmitter","NativeModules","RNPayMEMiniApp","init","appId","publicKey","privateKey","env","initPayME","open","type","openingParam","PayMEMiniAppEvents"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAGhE,MAAMC,cAAc,GAAGD,aAAa,CAACC,cAAc;AAEnD,OAAO,SAASC,IAAI,CAClBC,KAAa,EACbC,SAAiB,EACjBC,UAAkB,EAClBC,GAAa,EACb;EACA,OAAOL,cAAc,CAACM,SAAS,CAACJ,KAAK,EAAEC,SAAS,EAAEC,UAAU,EAAEC,GAAG,CAAC;AACpE;AAEA,OAAO,SAASE,IAAI,CAACC,IAAY,EAAEC,YAA+B,EAAE;EAClE,OAAOT,cAAc,CAACO,IAAI,CAACC,IAAI,EAAEC,YAAY,CAAC;AAChD;AAEA,OAAO,MAAMC,kBAAkB,GAAG,IAAIZ,kBAAkB,CAACE,cAAc,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { NativeEventEmitter } from 'react-native';
2
- import type { PayMEOpeningParam } from './index.type';
3
- export declare function init(appId: string, publicKey: string, privateKey: string): any;
2
+ import type { PayMEEnv, PayMEOpeningParam } from './index.type';
3
+ export declare function init(appId: string, publicKey: string, privateKey: string, env: PayMEEnv): any;
4
4
  export declare function open(type: string, openingParam: PayMEOpeningParam): any;
5
5
  export declare const PayMEMiniAppEvents: NativeEventEmitter;
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAiB,MAAM,cAAc,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAItD,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,OAExE;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,iBAAiB,OAEjE;AAED,eAAO,MAAM,kBAAkB,oBAAyC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAiB,MAAM,cAAc,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAIhE,wBAAgB,IAAI,CAClB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,QAAQ,OAGd;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,iBAAiB,OAEjE;AAED,eAAO,MAAM,kBAAkB,oBAAyC,CAAC"}
@@ -15,5 +15,6 @@ export type PayMEOpeningParam = {
15
15
  phone: string;
16
16
  data: PayMEPaymentParam;
17
17
  };
18
+ export type PayMEEnv = 'PRODUCTION' | 'SANDBOX';
18
19
  export {};
19
20
  //# sourceMappingURL=index.type.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.type.d.ts","sourceRoot":"","sources":["../../src/index.type.ts"],"names":[],"mappings":"AAAA,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GACzB;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,MAAM,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,iBAAiB,CAAA;CAAE,CAAC"}
1
+ {"version":3,"file":"index.type.d.ts","sourceRoot":"","sources":["../../src/index.type.ts"],"names":[],"mappings":"AAAA,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GACzB;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,MAAM,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,iBAAiB,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payme-mini-app",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "test",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
package/src/index.tsx CHANGED
@@ -1,10 +1,15 @@
1
1
  import { NativeEventEmitter, NativeModules } from 'react-native';
2
- import type { PayMEOpeningParam } from './index.type';
2
+ import type { PayMEEnv, PayMEOpeningParam } from './index.type';
3
3
 
4
4
  const RNPayMEMiniApp = NativeModules.RNPayMEMiniApp;
5
5
 
6
- export function init(appId: string, publicKey: string, privateKey: string) {
7
- return RNPayMEMiniApp.initPayME(appId, publicKey, privateKey);
6
+ export function init(
7
+ appId: string,
8
+ publicKey: string,
9
+ privateKey: string,
10
+ env: PayMEEnv
11
+ ) {
12
+ return RNPayMEMiniApp.initPayME(appId, publicKey, privateKey, env);
8
13
  }
9
14
 
10
15
  export function open(type: string, openingParam: PayMEOpeningParam) {
package/src/index.type.ts CHANGED
@@ -9,3 +9,5 @@ export type PayMEOpeningParam =
9
9
  | { action: 'PAYME'; phone: string }
10
10
  | { action: 'OPEN'; phone: string }
11
11
  | { action: 'PAY'; phone: string; data: PayMEPaymentParam };
12
+
13
+ export type PayMEEnv = 'PRODUCTION' | 'SANDBOX';