public function testDeletePlan()
 {
     setApiKey();
     $plans = Conekta_Plan::where();
     $plan = $plans[0];
     $plan->delete();
     $this->assertTrue($plan->deleted == true);
 }
 /**
  * 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'));
     }
 }
Example #3
0
 public function testParameterValidationError()
 {
     setApiKey();
     try {
         $plan = Conekta_Plan::create(array('id' => 'gold-plan'));
     } catch (Exception $e) {
         $this->assertTrue(strpos(get_class($e), 'Conekta_ParameterValidationError') !== false);
     }
 }
 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);
 }
Example #5
0
 public function testSuccesfulSubscriptionUpdate()
 {
     setApiKey();
     $customer = Conekta_Customer::create(array('cards' => array('tok_test_visa_4242')));
     $subscription = $customer->createSubscription(array('plan' => 'gold-plan'));
     try {
         $plan = Conekta_Plan::find('gold-plan2');
     } catch (Exception $e) {
         // Plan does not exist
         $plan = Conekta_Plan::create(array('id' => 'gold-plan2', 'name' => 'Gold Plan', 'amount' => 10000, 'currency' => 'MXN', 'interval' => 'month', 'frequency' => 1, 'trial_period_days' => 15, 'expiry_count' => 12));
     }
     $subscription->update(array('plan' => $plan->id));
     $this->assertTrue(strpos($subscription->plan_id, 'gold-plan2') !== false);
 }
Example #6
0
 public function testSuccesfulGetToken()
 {
     setApiKey();
     $token = Conekta_Plan::find('tok_test_visa_4242');
     $this->assertTrue(strpos(get_class($token), 'Conekta_Token') !== false);
 }