I am new to magento2 and developing a custom payment module for ccavenue.I am facing a problem regarding order confirmation email.
The order confirmation email is sending once the customer redirecting to payment gateway page and order is creating with pending status.I want to send this email after a successful transaction.
Here is my payment js code
define(
[
'jquery',
'Magento_Checkout/js/view/payment/default',
'Magento_Checkout/js/action/place-order',
'Magento_Checkout/js/action/select-payment-method',
'Magento_Customer/js/model/customer',
'Magento_Checkout/js/checkout-data',
'Magento_Checkout/js/model/payment/additional-validators',
'mage/url',
],
function (
$,
Component,
placeOrderAction,
selectPaymentMethodAction,
customer,
checkoutData,
additionalValidators,
url) {
return Component.extend({
defaults: {
template: 'Magekmf_Ccavenue/payment/ccavenue'
},
placeOrder: function (data, event) {
if (event) {
event.preventDefault();
}
var self = this,
placeOrder,
emailValidationResult = customer.isLoggedIn(),
loginFormSelector = 'form[data-role=email-with-possible-login]';
if (!customer.isLoggedIn()) {
$(loginFormSelector).validation();
emailValidationResult = Boolean($(loginFormSelector + ' input[name=username]').valid());
}
if (emailValidationResult && this.validate() && additionalValidators.validate()) {
this.isPlaceOrderActionAllowed(false);
placeOrder = placeOrderAction(this.getData(), true, this.messageContainer);
$.when(placeOrder).fail(function () {
self.isPlaceOrderActionAllowed(true);
}).done(this.afterPlaceOrder.bind(this));
return true;
}
return false;
},
selectPaymentMethod: function() {
selectPaymentMethodAction(this.getData());
checkoutData.setSelectedPaymentMethod(this.item.method);
return true;
},
afterPlaceOrder: function () {
window.location.replace(url.build('ccavenue/request'));
},
/** Returns send check to info */
getMailingAddress: function() {
return window.checkoutConfig.payment.checkmo.mailingAddress;
}
});
}
);
set-payment-information
, but you callspayment-information
(this is default action), but anyway you need to provide more details.set-payment-information
insteadpayment-information
(placeOrder
method) after that, redirect customer to external payment provider and when customer comes back to Magento store - callpayment-information
action (placeOrder
method)