Skip to content

Commit

Permalink
AD-291: Fixes for payment methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kpieloch committed Dec 6, 2024
1 parent d329895 commit efb071b
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 68 deletions.
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 @@ -126,7 +126,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 @@ -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 @@ -115,7 +115,6 @@ class PaymentComponentFactory {
}).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 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 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 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 AdeynWeb.AmazonPay(this.checkout,componentConfiguration);
try {
adyenComponent.mount(amazonPayNode);
} catch (e) {
Expand Down Expand Up @@ -411,7 +409,7 @@ class PaymentComponentFactory {
}

createAfterPay(countryCode) {
this.afterPay = this.checkout.create("afterpay_default", {
this.afterPay = new AdynWeb.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,6 +572,10 @@ 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');
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
* Populate TaxValues into the OrderEntryData object.
* This data is needed for OpenInvoice Payment Methods
*/
public class TaxValuesOrderEntryPopulator extends OrderEntryPopulator {
public class AdyenOrderEntryPopulator extends OrderEntryPopulator {

@Override
public void populate(@Nonnull final AbstractOrderEntryModel source, @Nonnull final OrderEntryData target)
{
target.setTaxValues(source.getTaxValues());
target.setUnitOfMeasure(source.getUnit().getName());
}
}
Loading

0 comments on commit efb071b

Please sign in to comment.