@delopay/sdk 0.61.0 → 0.62.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 +38 -29
- package/dist/{chunk-ADPSXHH7.js → chunk-2OWZIFZO.js} +18 -1
- package/dist/chunk-2OWZIFZO.js.map +1 -0
- package/dist/index.cjs +17 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -6
- package/dist/index.d.ts +40 -6
- package/dist/index.js +1 -1
- package/dist/internal.cjs +17 -0
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-ADPSXHH7.js.map +0 -1
package/README.md
CHANGED
|
@@ -50,52 +50,61 @@ const delopay = new Delopay(apiKey, {
|
|
|
50
50
|
|
|
51
51
|
## Usage Examples
|
|
52
52
|
|
|
53
|
-
### Create
|
|
53
|
+
### Create a payment
|
|
54
|
+
|
|
55
|
+
> **Never send raw card numbers through the SDK.** Delopay's API is not a
|
|
56
|
+
> raw-PAN endpoint: cards are collected on the Delopay **hosted checkout**
|
|
57
|
+
> (or via a payment link), so card data never touches your server and stays
|
|
58
|
+
> out of your PCI scope. Server-side you create the payment and hand the buyer
|
|
59
|
+
> off; you confirm server-side only with a saved `payment_token`, a
|
|
60
|
+
> `mandate_id`, or a redirect method (e.g. a PayPal wallet) — never card data.
|
|
54
61
|
|
|
55
62
|
```typescript
|
|
56
|
-
//
|
|
63
|
+
// Recommended: hosted checkout via a payment link.
|
|
57
64
|
const payment = await delopay.payments.create({
|
|
58
65
|
amount: 2500,
|
|
59
66
|
currency: 'EUR',
|
|
60
|
-
|
|
61
|
-
capture_method: 'automatic',
|
|
62
|
-
payment_method: 'card',
|
|
63
|
-
payment_method_data: {
|
|
64
|
-
card: {
|
|
65
|
-
card_number: '4242424242424242',
|
|
66
|
-
card_exp_month: '12',
|
|
67
|
-
card_exp_year: '2030',
|
|
68
|
-
card_cvc: '123',
|
|
69
|
-
},
|
|
70
|
-
},
|
|
67
|
+
payment_link: true,
|
|
71
68
|
customer_id: 'cus_abc123',
|
|
72
|
-
description: '
|
|
69
|
+
description: 'Order #1234',
|
|
73
70
|
return_url: 'https://example.com/checkout/complete',
|
|
74
71
|
});
|
|
75
72
|
|
|
76
|
-
//
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
// Send the buyer here — they pick a method and enter card details on the
|
|
74
|
+
// hosted page. Delopay handles 3-D Secure and redirects.
|
|
75
|
+
console.log(payment.payment_link?.link);
|
|
76
|
+
|
|
77
|
+
// Fulfil on the payment_succeeded webhook, or re-check server-side:
|
|
78
|
+
const final = await delopay.payments.retrieve(payment.payment_id);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Confirm server-side **without card data** — with a saved token (off-session):
|
|
82
82
|
|
|
83
|
+
```typescript
|
|
83
84
|
const confirmed = await delopay.payments.confirm(pending.payment_id, {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
card: {
|
|
87
|
-
card_number: '4242424242424242',
|
|
88
|
-
card_exp_month: '12',
|
|
89
|
-
card_exp_year: '2030',
|
|
90
|
-
card_cvc: '123',
|
|
91
|
-
},
|
|
92
|
-
},
|
|
85
|
+
payment_token: savedPaymentToken, // from paymentMethods.listForCustomer()
|
|
86
|
+
off_session: true,
|
|
93
87
|
return_url: 'https://example.com/checkout/complete',
|
|
94
88
|
});
|
|
95
89
|
|
|
96
90
|
console.log(confirmed.status); // 'succeeded' | 'requires_customer_action' | …
|
|
97
91
|
```
|
|
98
92
|
|
|
93
|
+
Or with a redirect payment method that involves no card data at all:
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
const paypal = await delopay.payments.create({
|
|
97
|
+
amount: 2500,
|
|
98
|
+
currency: 'EUR',
|
|
99
|
+
confirm: true,
|
|
100
|
+
payment_method: 'wallet',
|
|
101
|
+
payment_method_type: 'paypal',
|
|
102
|
+
payment_method_data: { wallet: { paypal_redirect: {} } },
|
|
103
|
+
return_url: 'https://example.com/checkout/complete',
|
|
104
|
+
});
|
|
105
|
+
// paypal.next_action?.redirect_to_url → send the buyer there to approve
|
|
106
|
+
```
|
|
107
|
+
|
|
99
108
|
### Create a refund
|
|
100
109
|
|
|
101
110
|
```typescript
|
|
@@ -2340,6 +2340,23 @@ var Users = class {
|
|
|
2340
2340
|
async addUser(params) {
|
|
2341
2341
|
return this.request("POST", "/user/employees/add", { body: params });
|
|
2342
2342
|
}
|
|
2343
|
+
/**
|
|
2344
|
+
* Impersonate one of your own team members — `POST /user/employees/impersonate`.
|
|
2345
|
+
*
|
|
2346
|
+
* Mints a session token **as** the given member, so the dashboard renders
|
|
2347
|
+
* exactly what they see (useful for support and role verification). The
|
|
2348
|
+
* caller needs the *Impersonation* permission, and the member's role must
|
|
2349
|
+
* rank **strictly below** the caller's (`Profile < Merchant < Organization`);
|
|
2350
|
+
* the server rejects self-impersonation, cross-merchant targets, and
|
|
2351
|
+
* equal/higher roles.
|
|
2352
|
+
*
|
|
2353
|
+
* The returned token is tab-scoped by design: open it in a fresh tab (e.g.
|
|
2354
|
+
* `/auth/impersonate?token=…`) rather than replacing the caller's own
|
|
2355
|
+
* session. No auth cookie is set on the response.
|
|
2356
|
+
*/
|
|
2357
|
+
async impersonateEmployee(params) {
|
|
2358
|
+
return this.request("POST", "/user/employees/impersonate", { body: params });
|
|
2359
|
+
}
|
|
2343
2360
|
async acceptInvitation(params) {
|
|
2344
2361
|
return this.request("POST", "/user/employees/invite/accept", { body: params });
|
|
2345
2362
|
}
|
|
@@ -4236,4 +4253,4 @@ export {
|
|
|
4236
4253
|
applyBrandingVariables,
|
|
4237
4254
|
shadowFor
|
|
4238
4255
|
};
|
|
4239
|
-
//# sourceMappingURL=chunk-
|
|
4256
|
+
//# sourceMappingURL=chunk-2OWZIFZO.js.map
|