如何获得Wepay Ipn Callback Uri

时间:2015-06-26 13:34:06

标签: php woocommerce

我正在使用woocommerce测试wepay订阅付款。现在我在wepay Ipn Callback uri中奋斗。 我想如何在wepay回复中获得回调uri。

我获得所有订阅ID,金额,状态但回调uri只有我得到这样的[" callback_uri"] => string(0)""。

这是我的代码

     global $woocommerce;
     require 'wepay.php';          

        $order = new WC_Order('39');
        $order->reduce_order_stock();
              $api_name = $this->get_option('api_username');
              $api_client = $this->get_option('api_clientid');
              $api_mailid = $this->get_option('api_emailid');
              $redirect_uri = $this->get_option('redirect_uri');
              $client_secretid = $this->get_option('api_client_secret');
              $access_token = $this->get_option('api_access_token');  
              $account_id   = $this->get_option('api_accountid');


              wepay::useStaging($api_client, $client_secretid);
              $wepay = new WePay($access_token);

            $resp = $wepay->request('subscription', array(
            'subscription_id'  => '1797054990',

));

告诉我是否有人使用wepay。

感谢

2 个答案:

答案 0 :(得分:0)

  1. WePay作为帖子请求发送。
  2. 尝试使用requestBin首先检查有效负载数据是什么。
  3. WePay只会向您发送实体:entityID,而不是完整数据,您必须再次调用WePay API才能获得状态,例如 WePay payload data sample

答案 1 :(得分:0)

此代码100%为我工作。希望它对你有所帮助。

 <?php

        require 'wepay.php';

        if (!empty($_POST['checkout_id'])) {
            $thecheckoutid = $_POST['checkout_id'];
        }

        // application settings

        $client_id = "<Your Client ID>";
        $client_secret = "<Your Client Secret>";
        $access_token = "<Your Client Token>";
        $account_id = "<Your Accout ID>";

        /**
         * Initialize the WePay SDK object
         */
        Wepay::useStaging($client_id, $client_secret);
        $wepay = new WePay($access_token);

        /**
         * Make the API request to get the checkout_uri
         *
         */
        //$thecheckoutid = 672117563;
        //$thecheckoutid = 1487059142;
        try {
            $checkout = $wepay->request('checkout', array(
                    'checkout_id' => $thecheckoutid, // ID of the account that you want the money to go to
                )
            );
        } catch (WePayException $e) { // if the API call returns an error, get the error message for display later
            $error = $e->getMessage();
        }
        echo "<pre>";
        print_r($checkout);
        ///some things you might want to use. Delete this stuff otherwise///
        print '<br /><br />';
        print $checkout->short_description;
        print '<br /><br />';
        print $checkout->checkout_id;
        print '<br /><br />';
        print $checkout->reference_id;
        print '<br /><br />';
        print $checkout->gross;
        print '<br /><br />';
        print $checkout->payer->name;
        print '<br /><br />';
        print $checkout->payer->email;
        ////stop deleteing here///

        if ($checkout->state == "captured") {
            ///do something here
        } elseif ($checkout->state == "authorized") {
            ///do something here
        } elseif ($checkout->state == "cancelled") {
            ///do something here
        } elseif ($checkout->state == "refunded") {
            ///do something here
        } elseif ($checkout->state == "expired") {
            ///do something here
        }
        ?>