首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何获取Wepay Ipn回调Uri

如何获取Wepay Ipn回调Uri
EN

Stack Overflow用户
提问于 2015-06-26 21:34:06
回答 2查看 401关注 0票数 1

我正在使用woocommerce测试wepay订阅支付。现在我在wepay Ipn回调uri中挣扎。我想知道如何在wepay响应中获取回调uri。

我得到了所有的订阅id,金额,状态,但回调uri只有我得到这样的"callback_uri"=>字符串(0) "“。

这是我的代码

代码语言:javascript
复制
     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,请告诉我。

谢谢

EN

回答 2

Stack Overflow用户

发布于 2016-03-01 15:53:05

  1. WePay作为post请求发送。
  2. 尝试使用requestBin首先检查负载数据。
  3. WePay将仅向您发送实体: entityID,而不是完整数据,您必须像WePay payload data sample

一样再次调用WePay API以获取状态

票数 0
EN

Stack Overflow用户

发布于 2016-05-31 21:10:20

这段代码是100%为我工作的。希望能对你有所帮助。

代码语言:javascript
复制
 <?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
        }
        ?>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31074589

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档