Skip to content

Commit

Permalink
chore(types): change payment provider types to interfaces (#11597)
Browse files Browse the repository at this point in the history
* chore(types): change payment provider types to interfaces

* add changeset
  • Loading branch information
shahednasser authored Feb 25, 2025
1 parent 3f2dcb2 commit 698a520
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 100 deletions.
5 changes: 5 additions & 0 deletions .changeset/brown-buttons-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/types": patch
---

chore(types): change payment provider types to interfaces
17 changes: 0 additions & 17 deletions packages/core/types/src/http/inventory-level/admin/payloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,6 @@ export interface AdminBatchCreateInventoryItemLocationLevels {
incoming_quantity?: number
}

export interface AdminBatchCreateInventoryItemLocationLevels {
/**
* The ID of the associated stock location.
*/
location_id: string
/**
* The associated inventory item's stocked quantity in the
* associated stock location.
*/
stocked_quantity?: number
/**
* The associated inventory item's incoming quantity in the
* associated stock location.
*/
incoming_quantity?: number
}

export interface AdminBatchUpdateInventoryItemLocationLevels
extends AdminBatchCreateInventoryItemLocationLevels {
/**
Expand Down
112 changes: 29 additions & 83 deletions packages/core/types/src/payment/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,10 @@ export type PaymentProviderInput = {
}

/**
* @interface
*
* The data used initiate a payment in a provider when a payment
* session is created.
*/
export type InitiatePaymentInput = PaymentProviderInput & {
export interface InitiatePaymentInput extends PaymentProviderInput {
/**
* The amount to be authorized.
*/
Expand All @@ -113,11 +111,9 @@ export type InitiatePaymentInput = PaymentProviderInput & {
}

/**
* @interface
*
* The attributes to update a payment related to a payment session in a provider.
*/
export type UpdatePaymentInput = PaymentProviderInput & {
export interface UpdatePaymentInput extends PaymentProviderInput {
/**
* The payment session's amount.
*/
Expand All @@ -130,58 +126,44 @@ export type UpdatePaymentInput = PaymentProviderInput & {
}

/**
* @interface
*
* The data to delete a payment.
*/
export type DeletePaymentInput = PaymentProviderInput
export interface DeletePaymentInput extends PaymentProviderInput {}

/**
* @interface
*
* The data to authorize a payment.
*/
export type AuthorizePaymentInput = PaymentProviderInput
export interface AuthorizePaymentInput extends PaymentProviderInput {}

/**
* @interface
*
* The data to capture a payment.
*/
export type CapturePaymentInput = PaymentProviderInput
export interface CapturePaymentInput extends PaymentProviderInput {}

/**
* @interface
*
* The data to refund a payment.
*/
export type RefundPaymentInput = PaymentProviderInput & {
export interface RefundPaymentInput extends PaymentProviderInput {
/**
* The amount to refund.
*/
amount: BigNumberInput
}

/**
* @interface
*
* The data to retrieve a payment.
*/
export type RetrievePaymentInput = PaymentProviderInput
export interface RetrievePaymentInput extends PaymentProviderInput {}

/**
* @interface
*
* The data to cancel a payment.
*/
export type CancelPaymentInput = PaymentProviderInput
export interface CancelPaymentInput extends PaymentProviderInput {}

/**
* @interface
*
* The data to create an account holder.
*/
export type CreateAccountHolderInput = PaymentProviderInput & {
export interface CreateAccountHolderInput extends PaymentProviderInput {
/**
* The context of creating the account holder.
*/
Expand All @@ -193,7 +175,7 @@ export type CreateAccountHolderInput = PaymentProviderInput & {
}
}

export type UpdateAccountHolderInput = PaymentProviderInput & {
export interface UpdateAccountHolderInput extends PaymentProviderInput {
/**
* The context of updating the account holder.
*/
Expand All @@ -206,11 +188,9 @@ export type UpdateAccountHolderInput = PaymentProviderInput & {
}

/**
* @interface
*
* The data to delete an account holder.
*/
export type DeleteAccountHolderInput = PaymentProviderInput & {
export interface DeleteAccountHolderInput extends Omit<PaymentProviderInput, "context"> {
/**
* The context of deleting the account holder.
*/
Expand All @@ -223,25 +203,19 @@ export type DeleteAccountHolderInput = PaymentProviderInput & {
}

/**
* @interface
*
* The data to list payment methods.
*/
export type ListPaymentMethodsInput = PaymentProviderInput
export interface ListPaymentMethodsInput extends PaymentProviderInput {}

/**
* @interface
*
* The data to save a payment method.
*/
export type SavePaymentMethodInput = PaymentProviderInput
export interface SavePaymentMethodInput extends PaymentProviderInput {}

/**
* @interface
*
* The data to get the payment status.
*/
export type GetPaymentStatusInput = PaymentProviderInput
export interface GetPaymentStatusInput extends PaymentProviderInput {}

/**
* @interface
Expand All @@ -256,78 +230,60 @@ export type PaymentProviderOutput = {
}

/**
* @interface
*
* The successful result of initiating a payment session using a third-party payment provider.
*/
export type InitiatePaymentOutput = PaymentProviderOutput & {
export interface InitiatePaymentOutput extends PaymentProviderOutput {
/**
* The ID of the payment session in the payment provider.
*/
id: string
}

/**
* @interface
*
* The successful result of authorizing a payment session using a payment provider.
*/
export type AuthorizePaymentOutput = PaymentProviderOutput & {
export interface AuthorizePaymentOutput extends PaymentProviderOutput {
/**
* The status of the payment, which will be stored in the payment session's `status` field.
*/
status: PaymentSessionStatus
}

/**
* @interface
*
* The result of updating a payment.
*/
export type UpdatePaymentOutput = PaymentProviderOutput
export interface UpdatePaymentOutput extends PaymentProviderOutput {}

/**
* @interface
*
* The result of deleting a payment.
*/
export type DeletePaymentOutput = PaymentProviderOutput
export interface DeletePaymentOutput extends PaymentProviderOutput {}

/**
* @interface
*
* The result of capturing the payment.
*/
export type CapturePaymentOutput = PaymentProviderOutput
export interface CapturePaymentOutput extends PaymentProviderOutput {}

/**
* @interface
*
* The result of refunding the payment.
*/
export type RefundPaymentOutput = PaymentProviderOutput
export interface RefundPaymentOutput extends PaymentProviderOutput {}

/**
* @interface
*
* The result of retrieving the payment.
*/
export type RetrievePaymentOutput = PaymentProviderOutput
export interface RetrievePaymentOutput extends PaymentProviderOutput {}

/**
* @interface
*
* The result of canceling the payment.
*/
export type CancelPaymentOutput = PaymentProviderOutput
export interface CancelPaymentOutput extends PaymentProviderOutput {}

/**
* @interface
*
* The result of creating an account holder in the third-party payment provider. The `data`
* property is stored as-is in Medusa's account holder's `data` property.
*/
export type CreateAccountHolderOutput = PaymentProviderOutput & {
export interface CreateAccountHolderOutput extends PaymentProviderOutput {
/**
* The ID of the account holder in the payment provider.
* This is stored in Medusa's account holder in the `external_id` property.
Expand All @@ -336,50 +292,40 @@ export type CreateAccountHolderOutput = PaymentProviderOutput & {
}

/**
* @interface
*
* The result of updating an account holder in the third-party payment provider. The `data`
* property is stored as-is in Medusa's account holder's `data` property.
*/
export type UpdateAccountHolderOutput = PaymentProviderOutput
export interface UpdateAccountHolderOutput extends PaymentProviderOutput {}

/**
* @interface
*
* The result of deleting an account holder in the third-party payment provider.
*/
export type DeleteAccountHolderOutput = PaymentProviderOutput
export interface DeleteAccountHolderOutput extends PaymentProviderOutput {}

/**
* @interface
*
* The result of listing payment methods for an account holder in the third-party payment provider.
*/
export type ListPaymentMethodsOutput = (PaymentProviderOutput & {
export interface ListPaymentMethodsOutput extends Array<PaymentProviderOutput & {
/**
* The ID of the payment method in the payment provider.
*/
id: string
})[]
}> {}

/**
* @interface
*
* The result of saving a payment method.
*/
export type SavePaymentMethodOutput = PaymentProviderOutput & {
export interface SavePaymentMethodOutput extends PaymentProviderOutput {
/**
* The ID of the payment method in the payment provider.
*/
id: string
}

/**
* @interface
*
* The result of getting the payment status.
*/
export type GetPaymentStatusOutput = PaymentProviderOutput & {
export interface GetPaymentStatusOutput extends PaymentProviderOutput {
/**
* The status of the payment, which will be stored in the payment session's `status` field.
*/
Expand Down

0 comments on commit 698a520

Please sign in to comment.