better-auth-mercadopago 0.1.8 → 0.1.9

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/dist/client.mjs DELETED
@@ -1,276 +0,0 @@
1
- // client.ts
2
- var mercadoPagoClientPlugin = () => {
3
- return {
4
- id: "mercadopago",
5
- $InferServerPlugin: {},
6
- getActions: ($fetch) => ({
7
- /**
8
- * Get or create a Mercado Pago customer for the authenticated user
9
- */
10
- getOrCreateCustomer: async (data, fetchOptions) => {
11
- return await $fetch("/mercado-pago/customer", {
12
- method: "POST",
13
- body: data || {},
14
- ...fetchOptions
15
- });
16
- },
17
- /**
18
- * Create a payment and get checkout URL
19
- *
20
- * @example
21
- * ```ts
22
- * const { data } = await authClient.mercadoPago.createPayment({
23
- * items: [{
24
- * title: "Premium Plan",
25
- * quantity: 1,
26
- * unitPrice: 99.90,
27
- * currencyId: "ARS"
28
- * }]
29
- * });
30
- *
31
- * // Redirect user to checkout
32
- * window.location.href = data.checkoutUrl;
33
- * ```
34
- */
35
- createPayment: async (data, fetchOptions) => {
36
- return await $fetch("/mercado-pago/payment/create", {
37
- method: "POST",
38
- body: data,
39
- ...fetchOptions
40
- });
41
- },
42
- /**
43
- * Create a marketplace payment with automatic split
44
- *
45
- * You need to have the seller's MP User ID (collector_id) which they get
46
- * after authorizing your app via OAuth.
47
- *
48
- * @example
49
- * ```ts
50
- * const { data } = await authClient.mercadoPago.createPayment({
51
- * items: [{
52
- * title: "Product from Seller",
53
- * quantity: 1,
54
- * unitPrice: 100
55
- * }],
56
- * marketplace: {
57
- * collectorId: "123456789", // Seller's MP User ID
58
- * applicationFeePercentage: 10 // Platform keeps 10%
59
- * }
60
- * });
61
- * ```
62
- */
63
- createMarketplacePayment: async (data, fetchOptions) => {
64
- return await $fetch("/mercado-pago/payment/create", {
65
- method: "POST",
66
- body: data,
67
- ...fetchOptions
68
- });
69
- },
70
- /**
71
- * Create a subscription with recurring payments
72
- *
73
- * Supports two modes:
74
- * 1. With preapproval plan (reusable): Pass preapprovalPlanId
75
- * 2. Direct subscription (one-off): Pass reason + autoRecurring
76
- *
77
- * @example With plan
78
- * ```ts
79
- * const { data } = await authClient.mercadoPago.createSubscription({
80
- * preapprovalPlanId: "plan_abc123"
81
- * });
82
- * ```
83
- *
84
- * @example Direct (without plan)
85
- * ```ts
86
- * const { data } = await authClient.mercadoPago.createSubscription({
87
- * reason: "Premium Monthly Plan",
88
- * autoRecurring: {
89
- * frequency: 1,
90
- * frequencyType: "months",
91
- * transactionAmount: 99.90,
92
- * currencyId: "ARS"
93
- * }
94
- * });
95
- * ```
96
- */
97
- createSubscription: async (data, fetchOptions) => {
98
- return await $fetch("/mercado-pago/subscription/create", {
99
- method: "POST",
100
- body: data,
101
- ...fetchOptions
102
- });
103
- },
104
- /**
105
- * Cancel a subscription
106
- *
107
- * @example
108
- * ```ts
109
- * await authClient.mercadoPago.cancelSubscription({
110
- * subscriptionId: "sub_123"
111
- * });
112
- * ```
113
- */
114
- cancelSubscription: async (data, fetchOptions) => {
115
- return await $fetch("/mercado-pago/subscription/cancel", {
116
- method: "POST",
117
- body: data,
118
- ...fetchOptions
119
- });
120
- },
121
- /**
122
- * Create a reusable preapproval plan (subscription template)
123
- *
124
- * Plans can be reused for multiple subscriptions. Create once,
125
- * use many times with createSubscription({ preapprovalPlanId })
126
- *
127
- * @example
128
- * ```ts
129
- * const { data } = await authClient.mercadoPago.createPreapprovalPlan({
130
- * reason: "Premium Monthly",
131
- * autoRecurring: {
132
- * frequency: 1,
133
- * frequencyType: "months",
134
- * transactionAmount: 99.90,
135
- * freeTrial: {
136
- * frequency: 7,
137
- * frequencyType: "days"
138
- * }
139
- * },
140
- * repetitions: 12 // 12 months, omit for infinite
141
- * });
142
- *
143
- * // Use the plan
144
- * const planId = data.plan.mercadoPagoPlanId;
145
- * ```
146
- */
147
- createPreapprovalPlan: async (data, fetchOptions) => {
148
- return await $fetch("/mercado-pago/plan/create", {
149
- method: "POST",
150
- body: data,
151
- ...fetchOptions
152
- });
153
- },
154
- /**
155
- * List all preapproval plans
156
- *
157
- * @example
158
- * ```ts
159
- * const { data } = await authClient.mercadoPago.listPreapprovalPlans();
160
- *
161
- * data.plans.forEach(plan => {
162
- * console.log(plan.reason); // "Premium Monthly"
163
- * console.log(plan.transactionAmount); // 99.90
164
- * });
165
- * ```
166
- */
167
- listPreapprovalPlans: async (fetchOptions) => {
168
- return await $fetch("/mercado-pago/plans", {
169
- method: "GET",
170
- ...fetchOptions
171
- });
172
- },
173
- /**
174
- * Get payment by ID
175
- */
176
- getPayment: async (paymentId, fetchOptions) => {
177
- return await $fetch(`/mercado-pago/payment/${paymentId}`, {
178
- method: "GET",
179
- ...fetchOptions
180
- });
181
- },
182
- /**
183
- * List all payments for the authenticated user
184
- *
185
- * @example
186
- * ```ts
187
- * const { data } = await authClient.mercadoPago.listPayments({
188
- * limit: 20,
189
- * offset: 0
190
- * });
191
- * ```
192
- */
193
- listPayments: async (params, fetchOptions) => {
194
- const query = new URLSearchParams();
195
- if (params?.limit) query.set("limit", params.limit.toString());
196
- if (params?.offset) query.set("offset", params.offset.toString());
197
- return await $fetch(`/mercado-pago/payments?${query.toString()}`, {
198
- method: "GET",
199
- ...fetchOptions
200
- });
201
- },
202
- /**
203
- * List all subscriptions for the authenticated user
204
- *
205
- * @example
206
- * ```ts
207
- * const { data } = await authClient.mercadoPago.listSubscriptions();
208
- * ```
209
- */
210
- listSubscriptions: async (fetchOptions) => {
211
- return await $fetch(`/mercado-pago/subscriptions`, {
212
- method: "GET",
213
- ...fetchOptions
214
- });
215
- },
216
- /**
217
- * Get OAuth authorization URL for marketplace sellers
218
- *
219
- * This is Step 1 of OAuth flow. Redirect the seller to this URL so they
220
- * can authorize your app to process payments on their behalf.
221
- *
222
- * @example
223
- * ```ts
224
- * const { data } = await authClient.mercadoPago.getOAuthUrl({
225
- * redirectUri: "https://myapp.com/oauth/callback"
226
- * });
227
- *
228
- * // Redirect seller to authorize
229
- * window.location.href = data.authUrl;
230
- * ```
231
- */
232
- getOAuthUrl: async (params, fetchOptions) => {
233
- const query = new URLSearchParams();
234
- query.set("redirectUri", params.redirectUri);
235
- return await $fetch(
236
- `/mercado-pago/oauth/authorize?${query.toString()}`,
237
- {
238
- method: "GET",
239
- ...fetchOptions
240
- }
241
- );
242
- },
243
- /**
244
- * Exchange OAuth code for access token
245
- *
246
- * This is Step 2 of OAuth flow. After the seller authorizes and MP redirects
247
- * them back with a code, exchange that code for an access token.
248
- *
249
- * @example
250
- * ```ts
251
- * // In your /oauth/callback page:
252
- * const code = new URLSearchParams(window.location.search).get("code");
253
- *
254
- * const { data } = await authClient.mercadoPago.exchangeOAuthCode({
255
- * code,
256
- * redirectUri: "https://myapp.com/oauth/callback"
257
- * });
258
- *
259
- * // Now you have the seller's MP User ID
260
- * console.log(data.oauthToken.mercadoPagoUserId);
261
- * ```
262
- */
263
- exchangeOAuthCode: async (data, fetchOptions) => {
264
- return await $fetch("/mercado-pago/oauth/callback", {
265
- method: "POST",
266
- body: data,
267
- ...fetchOptions
268
- });
269
- }
270
- })
271
- };
272
- };
273
- export {
274
- mercadoPagoClientPlugin
275
- };
276
- //# sourceMappingURL=client.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../client.ts"],"sourcesContent":["import type {\n\tBetterAuthClientPlugin,\n\tBetterFetch,\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 interface MercadoPagoClientActions {\n\t/**\n\t * Get or create a Mercado Pago customer for the authenticated user\n\t */\n\tgetOrCreateCustomer: (\n\t\tdata?: {\n\t\t\temail?: string;\n\t\t\tfirstName?: string;\n\t\t\tlastName?: string;\n\t\t},\n\t\tfetchOptions?: BetterFetchOption,\n\t) => Promise<{ customer: MercadoPagoCustomerRecord }>;\n\n\t/**\n\t * Create a payment and get checkout URL\n\t */\n\tcreatePayment: (\n\t\tdata: CreatePaymentParams,\n\t\tfetchOptions?: BetterFetchOption,\n\t) => Promise<CreatePaymentResponse>;\n\n\t/**\n\t * Create a marketplace payment with automatic split\n\t */\n\tcreateMarketplacePayment: (\n\t\tdata: CreatePaymentParams,\n\t\tfetchOptions?: BetterFetchOption,\n\t) => Promise<CreatePaymentResponse>;\n\n\t/**\n\t * Create a subscription with recurring payments\n\t */\n\tcreateSubscription: (\n\t\tdata: CreateSubscriptionParams,\n\t\tfetchOptions?: BetterFetchOption,\n\t) => Promise<CreateSubscriptionResponse>;\n\n\t/**\n\t * Cancel a subscription\n\t */\n\tcancelSubscription: (\n\t\tdata: { subscriptionId: string },\n\t\tfetchOptions?: BetterFetchOption,\n\t) => Promise<{ success: boolean }>;\n\n\t/**\n\t * Create a reusable preapproval plan (subscription template)\n\t */\n\tcreatePreapprovalPlan: (\n\t\tdata: CreatePreapprovalPlanParams,\n\t\tfetchOptions?: BetterFetchOption,\n\t) => Promise<CreatePreapprovalPlanResponse>;\n\n\t/**\n\t * List all preapproval plans\n\t */\n\tlistPreapprovalPlans: (\n\t\tfetchOptions?: BetterFetchOption,\n\t) => Promise<{ plans: MercadoPagoPreapprovalPlanRecord[] }>;\n\n\t/**\n\t * Get payment by ID\n\t */\n\tgetPayment: (\n\t\tpaymentId: string,\n\t\tfetchOptions?: BetterFetchOption,\n\t) => Promise<{ payment: MercadoPagoPaymentRecord }>;\n\n\t/**\n\t * List all payments for the authenticated user\n\t */\n\tlistPayments: (\n\t\tparams?: { limit?: number; offset?: number },\n\t\tfetchOptions?: BetterFetchOption,\n\t) => Promise<{ payments: MercadoPagoPaymentRecord[] }>;\n\n\t/**\n\t * List all subscriptions for the authenticated user\n\t */\n\tlistSubscriptions: (\n\t\tfetchOptions?: BetterFetchOption,\n\t) => Promise<{ subscriptions: MercadoPagoSubscriptionRecord[] }>;\n\n\t/**\n\t * Get OAuth authorization URL for marketplace sellers\n\t */\n\tgetOAuthUrl: (\n\t\tparams: { redirectUri: string },\n\t\tfetchOptions?: BetterFetchOption,\n\t) => Promise<OAuthUrlResponse>;\n\n\t/**\n\t * Exchange OAuth code for access token\n\t */\n\texchangeOAuthCode: (\n\t\tdata: { code: string; redirectUri: string },\n\t\tfetchOptions?: BetterFetchOption,\n\t) => Promise<OAuthTokenResponse>;\n}\n\ntype mercadopagoPlugin = typeof mercadoPagoPlugin;\n\n// Export the actions type for Better Auth type inference\nexport type MercadoPagoClient = MercadoPagoClientActions;\n\nexport const mercadoPagoClientPlugin = () => {\n\treturn {\n\t\tid: \"mercadopago\",\n\t\t$InferServerPlugin: {} as ReturnType<mercadopagoPlugin>,\n\n\t\tgetActions: ($fetch: BetterFetch): MercadoPagoClientActions => ({\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(\"/mercado-pago/customer\", {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: data || {},\n\t\t\t\t\t...fetchOptions,\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(\"/mercado-pago/payment/create\", {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: data,\n\t\t\t\t\t...fetchOptions,\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(\"/mercado-pago/payment/create\", {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: data,\n\t\t\t\t\t...fetchOptions,\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(\"/mercado-pago/subscription/create\", {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: data,\n\t\t\t\t\t...fetchOptions,\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(\"/mercado-pago/subscription/cancel\", {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: data,\n\t\t\t\t\t...fetchOptions,\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(\"/mercado-pago/plan/create\", {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: data,\n\t\t\t\t\t...fetchOptions,\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(\"/mercado-pago/plans\", {\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\t...fetchOptions,\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(`/mercado-pago/payment/${paymentId}`, {\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\t...fetchOptions,\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(`/mercado-pago/payments?${query.toString()}`, {\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\t...fetchOptions,\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(`/mercado-pago/subscriptions`, {\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\t...fetchOptions,\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(\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(\"/mercado-pago/oauth/callback\", {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: data,\n\t\t\t\t\t...fetchOptions,\n\t\t\t\t});\n\t\t\t},\n\t\t}),\n\t} satisfies BetterAuthClientPlugin;\n};\n"],"mappings":";AA8HO,IAAM,0BAA0B,MAAM;AAC5C,SAAO;AAAA,IACN,IAAI;AAAA,IACJ,oBAAoB,CAAC;AAAA,IAErB,YAAY,CAAC,YAAmD;AAAA;AAAA;AAAA;AAAA,MAI/D,qBAA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