payme-mini-app 0.4.26 → 0.4.27

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.
@@ -4,9 +4,12 @@ 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, env: String, mode: String? = "miniapp_product") {
7
+ @objc func initPayME(
8
+ _ appId: String, publicKey: String, privateKey: String, env: String? = "PRODUCTION",
9
+ mode: String? = "miniapp_product"
10
+ ) {
8
11
  DispatchQueue.main.sync {
9
- PayMEConfig.instance.setMode(mode)
12
+ PayMEConfig.instance.setMode(mode ?? "miniapp_product")
10
13
  PayMEConfig.instance.env = (env == "SANDBOX") ? .sbx : .prod
11
14
  self.payme = PayME(key: PayMEKey(appId: appId, publicKey: publicKey, privateKey: privateKey))
12
15
  self.payme.delegate = self
@@ -16,40 +19,47 @@ class RNPayMEMiniApp: RCTEventEmitter, PayMEDelegate {
16
19
  @objc func open(_ type: String, param: NSDictionary) {
17
20
  let openAction: PayMEAction = {
18
21
  switch param["action"] as? String {
19
- case "PAYME": return PayMEAction.PayME
20
- case "OPEN": return PayMEAction.Open
21
- case "PAY": return PayMEAction.Pay
22
- case "SERVICE": return PayMEAction.Service
23
- case "DEPOSIT": return PayMEAction.Deposit
24
- case "WITHDRAW": return PayMEAction.Withdraw
25
- case "TRANSFER": return PayMEAction.Transfer
26
- case "KYC": return PayMEAction.KYC
27
- default: fatalError("Invalid action!")
22
+ case "PAYME": return PayMEAction.PayME
23
+ case "OPEN": return PayMEAction.Open
24
+ case "PAY": return PayMEAction.Pay
25
+ case "SERVICE": return PayMEAction.Service
26
+ case "DEPOSIT": return PayMEAction.Deposit
27
+ case "WITHDRAW": return PayMEAction.Withdraw
28
+ case "TRANSFER": return PayMEAction.Transfer
29
+ case "KYC": return PayMEAction.KYC
30
+ default: fatalError("Invalid action!")
28
31
  }
29
32
  }()
30
33
  var openData: Any? {
31
34
  guard let data = param["data"] as? NSDictionary else { return nil }
32
35
  switch param["action"] as? String {
33
- case "PAYME": fallthrough
34
- case "OPEN": return nil
35
- case "KYC": return nil
36
- case "PAY":
37
- return PayMEPaymentParam(amount: data["amount"] as! Int, transactionId: data["transactionId"] as! String, note: data["note"] as? String, ipnUrl: data["ipnUrl"] as? String)
38
- case "SERVICE":
39
- return PayMEServiceParam(service: data["service"] as! String)
40
- case "DEPOSIT":
41
- return PayMEPayParam(amount: data["amount"] as? Int, description: data["description"] as? String)
42
- case "WITHDRAW":
43
- return PayMEPayParam(amount: data["amount"] as? Int, description: data["description"] as? String)
44
- case "TRANSFER":
45
- return PayMEPayParam(amount: data["amount"] as? Int, description: data["description"] as? String)
46
- default: fatalError("Invalid action!")
36
+ case "PAYME", "OPEN": return nil
37
+ case "KYC": return nil
38
+ case "PAY":
39
+ return PayMEPaymentParam(
40
+ amount: data["amount"] as! Int, transactionId: data["transactionId"] as! String,
41
+ note: data["note"] as? String, ipnUrl: data["ipnUrl"] as? String)
42
+ case "SERVICE":
43
+ return PayMEServiceParam(service: data["service"] as! String)
44
+ case "DEPOSIT":
45
+ return PayMEPayParam(
46
+ amount: data["amount"] as? Int, description: data["description"] as? String)
47
+ case "WITHDRAW":
48
+ return PayMEPayParam(
49
+ amount: data["amount"] as? Int, description: data["description"] as? String)
50
+ case "TRANSFER":
51
+ return PayMEPayParam(
52
+ amount: data["amount"] as? Int, description: data["description"] as? String)
53
+ default: fatalError("Invalid action!")
47
54
  }
48
55
  }
49
56
 
50
57
  DispatchQueue.main.sync {
51
58
  let RNVC = UIApplication.shared.delegate?.window??.rootViewController
52
- self.payme.open(with: PayMEOpeningParam(action: openAction, phone: param["phone"] as! String, data: openData), from: RNVC, type: PayMEOpeningType(rawValue: type) ?? .screen)
59
+ self.payme.open(
60
+ with: PayMEOpeningParam(
61
+ action: openAction, phone: param["phone"] as! String, data: openData), from: RNVC,
62
+ type: PayMEOpeningType(rawValue: type) ?? .screen)
53
63
  }
54
64
  }
55
65
 
@@ -70,15 +80,14 @@ class RNPayMEMiniApp: RCTEventEmitter, PayMEDelegate {
70
80
  }
71
81
 
72
82
  func onError(action: PayMEMiniApp.PayMEAction, error: PayMEMiniApp.PayMEError) {
73
- sendEvent(withName: "onError", body: ["action": action.rawValue, "code": error.code, "description": error.description])
83
+ sendEvent(
84
+ withName: "onError",
85
+ body: ["action": action.rawValue, "code": error.code, "description": error.description])
74
86
  }
75
87
 
76
88
  func onResponse(action: PayMEMiniApp.PayMEAction, response: [String: Any]) {
77
- sendEvent(withName: "onResponse", body: ["action": action.rawValue].merging(response) { (_, new) in new })
89
+ sendEvent(
90
+ withName: "onResponse",
91
+ body: ["action": action.rawValue].merging(response) { (_, new) in new })
78
92
  }
79
93
  }
80
-
81
-
82
-
83
-
84
-
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>SchemeUserState</key>
6
+ <dict>
7
+ <key>RNPayMEMiniApp.xcscheme_^#shared#^_</key>
8
+ <dict>
9
+ <key>orderHint</key>
10
+ <integer>0</integer>
11
+ </dict>
12
+ </dict>
13
+ </dict>
14
+ </plist>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payme-mini-app",
3
- "version": "0.4.26",
3
+ "version": "0.4.27",
4
4
  "description": "Thư viện tích hợp PayME Miniapp",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",