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:
Sebastian Rindom
2020-10-06 18:26:09 +02:00
parent 96d2235192
commit 1f3cbe7bf1
2 changed files with 3 additions and 32 deletions

View File

@@ -462,35 +462,6 @@ class BrightpearlService extends BaseService {
)
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) => {
return this.orderService_.setMetadata(
fromOrder._id,
@@ -500,7 +471,7 @@ class BrightpearlService extends BaseService {
})
}
async createCapturedPayment(fromOrder) {
async createPayment(fromOrder) {
const client = await this.getClient()
const soId =
fromOrder.metadata && fromOrder.metadata.brightpearl_sales_order_id
@@ -508,7 +479,7 @@ class BrightpearlService extends BaseService {
return
}
const paymentType = "CAPTURE"
const paymentType = "RECEIPT"
const paymentMethod = fromOrder.payment_method
const payment = {
transactionRef: `${paymentMethod._id}.${paymentType}`, // Brightpearl cannot accept an auth and capture with same ref

View File

@@ -22,7 +22,7 @@ class OrderSubscriber {
}
registerCapturedPayment = (order) => {
return this.brightpearlService_.createCapturedPayment(order)
return this.brightpearlService_.createPayment(order)
}
registerShipment = async (data) => {