2016-05-18 20 views
2

我已经在我的wordpress中集成了pay4later api。我需要在付款成功后显示付款回复详情。如何获取woocommerce中的付款响应网址?

我的插件文件:

class WC_Pay4later extends WC_Payment_Gateway{ 
     add_action('woocommerce_api_' . strtolower(get_class($this)), array($this, 'check_response')); 

     function check_response() 
     { 
      /* Update Process*/ 
     } 

    } 

设置我得到的回答网址为:

www.mysite/pay4later/?wc-api=WC_Payment_GatewayPay4later_check_response. 

当我把这个它只是显示1

我怎样才能解决这个问题?

+0

[这可能对你很有意思](http://stackoverflow.com/a/27331463/3730754),即使它并不特定于pay4later。和[** this **](https://support.woothemes.com/hc/en-us/community/posts/202413166-check-out-with-API-url-for-forward-and-get-the - 反应)一个。 – LoicTheAztec

+0

我反驳了这一点。但我不清楚主意。我在check_response()中更新了订单详细信息。所以,我可以通过网址这个功能。 – soniya

+0

对不起,如何通过url调用此函数? – soniya

回答

0

以下是woocommerce支付网关Pay4later的骨架结构。

if (! defined('ABSPATH')) { exit; } 

add_action('plugins_loaded', 'wc_pay4later_init', 0); 

function wc_pay4later_init() { 

    class WCPay4later extends WC_Payment_Gateway{ 

     public function __construct() { 
      // Put your initialization scripts here 
      // Which would be initializing merchan account info, secret keys, from this plugin's settings screen 

      /* This would be your gateway return url */ 
      $this->callback = str_replace('https:', 'http:', home_url('/wc-api/WCPay4later') ); 
      /* This action will redirect the gateway response to your 'check_pay_4_later_response' function */ 
      add_action('woocommerce_api_wcpay4later', array($this, 'check_pay_4_later_response'));   
      /* This is the action where you prepare your digital form and submit to the gateway server */ 
      add_action('woocommerce_receipt_wcpay4later', array($this, 'receipt_page'));   
     } 

     function receipt_page($order) { 
      echo '<p>'.__('Thank you for your order, please click the button below to pay with Pay 4 Later Gateway Service.', 'sark').'</p>'; 
      // prepare your digital form  
      echo $this -> generate_digital_form($order); 
     } 

     function generate_digital_form($order) { 
      // prepare and redirect to gateway server 
     } 

     function check_pay_4_later_response() { 
      /* Update Process*/ 
     } 

    } 

    function woocommerce_add_pay_4_later_gateway($methods) { 
     $methods[] = 'WCPay4later'; 
     return $methods; 
    } 
    add_filter('woocommerce_payment_gateways', 'woocommerce_add_pay_4_later_gateway'); 

} 
相关问题