コード例 #1
0
 /**
  * Verify that a plan with a given ID exists, or create a new one if it does
  * not.
  */
 protected static function retrieveOrCreatePlan($id)
 {
     authorizeFromEnv();
     try {
         $plan = Conekta_Plan::retrieve($id);
     } catch (Conekta_InvalidRequestError $exception) {
         $plan = Conekta_Plan::create(array('id' => $id, 'amount' => 0, 'currency' => 'usd', 'interval' => 'month', 'name' => 'Gold Test Plan'));
     }
 }
コード例 #2
0
 public function testSave()
 {
     authorizeFromEnv();
     $planId = 'gold-' . self::randomString();
     $p = Conekta_Plan::create(array('amount' => 2000, 'interval' => 'month', 'currency' => 'usd', 'name' => 'Plan', 'id' => $planId));
     $p->name = 'A new plan name';
     $p->save();
     $this->assertEqual($p->name, 'A new plan name');
     $p2 = Conekta_Plan::retrieve($planId);
     $this->assertEqual($p->name, $p2->name);
 }