I have a custom payment method. When the place order button is triggered, I want to process my payment gateway. After this, if payment is a success order should be placed successfully.
Here is a method-renderer file.
define(
[
'Magento_Checkout/js/view/payment/default'
],
function (Component) {
'use strict';
return Component.extend({
defaults: {
template: 'Iostpay_Iostpaymagento/payment/iostpay'
},
getMailingAddress: function () {
return window.checkoutConfig.payment.checkmo.mailingAddress;
},
getInstructions: function () {
return window.checkoutConfig.payment.checkmo.mailingAddress;
},
placeOrder: function () {
alert('heya');
var getresp = transfer();
console.log("transfer-resp: "+getresp);
var form = document.getElementById("co-payment-form");
form.submit();
}
});
}
);
This is my placeOrder Button HTML.
<button class="action primary checkoutplaceorder"
data-bind="
click: placeOrder,
attr: {title: $t('Place Order')},
css: {disabled: !isPlaceOrderActionAllowed()},
enable: (getCode() == isChecked())
"
type="submit" disabled>
<span data-bind="i18n: 'Place Order'"></span>
</button>
Basically this is how I wanna do.
- Click on placeOrder:- On click of place order, a payment modal will pop up. Then the user will make the payment from the modal-popup.
- After making payment the user gets the payment response.
- Place the Order successfully and submit the form.
Does anyone know about this?
Thanks in advance.
checkout_submit_before
eventplace order successfully only if my payment is success.
this is my button here for placeOrder<button class="action primary checkoutplaceorder" data-bind=" click: placeOrder, attr: {title: $t('Place Order')}, css: {disabled: !isPlaceOrderActionAllowed()}, enable: (getCode() == isChecked()) " type="submit" > <span data-bind="i18n: 'Place Order'"></span> </button>
Can i trigger placeOrder event with JS?