Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing payment instrument case is breaking jobs #894

Merged
merged 1 commit into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ module.exports = {
METHOD_ADYEN_POS: 'AdyenPOS',
METHOD_ADYEN_COMPONENT: 'AdyenComponent',
METHOD_CREDIT_CARD: 'CREDIT_CARD',

PAYMENT_INSTRUMENT_ADYEN_CREDIT: 'ADYEN_CREDIT',
PAYMENT_INSTRUMENT_ADYEN_POS: 'Adyen_POS',
PAYMENT_INSTRUMENT_ADYEN_COMPONENT: 'Adyen_Component',

// Possible checkout result codes
RESULTCODES: {
AUTHORISED: 'Authorised',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,34 @@ function handle(customObj) {
if (orderCreateDateDelay < currentDate) {
switch (customObj.custom.eventCode) {
case 'AUTHORISATION':
// Check if one of the adyen payment methods was used during payment
// Or if the payment method belongs to adyen payment processors
const paymentInstruments = order.getPaymentInstruments();
let adyenPaymentInstrument = null;
// Move adyen log request to order payment transaction
for (const pi in paymentInstruments) {
if (
[
constants.METHOD_ADYEN,
constants.METHOD_ADYEN_POS,
constants.METHOD_ADYEN_COMPONENT,
constants.METHOD_CREDIT_CARD,
].indexOf(paymentInstruments[pi].paymentMethod) !== -1 ||
PaymentMgr.getPaymentMethod(
[
constants.PAYMENT_INSTRUMENT_ADYEN_CREDIT,
constants.PAYMENT_INSTRUMENT_ADYEN_POS,
constants.PAYMENT_INSTRUMENT_ADYEN_COMPONENT,
].indexOf(PaymentMgr.getPaymentMethod(
paymentInstruments[pi].getPaymentMethod(),
).getPaymentProcessor().ID === 'ADYEN_CREDIT'
).getPaymentProcessor().ID) !== -1
) {
isAdyen = true;
// Move adyen log request to order payment transaction
paymentInstruments[pi].paymentTransaction.custom.Adyen_log =
customObj.custom.Adyen_log;
adyenPaymentInstrument = paymentInstruments[pi];
}
}
if (customObj.custom.success === 'true') {
if (customObj.custom.success === 'true' && adyenPaymentInstrument) {
const amountPaid = parseFloat(order.custom.Adyen_value) + parseFloat(customObj.custom.value);
const totalAmount = adyenHelper.getCurrencyValueForApi(adyenPaymentInstrument.getPaymentTransaction().getAmount()).value;
if (order.paymentStatus.value === Order.PAYMENT_STATUS_PAID) {
Expand Down Expand Up @@ -287,8 +294,7 @@ function handle(customObj) {
}

function setProcessedCOInfo(customObj) {
const now = new Date();
customObj.custom.processedDate = now;
customObj.custom.processedDate = new Date();
customObj.custom.updateStatus = 'SUCCESS';
customObj.custom.processedStatus = 'SUCCESS';
}
Expand Down