Skip to content

Commit

Permalink
AD-291a: Fix for payment methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kpieloch committed Dec 9, 2024
1 parent efb071b commit e4a6fbe
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 31 deletions.
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 @@ -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
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 @@ -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,7 +109,7 @@ 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');
Expand Down Expand Up @@ -158,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 @@ -247,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 @@ -296,7 +296,7 @@ class PaymentComponentFactory {
createGooglePay(params) {
const {amount, merchantAccount, label} = params;
const googlePayNode = document.getElementById('adyen-component-button-container-' + label);
const adyenComponent = new GooglePay (this.checkout, {
const adyenComponent = new AdyenWeb.GooglePay (this.checkout, {
environment: this.checkout.options.environment,
amount: {
currency: amount.currency,
Expand Down Expand Up @@ -380,7 +380,7 @@ class PaymentComponentFactory {
}
};
const amazonPayNode = document.getElementById('adyen-component-button-container-' + label);
const adyenComponent = new AdeynWeb.AmazonPay(this.checkout,componentConfiguration);
const adyenComponent = new AdyenWeb.AmazonPay(this.checkout,componentConfiguration);
try {
adyenComponent.mount(amazonPayNode);
} catch (e) {
Expand All @@ -391,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 = new AdynWeb.AfterPay(this.checkout, {
this.afterPay = new AdyenWeb.AfterPay(this.checkout, {
countryCode: countryCode,
visibility: { // Optional configuration
personalDetails: "editable",
Expand Down Expand Up @@ -582,7 +582,7 @@ class PaymentComponentFactory {
}

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
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class DefaultAdyenTransactionService implements AdyenTransactionService {
private AdyenPaymentServiceFactory adyenPaymentServiceFactory;
private BaseStoreService baseStoreService;
private TransactionOperations transactionTemplate;
private PaymentTransactionRepository paymentTransactionRepository;
private PaymentTransactionRepository adyenPaymentTransactionRepository;


@Override
Expand Down Expand Up @@ -112,7 +112,7 @@ public PaymentTransactionModel authorizeOrderModel(AbstractOrderModel abstractOr
return transactionTemplate.execute(transactionStatus -> {

//First save the transactions to the CartModel < AbstractOrderModel
PaymentTransactionModel paymentTransactionModel = paymentTransactionRepository.getTransactionModel(pspReference);
PaymentTransactionModel paymentTransactionModel = adyenPaymentTransactionRepository.getTransactionModel(pspReference);

if(paymentTransactionModel == null) {
paymentTransactionModel = createPaymentTransaction(merchantTransactionCode, pspReference, abstractOrderModel, paymentAmount);
Expand Down Expand Up @@ -249,7 +249,7 @@ public PaymentTransactionEntryModel createCancellationTransaction(final PaymentT
public PaymentTransactionModel createPaymentTransactionFromResultCode(final AbstractOrderModel abstractOrderModel, final String merchantTransactionCode, final String pspReference, final PaymentDetailsResponse.ResultCodeEnum resultCodeEnum) {
return transactionTemplate.execute(transactionStatus -> {

PaymentTransactionModel paymentTransactionModel = paymentTransactionRepository.getTransactionModel(pspReference);
PaymentTransactionModel paymentTransactionModel = adyenPaymentTransactionRepository.getTransactionModel(pspReference);

if(paymentTransactionModel == null) {
paymentTransactionModel = createPaymentTransaction(merchantTransactionCode, pspReference, abstractOrderModel);
Expand Down Expand Up @@ -350,4 +350,8 @@ public void setBaseStoreService(BaseStoreService baseStoreService) {
public void setTransactionTemplate(TransactionOperations transactionTemplate) {
this.transactionTemplate = transactionTemplate;
}

public void setAdyenPaymentTransactionRepository(PaymentTransactionRepository adyenPaymentTransactionRepository) {
this.adyenPaymentTransactionRepository = adyenPaymentTransactionRepository;
}
}

0 comments on commit e4a6fbe

Please sign in to comment.