@mayarin/react 0.1.0-next.0 → 0.1.0-next.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.
Files changed (2) hide show
  1. package/README.md +34 -2
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -22,6 +22,38 @@ import { PayButton } from "@mayarin/react";
22
22
  </PayButton>;
23
23
  ```
24
24
 
25
+ The backend behind `/api/pay` — e.g. a Next.js route handler:
26
+
27
+ ```ts
28
+ import { createMayarin } from "@mayarin/sdk";
29
+
30
+ const secretKey = process.env.MAYARIN_SECRET_KEY;
31
+ if (secretKey === undefined) throw new Error("MAYARIN_SECRET_KEY is required");
32
+
33
+ const mayarin = createMayarin({
34
+ baseUrl: "https://api-testnet.mayarin.xyz",
35
+ secretKey,
36
+ });
37
+
38
+ export async function POST(): Promise<Response> {
39
+ const { url } = await mayarin.commerce.carts.checkout({
40
+ currency: "SGD",
41
+ lines: [
42
+ {
43
+ name: "Order #123",
44
+ unitPrice: { amount: "25.00", asset: "SGD" },
45
+ quantity: 1,
46
+ },
47
+ ],
48
+ merchantReference: "order_123",
49
+ metadata: { checkoutSuccessBaseUrl: "https://shop.example/thanks" },
50
+ });
51
+ return Response.json({ url });
52
+ }
53
+ ```
54
+
55
+ `checkout` may resolve to the URL string or to any object with a `url` field.
56
+
25
57
  ## Browser mode — donations, tips, pay-what-you-want
26
58
 
27
59
  No backend: the browser mints the checkout with a publishable key (`pk_...`). The amount is whatever
@@ -31,8 +63,8 @@ the browser sends, so for a sale check the paid amount against your order in the
31
63
  <PayButton
32
64
  publishableKey="pk_..."
33
65
  baseUrl="https://api-testnet.mayarin.xyz"
34
- amount="150000.00"
35
- currency="IDR"
66
+ amount="10.00"
67
+ currency="SGD"
36
68
  merchantReference="donation_42"
37
69
  successUrl="https://shop.example/thanks"
38
70
  />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mayarin/react",
3
- "version": "0.1.0-next.0",
3
+ "version": "0.1.0-next.1",
4
4
  "description": "React pay button and checkout hook for Mayarin.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://docs.mayarin.xyz",
@@ -24,7 +24,7 @@
24
24
  "dist"
25
25
  ],
26
26
  "dependencies": {
27
- "@mayarin/sdk": "^0.1.0-next.0"
27
+ "@mayarin/sdk": "^0.1.0-next.1"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "react": ">=18"