2016-05-18 9 views
2

私は自分のwordpressにpay4later APIを統合しました。支払いの成功後に支払いの返答の詳細を表示する必要があります。woocommerceで支払い応答のURLを取得するにはどうすればよいですか?

私のプラグインファイル:

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

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

    } 

私は私のリターン応答URLを設定している:私はこれを呼び出すと

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-to-forward-and-get-the -response)も1つ。 – LoicTheAztec

+0

私はこれを言いました。しかし、私は考えを明確にすることはできません。 check_response()の注文の詳細を更新しました。だから私はURLを介してこの機能をすることができます。 – 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'); 

} 
関連する問題