feat: Remove fields from payment models that were leftovers from v1 (#10987)

This commit is contained in:
Stevche Radevski
2025-01-16 10:10:03 +01:00
committed by GitHub
parent 8cd58b3092
commit da8e173974
16 changed files with 37 additions and 287 deletions
@@ -9,13 +9,6 @@ import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"
* The details of the payment collections to create.
*/
export type CreatePaymentCollectionCartStepInput = {
/**
* The ID of the region that the payment collection belongs to.
*/
region_id: string
/**
* The payment collection's curency code.
*/
currency_code: string
/**
* The payment collection's amount.
@@ -30,10 +23,9 @@ export type CreatePaymentCollectionCartStepInput = {
export const createPaymentCollectionsStepId = "create-payment-collections"
/**
* This step creates payment collections in a cart.
*
*
* @example
* const data = createPaymentCollectionsStep([{
* "region_id": "region_123",
* "currency_code": "usd",
* "amount": 40
* }])
@@ -28,13 +28,13 @@ export type ValidateExistingPaymentCollectionStepInput = {
/**
* This step validates that a cart doesn't have a payment collection.
* If the cart has a payment collection, the step throws an error.
*
*
* :::tip
*
*
* You can use the {@link retrieveCartStep} to retrieve a cart's details.
*
*
* :::
*
*
* @example
* const data = validateExistingPaymentCollectionStep({
* cart: {
@@ -58,11 +58,11 @@ export const validateExistingPaymentCollectionStep = createStep(
export const createPaymentCollectionForCartWorkflowId =
"create-payment-collection-for-cart"
/**
* This workflow creates a payment collection for a cart. It's executed by the
* This workflow creates a payment collection for a cart. It's executed by the
* [Create Payment Collection Store API Route](https://docs.medusajs.com/api/store#payment-collections_postpaymentcollections).
*
*
* You can use this workflow within your own custom workflows, allowing you to wrap custom logic around adding creating a payment collection for a cart.
*
*
* @example
* const { result } = await createPaymentCollectionForCartWorkflow(container)
* .run({
@@ -73,9 +73,9 @@ export const createPaymentCollectionForCartWorkflowId =
* }
* }
* })
*
*
* @summary
*
*
* Create payment collection for cart.
*/
export const createPaymentCollectionForCartWorkflow = createWorkflow(
@@ -87,7 +87,6 @@ export const createPaymentCollectionForCartWorkflow = createWorkflow(
entry_point: "cart",
fields: [
"id",
"region_id",
"completed_at",
"currency_code",
"total",
@@ -106,10 +105,8 @@ export const createPaymentCollectionForCartWorkflow = createWorkflow(
const paymentData = transform({ cart }, ({ cart }) => {
return {
cart_id: cart.id,
currency_code: cart.currency_code,
amount: cart.raw_total,
region_id: cart.region_id,
}
})
@@ -108,7 +108,6 @@ export const refreshPaymentCollectionForCartWorkflow = createWorkflow(
update: {
amount: cart.total,
currency_code: cart.currency_code,
region_id: cart.region_id,
},
}
})
@@ -63,7 +63,6 @@ export const createOrderPaymentCollectionWorkflow = createWorkflow(
return {
currency_code: order.currency_code,
amount: input.amount,
region_id: order.region_id,
}
}
)
@@ -43,11 +43,6 @@ export interface BasePaymentCollection {
*/
currency_code: string
/**
* The id of the associated region.
*/
region_id: string
/**
* The total amount to be authorized and captured.
*/
@@ -141,26 +136,6 @@ export interface BasePayment {
*/
provider_id: string
/**
* The ID of the associated cart.
*/
cart_id?: string
/**
* The ID of the associated order.
*/
order_id?: string
/**
* The ID of the associated order edit.
*/
order_edit_id?: string
/**
* The ID of the associated customer.
*/
customer_id?: string
/**
* The data relevant for the payment provider to process the payment.
*/
+1 -56
View File
@@ -32,11 +32,6 @@ export interface PaymentCollectionDTO {
*/
currency_code: string
/**
* The id of the associated region.
*/
region_id: string
/**
* The total amount to be authorized and captured.
*/
@@ -114,11 +109,6 @@ export interface FilterablePaymentCollectionProps
*/
id?: string | string[]
/**
* Filter by associated region's ID.
*/
region_id?: string | string[] | OperatorMap<string>
/**
* Filter payment collections by created date.
*/
@@ -160,11 +150,6 @@ export interface FilterablePaymentSessionProps
*/
payment_collection_id?: string | string[]
/**
* Filter the payment sessions by the ID of their associated region.
*/
region_id?: string | string[] | OperatorMap<string>
/**
* Filter the payment sessions by their creation date.
*/
@@ -297,26 +282,6 @@ export interface PaymentDTO {
*/
provider_id: string
/**
* The ID of the associated cart.
*/
cart_id?: string
/**
* The ID of the associated order.
*/
order_id?: string
/**
* The ID of the associated order edit.
*/
order_edit_id?: string
/**
* The ID of the associated customer.
*/
customer_id?: string
/**
* The data relevant for the payment provider to process the payment.
*/
@@ -402,7 +367,7 @@ export interface PaymentDTO {
export interface FilterablePaymentProps
extends BaseFilterable<FilterablePaymentProps> {
/**
* Find payments based on cart, order, or customer IDs through this search term.
* Find payments based on different fields.
*/
q?: string
@@ -416,26 +381,6 @@ export interface FilterablePaymentProps
*/
payment_session_id?: string | string[] | OperatorMap<string>
/**
* Filter the payments by the ID of their associated customer.
*/
customer_id?: string | string[] | OperatorMap<string>
/**
* Filter the payments by the ID of their associated cart.
*/
cart_id?: string | string[] | OperatorMap<string>
/**
* Filter the payments by the ID of their associated order.
*/
order_id?: string | string[] | OperatorMap<string>
/**
* Filter the payments by the ID of their associated order edit.
*/
order_edit_id?: string | string[] | OperatorMap<string>
/**
* Filter the payments by their creation date.
*/
@@ -6,11 +6,6 @@ import { PaymentProviderContext } from "./provider"
* The payment collection to be created.
*/
export interface CreatePaymentCollectionDTO {
/**
* The associated region's ID.
*/
region_id: string
/**
* The ISO 3 character currency code of the payment collection.
*/
@@ -47,11 +42,6 @@ export interface UpsertPaymentCollectionDTO {
*/
id?: string
/**
* The associated region's ID.
*/
region_id?: string
/**
* The ISO 3 character currency code of the payment collection.
*/
@@ -72,11 +62,6 @@ export interface UpsertPaymentCollectionDTO {
* The attributes to update in the payment collection.
*/
export interface PaymentCollectionUpdatableFields {
/**
* The associated region's ID.
*/
region_id?: string
/**
* The ISO 3 character currency code of the payment collection.
*/
@@ -131,26 +116,6 @@ export interface CreatePaymentDTO {
* The associated payment collection's ID.
*/
payment_collection_id: string
/**
* The associated cart's ID.
*/
cart_id?: string
/**
* The associated order's ID.
*/
order_id?: string
/**
* The associated order edit's ID.
*/
order_edit_id?: string
/**
* The associated customer's ID.
*/
customer_id?: string
}
/**
@@ -161,26 +126,6 @@ export interface UpdatePaymentDTO {
* The ID of the payment.
*/
id: string
/**
* The associated cart's ID.
*/
cart_id?: string
/**
* The associated order's ID.
*/
order_id?: string
/**
* The associated order edit's ID.
*/
order_edit_id?: string
/**
* The associated customer's ID.
*/
customer_id?: string
}
/**
+3 -8
View File
@@ -50,12 +50,10 @@ export interface IPaymentModuleService extends IModuleService {
* const paymentCollections =
* await paymentModuleService.createPaymentCollections([
* {
* region_id: "reg_123",
* currency_code: "usd",
* amount: 3000,
* },
* {
* region_id: "reg_321",
* currency_code: "eur",
* amount: 2000,
* },
@@ -76,7 +74,6 @@ export interface IPaymentModuleService extends IModuleService {
* @example
* const paymentCollection =
* await paymentModuleService.createPaymentCollections({
* region_id: "reg_123",
* currency_code: "usd",
* amount: 3000,
* })
@@ -300,10 +297,8 @@ export interface IPaymentModuleService extends IModuleService {
* await paymentModuleService.upsertPaymentCollections([
* {
* id: "pay_col_123",
* region_id: "reg_123",
* },
* {
* region_id: "reg_123",
* currency_code: "usd",
* amount: 3000,
* },
@@ -326,7 +321,6 @@ export interface IPaymentModuleService extends IModuleService {
* const paymentCollection =
* await paymentModuleService.upsertPaymentCollections({
* id: "pay_col_123",
* region_id: "reg_123",
* })
*/
upsertPaymentCollections(
@@ -652,7 +646,6 @@ export interface IPaymentModuleService extends IModuleService {
* @example
* const payment = await paymentModuleService.updatePayment({
* id: "pay_123",
* customer_id: "cus_123",
* })
*/
updatePayment(
@@ -1077,7 +1070,9 @@ export interface IPaymentModuleService extends IModuleService {
* })
* ```
*/
getWebhookActionAndData(data: ProviderWebhookPayload): Promise<WebhookActionResult>
getWebhookActionAndData(
data: ProviderWebhookPayload
): Promise<WebhookActionResult>
}
/**