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

AD-291: Fixes for payment methods #485

Merged
merged 2 commits into from
Dec 10, 2024
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 @@ -24,7 +24,7 @@

<c:set var="VERSION" value="6.1.1"/>
<c:set var="jsHashVersion" value="sha384-ooyykkiG6hsCD+b97FrD/yvSSA4BHJv4I1mvz4KJEaAyJufGfooKzuLVotjKsEpP"/>
<c:set var="cssHashVersion" value="sha384-zgFNrGzbwuX5qJLys75cOUIGru/BoEzhGMyC07I3OSdHqXuhUfoDPVG03G+61oF4"/>
<c:set var="cssHashVersion" value="sha384-1DZgt5aKWxwX2jnOKDDpfVq8XQpnsaAr+tC/WMxeLx61TpRuPTKpo6Bo+uHboQTo"/>

<c:if test="${not empty(dfUrl)}">
<script type="text/javascript" src="${dfUrl}"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<spring:url value="/checkout/multi/termsAndConditions" var="getTermsAndConditionsUrl"/>

<c:set var="componentsWithPayButton"
value="[amazonpay],[applepay],[paypal],[paywithgoogle],[googlepay],[pix],[bcmc_mobile],[upi]"/>
value="[amazonpay],[applepay],[paypal],[paywithgoogle],[googlepay],[pix],[bcmc_mobile],[upi],[paysafecard]"/>
<c:set var="componentPaymentMethod" value="[${selectedPaymentMethod}]" />

<%-- Components --%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@
</json:object>
</c:set>

const { AdyenCheckout, Dropin, Card, PayPal, GooglePay,
ApplePay, CashAppPay, Sepa,Redirect,OnlineBankingIN,
OnlineBankingPL, Ideal, EPS, Pix, WalletIN, AfterPay, Bcmc,
Pos, PayBright, Boleto, SepaDirectDebit, RatePay, Paytm,Giftcard,Blik
} = AdyenWeb;

const initConfig = ${initConfig};
const callbackConfig = ${callbackConfig};
const paymentMethodConfigs = {};
Expand Down Expand Up @@ -126,7 +120,7 @@

<%-- API only payments methods --%>
<c:otherwise>
paymentMethodConfigs['createPayment'] = {
paymentMethodConfigs['createRedirectPaymentMethod'] = {
...callbackConfig,
paymentType: "${selectedPaymentMethod}"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@
showDefaultCss="${true}"
/>
<script type="text/javascript">

const { AdyenCheckout, Dropin, Card, PayPal, GooglePay,
ApplePay, CashAppPay, Sepa,Redirect,OnlineBankingIN,
OnlineBankingPL, Ideal, EPS, Pix, WalletIN, AfterPay, Bcmc,
Pos, PayBright, Boleto, SepaDirectDebit, RatePay, Paytm,Giftcard,Blik
} = AdyenWeb;

<c:if test="${not empty allowedCards}">
//Set the allowed cards
const allowedCards = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class AdyenCheckoutHelper {
},
};
console.log("Execution of initiateCheckout: ", this.i++);
this.checkout = await AdyenCheckout(configuration);
this.checkout = await AdyenWeb.AdyenCheckout(configuration);
this.factory = new PaymentComponentFactory(this.checkout, this);
this.factory.createFromConfigs(paymentMethodConfigs);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PaymentComponentFactory {
},
onError: (error, component) => {
console.log('Something went wrong trying to make the Gift Card payment: ' + error);
this.helper.handleResult(ErrorMessages.PaymentError, true);
this.helper.handleResult({resultCode: ErrorMessages.PaymentError}, true);
}
};
}
Expand Down Expand Up @@ -55,7 +55,7 @@ class PaymentComponentFactory {
context.selectedCardBrand = event.brand;
}

this.helper.card = new Card(this.checkout, {
this.helper.card = new AdyenWeb.Card(this.checkout, {
showPayButton: false,
type: 'card',
hasHolderName: true,
Expand All @@ -71,7 +71,7 @@ class PaymentComponentFactory {
if (storedCardList && storedCardList.length) {
for (const storedCard of storedCardList) {
const oneClickCardNode = document.getElementById("one-click-card_" + storedCard.storedPaymentMethodId);
const oneClickCard = new Card(this.checkout, {
const oneClickCard = new AdyenWeb.Card(this.checkout, {
showPayButton: false,
storedPaymentMethods: storedCard,
}).mount(oneClickCardNode);
Expand All @@ -93,7 +93,7 @@ class PaymentComponentFactory {
sepaIbanNumberField.value = sepaIbanNumber;
}

this.helper.sepaDirectDebit = new Sepa(this.checkout, {
this.helper.sepaDirectDebit = new AdyenWeb.Sepa(this.checkout, {
showPayButton: false,
onChange: handleOnChange
}).mount('#adyen_hpp_sepadirectdebit_container')
Expand All @@ -109,13 +109,12 @@ class PaymentComponentFactory {
}

createEps(epsDetails) {
const eps = new EPS(this.checkout, {
const eps = new AdyenWeb.EPS(this.checkout, {
issuers: epsDetails, // The array of issuers coming from the /paymentMethods api call
onChange: this.handleOnChange // Gets triggered once the shopper selects an issuer
}).mount('#adyen_hpp_eps_container');
}

// TODO: to check
createUPI() {
const label = this.getVisibleLabel();
const uPINode = document.getElementById('adyen-component-button-container-' + label);
Expand All @@ -134,7 +133,7 @@ class PaymentComponentFactory {
window.location.href = ACC.config.encodedContextPath + "/" + data.replace("redirect:/", "");
} catch (e) {
console.log('Error redirecting the user to the placeOrder page');
this.helper.handleResult(ErrorMessages.PaymentError, true);
this.helper.handleResult({resultCode: ErrorMessages.PaymentError}, true);
}
},
error: (xmlHttpResponse, exception) => {
Expand All @@ -143,14 +142,14 @@ class PaymentComponentFactory {
this.helper.handleResult(responseMessage, true);
} else {
console.log('Error on handling the redirect to the placeOrder page: ' + responseMessage);
this.helper.handleResult(ErrorMessages.PaymentError, true);
this.helper.handleResult({resultCode: ErrorMessages.PaymentError}, true);
}
}
})
}


let upi = this.checkout.create('upi', {
new UPI({
onPaymentCompleted: handlePaymentResult,
defaultMode: 'vpa',
showPayButton: true,
Expand All @@ -159,7 +158,7 @@ class PaymentComponentFactory {

createPaypal(params) {
const {amount, isImmediateCapture, paypalMerchantId, label} = params;
const paypal = new PayPal(this.checkout, {
const paypal = new AdyenWeb.PayPal(this.checkout, {
style: { // Optional configuration for PayPal payment buttons.
layout: "vertical",
color: "gold"
Expand Down Expand Up @@ -206,14 +205,14 @@ class PaymentComponentFactory {
},
onCancel: (data, component) => {
// Sets your prefered status of the component when a PayPal payment is cancelled.
this.helper.handleResult(ErrorMessages.PaymentCancelled, true);
this.helper.handleResult({resultCode: ErrorMessages.PaymentCancelled}, true);
},
onError: (error, component) =>{
// Sets your prefered status of the component when an error occurs.
if (error.name === 'CANCEL') {
this.helper.handleResult(ErrorMessages.PaymentCancelled, true);
this.helper.handleResult({resultCode: ErrorMessages.PaymentCancelled}, true);
} else {
this.helper.handleResult(ErrorMessages.PaymentError, true);
this.helper.handleResult({resultCode: ErrorMessages.PaymentError}, true);
}
},
onAdditionalDetails: (state, component) => {
Expand All @@ -232,7 +231,7 @@ class PaymentComponentFactory {
resolve();
} else {
reject();
this.helper.handleResult(ErrorMessages.TermsNotAccepted, true);
this.helper.handleResult({resultCode: ErrorMessages.TermsNotAccepted}, true);
}
// Your server uses the validation URL to request a session from the Apple Pay server.
// Call resolve(MERCHANTSESSION) or reject() to complete merchant validation.
Expand All @@ -248,7 +247,7 @@ class PaymentComponentFactory {
console.log(validationURL, reject, resolve);
}
};
const adyenComponent = new ApplePay(this.checkout, {
const adyenComponent = new AdyenWeb.ApplePay(this.checkout, {
amount: {
currency: amount.currency,
value: amount.value
Expand Down Expand Up @@ -278,7 +277,7 @@ class PaymentComponentFactory {
resolve();
} else {
reject();
this.helper.handleResult(ErrorMessages.TermsNotAccepted, true);
this.helper.handleResult({resultCode: ErrorMessages.TermsNotAccepted}, true);
}
}
}).mount('adyen-component-button-container-' + label);
Expand All @@ -290,14 +289,14 @@ class PaymentComponentFactory {
.catch( (e) => {
// Apple Pay is not available
console.log('Something went wrong trying to mount the Apple Pay component: ' + e);
this.helper.handleResult(ErrorMessages.PaymentNotAvailable, true);
this.helper.handleResult({resultCode: ErrorMessages.PaymentNotAvailable}, true);
});
}

createGooglePay(params) {
const {amount, merchantAccount, label} = params;
const googlePayNode = document.getElementById('adyen-component-button-container-' + label);
const adyenComponent = this.checkout.create("paywithgoogle", {
const adyenComponent = new AdyenWeb.GooglePay (this.checkout, {
environment: this.checkout.options.environment,
amount: {
currency: amount.currency,
Expand All @@ -310,23 +309,23 @@ class PaymentComponentFactory {
buttonColor: "white",
onChange: (state, component) => {
if (!state.isValid) {
this.helper.helper.hideSpinner();
this.helper.hideSpinner();
}
},
onSubmit: (state, component) => {
if (!state.isValid) {
this.helper.helper.hideSpinner();
this.helper.hideSpinner();
return false;
}
this.helper.helper.showSpinner();
this.helper.helper.makePayment(state.data, component, this.helper.handleResult, label);
this.helper.showSpinner();
this.helper.makePayment(state.data, component, this.helper.handleResult, label);
},
onClick: (resolve, reject) => {
if (this.helper.helper.isTermsAccepted(label)) {
if (this.helper.isTermsAccepted(label)) {
resolve();
} else {
reject();
this.helper.helper.handleResult(ErrorMessages.TermsNotAccepted, true);
this.helper.handleResult({resultCode: ErrorMessages.TermsNotAccepted}, true);
}
}
});
Expand All @@ -338,11 +337,10 @@ class PaymentComponentFactory {
.catch( (e) => {
// Google Pay is not available
console.log('Something went wrong trying to mount the Google Pay component: ' + e);
this.helper.handleResult(ErrorMessages.PaymentNotAvailable, true);
this.helper.handleResult({resultCode: ErrorMessages.PaymentNotAvailable }, true);
});
}

// TODO: to check
createAmazonPay(params) {
const {amount, deliveryAddress, amazonPayConfiguration, locale} = params;
const label = this.getVisibleLabel();
Expand Down Expand Up @@ -382,7 +380,7 @@ class PaymentComponentFactory {
}
};
const amazonPayNode = document.getElementById('adyen-component-button-container-' + label);
const adyenComponent = this.checkout.create("amazonpay", componentConfiguration);
const adyenComponent = new AdyenWeb.AmazonPay(this.checkout,componentConfiguration);
try {
adyenComponent.mount(amazonPayNode);
} catch (e) {
Expand All @@ -393,25 +391,25 @@ class PaymentComponentFactory {

createMbway(params) {
const {label} = params;
const adyenComponent = new MBWay(this.checkout, this.paymentConfiguration(label)).mount('#adyen-component-container-' + label);
const adyenComponent = new AdyenWeb.MBWay(this.checkout, this.paymentConfiguration(label)).mount('#adyen-component-container-' + label);
this.helper.configureButton(adyenComponent, false, label);
}

createBlik(params) {
const {label} = params;
const adyenComponent = new Blik(this.checkout, this.paymentConfiguration(label)).mount('#adyen-component-container-' + label);
const adyenComponent = new AdyenWeb.Blik(this.checkout, this.paymentConfiguration(label)).mount('#adyen-component-container-' + label);
this.helper.configureButton(adyenComponent, false, label);
}

createGiftCard (params) {
const {label} = params;
const adyenComponent = new Giftcard(this.checkout, this.paymentConfiguration(label)).mount('#adyen-component-container-' + label);;
const adyenComponent = new AdyenWeb.Giftcard(this.checkout, this.paymentConfiguration(label)).mount('#adyen-component-container-' + label);;
this.helper.configureButton(adyenComponent, false, label);

}

createAfterPay(countryCode) {
this.afterPay = this.checkout.create("afterpay_default", {
this.afterPay = new AdyenWeb.AfterPay(this.checkout, {
countryCode: countryCode,
visibility: { // Optional configuration
personalDetails: "editable",
Expand All @@ -430,31 +428,31 @@ class PaymentComponentFactory {
createPix(params) {
const {label, issuers} = params;
$("#generateqr-" + label).click( () => {
this.helper.helper.showSpinner();
if (!this.helper.helper.isTermsAccepted(label)) {
this.helper.helper.handleResult(ErrorMessages.TermsNotAccepted, true)
this.helper.showSpinner();
if (!this.helper.isTermsAccepted(label)) {
this.helper.handleResult({resultCode: ErrorMessages.TermsNotAccepted}, true)
} else {
$("#generateqr-" + label).hide();
$(".checkbox").hide();
var actionHandler = {
handleAction: (action) => {
this.helper.helper.checkout.createFromAction(action, { //TODO FXIME: check if this is correct
this.helper.checkout.createFromAction(action, { //TODO FXIME: check if this is correct
issuers: issuers,
onAdditionalDetails: (state) => {
this.helper.helper.hideSpinner();
this.helper.helper.submitDetails(state.data, this.helper.helper.handleResult);
this.helper.hideSpinner();
this.helper.submitDetails(state.data, this.helper.handleResult);
}
}).mount('#qrcode-container-' + label);
this.helper.helper.hideSpinner();
this.helper.hideSpinner();
}
};
this.helper.helper.makePayment({type: "pix"}, actionHandler, this.helper.helper.handleResult, label);
this.helper.makePayment({type: "pix"}, actionHandler, this.helper.handleResult, label);
}
});
}

createBcmc() {
this.bcmc = this.checkout.create("bcmc", {
this.bcmc = new AdyenWeb.BCMC(this.checkout, {
hasHolderName: true,
holderNameRequired: true
});
Expand All @@ -471,7 +469,7 @@ class PaymentComponentFactory {
$("#generateqr-" + label).click( () => {
this.helper.showSpinner();
if (!this.helper.isTermsAccepted(label)) {
this.helper.handleResult(ErrorMessages.TermsNotAccepted, true)
this.helper.handleResult({resultCode: ErrorMessages.TermsNotAccepted}, true)
} else {
$("#generateqr-" + label).hide();
$(".checkbox").hide();
Expand Down Expand Up @@ -503,7 +501,7 @@ class PaymentComponentFactory {
let termsCheck = document.getElementById('terms-conditions-check-' + label).checked

if (termsCheck === false) {
this.helper.handleResult(ErrorMessages.TermsNotAccepted, true);
this.helper.handleResult({resultCode: ErrorMessages.TermsNotAccepted}, true);
return;
}

Expand Down Expand Up @@ -574,13 +572,17 @@ class PaymentComponentFactory {
.mount("#adyen_hpp_ideal_container");
}

createRedirectPaymentMethod(paymentMethod) {
new Redirect(this.checkout, {type: paymentMethod.paymentType, onChange: this.handleOnChange}).mount('#adyen-component-button-container-' + paymentMethod.label);
}

initiateWalletIN() {
new Redirect(this.checkout, {type: 'wallet_IN', onChange: this.handleOnChange
}).mount('#adyen_hpp_wallet_IN_container');
}

initiatePaytm() {
const paytm = new Redirect(this.checkout, {type: 'paytm', onChange: this.handleOnChange}).mount('#adyen_hpp_paytm_container');
const paytm = new AdyenWeb.Redirect(this.checkout, {type: 'paytm', onChange: this.handleOnChange}).mount('#adyen_hpp_paytm_container');
}

// Helper methods
Expand Down
2 changes: 1 addition & 1 deletion adyenv6core/resources/adyenv6core-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@

<bean id="adyenCreateOrderFromCartStrategy" class="com.adyen.v6.impl.order.strategies.AdyenCreateOrderFromCartStrategy" parent="defaultCreateOrderFromCartStrategy" />

<bean id="adyenOrderEntryPopulator" class="com.adyen.v6.populator.TaxValuesOrderEntryPopulator" parent="defaultOrderEntryPopulator" />
<bean id="adyenOrderEntryPopulator" class="com.adyen.v6.populator.AdyenOrderEntryPopulator" parent="defaultOrderEntryPopulator" />

<alias name="adyenOrderCancelPopulator" alias="orderCancelPopulator"/>
<bean id="adyenOrderCancelPopulator" parent="defaultOrderCancelPopulator"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,10 @@ protected void updateOrderPaymentStatusAndInfo(OrderModel orderModel, PaymentDet
}

if (PaymentDetailsResponse.ResultCodeEnum.AUTHORISED == paymentDetailsResponse.getResultCode() || PaymentDetailsResponse.ResultCodeEnum.RECEIVED == paymentDetailsResponse.getResultCode()) {
//remove PAYMENT_PENDING status, will be processed by order management
LOGGER.info("Removing PAYMENT_PENDING status, will be processed by order management");
//PAYMENT_PENDING status, will be processed by order management
LOGGER.info("PAYMENT_PENDING status, will be processed by order management");

orderModel.setStatus(null);
orderModel.setStatusInfo(null);
orderModel.setStatus(OrderStatus.PAYMENT_PENDING);
} else {
//payment was not authorised, cancel pending order
LOGGER.warn("Payment was not authorised, cancel pending order");
Expand Down
Loading
Loading