/** * Verify that a plan with a given ID exists, or create a new one if it does * not. */ protected static function retrieveOrCreatePlan($id) { self::authorizeFromEnv(); try { $plan = Plan::retrieve($id); } catch (Error\InvalidRequest $exception) { $plan = Plan::create(array('id' => $id, 'amount' => 0, 'currency' => 'usd', 'interval' => 'month', 'name' => 'Gold Test Plan')); } }
public function testSave() { self::authorizeFromEnv(); $planID = 'gold-' . self::generateRandomString(20); $p = Plan::create(array('amount' => 2000, 'interval' => 'month', 'currency' => 'usd', 'name' => 'Plan', 'id' => $planID)); $p->name = 'A new plan name'; $p->save(); $this->assertSame($p->name, 'A new plan name'); $stripePlan = Plan::retrieve($planID); $this->assertSame($p->name, $stripePlan->name); }