@crediblemark/buayar 0.1.6 → 0.1.7

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/index.d.mts CHANGED
@@ -11,6 +11,8 @@ interface CreateInvoiceParams {
11
11
  callbackUrl: string;
12
12
  /** Specific Duitku payment method code (e.g. "BCA", "I1", "OV"). If omitted, all methods are available via Duitku's redirect page. */
13
13
  paymentMethod?: string;
14
+ /** Provider-specific parameters (e.g., token_id, billing details, custom headers/fields) */
15
+ providerParams?: any;
14
16
  }
15
17
  interface InvoiceResponse {
16
18
  success: boolean;
@@ -84,6 +86,69 @@ declare abstract class BasePaymentProvider {
84
86
  abstract verifyCallback(body: any, config: ProviderConfig): Promise<VerifyCallbackResult>;
85
87
  abstract getPaymentMethods(params: GetPaymentMethodsParams, config: ProviderConfig): Promise<GetPaymentMethodsResult>;
86
88
  abstract checkTransaction(params: CheckTransactionParams, config: ProviderConfig): Promise<CheckTransactionResult>;
89
+ /** Probe/discover which payment methods are actually enabled/active for the merchant */
90
+ probePaymentMethods?(config: ProviderConfig): Promise<{
91
+ success: boolean;
92
+ enabled: string[];
93
+ error?: string;
94
+ }>;
95
+ }
96
+
97
+ declare class MidtransClient {
98
+ private apiKey;
99
+ private sandbox;
100
+ constructor(config: {
101
+ apiKey: string;
102
+ sandbox: boolean;
103
+ } | ProviderConfig);
104
+ private getApiBaseUrl;
105
+ private request;
106
+ cancelTransaction(orderId: string): Promise<any>;
107
+ refundTransaction(orderId: string, payload: {
108
+ refund_key?: string;
109
+ amount?: number;
110
+ reason?: string;
111
+ }): Promise<any>;
112
+ expireTransaction(orderId: string): Promise<any>;
113
+ approveTransaction(orderId: string): Promise<any>;
114
+ denyTransaction(orderId: string): Promise<any>;
115
+ captureTransaction(transactionId: string, amount?: number): Promise<any>;
116
+ linkPayAccount(payload: any): Promise<any>;
117
+ getPayAccount(accountId: string): Promise<any>;
118
+ unbindPayAccount(accountId: string): Promise<any>;
119
+ getGoPayPromo(accountId: string, grossAmount: number, currency?: string): Promise<any>;
120
+ createSubscription(payload: any): Promise<any>;
121
+ getSubscription(subscriptionId: string): Promise<any>;
122
+ updateSubscription(subscriptionId: string, payload: any): Promise<any>;
123
+ disableSubscription(subscriptionId: string): Promise<any>;
124
+ enableSubscription(subscriptionId: string): Promise<any>;
125
+ createPaymentLink(payload: any): Promise<any>;
126
+ getPaymentLink(paymentLinkId: string): Promise<any>;
127
+ deletePaymentLink(paymentLinkId: string): Promise<any>;
128
+ getBalance(): Promise<any>;
129
+ createBillingInvoice(payload: any): Promise<any>;
130
+ getBillingInvoice(invoiceId: string): Promise<any>;
131
+ voidBillingInvoice(invoiceId: string): Promise<any>;
132
+ convertBillingInvoice(invoiceId: string): Promise<any>;
133
+ }
134
+
135
+ declare class MidtransProvider extends BasePaymentProvider {
136
+ readonly name = "midtrans";
137
+ private getSnapBaseUrl;
138
+ private getApiBaseUrl;
139
+ createInvoice(params: CreateInvoiceParams, config: ProviderConfig): Promise<InvoiceResponse>;
140
+ verifyCallback(body: any, config: ProviderConfig): Promise<VerifyCallbackResult>;
141
+ getPaymentMethods(params: GetPaymentMethodsParams, config: ProviderConfig): Promise<GetPaymentMethodsResult>;
142
+ checkTransaction(params: CheckTransactionParams, config: ProviderConfig): Promise<CheckTransactionResult>;
143
+ /**
144
+ * Get an instance of MidtransClient to perform transaction actions, subscriptions, invoicing, etc.
145
+ */
146
+ getClient(config: ProviderConfig): MidtransClient;
147
+ probePaymentMethods(config: ProviderConfig): Promise<{
148
+ success: boolean;
149
+ enabled: string[];
150
+ error?: string;
151
+ }>;
87
152
  }
88
153
 
89
154
  declare class DuitkuProvider extends BasePaymentProvider {
@@ -93,6 +158,11 @@ declare class DuitkuProvider extends BasePaymentProvider {
93
158
  verifyCallback(body: any, config: ProviderConfig): Promise<VerifyCallbackResult>;
94
159
  getPaymentMethods(params: GetPaymentMethodsParams, config: ProviderConfig): Promise<GetPaymentMethodsResult>;
95
160
  checkTransaction(params: CheckTransactionParams, config: ProviderConfig): Promise<CheckTransactionResult>;
161
+ probePaymentMethods(config: ProviderConfig): Promise<{
162
+ success: boolean;
163
+ enabled: string[];
164
+ error?: string;
165
+ }>;
96
166
  }
97
167
 
98
168
  declare function getPaymentMethodCategory(code: string, name?: string): "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya";
@@ -102,11 +172,18 @@ declare class PaymentManager {
102
172
  constructor();
103
173
  registerProvider(provider: BasePaymentProvider): void;
104
174
  getProvider(name: string): BasePaymentProvider;
175
+ getMidtransProvider(): MidtransProvider;
176
+ getMidtransClient(config: ProviderConfig): MidtransClient;
105
177
  createInvoice(providerName: string, params: CreateInvoiceParams, config: ProviderConfig): Promise<InvoiceResponse>;
106
178
  verifyCallback(providerName: string, body: any, config: ProviderConfig): Promise<VerifyCallbackResult>;
107
179
  getPaymentMethods(providerName: string, params: GetPaymentMethodsParams, config: ProviderConfig): Promise<GetPaymentMethodsResult>;
108
180
  checkTransaction(providerName: string, params: CheckTransactionParams, config: ProviderConfig): Promise<CheckTransactionResult>;
181
+ probePaymentMethods(providerName: string, config: ProviderConfig): Promise<{
182
+ success: boolean;
183
+ enabled: string[];
184
+ error?: string;
185
+ }>;
109
186
  }
110
187
  declare const paymentManager: PaymentManager;
111
188
 
112
- export { BasePaymentProvider, type CheckTransactionParams, type CheckTransactionResult, type CreateInvoiceParams, DuitkuProvider, type GetPaymentMethodsParams, type GetPaymentMethodsResult, type InvoiceResponse, PaymentManager, type PaymentMethod, type ProviderConfig, type VerifyCallbackResult, getPaymentMethodCategory, paymentManager };
189
+ export { BasePaymentProvider, type CheckTransactionParams, type CheckTransactionResult, type CreateInvoiceParams, DuitkuProvider, type GetPaymentMethodsParams, type GetPaymentMethodsResult, type InvoiceResponse, MidtransClient, MidtransProvider, PaymentManager, type PaymentMethod, type ProviderConfig, type VerifyCallbackResult, getPaymentMethodCategory, paymentManager };
package/dist/index.d.ts CHANGED
@@ -11,6 +11,8 @@ interface CreateInvoiceParams {
11
11
  callbackUrl: string;
12
12
  /** Specific Duitku payment method code (e.g. "BCA", "I1", "OV"). If omitted, all methods are available via Duitku's redirect page. */
13
13
  paymentMethod?: string;
14
+ /** Provider-specific parameters (e.g., token_id, billing details, custom headers/fields) */
15
+ providerParams?: any;
14
16
  }
15
17
  interface InvoiceResponse {
16
18
  success: boolean;
@@ -84,6 +86,69 @@ declare abstract class BasePaymentProvider {
84
86
  abstract verifyCallback(body: any, config: ProviderConfig): Promise<VerifyCallbackResult>;
85
87
  abstract getPaymentMethods(params: GetPaymentMethodsParams, config: ProviderConfig): Promise<GetPaymentMethodsResult>;
86
88
  abstract checkTransaction(params: CheckTransactionParams, config: ProviderConfig): Promise<CheckTransactionResult>;
89
+ /** Probe/discover which payment methods are actually enabled/active for the merchant */
90
+ probePaymentMethods?(config: ProviderConfig): Promise<{
91
+ success: boolean;
92
+ enabled: string[];
93
+ error?: string;
94
+ }>;
95
+ }
96
+
97
+ declare class MidtransClient {
98
+ private apiKey;
99
+ private sandbox;
100
+ constructor(config: {
101
+ apiKey: string;
102
+ sandbox: boolean;
103
+ } | ProviderConfig);
104
+ private getApiBaseUrl;
105
+ private request;
106
+ cancelTransaction(orderId: string): Promise<any>;
107
+ refundTransaction(orderId: string, payload: {
108
+ refund_key?: string;
109
+ amount?: number;
110
+ reason?: string;
111
+ }): Promise<any>;
112
+ expireTransaction(orderId: string): Promise<any>;
113
+ approveTransaction(orderId: string): Promise<any>;
114
+ denyTransaction(orderId: string): Promise<any>;
115
+ captureTransaction(transactionId: string, amount?: number): Promise<any>;
116
+ linkPayAccount(payload: any): Promise<any>;
117
+ getPayAccount(accountId: string): Promise<any>;
118
+ unbindPayAccount(accountId: string): Promise<any>;
119
+ getGoPayPromo(accountId: string, grossAmount: number, currency?: string): Promise<any>;
120
+ createSubscription(payload: any): Promise<any>;
121
+ getSubscription(subscriptionId: string): Promise<any>;
122
+ updateSubscription(subscriptionId: string, payload: any): Promise<any>;
123
+ disableSubscription(subscriptionId: string): Promise<any>;
124
+ enableSubscription(subscriptionId: string): Promise<any>;
125
+ createPaymentLink(payload: any): Promise<any>;
126
+ getPaymentLink(paymentLinkId: string): Promise<any>;
127
+ deletePaymentLink(paymentLinkId: string): Promise<any>;
128
+ getBalance(): Promise<any>;
129
+ createBillingInvoice(payload: any): Promise<any>;
130
+ getBillingInvoice(invoiceId: string): Promise<any>;
131
+ voidBillingInvoice(invoiceId: string): Promise<any>;
132
+ convertBillingInvoice(invoiceId: string): Promise<any>;
133
+ }
134
+
135
+ declare class MidtransProvider extends BasePaymentProvider {
136
+ readonly name = "midtrans";
137
+ private getSnapBaseUrl;
138
+ private getApiBaseUrl;
139
+ createInvoice(params: CreateInvoiceParams, config: ProviderConfig): Promise<InvoiceResponse>;
140
+ verifyCallback(body: any, config: ProviderConfig): Promise<VerifyCallbackResult>;
141
+ getPaymentMethods(params: GetPaymentMethodsParams, config: ProviderConfig): Promise<GetPaymentMethodsResult>;
142
+ checkTransaction(params: CheckTransactionParams, config: ProviderConfig): Promise<CheckTransactionResult>;
143
+ /**
144
+ * Get an instance of MidtransClient to perform transaction actions, subscriptions, invoicing, etc.
145
+ */
146
+ getClient(config: ProviderConfig): MidtransClient;
147
+ probePaymentMethods(config: ProviderConfig): Promise<{
148
+ success: boolean;
149
+ enabled: string[];
150
+ error?: string;
151
+ }>;
87
152
  }
88
153
 
89
154
  declare class DuitkuProvider extends BasePaymentProvider {
@@ -93,6 +158,11 @@ declare class DuitkuProvider extends BasePaymentProvider {
93
158
  verifyCallback(body: any, config: ProviderConfig): Promise<VerifyCallbackResult>;
94
159
  getPaymentMethods(params: GetPaymentMethodsParams, config: ProviderConfig): Promise<GetPaymentMethodsResult>;
95
160
  checkTransaction(params: CheckTransactionParams, config: ProviderConfig): Promise<CheckTransactionResult>;
161
+ probePaymentMethods(config: ProviderConfig): Promise<{
162
+ success: boolean;
163
+ enabled: string[];
164
+ error?: string;
165
+ }>;
96
166
  }
97
167
 
98
168
  declare function getPaymentMethodCategory(code: string, name?: string): "Virtual Account" | "QRIS" | "E-Wallet" | "Retail / Gerai" | "Kartu Kredit" | "Paylater / Cicilan" | "Lainnya";
@@ -102,11 +172,18 @@ declare class PaymentManager {
102
172
  constructor();
103
173
  registerProvider(provider: BasePaymentProvider): void;
104
174
  getProvider(name: string): BasePaymentProvider;
175
+ getMidtransProvider(): MidtransProvider;
176
+ getMidtransClient(config: ProviderConfig): MidtransClient;
105
177
  createInvoice(providerName: string, params: CreateInvoiceParams, config: ProviderConfig): Promise<InvoiceResponse>;
106
178
  verifyCallback(providerName: string, body: any, config: ProviderConfig): Promise<VerifyCallbackResult>;
107
179
  getPaymentMethods(providerName: string, params: GetPaymentMethodsParams, config: ProviderConfig): Promise<GetPaymentMethodsResult>;
108
180
  checkTransaction(providerName: string, params: CheckTransactionParams, config: ProviderConfig): Promise<CheckTransactionResult>;
181
+ probePaymentMethods(providerName: string, config: ProviderConfig): Promise<{
182
+ success: boolean;
183
+ enabled: string[];
184
+ error?: string;
185
+ }>;
109
186
  }
110
187
  declare const paymentManager: PaymentManager;
111
188
 
112
- export { BasePaymentProvider, type CheckTransactionParams, type CheckTransactionResult, type CreateInvoiceParams, DuitkuProvider, type GetPaymentMethodsParams, type GetPaymentMethodsResult, type InvoiceResponse, PaymentManager, type PaymentMethod, type ProviderConfig, type VerifyCallbackResult, getPaymentMethodCategory, paymentManager };
189
+ export { BasePaymentProvider, type CheckTransactionParams, type CheckTransactionResult, type CreateInvoiceParams, DuitkuProvider, type GetPaymentMethodsParams, type GetPaymentMethodsResult, type InvoiceResponse, MidtransClient, MidtransProvider, PaymentManager, type PaymentMethod, type ProviderConfig, type VerifyCallbackResult, getPaymentMethodCategory, paymentManager };