无法在cakephp中取消对条带的订阅 [英] Can't cancel the subscription on stripe in cakephp

查看:69
本文介绍了无法在cakephp中取消对条带的订阅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用这个Cakephp StripeComponent插件: https://github.com/chronon/CakePHP -StripeComponent-Plugin

I'm using this Cakephp StripeComponent plugin : https://github.com/chronon/CakePHP-StripeComponent-Plugin

一切正常,但无法使用此插件取消订阅。

Everything is working fine but I can't cancel the subscription with this plugin.

我已经尝试过 https://stripe.com/docs/api#cancel_subscription ,但没有成功。

I had tried this https://stripe.com/docs/api#cancel_subscription, but no success.

俗话说,要检索订阅,然后取消( )但是此插件没有任何检索订阅函数。

As its saying to retrieve the subscription and then cancel()But this plugin doesn't have any retrieve subscription function.

当我

$sub = \Stripe\Subscription::retrieve('SUBSCRIPTION_ID');
$sub->cancel();

我遇到错误致命错误:调用未定义的方法Stripe\ Subscription :: retrieve()

我被困住了。请帮助我。

I'm stuck.. Please help me out from this.

推荐答案

我在Google上搜索此问题的次数过多,但只得到了一些结果,例如

I searched this problem too much on google but I got only some results like


  • 将Stripe库更新到3.13.0。

  • Update Stripe library to 3.13.0.

添加自定义功能...。等等。

Add custom functions.... etc.

最后我自己解决了这个问题。

Finally I solved this problem by myself..

StripeComponent.php ,编写此函数:

public function subscriptionCancel($cust_id) {
    Stripe::setApiKey($this->key);
    $customer = false;
    try {
        $customer = Stripe_Customer::retrieve($cust_id);
        $customer->cancelSubscription();
    } catch (Exception $e) {
        return false;
    }
    return $customer;
}

并调用此 function subscriptionCancel()在您的控制器中为:

And call this function subscriptionCancel() in your Controller as:

$ subscription = $ this-> Stripe-> subscriptionCancel($ cust_id);

因此与特定 $ cust_id 相关的订阅将被取消。

So the subscription related to particular $cust_id will be canceled.

这篇关于无法在cakephp中取消对条带的订阅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆