chore(medusa): Migrate payment collection repository api (#3724)
* chore(medusa): Migrate payment repository api * Create fresh-ties-hide.md
This commit is contained in:
committed by
GitHub
parent
eab2d22f7d
commit
60abb91b7c
5
.changeset/fresh-ties-hide.md
Normal file
5
.changeset/fresh-ties-hide.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/medusa": patch
|
||||
---
|
||||
|
||||
chore(medusa): Migrate payment repository api
|
||||
@@ -1,27 +1,26 @@
|
||||
import { MedusaError } from "medusa-core-utils"
|
||||
import { PaymentCollection } from "./../models/payment-collection"
|
||||
import { FindConfig } from "../types/common"
|
||||
import { PaymentCollection } from "../models"
|
||||
import { dataSource } from "../loaders/database"
|
||||
import { FindManyOptions } from "typeorm"
|
||||
|
||||
export const PaymentCollectionRepository = dataSource
|
||||
.getRepository(PaymentCollection)
|
||||
.extend({
|
||||
async getPaymentCollectionIdBySessionId(
|
||||
sessionId: string,
|
||||
config: FindConfig<PaymentCollection> = {}
|
||||
config: FindManyOptions<PaymentCollection> = {}
|
||||
): Promise<PaymentCollection> {
|
||||
const paymentCollection = await this.find({
|
||||
join: {
|
||||
alias: "payment_col",
|
||||
innerJoin: { payment_sessions: "payment_col.payment_sessions" },
|
||||
},
|
||||
where: {
|
||||
payment_sessions: {
|
||||
id: sessionId,
|
||||
},
|
||||
},
|
||||
relations: config.relations,
|
||||
select: config.select,
|
||||
relations: {
|
||||
...(config.relations ?? {}),
|
||||
payment_sessions: true,
|
||||
},
|
||||
select: config.select ?? {},
|
||||
})
|
||||
|
||||
if (!paymentCollection.length) {
|
||||
@@ -36,20 +35,19 @@ export const PaymentCollectionRepository = dataSource
|
||||
|
||||
async getPaymentCollectionIdByPaymentId(
|
||||
paymentId: string,
|
||||
config: FindConfig<PaymentCollection> = {}
|
||||
config: FindManyOptions<PaymentCollection> = {}
|
||||
): Promise<PaymentCollection> {
|
||||
const paymentCollection = await this.find({
|
||||
join: {
|
||||
alias: "payment_col",
|
||||
innerJoin: { payments: "payment_col.payments" },
|
||||
},
|
||||
where: {
|
||||
payments: {
|
||||
id: paymentId,
|
||||
},
|
||||
},
|
||||
relations: config.relations,
|
||||
select: config.select,
|
||||
relations: {
|
||||
...(config.relations ?? {}),
|
||||
payment_sessions: true,
|
||||
},
|
||||
select: config.select ?? {},
|
||||
})
|
||||
|
||||
if (!paymentCollection.length) {
|
||||
|
||||
@@ -417,11 +417,12 @@ export default class PaymentCollectionService extends TransactionBaseService {
|
||||
await paymentCollectionRepository.getPaymentCollectionIdBySessionId(
|
||||
sessionId,
|
||||
{
|
||||
relations: [
|
||||
"region",
|
||||
"region.payment_providers",
|
||||
"payment_sessions",
|
||||
],
|
||||
relations: {
|
||||
region: {
|
||||
payment_providers: true,
|
||||
},
|
||||
payment_sessions: true,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user