better-auth-mercadopago 0.1.1 → 0.1.3

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 CHANGED
@@ -19,11 +19,11 @@ A robust and type-safe Mercado Pago plugin for [Better Auth](https://better-auth
19
19
  ## Installation
20
20
 
21
21
  ```bash
22
- pnpm add @better-auth/mercadopago
22
+ pnpm add better-auth-mercadopago
23
23
  # or
24
- npm install @better-auth/mercadopago
24
+ npm install better-auth-mercadopago
25
25
  # or
26
- yarn add @better-auth/mercadopago
26
+ yarn add better-auth-mercadopago
27
27
  ```
28
28
 
29
29
  ## Quick Start
@@ -34,7 +34,7 @@ Add the plugin to your Better Auth configuration. You need your Mercado Pago Acc
34
34
 
35
35
  ```typescript
36
36
  import { betterAuth } from "better-auth";
37
- import { mercadoPagoPlugin } from "@better-auth/mercadopago";
37
+ import { mercadoPagoPlugin } from "better-auth-mercadopago";
38
38
 
39
39
  export const auth = betterAuth({
40
40
  // ... other config
@@ -59,7 +59,7 @@ The plugin exposes client-side methods to create payments and subscriptions.
59
59
 
60
60
  ```typescript
61
61
  import { createAuthClient } from "better-auth/client";
62
- import { mercadoPagoClient } from "@better-auth/mercadopago/client";
62
+ import { mercadoPagoClient } from "better-auth-mercadopago/client";
63
63
 
64
64
  const authClient = createAuthClient({
65
65
  plugins: [mercadoPagoClient()]
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "better-auth-mercadopago",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Mercado Pago plugin for Better Auth - Simple payments, subscriptions and split payments",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
5
8
  "main": "./dist/index.js",
6
9
  "module": "./dist/index.mjs",
7
10
  "types": "./dist/index.d.ts",
package/dist/client.d.mts DELETED
@@ -1,4 +0,0 @@
1
- import 'better-auth/client';
2
- export { mercadoPagoClient } from './index.mjs';
3
- import 'better-auth';
4
- import 'zod';
package/dist/client.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import 'better-auth/client';
2
- export { mercadoPagoClient } from './index.js';
3
- import 'better-auth';
4
- import 'zod';
package/dist/client.js DELETED
@@ -1,334 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // client.ts
21
- var client_exports = {};
22
- __export(client_exports, {
23
- mercadoPagoClient: () => mercadoPagoClient
24
- });
25
- module.exports = __toCommonJS(client_exports);
26
- var mercadoPagoClient = () => {
27
- return {
28
- id: "mercado-pago",
29
- $InferServerPlugin: {},
30
- getActions: ($fetch) => ({
31
- /**
32
- * Get or create a Mercado Pago customer for the authenticated user
33
- */
34
- getOrCreateCustomer: async (data, fetchOptions) => {
35
- return await $fetch(
36
- "/mercado-pago/customer",
37
- {
38
- method: "POST",
39
- body: data || {},
40
- ...fetchOptions
41
- }
42
- );
43
- },
44
- /**
45
- * Create a payment and get checkout URL
46
- *
47
- * @example
48
- * ```ts
49
- * const { data } = await authClient.mercadoPago.createPayment({
50
- * items: [{
51
- * title: "Premium Plan",
52
- * quantity: 1,
53
- * unitPrice: 99.90,
54
- * currencyId: "ARS"
55
- * }]
56
- * });
57
- *
58
- * // Redirect user to checkout
59
- * window.location.href = data.checkoutUrl;
60
- * ```
61
- */
62
- createPayment: async (data, fetchOptions) => {
63
- return await $fetch(
64
- "/mercado-pago/payment/create",
65
- {
66
- method: "POST",
67
- body: data,
68
- ...fetchOptions
69
- }
70
- );
71
- },
72
- /**
73
- * Create a marketplace payment with automatic split
74
- *
75
- * You need to have the seller's MP User ID (collector_id) which they get
76
- * after authorizing your app via OAuth.
77
- *
78
- * @example
79
- * ```ts
80
- * const { data } = await authClient.mercadoPago.createPayment({
81
- * items: [{
82
- * title: "Product from Seller",
83
- * quantity: 1,
84
- * unitPrice: 100
85
- * }],
86
- * marketplace: {
87
- * collectorId: "123456789", // Seller's MP User ID
88
- * applicationFeePercentage: 10 // Platform keeps 10%
89
- * }
90
- * });
91
- * ```
92
- */
93
- createMarketplacePayment: async (data, fetchOptions) => {
94
- return await $fetch(
95
- "/mercado-pago/payment/create",
96
- {
97
- method: "POST",
98
- body: data,
99
- ...fetchOptions
100
- }
101
- );
102
- },
103
- /**
104
- * Create a subscription with recurring payments
105
- *
106
- * Supports two modes:
107
- * 1. With preapproval plan (reusable): Pass preapprovalPlanId
108
- * 2. Direct subscription (one-off): Pass reason + autoRecurring
109
- *
110
- * @example With plan
111
- * ```ts
112
- * const { data } = await authClient.mercadoPago.createSubscription({
113
- * preapprovalPlanId: "plan_abc123"
114
- * });
115
- * ```
116
- *
117
- * @example Direct (without plan)
118
- * ```ts
119
- * const { data } = await authClient.mercadoPago.createSubscription({
120
- * reason: "Premium Monthly Plan",
121
- * autoRecurring: {
122
- * frequency: 1,
123
- * frequencyType: "months",
124
- * transactionAmount: 99.90,
125
- * currencyId: "ARS"
126
- * }
127
- * });
128
- * ```
129
- */
130
- createSubscription: async (data, fetchOptions) => {
131
- return await $fetch(
132
- "/mercado-pago/subscription/create",
133
- {
134
- method: "POST",
135
- body: data,
136
- ...fetchOptions
137
- }
138
- );
139
- },
140
- /**
141
- * Cancel a subscription
142
- *
143
- * @example
144
- * ```ts
145
- * await authClient.mercadoPago.cancelSubscription({
146
- * subscriptionId: "sub_123"
147
- * });
148
- * ```
149
- */
150
- cancelSubscription: async (data, fetchOptions) => {
151
- return await $fetch(
152
- "/mercado-pago/subscription/cancel",
153
- {
154
- method: "POST",
155
- body: data,
156
- ...fetchOptions
157
- }
158
- );
159
- },
160
- /**
161
- * Create a reusable preapproval plan (subscription template)
162
- *
163
- * Plans can be reused for multiple subscriptions. Create once,
164
- * use many times with createSubscription({ preapprovalPlanId })
165
- *
166
- * @example
167
- * ```ts
168
- * const { data } = await authClient.mercadoPago.createPreapprovalPlan({
169
- * reason: "Premium Monthly",
170
- * autoRecurring: {
171
- * frequency: 1,
172
- * frequencyType: "months",
173
- * transactionAmount: 99.90,
174
- * freeTrial: {
175
- * frequency: 7,
176
- * frequencyType: "days"
177
- * }
178
- * },
179
- * repetitions: 12 // 12 months, omit for infinite
180
- * });
181
- *
182
- * // Use the plan
183
- * const planId = data.plan.mercadoPagoPlanId;
184
- * ```
185
- */
186
- createPreapprovalPlan: async (data, fetchOptions) => {
187
- return await $fetch(
188
- "/mercado-pago/plan/create",
189
- {
190
- method: "POST",
191
- body: data,
192
- ...fetchOptions
193
- }
194
- );
195
- },
196
- /**
197
- * List all preapproval plans
198
- *
199
- * @example
200
- * ```ts
201
- * const { data } = await authClient.mercadoPago.listPreapprovalPlans();
202
- *
203
- * data.plans.forEach(plan => {
204
- * console.log(plan.reason); // "Premium Monthly"
205
- * console.log(plan.transactionAmount); // 99.90
206
- * });
207
- * ```
208
- */
209
- listPreapprovalPlans: async (fetchOptions) => {
210
- return await $fetch(
211
- "/mercado-pago/plans",
212
- {
213
- method: "GET",
214
- ...fetchOptions
215
- }
216
- );
217
- },
218
- /**
219
- * Get payment by ID
220
- */
221
- getPayment: async (paymentId, fetchOptions) => {
222
- return await $fetch(
223
- `/mercado-pago/payment/${paymentId}`,
224
- {
225
- method: "GET",
226
- ...fetchOptions
227
- }
228
- );
229
- },
230
- /**
231
- * List all payments for the authenticated user
232
- *
233
- * @example
234
- * ```ts
235
- * const { data } = await authClient.mercadoPago.listPayments({
236
- * limit: 20,
237
- * offset: 0
238
- * });
239
- * ```
240
- */
241
- listPayments: async (params, fetchOptions) => {
242
- const query = new URLSearchParams();
243
- if (params?.limit) query.set("limit", params.limit.toString());
244
- if (params?.offset) query.set("offset", params.offset.toString());
245
- return await $fetch(
246
- `/mercado-pago/payments?${query.toString()}`,
247
- {
248
- method: "GET",
249
- ...fetchOptions
250
- }
251
- );
252
- },
253
- /**
254
- * List all subscriptions for the authenticated user
255
- *
256
- * @example
257
- * ```ts
258
- * const { data } = await authClient.mercadoPago.listSubscriptions();
259
- * ```
260
- */
261
- listSubscriptions: async (fetchOptions) => {
262
- return await $fetch(
263
- `/mercado-pago/subscriptions`,
264
- {
265
- method: "GET",
266
- ...fetchOptions
267
- }
268
- );
269
- },
270
- /**
271
- * Get OAuth authorization URL for marketplace sellers
272
- *
273
- * This is Step 1 of OAuth flow. Redirect the seller to this URL so they
274
- * can authorize your app to process payments on their behalf.
275
- *
276
- * @example
277
- * ```ts
278
- * const { data } = await authClient.mercadoPago.getOAuthUrl({
279
- * redirectUri: "https://myapp.com/oauth/callback"
280
- * });
281
- *
282
- * // Redirect seller to authorize
283
- * window.location.href = data.authUrl;
284
- * ```
285
- */
286
- getOAuthUrl: async (params, fetchOptions) => {
287
- const query = new URLSearchParams();
288
- query.set("redirectUri", params.redirectUri);
289
- return await $fetch(
290
- `/mercado-pago/oauth/authorize?${query.toString()}`,
291
- {
292
- method: "GET",
293
- ...fetchOptions
294
- }
295
- );
296
- },
297
- /**
298
- * Exchange OAuth code for access token
299
- *
300
- * This is Step 2 of OAuth flow. After the seller authorizes and MP redirects
301
- * them back with a code, exchange that code for an access token.
302
- *
303
- * @example
304
- * ```ts
305
- * // In your /oauth/callback page:
306
- * const code = new URLSearchParams(window.location.search).get("code");
307
- *
308
- * const { data } = await authClient.mercadoPago.exchangeOAuthCode({
309
- * code,
310
- * redirectUri: "https://myapp.com/oauth/callback"
311
- * });
312
- *
313
- * // Now you have the seller's MP User ID
314
- * console.log(data.oauthToken.mercadoPagoUserId);
315
- * ```
316
- */
317
- exchangeOAuthCode: async (data, fetchOptions) => {
318
- return await $fetch(
319
- "/mercado-pago/oauth/callback",
320
- {
321
- method: "POST",
322
- body: data,
323
- ...fetchOptions
324
- }
325
- );
326
- }
327
- })
328
- };
329
- };
330
- // Annotate the CommonJS export names for ESM import in node:
331
- 0 && (module.exports = {
332
- mercadoPagoClient
333
- });
334
- //# sourceMappingURL=client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../client.ts"],"sourcesContent":["import type {\n\tBetterAuthClientPlugin,\n\tBetterFetchOption,\n} from \"better-auth/client\";\nimport type { mercadoPagoPlugin } from \"./index\";\nimport type {\n\tCreatePaymentParams,\n\tCreatePaymentResponse,\n\tCreatePreapprovalPlanParams,\n\tCreatePreapprovalPlanResponse,\n\tCreateSubscriptionParams,\n\tCreateSubscriptionResponse,\n\tMercadoPagoCustomerRecord,\n\tMercadoPagoPaymentRecord,\n\tMercadoPagoPreapprovalPlanRecord,\n\tMercadoPagoSubscriptionRecord,\n\tOAuthTokenResponse,\n\tOAuthUrlResponse,\n} from \"./types\";\n\nexport const mercadoPagoClient = () => {\n\treturn {\n\t\tid: \"mercado-pago\",\n\t\t$InferServerPlugin: {} as ReturnType<typeof mercadoPagoPlugin>,\n\n\t\tgetActions: ($fetch) => ({\n\t\t\t/**\n\t\t\t * Get or create a Mercado Pago customer for the authenticated user\n\t\t\t */\n\t\t\tgetOrCreateCustomer: async (\n\t\t\t\tdata?: {\n\t\t\t\t\temail?: string;\n\t\t\t\t\tfirstName?: string;\n\t\t\t\t\tlastName?: string;\n\t\t\t\t},\n\t\t\t\tfetchOptions?: BetterFetchOption,\n\t\t\t) => {\n\t\t\t\treturn await $fetch<{ customer: MercadoPagoCustomerRecord }>(\n\t\t\t\t\t\"/mercado-pago/customer\",\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\tbody: data || {},\n\t\t\t\t\t\t...fetchOptions,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Create a payment and get checkout URL\n\t\t\t *\n\t\t\t * @example\n\t\t\t * ```ts\n\t\t\t * const { data } = await authClient.mercadoPago.createPayment({\n\t\t\t * items: [{\n\t\t\t * title: \"Premium Plan\",\n\t\t\t * quantity: 1,\n\t\t\t * unitPrice: 99.90,\n\t\t\t * currencyId: \"ARS\"\n\t\t\t * }]\n\t\t\t * });\n\t\t\t *\n\t\t\t * // Redirect user to checkout\n\t\t\t * window.location.href = data.checkoutUrl;\n\t\t\t * ```\n\t\t\t */\n\t\t\tcreatePayment: async (\n\t\t\t\tdata: CreatePaymentParams,\n\t\t\t\tfetchOptions?: BetterFetchOption,\n\t\t\t) => {\n\t\t\t\treturn await $fetch<CreatePaymentResponse>(\n\t\t\t\t\t\"/mercado-pago/payment/create\",\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\tbody: data,\n\t\t\t\t\t\t...fetchOptions,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Create a marketplace payment with automatic split\n\t\t\t *\n\t\t\t * You need to have the seller's MP User ID (collector_id) which they get\n\t\t\t * after authorizing your app via OAuth.\n\t\t\t *\n\t\t\t * @example\n\t\t\t * ```ts\n\t\t\t * const { data } = await authClient.mercadoPago.createPayment({\n\t\t\t * items: [{\n\t\t\t * title: \"Product from Seller\",\n\t\t\t * quantity: 1,\n\t\t\t * unitPrice: 100\n\t\t\t * }],\n\t\t\t * marketplace: {\n\t\t\t * collectorId: \"123456789\", // Seller's MP User ID\n\t\t\t * applicationFeePercentage: 10 // Platform keeps 10%\n\t\t\t * }\n\t\t\t * });\n\t\t\t * ```\n\t\t\t */\n\t\t\tcreateMarketplacePayment: async (\n\t\t\t\tdata: CreatePaymentParams,\n\t\t\t\tfetchOptions?: BetterFetchOption,\n\t\t\t) => {\n\t\t\t\treturn await $fetch<CreatePaymentResponse>(\n\t\t\t\t\t\"/mercado-pago/payment/create\",\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\tbody: data,\n\t\t\t\t\t\t...fetchOptions,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Create a subscription with recurring payments\n\t\t\t *\n\t\t\t * Supports two modes:\n\t\t\t * 1. With preapproval plan (reusable): Pass preapprovalPlanId\n\t\t\t * 2. Direct subscription (one-off): Pass reason + autoRecurring\n\t\t\t *\n\t\t\t * @example With plan\n\t\t\t * ```ts\n\t\t\t * const { data } = await authClient.mercadoPago.createSubscription({\n\t\t\t * preapprovalPlanId: \"plan_abc123\"\n\t\t\t * });\n\t\t\t * ```\n\t\t\t *\n\t\t\t * @example Direct (without plan)\n\t\t\t * ```ts\n\t\t\t * const { data } = await authClient.mercadoPago.createSubscription({\n\t\t\t * reason: \"Premium Monthly Plan\",\n\t\t\t * autoRecurring: {\n\t\t\t * frequency: 1,\n\t\t\t * frequencyType: \"months\",\n\t\t\t * transactionAmount: 99.90,\n\t\t\t * currencyId: \"ARS\"\n\t\t\t * }\n\t\t\t * });\n\t\t\t * ```\n\t\t\t */\n\t\t\tcreateSubscription: async (\n\t\t\t\tdata: CreateSubscriptionParams,\n\t\t\t\tfetchOptions?: BetterFetchOption,\n\t\t\t) => {\n\t\t\t\treturn await $fetch<CreateSubscriptionResponse>(\n\t\t\t\t\t\"/mercado-pago/subscription/create\",\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\tbody: data,\n\t\t\t\t\t\t...fetchOptions,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Cancel a subscription\n\t\t\t *\n\t\t\t * @example\n\t\t\t * ```ts\n\t\t\t * await authClient.mercadoPago.cancelSubscription({\n\t\t\t * subscriptionId: \"sub_123\"\n\t\t\t * });\n\t\t\t * ```\n\t\t\t */\n\t\t\tcancelSubscription: async (\n\t\t\t\tdata: { subscriptionId: string },\n\t\t\t\tfetchOptions?: BetterFetchOption,\n\t\t\t) => {\n\t\t\t\treturn await $fetch<{ success: boolean }>(\n\t\t\t\t\t\"/mercado-pago/subscription/cancel\",\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\tbody: data,\n\t\t\t\t\t\t...fetchOptions,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Create a reusable preapproval plan (subscription template)\n\t\t\t *\n\t\t\t * Plans can be reused for multiple subscriptions. Create once,\n\t\t\t * use many times with createSubscription({ preapprovalPlanId })\n\t\t\t *\n\t\t\t * @example\n\t\t\t * ```ts\n\t\t\t * const { data } = await authClient.mercadoPago.createPreapprovalPlan({\n\t\t\t * reason: \"Premium Monthly\",\n\t\t\t * autoRecurring: {\n\t\t\t * frequency: 1,\n\t\t\t * frequencyType: \"months\",\n\t\t\t * transactionAmount: 99.90,\n\t\t\t * freeTrial: {\n\t\t\t * frequency: 7,\n\t\t\t * frequencyType: \"days\"\n\t\t\t * }\n\t\t\t * },\n\t\t\t * repetitions: 12 // 12 months, omit for infinite\n\t\t\t * });\n\t\t\t *\n\t\t\t * // Use the plan\n\t\t\t * const planId = data.plan.mercadoPagoPlanId;\n\t\t\t * ```\n\t\t\t */\n\t\t\tcreatePreapprovalPlan: async (\n\t\t\t\tdata: CreatePreapprovalPlanParams,\n\t\t\t\tfetchOptions?: BetterFetchOption,\n\t\t\t) => {\n\t\t\t\treturn await $fetch<CreatePreapprovalPlanResponse>(\n\t\t\t\t\t\"/mercado-pago/plan/create\",\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\tbody: data,\n\t\t\t\t\t\t...fetchOptions,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * List all preapproval plans\n\t\t\t *\n\t\t\t * @example\n\t\t\t * ```ts\n\t\t\t * const { data } = await authClient.mercadoPago.listPreapprovalPlans();\n\t\t\t *\n\t\t\t * data.plans.forEach(plan => {\n\t\t\t * console.log(plan.reason); // \"Premium Monthly\"\n\t\t\t * console.log(plan.transactionAmount); // 99.90\n\t\t\t * });\n\t\t\t * ```\n\t\t\t */\n\t\t\tlistPreapprovalPlans: async (fetchOptions?: BetterFetchOption) => {\n\t\t\t\treturn await $fetch<{ plans: MercadoPagoPreapprovalPlanRecord[] }>(\n\t\t\t\t\t\"/mercado-pago/plans\",\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\t\t...fetchOptions,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Get payment by ID\n\t\t\t */\n\t\t\tgetPayment: async (\n\t\t\t\tpaymentId: string,\n\t\t\t\tfetchOptions?: BetterFetchOption,\n\t\t\t) => {\n\t\t\t\treturn await $fetch<{ payment: MercadoPagoPaymentRecord }>(\n\t\t\t\t\t`/mercado-pago/payment/${paymentId}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\t\t...fetchOptions,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * List all payments for the authenticated user\n\t\t\t *\n\t\t\t * @example\n\t\t\t * ```ts\n\t\t\t * const { data } = await authClient.mercadoPago.listPayments({\n\t\t\t * limit: 20,\n\t\t\t * offset: 0\n\t\t\t * });\n\t\t\t * ```\n\t\t\t */\n\t\t\tlistPayments: async (\n\t\t\t\tparams?: { limit?: number; offset?: number },\n\t\t\t\tfetchOptions?: BetterFetchOption,\n\t\t\t) => {\n\t\t\t\tconst query = new URLSearchParams();\n\t\t\t\tif (params?.limit) query.set(\"limit\", params.limit.toString());\n\t\t\t\tif (params?.offset) query.set(\"offset\", params.offset.toString());\n\n\t\t\t\treturn await $fetch<{ payments: MercadoPagoPaymentRecord[] }>(\n\t\t\t\t\t`/mercado-pago/payments?${query.toString()}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\t\t...fetchOptions,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * List all subscriptions for the authenticated user\n\t\t\t *\n\t\t\t * @example\n\t\t\t * ```ts\n\t\t\t * const { data } = await authClient.mercadoPago.listSubscriptions();\n\t\t\t * ```\n\t\t\t */\n\t\t\tlistSubscriptions: async (fetchOptions?: BetterFetchOption) => {\n\t\t\t\treturn await $fetch<{ subscriptions: MercadoPagoSubscriptionRecord[] }>(\n\t\t\t\t\t`/mercado-pago/subscriptions`,\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\t\t...fetchOptions,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Get OAuth authorization URL for marketplace sellers\n\t\t\t *\n\t\t\t * This is Step 1 of OAuth flow. Redirect the seller to this URL so they\n\t\t\t * can authorize your app to process payments on their behalf.\n\t\t\t *\n\t\t\t * @example\n\t\t\t * ```ts\n\t\t\t * const { data } = await authClient.mercadoPago.getOAuthUrl({\n\t\t\t * redirectUri: \"https://myapp.com/oauth/callback\"\n\t\t\t * });\n\t\t\t *\n\t\t\t * // Redirect seller to authorize\n\t\t\t * window.location.href = data.authUrl;\n\t\t\t * ```\n\t\t\t */\n\t\t\tgetOAuthUrl: async (\n\t\t\t\tparams: { redirectUri: string },\n\t\t\t\tfetchOptions?: BetterFetchOption,\n\t\t\t) => {\n\t\t\t\tconst query = new URLSearchParams();\n\t\t\t\tquery.set(\"redirectUri\", params.redirectUri);\n\n\t\t\t\treturn await $fetch<OAuthUrlResponse>(\n\t\t\t\t\t`/mercado-pago/oauth/authorize?${query.toString()}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\t\t...fetchOptions,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Exchange OAuth code for access token\n\t\t\t *\n\t\t\t * This is Step 2 of OAuth flow. After the seller authorizes and MP redirects\n\t\t\t * them back with a code, exchange that code for an access token.\n\t\t\t *\n\t\t\t * @example\n\t\t\t * ```ts\n\t\t\t * // In your /oauth/callback page:\n\t\t\t * const code = new URLSearchParams(window.location.search).get(\"code\");\n\t\t\t *\n\t\t\t * const { data } = await authClient.mercadoPago.exchangeOAuthCode({\n\t\t\t * code,\n\t\t\t * redirectUri: \"https://myapp.com/oauth/callback\"\n\t\t\t * });\n\t\t\t *\n\t\t\t * // Now you have the seller's MP User ID\n\t\t\t * console.log(data.oauthToken.mercadoPagoUserId);\n\t\t\t * ```\n\t\t\t */\n\t\t\texchangeOAuthCode: async (\n\t\t\t\tdata: { code: string; redirectUri: string },\n\t\t\t\tfetchOptions?: BetterFetchOption,\n\t\t\t) => {\n\t\t\t\treturn await $fetch<OAuthTokenResponse>(\n\t\t\t\t\t\"/mercado-pago/oauth/callback\",\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\tbody: data,\n\t\t\t\t\t\t...fetchOptions,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t},\n\t\t}),\n\t} satisfies BetterAuthClientPlugin;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBO,IAAM,oBAAoB,MAAM;AACtC,SAAO;AAAA,IACN,IAAI;AAAA,IACJ,oBAAoB,CAAC;AAAA,IAErB,YAAY,CAAC,YAAY;AAAA;AAAA;AAAA;AAAA,MAIxB,qBAAqB,OACpB,MAKA,iBACI;AACJ,eAAO,MAAM;AAAA,UACZ;AAAA,UACA;AAAA,YACC,QAAQ;AAAA,YACR,MAAM,QAAQ,CAAC;AAAA,YACf,GAAG;AAAA,UACJ;AAAA,QACD;AAAA,MACD;AAAA;AAAA;AAAA;AAAA;AAAA;A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