@undernouzen/ay-payments-sdk 2.0.0 → 2.1.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 +44 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,6 +22,7 @@ import { createAYPaymentsClient } from "@undernouzen/ay-payments-sdk";
|
|
|
22
22
|
const ay = createAYPaymentsClient({
|
|
23
23
|
baseUrl: "https://aypayments.undernouzen.com.br",
|
|
24
24
|
apiKey: process.env.AYP_API_KEY,
|
|
25
|
+
language: "pt-BR",
|
|
25
26
|
});
|
|
26
27
|
```
|
|
27
28
|
|
|
@@ -68,6 +69,49 @@ const ay = createAYPaymentsClient({
|
|
|
68
69
|
|
|
69
70
|
The client can be created without an API key. Protected routes will then depend on session cookies or return an API auth error.
|
|
70
71
|
|
|
72
|
+
## Language
|
|
73
|
+
|
|
74
|
+
You can set the default API error language when creating the client:
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
const ay = createAYPaymentsClient({
|
|
78
|
+
apiKey: "ayp_secret",
|
|
79
|
+
language: "pt-BR",
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
This automatically sends both `x-ay-language` and `Accept-Language`.
|
|
84
|
+
|
|
85
|
+
For a single call, derive a temporary client:
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
const productsPt = await ay.idioma("pt-BR").products.list();
|
|
89
|
+
const productsEn = await ay.language("en-US").products.list();
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
For methods that accept request options, you can also send headers directly:
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
const checkout = await ay.checkouts.create(payload, {
|
|
96
|
+
idempotencyKey: "guild-832320430277918720-order-001",
|
|
97
|
+
headers: {
|
|
98
|
+
"x-ay-language": "pt-BR",
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
For any endpoint, `raw` also accepts request headers:
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
const result = await ay.raw({
|
|
107
|
+
method: "GET",
|
|
108
|
+
url: "/projects",
|
|
109
|
+
headers: {
|
|
110
|
+
"x-ay-language": "en-US",
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
71
115
|
## Error handling
|
|
72
116
|
|
|
73
117
|
Mapped SDK methods return `ApiResult<T>`, which is either the expected response or an `ErrorResponse`.
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAGvE,cAAc,YAAY,CAAC;AAG3B,eAAO,MAAM,WAAW,QAAiC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
* @ay-payments/sdk
|
|
3
3
|
* Official TypeScript/JavaScript SDK for AY Payments
|
|
4
4
|
*/
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
const packageJson = require("../package.json");
|
|
5
8
|
// Export client and factory
|
|
6
9
|
export { AYPaymentsClient, createAYPaymentsClient } from './client.js';
|
|
7
10
|
// Export all types
|
|
8
11
|
export * from './types.js';
|
|
9
12
|
// Version
|
|
10
|
-
export const SDK_VERSION = "
|
|
13
|
+
export const SDK_VERSION = packageJson.version || "0.0.0";
|
|
11
14
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,4BAA4B;AAC5B,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEvE,mBAAmB;AACnB,cAAc,YAAY,CAAC;AAE3B,UAAU;AACV,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAyB,CAAC;AAEvE,4BAA4B;AAC5B,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEvE,mBAAmB;AACnB,cAAc,YAAY,CAAC;AAE3B,UAAU;AACV,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC,OAAO,IAAI,OAAO,CAAC"}
|