@edutecka-mz/edpay-sdk 1.0.0 → 1.0.2
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 +12 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,16 +15,6 @@ Install the package from npm:
|
|
|
15
15
|
npm install @edutecka-mz/edpay-sdk
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
To build and test a local checkout:
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
git clone https://github.com/edutecka/edpay-javascript-sdk.git
|
|
22
|
-
cd edpay-javascript-sdk
|
|
23
|
-
npm install
|
|
24
|
-
npm run build
|
|
25
|
-
npm test
|
|
26
|
-
```
|
|
27
|
-
|
|
28
18
|
The package import name is `@edutecka-mz/edpay-sdk`.
|
|
29
19
|
|
|
30
20
|
## Create a payment from a Node.js service
|
|
@@ -60,14 +50,25 @@ console.log(payment);
|
|
|
60
50
|
|
|
61
51
|
By default, the client uses `https://api-pay.edutecka.com`; set `baseUrl` only when EDPay provides a different API host for your account. Sandbox or production access is determined by the API keys. The client sends `X-EDPay-Public-Key` and `X-EDPay-Private-Key` headers. `idempotencyKey` is sent as the `Idempotency-Key` header. Payment amounts are expressed in minor currency units. The `method` is dynamic and should be an identifier returned by `GET /v1/public/payment-methods` or otherwise supported for the account; do not hard-code a particular gateway into a multi-gateway flow.
|
|
62
52
|
|
|
63
|
-
Browser checkout
|
|
53
|
+
### Browser checkout (frontend only)
|
|
54
|
+
|
|
55
|
+
`EDPay` is the browser checkout helper. It is separate from the server-side `EDPayClient` instance named `edpay` above. Use a public key only; never bundle a private key into browser code. Pass the checkout token created by your server:
|
|
64
56
|
|
|
65
57
|
```typescript
|
|
66
58
|
import { EDPay } from "@edutecka-mz/edpay-sdk/frontend";
|
|
59
|
+
|
|
60
|
+
const checkoutClient = new EDPay({
|
|
61
|
+
publicKey: process.env.NEXT_PUBLIC_EDPAY_PUBLIC_KEY!,
|
|
62
|
+
environment: "sandbox",
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
checkoutClient.checkout({ token: checkoutToken, mode: "redirect" });
|
|
67
66
|
```
|
|
68
67
|
|
|
69
68
|
To retrieve a payment:
|
|
70
69
|
|
|
70
|
+
Use the server-side `edpay` (`EDPayClient`) instance created in the first example:
|
|
71
|
+
|
|
71
72
|
```typescript
|
|
72
73
|
const payment = await edpay.payments.retrieve("PAYMENT_ID");
|
|
73
74
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edutecka-mz/edpay-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Official EDPay SDK for Node.js and TypeScript with multi-gateway payments, hosted checkout, and webhook verification.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|