better-auth-mercadopago 0.1.8 → 0.2.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/CHANGELOG.md ADDED
@@ -0,0 +1,48 @@
1
+ # better-auth-mercadopago
2
+
3
+ ## 0.1.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 79b98d9: rename and type plugin client
8
+
9
+ ## 0.1.7
10
+
11
+ ### Patch Changes
12
+
13
+ - Fix plugin ID casing so the plugin is mounted under `authClient.mercadopago` instead of `authClient.mercadoPago`.
14
+
15
+ This fixes a bug where the plugin ID used camelCase which caused mismatches with expected client property names. Tests were added/updated to validate the plugin structure.
16
+
17
+ ## 0.1.6
18
+
19
+ ### Patch Changes
20
+
21
+ - Fix client plugin structure to properly expose methods through getActions. This resolves the issue where authClient.mercadoPago.createSubscription and other methods were not accessible, even though they were available when destructuring.
22
+
23
+ ## 0.1.4
24
+
25
+ ### Patch Changes
26
+
27
+ - 31a0418: fix-github-action
28
+
29
+ ## 0.1.3
30
+
31
+ ### Patch Changes
32
+
33
+ - 9438e75: Fixed linting errors reported by Biome without breaking any functionality:
34
+ - Replaced non-null assertions with proper conditional checks
35
+ - Added explicit types to avoid implicit `any`
36
+ - Fixed TypeScript type assertions in test files
37
+
38
+ ## 0.1.2
39
+
40
+ ### Patch Changes
41
+
42
+ - docs: correct package name in readme
43
+
44
+ ## 0.1.1
45
+
46
+ ### Patch Changes
47
+
48
+ - Initial release: Fixed build issues and updated package name.
package/dist/client.d.ts CHANGED
@@ -1,4 +1,88 @@
1
- import 'better-auth/client';
2
- export { MercadoPagoClient, MercadoPagoClientActions, mercadoPagoClientPlugin } from './index.js';
3
- import 'better-auth';
4
- import 'zod';
1
+ import type { BetterFetch, BetterFetchOption } from "better-auth/client";
2
+ import type { mercadoPagoPlugin } from "./index";
3
+ import type { CreatePaymentParams, CreatePaymentResponse, CreatePreapprovalPlanParams, CreatePreapprovalPlanResponse, CreateSubscriptionParams, CreateSubscriptionResponse, MercadoPagoCustomerRecord, MercadoPagoPaymentRecord, MercadoPagoPreapprovalPlanRecord, MercadoPagoSubscriptionRecord, OAuthTokenResponse, OAuthUrlResponse } from "./types";
4
+ export interface MercadoPagoClientActions {
5
+ /**
6
+ * Get or create a Mercado Pago customer for the authenticated user
7
+ */
8
+ getOrCreateCustomer: (data?: {
9
+ email?: string;
10
+ firstName?: string;
11
+ lastName?: string;
12
+ }, fetchOptions?: BetterFetchOption) => Promise<{
13
+ customer: MercadoPagoCustomerRecord;
14
+ }>;
15
+ /**
16
+ * Create a payment and get checkout URL
17
+ */
18
+ createPayment: (data: CreatePaymentParams, fetchOptions?: BetterFetchOption) => Promise<CreatePaymentResponse>;
19
+ /**
20
+ * Create a marketplace payment with automatic split
21
+ */
22
+ createMarketplacePayment: (data: CreatePaymentParams, fetchOptions?: BetterFetchOption) => Promise<CreatePaymentResponse>;
23
+ /**
24
+ * Create a subscription with recurring payments
25
+ */
26
+ createSubscription: (data: CreateSubscriptionParams, fetchOptions?: BetterFetchOption) => Promise<CreateSubscriptionResponse>;
27
+ /**
28
+ * Cancel a subscription
29
+ */
30
+ cancelSubscription: (data: {
31
+ subscriptionId: string;
32
+ }, fetchOptions?: BetterFetchOption) => Promise<{
33
+ success: boolean;
34
+ }>;
35
+ /**
36
+ * Create a reusable preapproval plan (subscription template)
37
+ */
38
+ createPreapprovalPlan: (data: CreatePreapprovalPlanParams, fetchOptions?: BetterFetchOption) => Promise<CreatePreapprovalPlanResponse>;
39
+ /**
40
+ * List all preapproval plans
41
+ */
42
+ listPreapprovalPlans: (fetchOptions?: BetterFetchOption) => Promise<{
43
+ plans: MercadoPagoPreapprovalPlanRecord[];
44
+ }>;
45
+ /**
46
+ * Get payment by ID
47
+ */
48
+ getPayment: (paymentId: string, fetchOptions?: BetterFetchOption) => Promise<{
49
+ payment: MercadoPagoPaymentRecord;
50
+ }>;
51
+ /**
52
+ * List all payments for the authenticated user
53
+ */
54
+ listPayments: (params?: {
55
+ limit?: number;
56
+ offset?: number;
57
+ }, fetchOptions?: BetterFetchOption) => Promise<{
58
+ payments: MercadoPagoPaymentRecord[];
59
+ }>;
60
+ /**
61
+ * List all subscriptions for the authenticated user
62
+ */
63
+ listSubscriptions: (fetchOptions?: BetterFetchOption) => Promise<{
64
+ subscriptions: MercadoPagoSubscriptionRecord[];
65
+ }>;
66
+ /**
67
+ * Get OAuth authorization URL for marketplace sellers
68
+ */
69
+ getOAuthUrl: (params: {
70
+ redirectUri: string;
71
+ }, fetchOptions?: BetterFetchOption) => Promise<OAuthUrlResponse>;
72
+ /**
73
+ * Exchange OAuth code for access token
74
+ */
75
+ exchangeOAuthCode: (data: {
76
+ code: string;
77
+ redirectUri: string;
78
+ }, fetchOptions?: BetterFetchOption) => Promise<OAuthTokenResponse>;
79
+ }
80
+ type mercadopagoPlugin = typeof mercadoPagoPlugin;
81
+ export type MercadoPagoClient = MercadoPagoClientActions;
82
+ export declare const mercadoPagoClientPlugin: () => {
83
+ id: "mercadopago";
84
+ $InferServerPlugin: ReturnType<mercadopagoPlugin>;
85
+ getActions: ($fetch: BetterFetch) => MercadoPagoClientActions;
86
+ };
87
+ export {};
88
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEX,WAAW,EACX,iBAAiB,EACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EACX,mBAAmB,EACnB,qBAAqB,EACrB,2BAA2B,EAC3B,6BAA6B,EAC7B,wBAAwB,EACxB,0BAA0B,EAC1B,yBAAyB,EACzB,wBAAwB,EACxB,gCAAgC,EAChC,6BAA6B,EAC7B,kBAAkB,EAClB,gBAAgB,EAChB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,wBAAwB;IACxC;;OAEG;IACH,mBAAm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