react-native-cashfree-pg-sdk 2.5.0 → 3.0.0
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/README.md +36 -16
- package/android/build.gradle +5 -3
- package/android/src/main/java/com/reactnativecashfreepgsdk/CashfreePgApiModule.java +75 -27
- package/android/src/main/java/com/reactnativecashfreepgsdk/CashfreePgApiPackage.java +32 -18
- package/ios/CashfreeEmitter.swift +11 -11
- package/ios/CashfreePgApi.swift +35 -19
- package/ios/CashfreePgApiAdapter.h +15 -0
- package/ios/CashfreePgApiAdapter.mm +94 -0
- package/lib/commonjs/Card/CFCardComponent.js +4 -2
- package/lib/commonjs/Card/CFCardComponent.js.map +1 -1
- package/lib/commonjs/Card/CFSubsCardComponent.js +4 -2
- package/lib/commonjs/Card/CFSubsCardComponent.js.map +1 -1
- package/lib/commonjs/NativeCashfreePgApi.js +9 -0
- package/lib/commonjs/NativeCashfreePgApi.js.map +1 -0
- package/lib/commonjs/index.js +18 -50
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/Card/CFCardComponent.js +12 -6
- package/lib/module/Card/CFCardComponent.js.map +1 -1
- package/lib/module/Card/CFSubsCardComponent.js +4 -2
- package/lib/module/Card/CFSubsCardComponent.js.map +1 -1
- package/lib/module/NativeCashfreePgApi.js +3 -0
- package/lib/module/NativeCashfreePgApi.js.map +1 -0
- package/lib/module/PPIWallet/PPIWalletPayment.js.map +1 -1
- package/lib/module/index.js +4 -38
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NativeCashfreePgApi.d.ts +21 -0
- package/lib/typescript/src/index.d.ts +1 -2
- package/package.json +31 -9
- package/react-native-cashfree-pg-sdk.podspec +5 -2
- package/src/Card/CFCardComponent.tsx +4 -2
- package/src/Card/CFSubsCardComponent.tsx +4 -2
- package/src/NativeCashfreePgApi.ts +23 -0
- package/src/index.ts +5 -59
- package/ios/CashfreeEventEmitter.m +0 -16
- package/ios/CashfreeEventEmitter.swift +0 -28
- package/ios/CashfreePgApi.m +0 -26
- package/src/CFErrorResponse.js +0 -35
- package/src/Card/CFCardComponent.js +0 -238
- package/src/Card/CFSubsCardComponent.js +0 -203
- package/src/Card/index.js +0 -2
- package/src/PPIWallet/PPIWalletPayment.js +0 -94
- package/src/index.js +0 -174
package/lib/module/index.js
CHANGED
|
@@ -1,30 +1,21 @@
|
|
|
1
1
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
2
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
3
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
-
import {
|
|
4
|
+
import { NativeEventEmitter } from 'react-native';
|
|
5
|
+
import CashfreePgApi from './NativeCashfreePgApi';
|
|
5
6
|
import { version } from '../package.json';
|
|
6
7
|
import { CFUPIPayment, CFCardPayment, CFNBPayment, CFSubsUPIPayment, CFSubsCardPayment, CFSubsNBPayment } from 'cashfree-pg-api-contract';
|
|
7
8
|
import CFCardComponent from './Card/CFCardComponent';
|
|
8
9
|
import CFSubsCardComponent from './Card/CFSubsCardComponent';
|
|
9
10
|
import { CFErrorResponse } from './CFErrorResponse';
|
|
10
11
|
import { doPPIWalletPayment } from './PPIWallet/PPIWalletPayment';
|
|
11
|
-
const LINKING_ERROR = `The package 'react-native-cashfree-pg-api' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
12
|
-
ios: "- You have run 'pod install'\n",
|
|
13
|
-
default: ''
|
|
14
|
-
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
|
|
15
|
-
const CashfreePgApi = NativeModules.CashfreePgApi ? NativeModules.CashfreePgApi : new Proxy({}, {
|
|
16
|
-
get() {
|
|
17
|
-
throw new Error(LINKING_ERROR);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
12
|
class CFPaymentGateway {
|
|
21
13
|
constructor() {
|
|
22
14
|
_defineProperty(this, "emitter", void 0);
|
|
23
15
|
_defineProperty(this, "successSubscription", null);
|
|
24
16
|
_defineProperty(this, "failureSubscription", null);
|
|
25
17
|
_defineProperty(this, "eventSubscription", null);
|
|
26
|
-
|
|
27
|
-
this.emitter = Platform.OS === 'ios' ? new NativeEventEmitter(NativeModules.CashfreeEventEmitter) : NativeAppEventEmitter;
|
|
18
|
+
this.emitter = new NativeEventEmitter(CashfreePgApi);
|
|
28
19
|
}
|
|
29
20
|
doPayment(checkoutPayment) {
|
|
30
21
|
checkoutPayment.version = version;
|
|
@@ -48,28 +39,7 @@ class CFPaymentGateway {
|
|
|
48
39
|
this.makePayment(cardPayment);
|
|
49
40
|
}
|
|
50
41
|
async getInstalledUpiApps() {
|
|
51
|
-
return
|
|
52
|
-
if (Platform.OS === 'ios') {
|
|
53
|
-
let fetchUpiList = apps => {
|
|
54
|
-
console.log(JSON.stringify(apps));
|
|
55
|
-
if (apps) {
|
|
56
|
-
resolve(apps);
|
|
57
|
-
} else {
|
|
58
|
-
reject('No UPI apps found');
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
this.upiAppsSubscription = this.emitter.addListener('cfUpiApps', fetchUpiList);
|
|
62
|
-
CashfreePgApi.getInstalledUpiApps();
|
|
63
|
-
} else {
|
|
64
|
-
CashfreePgApi.getInstalledUpiApps(apps => {
|
|
65
|
-
if (apps) {
|
|
66
|
-
resolve(apps);
|
|
67
|
-
} else {
|
|
68
|
-
reject('No UPI apps found');
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
});
|
|
42
|
+
return CashfreePgApi.getInstalledUpiApps();
|
|
73
43
|
}
|
|
74
44
|
makePayment(cfPayment) {
|
|
75
45
|
cfPayment.version = version;
|
|
@@ -149,10 +119,6 @@ class CFPaymentGateway {
|
|
|
149
119
|
this.failureSubscription.remove();
|
|
150
120
|
this.failureSubscription = null;
|
|
151
121
|
}
|
|
152
|
-
if (this.upiAppsSubscription !== undefined && this.upiAppsSubscription !== null) {
|
|
153
|
-
this.upiAppsSubscription.remove();
|
|
154
|
-
this.upiAppsSubscription = null;
|
|
155
|
-
}
|
|
156
122
|
}
|
|
157
123
|
}
|
|
158
124
|
export { CFErrorResponse };
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeAppEventEmitter","NativeEventEmitter","NativeModules","Platform","version","CFUPIPayment","CFCardPayment","CFNBPayment","CFSubsUPIPayment","CFSubsCardPayment","CFSubsNBPayment","CFCardComponent","CFSubsCardComponent","CFErrorResponse","doPPIWalletPayment","LINKING_ERROR","select","ios","default","CashfreePgApi","Proxy","get","Error","CFPaymentGateway","constructor","_defineProperty","emitter","OS","CashfreeEventEmitter","doPayment","checkoutPayment","JSON","stringify","doUPIPayment","doWebPayment","cfSession","doSubscriptionPayment","doCardPayment","cardPayment","makePayment","getInstalledUpiApps","Promise","resolve","reject","fetchUpiList","apps","console","log","upiAppsSubscription","addListener","cfPayment","paymentData","doElementUPIPayment","doElementNBPayment","makeSubsPayment","doSubsUPIPayment","doSubsCardPayment","doSubsNBPayment","payment","setEventSubscriber","cfEventCallback","eventFunction","event","data","parse","onReceivedEvent","eventName","meta","eventSubscription","removeEventSubscriber","undefined","remove","setCallback","cfCallback","successFunction","orderID","onVerify","failureFunction","error","response","message","fromJSON","onError","successSubscription","failureSubscription","removeCallback","CFCard","CFSubsCard","CFPaymentGatewayService"],"sources":["index.ts"],"sourcesContent":["import {\n EmitterSubscription,\n NativeAppEventEmitter,\n NativeEventEmitter,\n NativeModules,\n Platform,\n} from 'react-native';\nimport { version } from '../package.json';\nimport {\n type CheckoutPayment,\n type CFSession,\n type CFSubscriptionSession,\n CFUPIPayment,\n CFCardPayment,\n CFNBPayment,\n CFSubsUPIPayment,\n CFSubsCardPayment,\n CFSubsNBPayment,\n type CFPPIWalletPayment,\n} from 'cashfree-pg-api-contract';\nimport CFCardComponent from './Card/CFCardComponent';\nimport CFSubsCardComponent from './Card/CFSubsCardComponent';\nimport { CFErrorResponse } from './CFErrorResponse';\nimport { doPPIWalletPayment } from './PPIWallet/PPIWalletPayment';\n\nconst LINKING_ERROR =\n `The package 'react-native-cashfree-pg-api' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst CashfreePgApi = NativeModules.CashfreePgApi\n ? NativeModules.CashfreePgApi\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nclass CFPaymentGateway {\n private emitter: NativeEventEmitter | typeof NativeAppEventEmitter;\n private successSubscription: EmitterSubscription | null = null;\n private failureSubscription: EmitterSubscription | null = null;\n private eventSubscription: EmitterSubscription | null = null;\n private upiAppsSubscription: EmitterSubscription | null = null;\n\n constructor() {\n this.emitter =\n Platform.OS === 'ios'\n ? new NativeEventEmitter(NativeModules.CashfreeEventEmitter)\n : NativeAppEventEmitter;\n }\n\n doPayment(checkoutPayment: CheckoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doPayment(JSON.stringify(checkoutPayment));\n }\n\n doUPIPayment(checkoutPayment: CheckoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doUPIPayment(JSON.stringify(checkoutPayment));\n }\n\n doWebPayment(cfSession: CFSession) {\n CashfreePgApi.doWebPayment(JSON.stringify(cfSession));\n }\n\n doSubscriptionPayment(cfSession: CFSubscriptionSession) {\n CashfreePgApi.doSubscriptionPayment(JSON.stringify(cfSession));\n }\n\n /**\n * @deprecated : Instead call makePayment\n */\n doCardPayment(cardPayment: CheckoutPayment) {\n this.makePayment(cardPayment);\n }\n\n async getInstalledUpiApps() {\n return new Promise((resolve, reject) => {\n if (Platform.OS === 'ios') {\n let fetchUpiList = (apps: string) => {\n console.log(JSON.stringify(apps));\n if (apps) {\n resolve(apps);\n } else {\n reject('No UPI apps found');\n }\n };\n this.upiAppsSubscription = this.emitter.addListener(\n 'cfUpiApps',\n fetchUpiList\n );\n CashfreePgApi.getInstalledUpiApps();\n } else {\n CashfreePgApi.getInstalledUpiApps((apps: string) => {\n if (apps) {\n resolve(apps);\n } else {\n reject('No UPI apps found');\n }\n });\n }\n });\n }\n\n makePayment(cfPayment: CheckoutPayment) {\n cfPayment.version = version;\n const paymentData = JSON.stringify(cfPayment);\n if (cfPayment instanceof CFUPIPayment) {\n CashfreePgApi.doElementUPIPayment(paymentData);\n } else if (cfPayment instanceof CFCardPayment) {\n CashfreePgApi.doCardPayment(paymentData);\n } else if (cfPayment instanceof CFNBPayment) {\n CashfreePgApi.doElementNBPayment(paymentData);\n } else {\n console.log('makePayment::==> Wrong payment object');\n }\n }\n\n makeSubsPayment(cfPayment: CheckoutPayment){\n cfPayment.version = version;\n const paymentData = JSON.stringify(cfPayment);\n if (cfPayment instanceof CFSubsUPIPayment) {\n CashfreePgApi.doSubsUPIPayment(paymentData);\n } else if (cfPayment instanceof CFSubsCardPayment) {\n CashfreePgApi.doSubsCardPayment(paymentData);\n } else if (cfPayment instanceof CFSubsNBPayment) {\n CashfreePgApi.doSubsNBPayment(paymentData);\n } else {\n console.log('makePayment::==> Wrong payment object');\n }\n }\n\n /**\n * Creates a PPI wallet order session via Cashfree's API.\n * Resolves with the API response as-is; rejects with CFErrorResponse.\n */\n doPPIWalletPayment(payment: CFPPIWalletPayment): Promise<unknown> {\n return doPPIWalletPayment(payment);\n }\n\n setEventSubscriber(cfEventCallback: CFEventCallback) {\n let eventFunction = (event: string) => {\n console.log(JSON.stringify(event));\n let data = JSON.parse(event);\n cfEventCallback.onReceivedEvent(data.eventName, data.meta);\n };\n this.eventSubscription = this.emitter.addListener('cfEvent', eventFunction);\n CashfreePgApi.setEventSubscriber();\n }\n\n removeEventSubscriber() {\n if (\n this.eventSubscription !== undefined &&\n this.eventSubscription !== null\n ) {\n this.eventSubscription.remove();\n this.eventSubscription = null;\n }\n CashfreePgApi.removeEventSubscriber();\n }\n\n setCallback(cfCallback: CFCallback) {\n // this.cfCallback = cfCallback;\n let successFunction = (orderID: string) => {\n console.log('response is : ' + JSON.stringify(orderID));\n cfCallback.onVerify(orderID);\n };\n let failureFunction = (error: string) => {\n console.log('reason: ' + JSON.stringify(error));\n const response = new CFErrorResponse();\n // @ts-ignore\n const message = JSON.parse(error);\n response.fromJSON(message.error);\n // @ts-ignore\n cfCallback.onError(response, message.orderID);\n };\n this.successSubscription = this.emitter.addListener(\n 'cfSuccess',\n successFunction\n );\n this.failureSubscription = this.emitter.addListener(\n 'cfFailure',\n failureFunction\n );\n CashfreePgApi.setCallback();\n }\n\n removeCallback() {\n if (\n this.successSubscription !== undefined &&\n this.successSubscription !== null\n ) {\n this.successSubscription.remove();\n this.successSubscription = null;\n }\n if (\n this.failureSubscription !== undefined &&\n this.failureSubscription !== null\n ) {\n this.failureSubscription.remove();\n this.failureSubscription = null;\n }\n if (\n this.upiAppsSubscription !== undefined &&\n this.upiAppsSubscription !== null\n ) {\n this.upiAppsSubscription.remove();\n this.upiAppsSubscription = null;\n }\n }\n}\n\nexport interface CFCallback {\n onVerify(orderID: string): void;\n\n onError(error: CFErrorResponse, orderID: string): void;\n}\n\nexport interface CFEventCallback {\n onReceivedEvent(eventName: string, map: Map<string, string>): void;\n}\n\nexport { CFErrorResponse };\nexport const CFCard = CFCardComponent;\nexport const CFSubsCard = CFSubsCardComponent;\nexport const CFPaymentGatewayService = new CFPaymentGateway();\n"],"mappings":";;;AAAA,SAEEA,qBAAqB,EACrBC,kBAAkB,EAClBC,aAAa,EACbC,QAAQ,QACH,cAAc;AACrB,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAIEC,YAAY,EACZC,aAAa,EACbC,W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EACX4B,eACF,CAAC;IACD1D,aAAa,CAACqD,WAAW,CAAC,CAAC;EAC7B;EAEAa,cAAcA,CAAA,EAAG;IACf,IACE,IAAI,CAACF,mBAAmB,KAAKb,SAAS,IACtC,IAAI,CAACa,mBAAmB,KAAK,IAAI,EACjC;MACA,IAAI,CAACA,mBAAmB,CAACZ,MAAM,CAAC,CAAC;MACjC,IAAI,CAACY,mBAAmB,GAAG,IAAI;IACjC;IACA,IACE,IAAI,CAACC,mBAAmB,KAAKd,SAAS,IACtC,IAAI,CAACc,mBAAmB,KAAK,IAAI,EACjC;MACA,IAAI,CAACA,mBAAmB,CAACb,MAAM,CAAC,CAAC;MACjC,IAAI,CAACa,mBAAmB,GAAG,IAAI;IACjC;IACA,IACE,IAAI,CAACpC,mBAAmB,KAAKsB,SAAS,IACtC,IAAI,CAACtB,mBAAmB,KAAK,IAAI,EACjC;MACA,IAAI,CAACA,mBAAmB,CAACuB,MAAM,CAAC,CAAC;MACjC,IAAI,CAACvB,mBAAmB,GAAG,IAAI;IACjC;EACF;AACF;AAYA,SAASnC,eAAe;AACxB,OAAO,MAAMyE,MAAM,GAAG3E,eAAe;AACrC,OAAO,MAAM4E,UAAU,GAAG3E,mBAAmB;AAC7C,OAAO,MAAM4E,uBAAuB,GAAG,IAAIjE,gBAAgB,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","CashfreePgApi","version","CFUPIPayment","CFCardPayment","CFNBPayment","CFSubsUPIPayment","CFSubsCardPayment","CFSubsNBPayment","CFCardComponent","CFSubsCardComponent","CFErrorResponse","doPPIWalletPayment","CFPaymentGateway","constructor","_defineProperty","emitter","doPayment","checkoutPayment","JSON","stringify","doUPIPayment","doWebPayment","cfSession","doSubscriptionPayment","doCardPayment","cardPayment","makePayment","getInstalledUpiApps","cfPayment","paymentData","doElementUPIPayment","doElementNBPayment","console","log","makeSubsPayment","doSubsUPIPayment","doSubsCardPayment","doSubsNBPayment","payment","setEventSubscriber","cfEventCallback","eventFunction","event","data","parse","onReceivedEvent","eventName","meta","eventSubscription","addListener","removeEventSubscriber","undefined","remove","setCallback","cfCallback","successFunction","orderID","onVerify","failureFunction","error","response","message","fromJSON","onError","successSubscription","failureSubscription","removeCallback","CFCard","CFSubsCard","CFPaymentGatewayService"],"sources":["index.ts"],"sourcesContent":["import {\n EmitterSubscription,\n NativeEventEmitter,\n} from 'react-native';\nimport CashfreePgApi from './NativeCashfreePgApi';\nimport { version } from '../package.json';\nimport {\n type CheckoutPayment,\n type CFSession,\n type CFSubscriptionSession,\n CFUPIPayment,\n CFCardPayment,\n CFNBPayment,\n CFSubsUPIPayment,\n CFSubsCardPayment,\n CFSubsNBPayment,\n type CFPPIWalletPayment,\n} from 'cashfree-pg-api-contract';\nimport CFCardComponent from './Card/CFCardComponent';\nimport CFSubsCardComponent from './Card/CFSubsCardComponent';\nimport { CFErrorResponse } from './CFErrorResponse';\nimport { doPPIWalletPayment } from './PPIWallet/PPIWalletPayment';\n\nclass CFPaymentGateway {\n private emitter: NativeEventEmitter;\n private successSubscription: EmitterSubscription | null = null;\n private failureSubscription: EmitterSubscription | null = null;\n private eventSubscription: EmitterSubscription | null = null;\n\n constructor() {\n this.emitter = new NativeEventEmitter(CashfreePgApi as any);\n }\n\n doPayment(checkoutPayment: CheckoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doPayment(JSON.stringify(checkoutPayment));\n }\n\n doUPIPayment(checkoutPayment: CheckoutPayment) {\n checkoutPayment.version = version;\n CashfreePgApi.doUPIPayment(JSON.stringify(checkoutPayment));\n }\n\n doWebPayment(cfSession: CFSession) {\n CashfreePgApi.doWebPayment(JSON.stringify(cfSession));\n }\n\n doSubscriptionPayment(cfSession: CFSubscriptionSession) {\n CashfreePgApi.doSubscriptionPayment(JSON.stringify(cfSession));\n }\n\n /**\n * @deprecated : Instead call makePayment\n */\n doCardPayment(cardPayment: CheckoutPayment) {\n this.makePayment(cardPayment);\n }\n\n async getInstalledUpiApps(): Promise<string> {\n return CashfreePgApi.getInstalledUpiApps();\n }\n\n makePayment(cfPayment: CheckoutPayment) {\n cfPayment.version = version;\n const paymentData = JSON.stringify(cfPayment);\n if (cfPayment instanceof CFUPIPayment) {\n CashfreePgApi.doElementUPIPayment(paymentData);\n } else if (cfPayment instanceof CFCardPayment) {\n CashfreePgApi.doCardPayment(paymentData);\n } else if (cfPayment instanceof CFNBPayment) {\n CashfreePgApi.doElementNBPayment(paymentData);\n } else {\n console.log('makePayment::==> Wrong payment object');\n }\n }\n\n makeSubsPayment(cfPayment: CheckoutPayment){\n cfPayment.version = version;\n const paymentData = JSON.stringify(cfPayment);\n if (cfPayment instanceof CFSubsUPIPayment) {\n CashfreePgApi.doSubsUPIPayment(paymentData);\n } else if (cfPayment instanceof CFSubsCardPayment) {\n CashfreePgApi.doSubsCardPayment(paymentData);\n } else if (cfPayment instanceof CFSubsNBPayment) {\n CashfreePgApi.doSubsNBPayment(paymentData);\n } else {\n console.log('makePayment::==> Wrong payment object');\n }\n }\n\n /**\n * Creates a PPI wallet order session via Cashfree's API.\n * Resolves with the API response as-is; rejects with CFErrorResponse.\n */\n doPPIWalletPayment(payment: CFPPIWalletPayment): Promise<unknown> {\n return doPPIWalletPayment(payment);\n }\n\n setEventSubscriber(cfEventCallback: CFEventCallback) {\n let eventFunction = (event: string) => {\n console.log(JSON.stringify(event));\n let data = JSON.parse(event);\n cfEventCallback.onReceivedEvent(data.eventName, data.meta);\n };\n this.eventSubscription = this.emitter.addListener('cfEvent', eventFunction);\n CashfreePgApi.setEventSubscriber();\n }\n\n removeEventSubscriber() {\n if (\n this.eventSubscription !== undefined &&\n this.eventSubscription !== null\n ) {\n this.eventSubscription.remove();\n this.eventSubscription = null;\n }\n CashfreePgApi.removeEventSubscriber();\n }\n\n setCallback(cfCallback: CFCallback) {\n // this.cfCallback = cfCallback;\n let successFunction = (orderID: string) => {\n console.log('response is : ' + JSON.stringify(orderID));\n cfCallback.onVerify(orderID);\n };\n let failureFunction = (error: string) => {\n console.log('reason: ' + JSON.stringify(error));\n const response = new CFErrorResponse();\n // @ts-ignore\n const message = JSON.parse(error);\n response.fromJSON(message.error);\n // @ts-ignore\n cfCallback.onError(response, message.orderID);\n };\n this.successSubscription = this.emitter.addListener(\n 'cfSuccess',\n successFunction\n );\n this.failureSubscription = this.emitter.addListener(\n 'cfFailure',\n failureFunction\n );\n CashfreePgApi.setCallback();\n }\n\n removeCallback() {\n if (\n this.successSubscription !== undefined &&\n this.successSubscription !== null\n ) {\n this.successSubscription.remove();\n this.successSubscription = null;\n }\n if (\n this.failureSubscription !== undefined &&\n this.failureSubscription !== null\n ) {\n this.failureSubscription.remove();\n this.failureSubscription = null;\n }\n }\n}\n\nexport interface CFCallback {\n onVerify(orderID: string): void;\n\n onError(error: CFErrorResponse, orderID: string): void;\n}\n\nexport interface CFEventCallback {\n onReceivedEvent(eventName: string, map: Map<string, string>): void;\n}\n\nexport { CFErrorResponse };\nexport const CFCard = CFCardComponent;\nexport const CFSubsCard = CFSubsCardComponent;\nexport const CFPaymentGatewayService = new CFPaymentGateway();\n"],"mappings":";;;AAAA,SAEEA,kBAAkB,QACb,cAAc;AACrB,OAAOC,aAAa,MAAM,uBAAuB;AACjD,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAIEC,YAAY,EACZC,aAAa,EACbC,WAAW,EACXC,gBAAgB,EAChBC,iBAAiB,EACjBC,eAAe,QAEV,0BAA0B;AACjC,OAAOC,eAAe,MAAM,wBAAwB;AACpD,OAAOC,mBAAmB,MAAM,4BAA4B;AAC5D,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,kBAAkB,QAAQ,8BAA8B;AAEjE,MAAMC,gBAAgB,CAAC;EAMrBC,WAAWA,CAAA,EAAG;IAAAC,eAAA;IAAAA,eAAA,8BAJ4C,IAAI;IAAAA,eAAA,8BACJ,IAAI;IAAAA,eAAA,4BACN,IAAI;IAG1D,IAAI,CAACC,OAAO,GAAG,IAAIhB,kBAAkB,CAACC,aAAoB,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IACtC,IAAI,CAACc,mBAAmB,KAAK,IAAI,EACjC;MACA,IAAI,CAACA,mBAAmB,CAACb,MAAM,CAAC,CAAC;MACjC,IAAI,CAACa,mBAAmB,GAAG,IAAI;IACjC;EACF;AACF;AAYA,SAASvD,eAAe;AACxB,OAAO,MAAMyD,MAAM,GAAG3D,eAAe;AACrC,OAAO,MAAM4D,UAAU,GAAG3D,mBAAmB;AAC7C,OAAO,MAAM4D,uBAAuB,GAAG,IAAIzD,gBAAgB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
export interface Spec extends TurboModule {
|
|
3
|
+
doPayment(paymentData: string): void;
|
|
4
|
+
doUPIPayment(paymentData: string): void;
|
|
5
|
+
doWebPayment(paymentData: string): void;
|
|
6
|
+
doSubscriptionPayment(paymentData: string): void;
|
|
7
|
+
doCardPayment(paymentData: string): void;
|
|
8
|
+
doElementUPIPayment(paymentData: string): void;
|
|
9
|
+
doElementNBPayment(paymentData: string): void;
|
|
10
|
+
doSubsCardPayment(paymentData: string): void;
|
|
11
|
+
doSubsUPIPayment(paymentData: string): void;
|
|
12
|
+
doSubsNBPayment(paymentData: string): void;
|
|
13
|
+
getInstalledUpiApps(): Promise<string>;
|
|
14
|
+
setCallback(): void;
|
|
15
|
+
setEventSubscriber(): void;
|
|
16
|
+
removeEventSubscriber(): void;
|
|
17
|
+
addListener(eventName: string): void;
|
|
18
|
+
removeListeners(count: number): void;
|
|
19
|
+
}
|
|
20
|
+
declare const _default: Spec;
|
|
21
|
+
export default _default;
|
|
@@ -5,7 +5,6 @@ declare class CFPaymentGateway {
|
|
|
5
5
|
private successSubscription;
|
|
6
6
|
private failureSubscription;
|
|
7
7
|
private eventSubscription;
|
|
8
|
-
private upiAppsSubscription;
|
|
9
8
|
constructor();
|
|
10
9
|
doPayment(checkoutPayment: CheckoutPayment): void;
|
|
11
10
|
doUPIPayment(checkoutPayment: CheckoutPayment): void;
|
|
@@ -15,7 +14,7 @@ declare class CFPaymentGateway {
|
|
|
15
14
|
* @deprecated : Instead call makePayment
|
|
16
15
|
*/
|
|
17
16
|
doCardPayment(cardPayment: CheckoutPayment): void;
|
|
18
|
-
getInstalledUpiApps(): Promise<
|
|
17
|
+
getInstalledUpiApps(): Promise<string>;
|
|
19
18
|
makePayment(cfPayment: CheckoutPayment): void;
|
|
20
19
|
makeSubsPayment(cfPayment: CheckoutPayment): void;
|
|
21
20
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-cashfree-pg-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Cashfree PG Plugin for React Native",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"ios",
|
|
15
15
|
"cpp",
|
|
16
16
|
"react-native-cashfree-pg-sdk.podspec",
|
|
17
|
-
"!lib/typescript/
|
|
17
|
+
"!lib/typescript/sampleApps",
|
|
18
18
|
"!android/build",
|
|
19
19
|
"!android/.gradle",
|
|
20
20
|
"!android/.idea",
|
|
@@ -34,9 +34,13 @@
|
|
|
34
34
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
35
35
|
"prepare": "bob build",
|
|
36
36
|
"release": "release-it",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
37
|
+
"oldarch": "npm --prefix sampleApps/OldArchSample",
|
|
38
|
+
"newarch": "npm --prefix sampleApps/NewArchSample",
|
|
39
|
+
"expo": "npm --prefix sampleApps/ExpoSample",
|
|
40
|
+
"pods:oldarch": "cd sampleApps/OldArchSample && pod-install --quiet",
|
|
41
|
+
"pods:newarch": "cd sampleApps/NewArchSample && pod-install --quiet",
|
|
42
|
+
"pods:expo": "cd sampleApps/ExpoSample && pod-install --quiet",
|
|
43
|
+
"bootstrap": "yarn && npm --prefix sampleApps/OldArchSample install && npm --prefix sampleApps/NewArchSample install && npm --prefix sampleApps/ExpoSample install"
|
|
40
44
|
},
|
|
41
45
|
"keywords": [
|
|
42
46
|
"react-native",
|
|
@@ -58,7 +62,16 @@
|
|
|
58
62
|
},
|
|
59
63
|
"homepage": "https://docs.cashfree.com/docs/react-native-integration",
|
|
60
64
|
"publishConfig": {
|
|
61
|
-
"registry": "https://registry.npmjs.org/"
|
|
65
|
+
"registry": "https://registry.npmjs.org/",
|
|
66
|
+
"tag": "turbo"
|
|
67
|
+
},
|
|
68
|
+
"codegenConfig": {
|
|
69
|
+
"name": "RNCashfreePgApiSpec",
|
|
70
|
+
"type": "modules",
|
|
71
|
+
"jsSrcsDir": "src",
|
|
72
|
+
"android": {
|
|
73
|
+
"javaPackageName": "com.reactnativecashfreepgsdk"
|
|
74
|
+
}
|
|
62
75
|
},
|
|
63
76
|
"devDependencies": {
|
|
64
77
|
"@commitlint/config-conventional": "^11.0.0",
|
|
@@ -66,6 +79,7 @@
|
|
|
66
79
|
"@react-native/babel-preset": "^0.73.18",
|
|
67
80
|
"@release-it/conventional-changelog": "^2.0.0",
|
|
68
81
|
"@types/jest": "^26.0.0",
|
|
82
|
+
"@types/node": "^18.0.0",
|
|
69
83
|
"@types/react": "^18.2.0",
|
|
70
84
|
"@types/react-native": "^0.73.0",
|
|
71
85
|
"commitlint": "^11.0.0",
|
|
@@ -84,12 +98,19 @@
|
|
|
84
98
|
},
|
|
85
99
|
"peerDependencies": {
|
|
86
100
|
"react": "*",
|
|
87
|
-
"react-native": "
|
|
101
|
+
"react-native": ">=0.73.0"
|
|
88
102
|
},
|
|
89
103
|
"jest": {
|
|
90
104
|
"preset": "react-native",
|
|
105
|
+
"testPathIgnorePatterns": [
|
|
106
|
+
"<rootDir>/sampleApps/",
|
|
107
|
+
"<rootDir>/lib/",
|
|
108
|
+
"<rootDir>/node_modules/"
|
|
109
|
+
],
|
|
91
110
|
"modulePathIgnorePatterns": [
|
|
92
|
-
"<rootDir>/
|
|
111
|
+
"<rootDir>/sampleApps/OldArchSample/node_modules",
|
|
112
|
+
"<rootDir>/sampleApps/NewArchSample/node_modules",
|
|
113
|
+
"<rootDir>/sampleApps/ExpoSample/node_modules",
|
|
93
114
|
"<rootDir>/lib/"
|
|
94
115
|
]
|
|
95
116
|
},
|
|
@@ -104,7 +125,8 @@
|
|
|
104
125
|
"tagName": "v${version}"
|
|
105
126
|
},
|
|
106
127
|
"npm": {
|
|
107
|
-
"publish": true
|
|
128
|
+
"publish": true,
|
|
129
|
+
"tag": "turbo"
|
|
108
130
|
},
|
|
109
131
|
"github": {
|
|
110
132
|
"release": true
|
|
@@ -10,11 +10,14 @@ Pod::Spec.new do |s|
|
|
|
10
10
|
s.license = package["license"]
|
|
11
11
|
s.authors = package["author"]
|
|
12
12
|
|
|
13
|
-
s.platforms = { :ios => "
|
|
13
|
+
s.platforms = { :ios => "13.0" }
|
|
14
14
|
s.source = { :git => "https://www.cashfree.com/.git", :tag => "#{s.version}" }
|
|
15
15
|
|
|
16
16
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
17
17
|
|
|
18
|
-
s.
|
|
18
|
+
s.frameworks = "WebKit"
|
|
19
|
+
|
|
19
20
|
s.dependency "CashfreePG", "2.5.2"
|
|
21
|
+
|
|
22
|
+
install_modules_dependencies(s)
|
|
20
23
|
end
|
|
@@ -244,7 +244,8 @@ const CardInput: any = forwardRef<CardPaymentHandle, CardInputProps>(
|
|
|
244
244
|
const cardPayment = new CFCardPayment(sessionRef.current, cardInfo);
|
|
245
245
|
CFPaymentGatewayService.makePayment(cardPayment);
|
|
246
246
|
} catch (e: any) {
|
|
247
|
-
console.
|
|
247
|
+
console.error('[CFCard] payment call failed:', e?.message ?? e);
|
|
248
|
+
throw e;
|
|
248
249
|
}
|
|
249
250
|
};
|
|
250
251
|
|
|
@@ -256,7 +257,8 @@ const CardInput: any = forwardRef<CardPaymentHandle, CardInputProps>(
|
|
|
256
257
|
sessionRef.current = session;
|
|
257
258
|
doPayment(cardInfo);
|
|
258
259
|
} catch (e: any) {
|
|
259
|
-
console.
|
|
260
|
+
console.error('[CFCard] payment call failed:', e?.message ?? e);
|
|
261
|
+
throw e;
|
|
260
262
|
}
|
|
261
263
|
};
|
|
262
264
|
|
|
@@ -215,7 +215,8 @@ const SubsCardInput: any = forwardRef<
|
|
|
215
215
|
const cardPayment = new CFSubsCardPayment(sessionRef.current, cardInfo);
|
|
216
216
|
CFPaymentGatewayService.makeSubsPayment(cardPayment);
|
|
217
217
|
} catch (e: any) {
|
|
218
|
-
console.
|
|
218
|
+
console.error('[CFSubsCard] payment call failed:', e?.message ?? e);
|
|
219
|
+
throw e;
|
|
219
220
|
}
|
|
220
221
|
};
|
|
221
222
|
|
|
@@ -227,7 +228,8 @@ const SubsCardInput: any = forwardRef<
|
|
|
227
228
|
sessionRef.current = session;
|
|
228
229
|
doSubscriptionPayment(cardInfo);
|
|
229
230
|
} catch (e: any) {
|
|
230
|
-
console.
|
|
231
|
+
console.error('[CFSubsCard] payment call failed:', e?.message ?? e);
|
|
232
|
+
throw e;
|
|
231
233
|
}
|
|
232
234
|
};
|
|
233
235
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
doPayment(paymentData: string): void;
|
|
6
|
+
doUPIPayment(paymentData: string): void;
|
|
7
|
+
doWebPayment(paymentData: string): void;
|
|
8
|
+
doSubscriptionPayment(paymentData: string): void;
|
|
9
|
+
doCardPayment(paymentData: string): void;
|
|
10
|
+
doElementUPIPayment(paymentData: string): void;
|
|
11
|
+
doElementNBPayment(paymentData: string): void;
|
|
12
|
+
doSubsCardPayment(paymentData: string): void;
|
|
13
|
+
doSubsUPIPayment(paymentData: string): void;
|
|
14
|
+
doSubsNBPayment(paymentData: string): void;
|
|
15
|
+
getInstalledUpiApps(): Promise<string>;
|
|
16
|
+
setCallback(): void;
|
|
17
|
+
setEventSubscriber(): void;
|
|
18
|
+
removeEventSubscriber(): void;
|
|
19
|
+
addListener(eventName: string): void;
|
|
20
|
+
removeListeners(count: number): void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('CashfreePgApi');
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EmitterSubscription,
|
|
3
|
-
NativeAppEventEmitter,
|
|
4
3
|
NativeEventEmitter,
|
|
5
|
-
NativeModules,
|
|
6
|
-
Platform,
|
|
7
4
|
} from 'react-native';
|
|
5
|
+
import CashfreePgApi from './NativeCashfreePgApi';
|
|
8
6
|
import { version } from '../package.json';
|
|
9
7
|
import {
|
|
10
8
|
type CheckoutPayment,
|
|
@@ -23,35 +21,14 @@ import CFSubsCardComponent from './Card/CFSubsCardComponent';
|
|
|
23
21
|
import { CFErrorResponse } from './CFErrorResponse';
|
|
24
22
|
import { doPPIWalletPayment } from './PPIWallet/PPIWalletPayment';
|
|
25
23
|
|
|
26
|
-
const LINKING_ERROR =
|
|
27
|
-
`The package 'react-native-cashfree-pg-api' doesn't seem to be linked. Make sure: \n\n` +
|
|
28
|
-
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
29
|
-
'- You rebuilt the app after installing the package\n' +
|
|
30
|
-
'- You are not using Expo managed workflow\n';
|
|
31
|
-
|
|
32
|
-
const CashfreePgApi = NativeModules.CashfreePgApi
|
|
33
|
-
? NativeModules.CashfreePgApi
|
|
34
|
-
: new Proxy(
|
|
35
|
-
{},
|
|
36
|
-
{
|
|
37
|
-
get() {
|
|
38
|
-
throw new Error(LINKING_ERROR);
|
|
39
|
-
},
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
|
|
43
24
|
class CFPaymentGateway {
|
|
44
|
-
private emitter: NativeEventEmitter
|
|
25
|
+
private emitter: NativeEventEmitter;
|
|
45
26
|
private successSubscription: EmitterSubscription | null = null;
|
|
46
27
|
private failureSubscription: EmitterSubscription | null = null;
|
|
47
28
|
private eventSubscription: EmitterSubscription | null = null;
|
|
48
|
-
private upiAppsSubscription: EmitterSubscription | null = null;
|
|
49
29
|
|
|
50
30
|
constructor() {
|
|
51
|
-
this.emitter =
|
|
52
|
-
Platform.OS === 'ios'
|
|
53
|
-
? new NativeEventEmitter(NativeModules.CashfreeEventEmitter)
|
|
54
|
-
: NativeAppEventEmitter;
|
|
31
|
+
this.emitter = new NativeEventEmitter(CashfreePgApi as any);
|
|
55
32
|
}
|
|
56
33
|
|
|
57
34
|
doPayment(checkoutPayment: CheckoutPayment) {
|
|
@@ -79,32 +56,8 @@ class CFPaymentGateway {
|
|
|
79
56
|
this.makePayment(cardPayment);
|
|
80
57
|
}
|
|
81
58
|
|
|
82
|
-
async getInstalledUpiApps() {
|
|
83
|
-
return
|
|
84
|
-
if (Platform.OS === 'ios') {
|
|
85
|
-
let fetchUpiList = (apps: string) => {
|
|
86
|
-
console.log(JSON.stringify(apps));
|
|
87
|
-
if (apps) {
|
|
88
|
-
resolve(apps);
|
|
89
|
-
} else {
|
|
90
|
-
reject('No UPI apps found');
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
this.upiAppsSubscription = this.emitter.addListener(
|
|
94
|
-
'cfUpiApps',
|
|
95
|
-
fetchUpiList
|
|
96
|
-
);
|
|
97
|
-
CashfreePgApi.getInstalledUpiApps();
|
|
98
|
-
} else {
|
|
99
|
-
CashfreePgApi.getInstalledUpiApps((apps: string) => {
|
|
100
|
-
if (apps) {
|
|
101
|
-
resolve(apps);
|
|
102
|
-
} else {
|
|
103
|
-
reject('No UPI apps found');
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
});
|
|
59
|
+
async getInstalledUpiApps(): Promise<string> {
|
|
60
|
+
return CashfreePgApi.getInstalledUpiApps();
|
|
108
61
|
}
|
|
109
62
|
|
|
110
63
|
makePayment(cfPayment: CheckoutPayment) {
|
|
@@ -205,13 +158,6 @@ class CFPaymentGateway {
|
|
|
205
158
|
this.failureSubscription.remove();
|
|
206
159
|
this.failureSubscription = null;
|
|
207
160
|
}
|
|
208
|
-
if (
|
|
209
|
-
this.upiAppsSubscription !== undefined &&
|
|
210
|
-
this.upiAppsSubscription !== null
|
|
211
|
-
) {
|
|
212
|
-
this.upiAppsSubscription.remove();
|
|
213
|
-
this.upiAppsSubscription = null;
|
|
214
|
-
}
|
|
215
161
|
}
|
|
216
162
|
}
|
|
217
163
|
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// CashfreeEventEmitter.m
|
|
3
|
-
// DoubleConversion
|
|
4
|
-
//
|
|
5
|
-
// Created by Aabhas Jindal on 13/06/22.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
#import <Foundation/Foundation.h>
|
|
9
|
-
#import <React/RCTBridgeModule.h>
|
|
10
|
-
#import <React/RCTEventEmitter.h>
|
|
11
|
-
|
|
12
|
-
@interface RCT_EXTERN_MODULE(CashfreeEventEmitter, RCTEventEmitter)
|
|
13
|
-
|
|
14
|
-
RCT_EXTERN_METHOD(supportedEvents)
|
|
15
|
-
|
|
16
|
-
@end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// CashfreeEventEmitter.swift
|
|
3
|
-
// DoubleConversion
|
|
4
|
-
//
|
|
5
|
-
// Created by Aabhas Jindal on 13/06/22.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
import Foundation
|
|
9
|
-
|
|
10
|
-
@objc(CashfreeEventEmitter)
|
|
11
|
-
open class CashfreeEventEmitter: RCTEventEmitter {
|
|
12
|
-
|
|
13
|
-
override init() {
|
|
14
|
-
super.init()
|
|
15
|
-
CashfreeEmitter.sharedInstance.registerEventEmitter(eventEmitter: self)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/// Base overide for RCTEventEmitter.
|
|
19
|
-
///
|
|
20
|
-
/// - Returns: all supported events
|
|
21
|
-
@objc open override func supportedEvents() -> [String] {
|
|
22
|
-
return CashfreeEmitter.sharedInstance.allEvents
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@objc public override static func requiresMainQueueSetup() -> Bool {
|
|
26
|
-
return false
|
|
27
|
-
}
|
|
28
|
-
}
|
package/ios/CashfreePgApi.m
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#import <React/RCTBridgeModule.h>
|
|
2
|
-
#import <React/RCTUtils.h>
|
|
3
|
-
|
|
4
|
-
@interface RCT_EXTERN_MODULE(CashfreePgApi, NSObject)
|
|
5
|
-
|
|
6
|
-
RCT_EXTERN_METHOD(doPayment:(NSString)paymentObject)
|
|
7
|
-
|
|
8
|
-
RCT_EXTERN_METHOD(doUPIPayment:(NSString)paymentObject)
|
|
9
|
-
|
|
10
|
-
RCT_EXTERN_METHOD(doWebPayment:(NSString)paymentObject)
|
|
11
|
-
RCT_EXTERN_METHOD(doSubscriptionPayment:(NSString)paymentObject)
|
|
12
|
-
RCT_EXTERN_METHOD(doCardPayment:(NSString)paymentObject)
|
|
13
|
-
RCT_EXTERN_METHOD(doElementNBPayment:(NSString)paymentObject)
|
|
14
|
-
RCT_EXTERN_METHOD(doElementUPIPayment:(NSString)paymentObject)
|
|
15
|
-
RCT_EXTERN_METHOD(doSubsCardPayment:(NSString)paymentObject)
|
|
16
|
-
RCT_EXTERN_METHOD(doSubsUPIPayment:(NSString)paymentObject)
|
|
17
|
-
RCT_EXTERN_METHOD(doSubsNBPayment:(NSString)paymentObject)
|
|
18
|
-
RCT_EXTERN_METHOD(getInstalledUpiApps)
|
|
19
|
-
|
|
20
|
-
RCT_EXTERN_METHOD(setCallback)
|
|
21
|
-
|
|
22
|
-
RCT_EXTERN_METHOD(setEventSubscriber)
|
|
23
|
-
|
|
24
|
-
RCT_EXTERN_METHOD(removeEventSubscriber)
|
|
25
|
-
|
|
26
|
-
@end
|
package/src/CFErrorResponse.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export class CFErrorResponse {
|
|
2
|
-
status = 'FAILED';
|
|
3
|
-
message = 'payment has failed';
|
|
4
|
-
code = 'payment_failed';
|
|
5
|
-
type = 'request_failed';
|
|
6
|
-
constructor(fields) {
|
|
7
|
-
if (fields?.message !== undefined)
|
|
8
|
-
this.message = fields.message;
|
|
9
|
-
if (fields?.code !== undefined)
|
|
10
|
-
this.code = fields.code;
|
|
11
|
-
if (fields?.type !== undefined)
|
|
12
|
-
this.type = fields.type;
|
|
13
|
-
}
|
|
14
|
-
fromJSON(errorString) {
|
|
15
|
-
console.log('errorString :' + errorString);
|
|
16
|
-
const object = JSON.parse(errorString);
|
|
17
|
-
console.log('errorStringObject :' + object);
|
|
18
|
-
this.status = object.status;
|
|
19
|
-
this.message = object.message;
|
|
20
|
-
this.code = object.code;
|
|
21
|
-
this.type = object.type;
|
|
22
|
-
}
|
|
23
|
-
getStatus() {
|
|
24
|
-
return this.status;
|
|
25
|
-
}
|
|
26
|
-
getMessage() {
|
|
27
|
-
return this.message;
|
|
28
|
-
}
|
|
29
|
-
getCode() {
|
|
30
|
-
return this.code;
|
|
31
|
-
}
|
|
32
|
-
getType() {
|
|
33
|
-
return this.type;
|
|
34
|
-
}
|
|
35
|
-
}
|