获取WooCommerce下订单按钮以运行付款网关功能

时间:2019-04-08 20:47:13

标签: javascript php woocommerce checkout

我在使用结帐页面上的“下单”按钮时遇到问题,无法运行使用woocommerce_review_order_after_submit钩子链接到付款网关的功能。

我尝试使用woocommerce_review_order_after_submit'钩子:

function renderMMoneyPaymentButton(amount, merchantOrderId, apiKey) {
    let paymentParams = {
        amount: amount,
        api_key: apiKey,
        currency: 'BBD',
        merchant_order_id: merchantOrderId,
        onCancel: function() { console.log('Modal closed'); },
        onError: function(error) { console.log('Error', error); },
        onPaid: function(invoice) { console.log('Payment complete', invoice); }
    }

    // "mMoney" window global provided by sourcing mmoney-payment.js script.
    // Attach the button to the empty element.
    mMoney.payment.button.render(paymentParams, '#mmoney-payment-button');
}

0 个答案:

没有答案