成功订购magento后触发网址

时间:2015-04-30 15:26:05

标签: javascript php jquery magento-1.8 magento-1.9

我正在使用magento 1.8.1,我正在进行短信集成。我在点击下订单按钮后尝试触发api url。但是,当我在magento上新手时,我不知道我把这个网址放在哪里。找到后,我得到了这些按钮代码

  <div class="clear"></div>
    <button style="float:left" onclick="oscPlaceOrder(this);" 
      id="onestepcheckout-button-place-order" type="button" 
      title="<?php echo $this->__('Place Order') ?>" 
      class="btn-proceed-checkout onestepcheckout-btn-checkout onestepcheckout-place">
    <span>
       <span><?php echo $this->__('Place order now') ?></span>
    </span>
   </button>      
  </div>

现在这里有一个函数oscPlaceOrder

&#13;
&#13;
function oscPlaceOrder(element) {
        var validator = new Validation('one-step-checkout-form');
        var form = $('one-step-checkout-form');
        if (validator.validate()) {
            if (($('p_method_hosted_pro') && $('p_method_hosted_pro').checked) || ($('p_method_payflow_advanced') && $('p_method_payflow_advanced').checked)) {
                $('onestepcheckout-place-order-loading').show();
                $('onestepcheckout-button-place-order').removeClassName('onestepcheckout-btn-checkout');
                $('onestepcheckout-button-place-order').addClassName('place-order-loader');
                $('ajaxcart-load-ajax').show();
                checkAjax('<?php echo $this->getUrl('onestepcheckout/index/saveOrderPro', array('_secure' => true)); ?>');
            } else {
                if (checkpayment()) {
                    element.disabled = true;
                    var already_placing_order = true;
                    disable_payment();
                    $('onestepcheckout-place-order-loading').show();
                    $('onestepcheckout-button-place-order').removeClassName('onestepcheckout-btn-checkout');
                    $('onestepcheckout-button-place-order').addClassName('place-order-loader');
                    //$('one-step-checkout-form').submit();
                    var options = document.getElementsByName('payment[method]');
                    for (var i = 0; i < options.length; i++) {
                        if ($(options[i].id).checked) {
                            if (options[i].id.indexOf("tco") != -1) {
                                var params = Form.serialize('one-step-checkout-form');
                                var request = new Ajax.Request(
                                '<?php echo $this->getCheckoutUrl() . 'isAjax/tco'; ?>',
                                {
                                    method: 'post',
                                    onComplete: this.onComplete,
                                    onSuccess: function(transport) {
                                        if (transport.status == 200) {
                                            if (transport.responseText.isJSON) {
                                                var response = JSON.parse(transport.responseText);
                                                $('onestepcheckout-place-order-loading').style.display = 'none';
                                                $('checkout-' + response.update_section.name + '-load').update(response.update_section.html);
                                                $('onestepcheckout-button-place-order').removeAttribute('onclick');
                                                $('onestepcheckout-button-place-order').observe('click', formsubmit());
                                                $('onestepcheckout-button-place-order').disabled = false;
                                            }
                                        }
                                    },
                                    onFailure: '', //checkout.ajaxFailure.bind(checkout),
                                    parameters: params
                                });
                            } else if (options[i].id.indexOf("wirecard") != -1) {
                                var params = Form.serialize('one-step-checkout-form');
                                var request = new Ajax.Request(
                                '<?php echo $this->getCheckoutUrl() . 'isAjax/wirecard'; ?>',
                                {
                                    method: 'post',
                                    onComplete: this.onComplete,
                                    onSuccess: function(transport) {
                                        var response = JSON.parse(transport.responseText);
                                        if (response.url) {
                                            window.location.href = response.url;
                                        } else {
                                            var payment_method = $RF(form, 'payment[method]');
                                            var wireparams = {'paymentMethod': payment_method};
                                            url = '<?php echo Mage::getBaseUrl() . 'wirecard_checkout_page/processing/wirecard_checkout_pagecheckout/'; ?>';
                                            var wirerequest = new Ajax.Request(
                                            qmoreIsIframe,
                                            {
                                                method: 'get',
                                                parameters: wireparams,
                                                onSuccess: function(innerTransport) {
                                                    if (innerTransport && innerTransport.responseText) {
                                                        try {
                                                            var innerResponse = eval('(' + innerTransport.responseText + ')');
                                                        }
                                                        catch (e) {
                                                            innerResponse = {};
                                                        }
                                                        if (innerResponse.isIframe)
                                                        {
                                                            toggleQMoreIFrame();
                                                            $('qmore-iframe').src = url;
                                                        } else {
                                                            window.location.href = url;
                                                        }
                                                    }
                                                },
                                                onFailure: ''
                                            });
                                        }
                                    },
                                    onFailure: '', //checkout.ajaxFailure.bind(checkout),
                                    parameters: params
                                });
                            } else {
								if(isUseAmazon() == false){
									$('one-step-checkout-form').submit();
								}
								else{ 
									<?php 
										if(Mage::helper('core')->isModuleEnabled('Amazon_Payments')){
											$helperAmz = new Amazon_Payments_Helper_Data();
											if(isset($helperAmz))
											$checkoutUrl = $helperAmz->getCheckoutUrl(false);
										}
									?>
									window.location.href = "<?php if(isset($checkoutUrl)) echo $checkoutUrl;?>";
								}
                            }
                            break;
                        }
                    }
                }
            }
        }
    }
    function checkAjax(url) {
        var form = $('one-step-checkout-form');
        var payment_method = $RF(form, 'payment[method]');
        var shipping_method = $RF(form, 'shipping_method');
        var parameters = {
            payment: payment_method,
            shipping_method: shipping_method
        }
        get_billing_data(parameters);
        get_shipping_data(parameters);

        if ($('giftmessage-type') && $('giftmessage-type').value != '') {
            parameters[$('giftmessage-type').name] = $('giftmessage-type').value;
        }
        if ($('create_account_checkbox_id') && $('create_account_checkbox_id').checked) {
            parameters['create_account_checkbox'] = 1;
        }
        if ($('gift-message-whole-from') && $('gift-message-whole-from').value != '') {
            parameters[$('gift-message-whole-from').name] = $('gift-message-whole-from').value;
        }
        if ($('gift-message-whole-to') && $('gift-message-whole-to').value != '') {
            parameters[$('gift-message-whole-to').name] = $('gift-message-whole-to').value;
        }
        if ($('gift-message-whole-message') && $('gift-message-whole-message').value != '') {
            parameters[$('gift-message-whole-message').name] = $('gift-message-whole-message').value;
        }
        if ($('billing-address-select') && $('billing-address-select').value != '') {
            parameters[$('billing-address-select').name] = $('billing-address-select').value;
        }
        if ($('shipping-address-select') && $('shipping-address-select').value != '') {
            parameters[$('shipping-address-select').name] = $('shipping-address-select').value;
        }

        new Ajax.Request(url, {
            method: 'post',
            evalJS: 'force',
            onSuccess: function(transport) {
                // alert(JSON.parse(transport.responseText).url);
                if (JSON.parse(transport.responseText).url == 'null' || JSON.parse(transport.responseText).url == null) {
                    $('ajaxcart-loading').style.display = 'block';
                    $('ajaxcart-loading').style.top = '15%';
                    $('ajaxcart-loading').style.left = '40%';
                    $('ajaxcart-loading').style.width = '551px';
                    $('ajaxcart-loading').style.height = '400px';
                    $('ajaxcart-loading').style.overflow = 'hidden';
                    $('ajaxcart-loading').style.padding = '5px';
                    $('ajaxcart-loading').innerHTML = JSON.parse(transport.responseText).html;
                    $('iframe-warning').style.textAlign = 'left';
                }
                else
                {
                    window.location.href = JSON.parse(transport.responseText).url;
                }
            },
            onFailure: function(transport) {
            },
            parameters: parameters
        });
    }
&#13;
&#13;
&#13;

我想我必须把网址放在这个功能中,但是在哪里以及如何,我不明白。所以请帮帮我

1 个答案:

答案 0 :(得分:0)

您始终可以使用getOrderPlaceRedirectUrl()在您的支付模块模型中,并返回您的网址以将客户重定向到外部网页。

另一种选择可能是使用authorize()并将curl触发到外部URL。