Skip to content
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 @@ -149,18 +149,28 @@ define(
},
// Build AdyenCheckout library and creates the payment method component
createCheckoutComponent: async function () {
if (!this.checkoutComponent) {
const paymentMethodsResponse = adyenPaymentService.getPaymentMethods();
const countryCode = quote.billingAddress().countryId;

this.checkoutComponent = await adyenCheckout.buildCheckoutComponent(
paymentMethodsResponse(),
countryCode,
this.handleOnAdditionalDetails.bind(this)
)
}
const billingAddressObservable = quote.billingAddress;
let self = this;

if (billingAddressObservable() && billingAddressObservable().countryId) {
if (!this.checkoutComponent) {
const paymentMethodsResponse = adyenPaymentService.getPaymentMethods();

this.checkoutComponent = await adyenCheckout.buildCheckoutComponent(
paymentMethodsResponse(),
billingAddressObservable().countryId,
this.handleOnAdditionalDetails.bind(this)
)
}

this.renderCCPaymentMethod();
this.renderCCPaymentMethod();
} else {
billingAddressObservable.subscribe(function (updatedBillingAddress) {
if (updatedBillingAddress && updatedBillingAddress.countryId) {
self.createCheckoutComponent();
}
});
Comment thread
candemiralp marked this conversation as resolved.
}
},
/**
* Returns true if card details can be stored
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,28 @@ define([

// Build AdyenCheckout library and creates the payment method component
createCheckoutComponent: async function() {
if (!this.checkoutComponent) {
const paymentMethodsResponse = adyenPaymentService.getPaymentMethods();
const countryCode = quote.billingAddress().countryId;

this.checkoutComponent = await adyenCheckout.buildCheckoutComponent(
paymentMethodsResponse(),
countryCode,
this.handleOnAdditionalDetails.bind(this)
);
}
const billingAddressObservable = quote.billingAddress;
let self = this;

this.renderCheckoutComponent();
if (billingAddressObservable() && billingAddressObservable().countryId) {
if (!this.checkoutComponent) {
const paymentMethodsResponse = adyenPaymentService.getPaymentMethods();

this.checkoutComponent = await adyenCheckout.buildCheckoutComponent(
paymentMethodsResponse(),
billingAddressObservable().countryId,
this.handleOnAdditionalDetails.bind(this)
);
}

this.renderCheckoutComponent();
} else {
billingAddressObservable.subscribe(function (updatedBillingAddress) {
if (updatedBillingAddress && updatedBillingAddress.countryId) {
self.createCheckoutComponent();
}
});
Comment thread
candemiralp marked this conversation as resolved.
}
},

handleOnAdditionalDetails: function (result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ define(
selectedGiftcardPaymentMethod: ko.observable(null),
giftcardTitle: ko.observable(null),
icon: ko.observable(window.checkoutConfig.payment.adyen.giftcard.icon),
billingAddressAvailable: ko.observable(false),

initialize: async function () {
this._super();
Expand All @@ -74,6 +75,8 @@ define(
this.fetchGiftcardPaymentMethods(paymentMethodsObserver());
this.fetchRedeemedGiftcards();
}

this.billingAddressAvailable(quote.billingAddress() !== null);
Comment thread
candemiralp marked this conversation as resolved.
},

addNewGiftcard: function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ define(

this._lastGrandTotal = undefined;

// This event is triggered when the total changes or billing address is added (virtual products)
quote.totals.subscribe(function (totals) {
if (!totals) {
return;
Expand Down Expand Up @@ -177,20 +178,24 @@ define(

// Build AdyenCheckout library and creates the payment method component
createCheckoutComponent: async function(forceCreate = false) {
if (!this.checkoutComponent || forceCreate) {
const paymentMethodsResponse = adyenPaymentService.getPaymentMethods();
const countryCode = quote.billingAddress().countryId;

this.checkoutComponent = await adyenCheckout.buildCheckoutComponent(
paymentMethodsResponse(),
countryCode,
this.handleOnAdditionalDetails.bind(this),
this.handleOnCancel.bind(this),
this.handleOnSubmit.bind(this),
this.handleOnError.bind(this)
);
const billingAddressObservable = quote.billingAddress;
let self = this;

this.renderCheckoutComponent();
if (billingAddressObservable() && billingAddressObservable().countryId) {
if (!this.checkoutComponent || forceCreate) {
const paymentMethodsResponse = adyenPaymentService.getPaymentMethods();

this.checkoutComponent = await adyenCheckout.buildCheckoutComponent(
paymentMethodsResponse(),
billingAddressObservable().countryId,
this.handleOnAdditionalDetails.bind(this),
this.handleOnCancel.bind(this),
this.handleOnSubmit.bind(this),
this.handleOnError.bind(this)
);

this.renderCheckoutComponent();
}
}
Comment thread
candemiralp marked this conversation as resolved.
},

Expand Down
2 changes: 2 additions & 0 deletions view/frontend/web/template/payment/giftcard-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<!--/ko-->
</div>

<!-- ko if: billingAddressAvailable -->
<div data-bind="attr: {'id': getCode() + '_new_giftcard_wrapper'}">
<div class="field" data-bind="attr: {'id': getCode() + '_giftcard_button_wrapper'}, visible: canAddNewGiftCard">
<button data-bind="click: addNewGiftcard, attr: {'class': 'adyen-checkout__button'}">
Expand All @@ -59,6 +60,7 @@
</select>
</div>
</div>
<!-- /ko -->

<h2 data-bind="attr: {'class': 'adyen-giftcard-header'}, visible: giftcardTitle, text: giftcardTitle"></h2>
<div class="field" data-bind="attr: {'id': 'giftcard-component-wrapper'}"></div>
Expand Down
Loading