payme-mini-app 0.1.0 → 0.1.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/ios/RNPayMEMiniApp-Bridging-Header.h +1 -0
- package/ios/RNPayMEMiniApp.m +6 -2
- package/ios/RNPayMEMiniApp.swift +57 -11
- package/lib/commonjs/index.js +9 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.type.js +2 -0
- package/lib/commonjs/index.type.js.map +1 -0
- package/lib/module/index.js +7 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.type.js +2 -0
- package/lib/module/index.type.js.map +1 -0
- package/lib/typescript/index.d.ts +5 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/index.type.d.ts +18 -0
- package/lib/typescript/index.type.d.ts.map +1 -0
- package/package.json +1 -1
- package/payme-mini-app.podspec +1 -1
- package/src/index.tsx +11 -4
- package/src/index.type.ts +10 -0
package/ios/RNPayMEMiniApp.m
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
#import <React/RCTBridgeModule.h>
|
|
2
|
+
#import <React/RCTEventEmitter.h>
|
|
2
3
|
|
|
3
|
-
@interface RCT_EXTERN_MODULE(RNPayMEMiniApp,
|
|
4
|
+
@interface RCT_EXTERN_MODULE(RNPayMEMiniApp, RCTEventEmitter)
|
|
4
5
|
|
|
5
|
-
RCT_EXTERN_METHOD(
|
|
6
|
+
RCT_EXTERN_METHOD(initPayME:(NSString*)appId publicKey:(NSString)publicKey privateKey:(NSString)privateKey)
|
|
7
|
+
RCT_EXTERN_METHOD(open:(NSString*)type param:(NSDictionary)param)
|
|
6
8
|
|
|
7
9
|
+ (BOOL)requiresMainQueueSetup
|
|
8
10
|
{
|
|
@@ -10,3 +12,5 @@ RCT_EXTERN_METHOD(open:(NSString*)type)
|
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
@end
|
|
15
|
+
|
|
16
|
+
|
package/ios/RNPayMEMiniApp.swift
CHANGED
|
@@ -1,17 +1,63 @@
|
|
|
1
1
|
import PayMEMiniApp
|
|
2
2
|
|
|
3
3
|
@objc(RNPayMEMiniApp)
|
|
4
|
-
class RNPayMEMiniApp:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@objc func
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
payme.open()
|
|
13
|
-
} else {
|
|
14
|
-
payme.open(from: RNVC)
|
|
4
|
+
class RNPayMEMiniApp: RCTEventEmitter, PayMEDelegate {
|
|
5
|
+
var payme: PayME!
|
|
6
|
+
|
|
7
|
+
@objc func initPayME(_ appId: String, publicKey: String, privateKey: String) {
|
|
8
|
+
DispatchQueue.main.sync {
|
|
9
|
+
PayMEConfig.instance.env = .local
|
|
10
|
+
self.payme = PayME(key: PayMEKey(appId: appId, publicKey: publicKey, privateKey: privateKey))
|
|
11
|
+
self.payme.delegate = self
|
|
15
12
|
}
|
|
16
13
|
}
|
|
14
|
+
|
|
15
|
+
@objc func open(_ type: String = "modal", param: NSDictionary) {
|
|
16
|
+
let openAction: PayMEAction = {
|
|
17
|
+
switch param["action"] as? String {
|
|
18
|
+
case "PAYME": return PayMEAction.PayME
|
|
19
|
+
case "OPEN": return PayMEAction.Open
|
|
20
|
+
case "PAY": return PayMEAction.Pay
|
|
21
|
+
default: fatalError("Invalid action!")
|
|
22
|
+
}
|
|
23
|
+
}()
|
|
24
|
+
var openData: Any? {
|
|
25
|
+
guard let data = param["data"] as? NSDictionary else { return nil }
|
|
26
|
+
switch param["action"] as? String {
|
|
27
|
+
case "PAYME": fallthrough
|
|
28
|
+
case "OPEN": return nil
|
|
29
|
+
case "PAY":
|
|
30
|
+
return PayMEPaymentParam(amount: data["amount"] as! Int, transactionId: data["transactionId"] as! String, note: data["note"] as? String)
|
|
31
|
+
default: fatalError("Invalid action!")
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
DispatchQueue.main.sync {
|
|
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
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
override func supportedEvents() -> [String]! {
|
|
48
|
+
return ["onError", "onResponse"]
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
func onError(action: PayMEMiniApp.PayMEAction, error: PayMEMiniApp.PayMEError) {
|
|
52
|
+
sendEvent(withName: "onError", body: ["action": action.value, "code": error.code, "description": error.description])
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
func onResponse(action: PayMEMiniApp.PayMEAction, response: [String: String]) {
|
|
56
|
+
sendEvent(withName: "onResponse", body: ["action": action.value].merging(response) { (_, new) in new })
|
|
57
|
+
}
|
|
17
58
|
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
package/lib/commonjs/index.js
CHANGED
|
@@ -3,10 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.PayMEMiniAppEvents = void 0;
|
|
7
|
+
exports.init = init;
|
|
6
8
|
exports.open = open;
|
|
7
9
|
var _reactNative = require("react-native");
|
|
8
10
|
const RNPayMEMiniApp = _reactNative.NativeModules.RNPayMEMiniApp;
|
|
9
|
-
function
|
|
10
|
-
return RNPayMEMiniApp.
|
|
11
|
+
function init(appId, publicKey, privateKey) {
|
|
12
|
+
return RNPayMEMiniApp.initPayME(appId, publicKey, privateKey);
|
|
11
13
|
}
|
|
14
|
+
function open(type, openingParam) {
|
|
15
|
+
return RNPayMEMiniApp.open(type, openingParam);
|
|
16
|
+
}
|
|
17
|
+
const PayMEMiniAppEvents = new _reactNative.NativeEventEmitter(RNPayMEMiniApp);
|
|
18
|
+
exports.PayMEMiniAppEvents = PayMEMiniAppEvents;
|
|
12
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RNPayMEMiniApp","NativeModules","open","type"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.type.ts"],"mappings":""}
|
package/lib/module/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
1
|
+
import { NativeEventEmitter, NativeModules } from 'react-native';
|
|
2
2
|
const RNPayMEMiniApp = NativeModules.RNPayMEMiniApp;
|
|
3
|
-
export function
|
|
4
|
-
return RNPayMEMiniApp.
|
|
3
|
+
export function init(appId, publicKey, privateKey) {
|
|
4
|
+
return RNPayMEMiniApp.initPayME(appId, publicKey, privateKey);
|
|
5
5
|
}
|
|
6
|
+
export function open(type, openingParam) {
|
|
7
|
+
return RNPayMEMiniApp.open(type, openingParam);
|
|
8
|
+
}
|
|
9
|
+
export const PayMEMiniAppEvents = new NativeEventEmitter(RNPayMEMiniApp);
|
|
6
10
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","RNPayMEMiniApp","open","type"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.type.ts"],"mappings":""}
|
|
@@ -1,2 +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;
|
|
4
|
+
export declare function open(type: string, openingParam: PayMEOpeningParam): any;
|
|
5
|
+
export declare const PayMEMiniAppEvents: NativeEventEmitter;
|
|
2
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type PayMEPaymentParam = {
|
|
2
|
+
amount: number;
|
|
3
|
+
transactionId: string;
|
|
4
|
+
note?: string;
|
|
5
|
+
};
|
|
6
|
+
export type PayMEOpeningParam = {
|
|
7
|
+
action: 'PAYME';
|
|
8
|
+
phone: string;
|
|
9
|
+
} | {
|
|
10
|
+
action: 'OPEN';
|
|
11
|
+
phone: string;
|
|
12
|
+
} | {
|
|
13
|
+
action: 'PAY';
|
|
14
|
+
phone: string;
|
|
15
|
+
data: PayMEPaymentParam;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=index.type.d.ts.map
|
|
@@ -0,0 +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;CACf,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"}
|
package/package.json
CHANGED
package/payme-mini-app.podspec
CHANGED
|
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
|
|
|
16
16
|
s.swift_versions = "5.0"
|
|
17
17
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
18
18
|
|
|
19
|
-
s.dependency "PayMEMiniApp", "1.0.
|
|
19
|
+
s.dependency "PayMEMiniApp", "1.0.15"
|
|
20
20
|
s.dependency "React-Core"
|
|
21
21
|
s.pod_target_xcconfig = { 'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES' }
|
|
22
22
|
# Don't install the dependencies when we run `pod install` in the old architecture.
|
package/src/index.tsx
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
1
|
+
import { NativeEventEmitter, NativeModules } from 'react-native';
|
|
2
|
+
import type { PayMEOpeningParam } from './index.type';
|
|
2
3
|
|
|
3
|
-
const RNPayMEMiniApp = NativeModules.RNPayMEMiniApp
|
|
4
|
+
const RNPayMEMiniApp = NativeModules.RNPayMEMiniApp;
|
|
4
5
|
|
|
5
|
-
export function
|
|
6
|
-
return RNPayMEMiniApp.
|
|
6
|
+
export function init(appId: string, publicKey: string, privateKey: string) {
|
|
7
|
+
return RNPayMEMiniApp.initPayME(appId, publicKey, privateKey);
|
|
7
8
|
}
|
|
9
|
+
|
|
10
|
+
export function open(type: string, openingParam: PayMEOpeningParam) {
|
|
11
|
+
return RNPayMEMiniApp.open(type, openingParam);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const PayMEMiniAppEvents = new NativeEventEmitter(RNPayMEMiniApp);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type PayMEPaymentParam = {
|
|
2
|
+
amount: number;
|
|
3
|
+
transactionId: string;
|
|
4
|
+
note?: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type PayMEOpeningParam =
|
|
8
|
+
| { action: 'PAYME'; phone: string }
|
|
9
|
+
| { action: 'OPEN'; phone: string }
|
|
10
|
+
| { action: 'PAY'; phone: string; data: PayMEPaymentParam };
|