1

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.

  1. 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.
  2. After making payment the user gets the payment response.
  3. Place the Order successfully and submit the form.

Does anyone know about this?

Thanks in advance.

7
  • Hi, do you want to do this only with knockout? otherwise you can use place order checkout_submit_before event
    – temper
    Commented Nov 13, 2019 at 5:04
  • Hi, I want to process the payment and place 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?
    – Garry
    Commented Nov 13, 2019 at 5:11
  • According to my view, there is no need to do this by knockout, you can do this via observer, create a place order event, and check if you receive your custom payment method then do your code.
    – temper
    Commented Nov 13, 2019 at 5:13
  • But i am making payment on click of placeOrder.
    – Garry
    Commented Nov 13, 2019 at 5:15
  • please share more details about the issue if possible
    – tru.d
    Commented Nov 13, 2019 at 6:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.