Skip to content

Commit d651144

Browse files
authored
Export types from braintree-payment plugin
2 parents cce477b + 55e5191 commit d651144

File tree

9 files changed

+525
-432
lines changed

9 files changed

+525
-432
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './providers/payment-braintree/src/types';
2+
export * from './providers/payment-braintree/src/core/braintree-base';
3+
export { default as BraintreePaymentProvider } from './providers/payment-braintree/src';
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { AbstractPaymentProvider } from '@medusajs/framework/utils';
2+
import type { AuthorizePaymentInput, AuthorizePaymentOutput, CancelPaymentInput, CancelPaymentOutput, CapturePaymentInput, CapturePaymentOutput, CreateAccountHolderInput, CreateAccountHolderOutput, DeleteAccountHolderInput, DeleteAccountHolderOutput, DeletePaymentInput, DeletePaymentOutput, GetPaymentStatusInput, GetPaymentStatusOutput, InitiatePaymentInput, InitiatePaymentOutput, Logger, MedusaContainer, ProviderWebhookPayload, RefundPaymentInput, RefundPaymentOutput, RetrievePaymentInput, RetrievePaymentOutput, SavePaymentMethodInput, SavePaymentMethodOutput, UpdateAccountHolderInput, UpdateAccountHolderOutput, UpdatePaymentInput, UpdatePaymentOutput, WebhookActionResult } from '@medusajs/types';
3+
import type { Transaction } from 'braintree';
4+
import Braintree from 'braintree';
5+
import type { BraintreeOptions } from '../types';
6+
export interface BraintreePaymentSessionData {
7+
clientToken: string;
8+
amount: number;
9+
currency_code: string;
10+
paymentMethodNonce?: string;
11+
braintreeTransaction?: Transaction;
12+
}
13+
declare class BraintreeBase extends AbstractPaymentProvider<BraintreeOptions> {
14+
identifier: string;
15+
protected readonly options_: BraintreeOptions;
16+
protected gateway: Braintree.BraintreeGateway;
17+
logger: Logger;
18+
container_: MedusaContainer;
19+
protected constructor(container: MedusaContainer, options: BraintreeOptions);
20+
private parsePaymentSessionData;
21+
protected init(): void;
22+
static validateOptions(options: BraintreeOptions): void;
23+
capturePayment(input: CapturePaymentInput): Promise<CapturePaymentOutput>;
24+
authorizePayment(input: AuthorizePaymentInput): Promise<AuthorizePaymentOutput>;
25+
cancelPayment(input: CancelPaymentInput): Promise<CancelPaymentOutput>;
26+
private getBraintreeTransactionCreateRequestBody;
27+
retrieveTransaction(braintreeTransactionId: string): Promise<{
28+
braintreeTransaction: Transaction;
29+
}>;
30+
initiatePayment(input: InitiatePaymentInput): Promise<InitiatePaymentOutput>;
31+
private createTransaction;
32+
private createBraintreeCustomer;
33+
createAccountHolder(input: CreateAccountHolderInput): Promise<CreateAccountHolderOutput>;
34+
updateAccountHolder(input: UpdateAccountHolderInput): Promise<UpdateAccountHolderOutput>;
35+
deleteAccountHolder(input: DeleteAccountHolderInput): Promise<DeleteAccountHolderOutput>;
36+
deletePayment(input: DeletePaymentInput): Promise<DeletePaymentOutput>;
37+
getPaymentStatus(input: GetPaymentStatusInput): Promise<GetPaymentStatusOutput>;
38+
savePaymentMethod(input: SavePaymentMethodInput): Promise<SavePaymentMethodOutput>;
39+
refundPayment(input: RefundPaymentInput): Promise<RefundPaymentOutput>;
40+
retrievePayment(input: RetrievePaymentInput): Promise<RetrievePaymentOutput>;
41+
updatePayment(input: UpdatePaymentInput): Promise<UpdatePaymentOutput>;
42+
getWebhookActionAndData(webhookData: ProviderWebhookPayload['payload']): Promise<WebhookActionResult>;
43+
}
44+
export default BraintreeBase;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type Braintree from 'braintree';
2+
export interface BraintreeOptions extends Braintree.ClientGatewayConfig {
3+
environment: 'production' | 'sandbox' | 'development' | 'qa';
4+
merchantId: string;
5+
publicKey: string;
6+
privateKey: string;
7+
enable3DSecure: boolean;
8+
savePaymentMethod: boolean;
9+
webhookSecret: string;
10+
autoCapture: boolean;
11+
}
12+
export declare const PaymentProviderKeys: {
13+
BRAINTREE: string;
14+
};
15+
export interface CustomFields {
16+
medusa_payment_session_id?: string;
17+
cart_id?: string;
18+
customer_id: string;
19+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from '../providers/payment-braintree/src/types';
2+
export * from '../providers/payment-braintree/src/core/braintree-base';

plugins/braintree-payment/package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lambdacurry/medusa-payment-braintree",
3-
"version": "0.0.6",
3+
"version": "0.0.7",
44
"description": "Braintree plugin for Medusa",
55
"author": "Lambda Curry (https://lambdacurry.dev)",
66
"license": "MIT",
@@ -12,10 +12,18 @@
1212
"files": [
1313
".medusa/server"
1414
],
15+
"main": "./.medusa/server/src/index.js",
16+
"types": "./.medusa/server/src/index.d.ts",
1517
"exports": {
1618
"./package.json": "./package.json",
1719
"./.medusa/server/src/modules/*": "./.medusa/server/src/modules/*/index.js",
1820
"./providers/*": "./.medusa/server/src/providers/*/src/index.js",
21+
"./types": {
22+
"types": "./.medusa/server/src/types/index.d.ts",
23+
"import": "./.medusa/server/src/types/index.js",
24+
"require": "./.medusa/server/src/types/index.js",
25+
"default": "./.medusa/server/src/types/index.js"
26+
},
1927
"./*": "./.medusa/server/src/*.js"
2028
},
2129
"keywords": [
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Export types
2+
export * from './providers/payment-braintree/src/types'
3+
export * from './providers/payment-braintree/src/core/braintree-base'
4+
5+
// Export provider
6+
export { default as BraintreePaymentProvider } from './providers/payment-braintree/src'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Re-export all types from the provider
2+
export * from '../providers/payment-braintree/src/types'
3+
export * from '../providers/payment-braintree/src/core/braintree-base'

plugins/braintree-payment/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"experimentalDecorators": true,
99
"skipLibCheck": true,
1010
"skipDefaultLibCheck": true,
11-
"declaration": false,
11+
"declaration": true,
1212
"sourceMap": false,
1313
"inlineSourceMap": true,
1414
"outDir": "./.medusa/server",

0 commit comments

Comments
 (0)