Skip to content

Commit

Permalink
[SFI-525] Apple pay donations are enabled (#1026)
Browse files Browse the repository at this point in the history
  • Loading branch information
zenit2001 authored Dec 14, 2023
1 parent d57438f commit b747967
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 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 @@ -42,14 +42,18 @@ function donate(donationReference, donationAmount, orderToken) {
const donationToken = paymentInstrument.paymentTransaction.custom.Adyen_donationToken;
const originalReference = paymentInstrument.paymentTransaction.custom.Adyen_pspReference;
const paymentData = JSON.parse(paymentInstrument.paymentTransaction.custom.Adyen_log);
const paymentCurrency = paymentData.amount.currency;
const paymentCurrency = paymentData.amount.currency || paymentData.fullResponse?.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 b747967

Please sign in to comment.