hotfix(medusa-plugin-brightpearl): remove AUTH/CAPTURE
Removes the AUTH/CAPTURE flow; as it creates an issue when a user wants to delete an authorized order. The order will at that point have a payment and can thereby not be deleted. By simply using the RECEIPT payment type we avoid this issue and make it possible to do extended authorization periods.
This commit is contained in:
1 parent
96d2235192
commit
1f3cbe7bf1
2 files changed
+3
-32
No files matched your search
@@ -462,35 +462,6 @@ class BrightpearlService extends BaseService {
|
|||||||
)
|
)
|
||||||
return salesOrderId
|
return salesOrderId
|
||||||
})
|
})
|
||||||
.then(async (salesOrderId) => {
|
|
||||||
const paymentMethod = fromOrder.payment_method
|
|
||||||
const paymentType = "AUTH"
|
|
||||||
const payment = {
|
|
||||||
transactionRef: `${paymentMethod._id}.${paymentType}`, // Brightpearl cannot accept an auth and capture with same ref
|
|
||||||
transactionCode: fromOrder._id,
|
|
||||||
paymentMethodCode: this.options.payment_method_code || "1220",
|
|
||||||
orderId: salesOrderId,
|
|
||||||
currencyIsoCode: fromOrder.currency_code,
|
|
||||||
paymentDate: new Date(),
|
|
||||||
paymentType,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only if authorization type
|
|
||||||
if (paymentType === "AUTH") {
|
|
||||||
const today = new Date()
|
|
||||||
const authExpire = today.setDate(today.getDate() + 7)
|
|
||||||
payment.amountAuthorized = await this.totalsService_.getTotal(
|
|
||||||
fromOrder
|
|
||||||
)
|
|
||||||
payment.authorizationExpiry = new Date(authExpire)
|
|
||||||
} else {
|
|
||||||
// For captured
|
|
||||||
}
|
|
||||||
|
|
||||||
await client.payments.create(payment)
|
|
||||||
|
|
||||||
return salesOrderId
|
|
||||||
})
|
|
||||||
.then((salesOrderId) => {
|
.then((salesOrderId) => {
|
||||||
return this.orderService_.setMetadata(
|
return this.orderService_.setMetadata(
|
||||||
fromOrder._id,
|
fromOrder._id,
|
||||||
@@ -500,7 +471,7 @@ class BrightpearlService extends BaseService {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async createCapturedPayment(fromOrder) {
|
async createPayment(fromOrder) {
|
||||||
const client = await this.getClient()
|
const client = await this.getClient()
|
||||||
const soId =
|
const soId =
|
||||||
fromOrder.metadata && fromOrder.metadata.brightpearl_sales_order_id
|
fromOrder.metadata && fromOrder.metadata.brightpearl_sales_order_id
|
||||||
@@ -508,7 +479,7 @@ class BrightpearlService extends BaseService {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const paymentType = "CAPTURE"
|
const paymentType = "RECEIPT"
|
||||||
const paymentMethod = fromOrder.payment_method
|
const paymentMethod = fromOrder.payment_method
|
||||||
const payment = {
|
const payment = {
|
||||||
transactionRef: `${paymentMethod._id}.${paymentType}`, // Brightpearl cannot accept an auth and capture with same ref
|
transactionRef: `${paymentMethod._id}.${paymentType}`, // Brightpearl cannot accept an auth and capture with same ref
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class OrderSubscriber {
|
|||||||
}
|
}
|
||||||
|
|
||||||
registerCapturedPayment = (order) => {
|
registerCapturedPayment = (order) => {
|
||||||
return this.brightpearlService_.createCapturedPayment(order)
|
return this.brightpearlService_.createPayment(order)
|
||||||
}
|
}
|
||||||
|
|
||||||
registerShipment = async (data) => {
|
registerShipment = async (data) => {
|
||||||
|
|||||||
Reference in new issue
Block a user