paperless-client 1.0.2 → 1.0.4
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 +4 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,14 +25,14 @@ import PaperlessClient, { formatDescription } from 'paperless-client'
|
|
|
25
25
|
const client = new PaperlessClient(
|
|
26
26
|
'YOUR_MUID',
|
|
27
27
|
'YOUR_APP_ACCESS_KEY',
|
|
28
|
-
'YOUR_MERCHANT_REF_ID',
|
|
29
28
|
'https://payment-sandbox.paperlessltd.com' // or production URL
|
|
30
29
|
)
|
|
31
30
|
|
|
32
31
|
// 2. Generate a Payment URL
|
|
33
32
|
async function initiate() {
|
|
34
|
-
const url = await client.
|
|
33
|
+
const { url, token } = await client.newPayment({
|
|
35
34
|
merchant_order_id: '105',
|
|
35
|
+
merchant_ref_id: 'REF_105',
|
|
36
36
|
customer_name: 'John Doe',
|
|
37
37
|
customer_email: 'john@example.com',
|
|
38
38
|
customer_phone: '01700000000',
|
|
@@ -47,11 +47,12 @@ async function initiate() {
|
|
|
47
47
|
})
|
|
48
48
|
|
|
49
49
|
console.log('Redirect user to ->', url)
|
|
50
|
+
console.log('Save this token for later use ->', token)
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
// 3. Check Payment Status
|
|
53
54
|
async function checkStatus(token: string) {
|
|
54
|
-
const status = await client.
|
|
55
|
+
const status = await client.checkPayment(token)
|
|
55
56
|
console.log('Transaction Status:', status.txn_status)
|
|
56
57
|
}
|
|
57
58
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -8,9 +8,9 @@ export default class PaperlessClient {
|
|
|
8
8
|
/**
|
|
9
9
|
* @param muid It will be provided upon registration
|
|
10
10
|
* @param app_access_key It will be provided upon registration
|
|
11
|
-
* @param
|
|
11
|
+
* @param origin The origin of the server
|
|
12
12
|
*/
|
|
13
|
-
constructor(muid: string, app_access_key: string,
|
|
13
|
+
constructor(muid: string, app_access_key: string, origin: string);
|
|
14
14
|
/**
|
|
15
15
|
* merchant_order_id and merchant_ref_id should be unique for each payment.
|
|
16
16
|
* marchant_order_id is the order id is used by Peperless to identify the order. Max 20 characters.
|
package/dist/index.js
CHANGED
|
@@ -8,16 +8,16 @@ export {} from "./callback_data.js";
|
|
|
8
8
|
export default class PaperlessClient {
|
|
9
9
|
#muid;
|
|
10
10
|
#app_access_key;
|
|
11
|
-
#
|
|
11
|
+
#origin;
|
|
12
12
|
/**
|
|
13
13
|
* @param muid It will be provided upon registration
|
|
14
14
|
* @param app_access_key It will be provided upon registration
|
|
15
|
-
* @param
|
|
15
|
+
* @param origin The origin of the server
|
|
16
16
|
*/
|
|
17
|
-
constructor(muid, app_access_key,
|
|
17
|
+
constructor(muid, app_access_key, origin) {
|
|
18
18
|
this.#muid = muid;
|
|
19
19
|
this.#app_access_key = app_access_key;
|
|
20
|
-
this.#
|
|
20
|
+
this.#origin = origin;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* merchant_order_id and merchant_ref_id should be unique for each payment.
|
|
@@ -25,7 +25,7 @@ export default class PaperlessClient {
|
|
|
25
25
|
* merchant_ref_id is used by the merchant to identify the order in the dashboard.
|
|
26
26
|
*/
|
|
27
27
|
async newPayment(options) {
|
|
28
|
-
const checkServerResponse = await checkServer(this.#
|
|
28
|
+
const checkServerResponse = await checkServer(this.#origin);
|
|
29
29
|
if (!checkServerResponse.success) {
|
|
30
30
|
throw new Error('Server check failed', {
|
|
31
31
|
cause: checkServerResponse.data
|
|
@@ -50,7 +50,7 @@ export default class PaperlessClient {
|
|
|
50
50
|
* @param token The token received from the newPayment method
|
|
51
51
|
*/
|
|
52
52
|
async checkPayment(token) {
|
|
53
|
-
const checkPaymentResponse = await checkPayment(this.#
|
|
53
|
+
const checkPaymentResponse = await checkPayment(this.#origin, this.#muid, token);
|
|
54
54
|
if (!checkPaymentResponse.success) {
|
|
55
55
|
throw new Error('Payment check failed', {
|
|
56
56
|
cause: checkPaymentResponse.data
|