如何获得Wepay Ipn回调Uri



我正在使用wooccommerce测试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,请告诉我。

感谢

  1. WePay以邮件请求的形式发送
  2. 尝试使用requestBin首先检查负载数据
  3. WePay只会向你发送实体:entityID,而不是完整的数据,你必须再次调用WePay API才能获得状态,比如WePay有效载荷数据示例

这段代码对我来说是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
        }
        ?>

最新更新