Skip to content

Commit

Permalink
fix: enabled adyen giving for apple pay payments
Browse files Browse the repository at this point in the history
  • Loading branch information
zenit2001 committed Dec 8, 2023
1 parent d57438f commit dbb8b14
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ function handleAuthorised(response, resolveApplePay) {
paymentMethod: response.fullResponse?.paymentMethod
? response.fullResponse.paymentMethod
: response.fullResponse?.additionalData?.paymentMethod,
donationToken: response.fullResponse?.donationToken,
amount: response.fullResponse?.amount,
});
document.querySelector('#showConfirmationForm').submit();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,16 @@ function donate(donationReference, donationAmount, orderToken) {
const paymentData = JSON.parse(paymentInstrument.paymentTransaction.custom.Adyen_log);
const paymentCurrency = paymentData.amount.currency;
const availableDonationAmounts = AdyenHelper.getDonationAmounts();
paymentMethodVariant = paymentInstrument.custom.Adyen_Payment_Method_Variant;
paymentMethodVariant = paymentData.paymentMethod?.type || paymentData.fullResponse?.paymentMethod?.type;

// for iDeal donations, the payment method variant needs to be set to sepadirectdebit
if (paymentMethodVariant === 'ideal') {
paymentMethodVariant = 'sepadirectdebit';
}
// for Apple Pay donations, the payment method variant needs to be the brand
if (paymentMethodVariant === 'applepay'){
paymentMethodVariant = paymentData.paymentMethod?.brand || paymentData.fullResponse?.paymentMethod?.brand;
}
const requestObject = {
merchantAccount: AdyenConfigs.getAdyenMerchantAccount(),
donationAccount: AdyenConfigs.getAdyenGivingCharityAccount(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -683,8 +683,8 @@ var adyenHelperObj = {
? result.resultCode
: '';
order.custom.Adyen_value = '0';
if (result.donationToken){
paymentInstrument.paymentTransaction.custom.Adyen_donationToken = result.donationToken;
if (result.donationToken || result.fullResponse?.donationToken){
paymentInstrument.paymentTransaction.custom.Adyen_donationToken = result.donationToken || result.fullResponse.donationToken;
}
// Save full response to transaction custom attribute
paymentInstrument.paymentTransaction.custom.Adyen_log = JSON.stringify(
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/fixtures/USD.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ for (const environment of environments) {
await checkoutPage.expectRefusal();
});

test('Card payment no 3DS with adyen giving donation success', async () => {
test('Card payment no 3DS with adyen giving donation success @quick', async () => {
await cards.doCardPayment(cardData.noThreeDs);
await checkoutPage.completeCheckout();
await checkoutPage.makeSuccessfulDonation();
Expand Down

0 comments on commit dbb8b14

Please sign in to comment.