当前位置: 首页>>代码示例>>PHP>>正文


PHP Subscription::retrieve方法代码示例

本文整理汇总了PHP中Subscription::retrieve方法的典型用法代码示例。如果您正苦于以下问题:PHP Subscription::retrieve方法的具体用法?PHP Subscription::retrieve怎么用?PHP Subscription::retrieve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Subscription的用法示例。


在下文中一共展示了Subscription::retrieve方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCreateUpdateListCancel

 public function testCreateUpdateListCancel()
 {
     $planID = 'gold-' . self::generateRandomString(20);
     self::retrieveOrCreatePlan($planID);
     $customer = self::createTestCustomer();
     $sub = Subscription::create(array('plan' => $planID, 'customer' => $customer->id));
     $this->assertSame($sub->status, 'active');
     $this->assertSame($sub->plan->id, $planID);
     $sub->quantity = 2;
     $sub->save();
     $sub = Subscription::retrieve($sub->id);
     $this->assertSame($sub->status, 'active');
     $this->assertSame($sub->plan->id, $planID);
     $this->assertSame($sub->quantity, 2);
     // Update the quantity parameter one more time
     $sub = Subscription::update($sub->id, array("quantity" => 3));
     $this->assertSame($sub->status, 'active');
     $this->assertSame($sub->plan->id, $planID);
     $this->assertSame($sub->quantity, 3);
     $subs = Subscription::all(array('customer' => $customer->id, 'plan' => $planID, 'limit' => 3));
     $this->assertSame(get_class($subs->data[0]), 'Stripe\\Subscription');
     $sub->cancel(array('at_period_end' => true));
     $sub = Subscription::retrieve($sub->id);
     $this->assertSame($sub->status, 'active');
     $this->assertTrue($sub->cancel_at_period_end);
 }
开发者ID:wp-premium,项目名称:gravityformsstripe,代码行数:26,代码来源:SubscriptionTest.php

示例2: testCreateRetrieveUpdatePauseResumeCancelDelete

 public function testCreateRetrieveUpdatePauseResumeCancelDelete()
 {
     $planID = 'gold-' . self::randomString();
     self::retrieveOrCreatePlan($planID);
     $customer = self::createTestCustomer();
     $sub = Subscription::create(array('customer' => $customer->id, 'plan' => $planID));
     $this->assertSame($sub->status, 'active');
     $this->assertSame($sub->trial_end, null);
     $this->assertSame($sub->plan->id, $planID);
     $sub_retrieve = Subscription::retrieve($sub->id);
     $sub->pause();
     $sub_pause = Subscription::retrieve($sub->id);
     $this->assertSame($sub_pause->status, 'paused');
     $sub->resume();
     $sub_resume = Subscription::retrieve($sub->id);
     $this->assertSame($sub_resume->status, 'active');
     $resuumed_at = $sub->created + 10000;
     $sub->pause();
     $sub_pause = Subscription::retrieve($sub->id);
     $this->assertSame($sub_pause->status, 'paused');
     $this->assertSame(null, $sub->resumed_at);
     $trial_end = $sub->created + 5000;
     $sub->resume(array('trial_end' => $trial_end));
     $sub_resume = Subscription::retrieve($sub->id);
     $this->assertSame($sub_resume->status, 'trial');
     $this->assertSame(500, $sub->plan->amount);
     $this->assertSame($trial_end, $sub->trial_end);
     try {
         $sub->cancel(array('foo' => "bar"));
     } catch (Error\InvalidRequest $e) {
         $actual = $e->getJsonBody();
         $this->assertSame('Invalid param key to subscription.', $actual['error']['message']);
     }
     $sub->cancel();
     $sub_cancel = Subscription::retrieve($sub->id);
     $this->assertSame($sub_cancel->status, 'canceled');
     $sub_id = $sub->id;
     $sub->delete();
     $this->assertSame($sub_id, $sub->id);
     $this->assertTrue($sub->deleted);
 }
开发者ID:payjp,项目名称:payjp-php,代码行数:41,代码来源:SubscriptionTest.php


注:本文中的Subscription::retrieve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。