edfapay-softpos-sdk-rn 1.0.5-dev.9 → 1.0.6-beta.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/README.md
CHANGED
|
@@ -309,7 +309,7 @@ Full working example — copy and paste into your `App.tsx`:
|
|
|
309
309
|
|
|
310
310
|
```tsx
|
|
311
311
|
import * as React from 'react';
|
|
312
|
-
import { View, Button } from 'react-native';
|
|
312
|
+
import { View, Button, Image, Text } from 'react-native';
|
|
313
313
|
import {
|
|
314
314
|
EdfaPayPlugin,
|
|
315
315
|
EdfaPayCredentials,
|
|
@@ -317,16 +317,27 @@ import {
|
|
|
317
317
|
TxnParams,
|
|
318
318
|
Transaction,
|
|
319
319
|
TransactionType,
|
|
320
|
+
EPStrings,
|
|
321
|
+
EPStyles
|
|
320
322
|
} from 'edfapay-softpos-sdk-rn';
|
|
321
323
|
|
|
322
|
-
const TERMINAL_TOKEN = '
|
|
323
|
-
const amountToPay = '01.
|
|
324
|
+
const TERMINAL_TOKEN = '47FC92D42FA08EDC1BB663C4709363654942875EE9F18E3BB075EEC70F4A8828';
|
|
325
|
+
const amountToPay = '01.00';
|
|
324
326
|
|
|
325
327
|
export default function App() {
|
|
326
328
|
const [initialized, setInitialized] = React.useState(false);
|
|
327
329
|
|
|
328
330
|
return (
|
|
329
331
|
<View style={{ flex: 1, justifyContent: 'flex-end', padding: 20, gap: 12 }}>
|
|
332
|
+
|
|
333
|
+
<View style={EPStyles.content}>
|
|
334
|
+
<Text style={EPStyles.heading1}>{EPStrings.sdk}</Text>
|
|
335
|
+
<Text style={EPStyles.heading2}>{EPStrings.version}</Text>
|
|
336
|
+
<Text style={[EPStyles.heading3, { textAlign: 'center' }]}>
|
|
337
|
+
{EPStrings.message}
|
|
338
|
+
</Text>
|
|
339
|
+
</View>
|
|
340
|
+
|
|
330
341
|
{!initialized && (
|
|
331
342
|
<Button
|
|
332
343
|
color="#06E59F"
|
|
@@ -351,7 +362,7 @@ function initiateSdk(onInitialized: (status: boolean) => void) {
|
|
|
351
362
|
EdfaPayPlugin.enableLogs(true);
|
|
352
363
|
EdfaPayPlugin.setAnimationSpeedX(2.5);
|
|
353
364
|
|
|
354
|
-
const credentials = EdfaPayCredentials.withToken(Env.
|
|
365
|
+
const credentials = EdfaPayCredentials.withToken(Env.REVAMP, TERMINAL_TOKEN);
|
|
355
366
|
|
|
356
367
|
EdfaPayPlugin.initiate({
|
|
357
368
|
credentials,
|
|
@@ -1,33 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { TransactionType } from "../enums/TransactionType.js";
|
|
4
|
+
|
|
3
5
|
/// Lightweight transaction reference used for reverse/void/capture/refund.
|
|
4
6
|
/// Matches: Transaction.withRRN(...) / Transaction.withTxnNumber(...) in native SDK.
|
|
5
7
|
export class Transaction {
|
|
6
|
-
constructor(rrn, txnNumber, txnDate,
|
|
7
|
-
// ISO date string formatted as YYYY-MM-DD
|
|
8
|
-
type) {
|
|
8
|
+
constructor(rrn, txnNumber, txnDate, type) {
|
|
9
9
|
this.rrn = rrn;
|
|
10
10
|
this.txnNumber = txnNumber;
|
|
11
11
|
this.txnDate = txnDate;
|
|
12
12
|
this.type = type;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
/// Create a transaction reference using RRN (for refund, capture, reversal).
|
|
16
14
|
static withRRN(rrn, txnDate, type) {
|
|
17
15
|
return new Transaction(rrn, undefined, txnDate, type);
|
|
18
16
|
}
|
|
19
|
-
|
|
20
|
-
/// Create a transaction reference using transaction number.
|
|
21
17
|
static withTxnNumber(txnNumber, txnDate, type) {
|
|
22
18
|
return new Transaction(undefined, txnNumber, txnDate, type);
|
|
23
19
|
}
|
|
24
20
|
toJSON() {
|
|
25
21
|
return {
|
|
26
22
|
rrn: this.rrn,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
transaction_number: this.txnNumber,
|
|
24
|
+
created_date: formatDateSafe(this.txnDate),
|
|
25
|
+
operation_type: this.type ?? TransactionType.PURCHASE
|
|
30
26
|
};
|
|
31
27
|
}
|
|
32
28
|
}
|
|
29
|
+
const formatDateSafe = input => {
|
|
30
|
+
if (!input) return formatDate(new Date());
|
|
31
|
+
if (input instanceof Date) {
|
|
32
|
+
return formatDate(input);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// If already yyyy-MM-dd → return as-is
|
|
36
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(input)) {
|
|
37
|
+
return input;
|
|
38
|
+
}
|
|
39
|
+
const parsed = new Date(input);
|
|
40
|
+
if (isNaN(parsed.getTime())) {
|
|
41
|
+
console.warn('Invalid txnDate, fallback to today:', input);
|
|
42
|
+
return formatDate(new Date());
|
|
43
|
+
}
|
|
44
|
+
return formatDate(parsed);
|
|
45
|
+
};
|
|
46
|
+
const formatDate = date => {
|
|
47
|
+
const yyyy = date.getFullYear();
|
|
48
|
+
const mm = String(date.getMonth() + 1).padStart(2, '0');
|
|
49
|
+
const dd = String(date.getDate()).padStart(2, '0');
|
|
50
|
+
return `${yyyy}-${mm}-${dd}`;
|
|
51
|
+
};
|
|
33
52
|
//# sourceMappingURL=Transaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Transaction","constructor","rrn","txnNumber","txnDate","type","withRRN","undefined","withTxnNumber","toJSON"],"sourceRoot":"../../../src","sources":["models/Transaction.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"names":["TransactionType","Transaction","constructor","rrn","txnNumber","txnDate","type","withRRN","undefined","withTxnNumber","toJSON","transaction_number","created_date","formatDateSafe","operation_type","PURCHASE","input","formatDate","Date","test","parsed","isNaN","getTime","console","warn","date","yyyy","getFullYear","mm","String","getMonth","padStart","dd","getDate"],"sourceRoot":"../../../src","sources":["models/Transaction.ts"],"mappings":";;AAAA,SAASA,eAAe,QAAQ,6BAA0B;;AAE1D;AACA;AACA,OAAO,MAAMC,WAAW,CAAC;EACfC,WAAWA,CACDC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,KAAK,CAAC;IAC1D,OAAOC,UAAU,CAAC,IAAIC,IAAI,CAAC,CAAC,CAAC;EAC/B;EAEA,OAAOD,UAAU,CAACG,MAAM,CAAC;AAC3B,CAAC;AAED,MAAMH,UAAU,GAAIQ,IAAU,IAAa;EACzC,MAAMC,IAAI,GAAGD,IAAI,CAACE,WAAW,CAAC,CAAC;EAC/B,MAAMC,EAAE,GAAGC,MAAM,CAACJ,IAAI,CAACK,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EACvD,MAAMC,EAAE,GAAGH,MAAM,CAACJ,IAAI,CAACQ,OAAO,CAAC,CAAC,CAAC,CAACF,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EAElD,OAAO,GAAGL,IAAI,IAAIE,EAAE,IAAII,EAAE,EAAE;AAC9B,CAAC","ignoreList":[]}
|
|
@@ -2,11 +2,11 @@ import { TransactionType } from '../enums/TransactionType';
|
|
|
2
2
|
export declare class Transaction {
|
|
3
3
|
readonly rrn?: string | undefined;
|
|
4
4
|
readonly txnNumber?: string | undefined;
|
|
5
|
-
readonly txnDate?: string | undefined;
|
|
5
|
+
readonly txnDate?: (Date | string) | undefined;
|
|
6
6
|
readonly type?: TransactionType | undefined;
|
|
7
7
|
private constructor();
|
|
8
|
-
static withRRN(rrn: string, txnDate?: string, type?: TransactionType): Transaction;
|
|
9
|
-
static withTxnNumber(txnNumber: string, txnDate?: string, type?: TransactionType): Transaction;
|
|
8
|
+
static withRRN(rrn: string, txnDate?: Date | string, type?: TransactionType): Transaction;
|
|
9
|
+
static withTxnNumber(txnNumber: string, txnDate?: Date | string, type?: TransactionType): Transaction;
|
|
10
10
|
toJSON(): Record<string, any>;
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=Transaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.d.ts","sourceRoot":"","sources":["../../../../src/models/Transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAI3D,qBAAa,WAAW;aAEJ,GAAG,CAAC,EAAE,MAAM;aACZ,SAAS,CAAC,EAAE,MAAM;aAClB,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"Transaction.d.ts","sourceRoot":"","sources":["../../../../src/models/Transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAI3D,qBAAa,WAAW;aAEJ,GAAG,CAAC,EAAE,MAAM;aACZ,SAAS,CAAC,EAAE,MAAM;aAClB,OAAO,CAAC,GAAE,IAAI,GAAG,MAAM;aACvB,IAAI,CAAC,EAAE,eAAe;IAJxC,OAAO;IAOP,MAAM,CAAC,OAAO,CACZ,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,EACvB,IAAI,CAAC,EAAE,eAAe,GACrB,WAAW;IAId,MAAM,CAAC,aAAa,CAClB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,EACvB,IAAI,CAAC,EAAE,eAAe,GACrB,WAAW;IAId,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAQ9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "edfapay-softpos-sdk-rn",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6-beta.1",
|
|
4
4
|
"description": "Edfapay SoftPOS SDK helps developer to easily integrate Edfapay SoftPOS to their mobile application",
|
|
5
5
|
"scope": "edfapay/edfapay-softpos-sdk-rn",
|
|
6
6
|
"main": "./lib/module/index.js",
|