/**
  * @depends testCustomerCreate
  * @group   ecommerce
  */
 public function testCustomerRetrieve($customer_existing)
 {
     $this->mockResponse($this->success_customer_retrieve_response());
     $customer = Customer::retrieve($customer_existing->token);
     $this->assertTrue($customer->is_active);
     $this->assertNotNull($customer->token);
 }
 public function testCustomerRetrieve()
 {
     $token = 'cus_zDdjHBuNW3do8G3jaTqApzsI';
     $this->mockResponse($this->success_customer_retrieve_response());
     $customer = Customer::retrieve($token);
     $this->assertTrue($customer->is_active);
     $this->assertNotNull($customer->token);
 }
 public function testInvalidObject()
 {
     self::authorizeFromEnv();
     try {
         Customer::retrieve('invalid');
     } catch (Error\InvalidRequest $e) {
         $this->assertSame(404, $e->getHttpStatus());
     }
 }
Exemple #4
0
 public function testDeletion()
 {
     self::authorizeFromEnv();
     $id = 'test-coupon-' . self::randomString();
     $coupon = Coupon::create(array('percent_off' => 25, 'duration' => 'repeating', 'duration_in_months' => 5, 'id' => $id));
     $customer = self::createTestCustomer(array('coupon' => $id));
     $this->assertTrue(isset($customer->discount));
     $this->assertTrue(isset($customer->discount->coupon));
     $this->assertSame($id, $customer->discount->coupon->id);
     $customer->deleteDiscount();
     $this->assertFalse(isset($customer->discount));
     $customer = Customer::retrieve($customer->id);
     $this->assertFalse(isset($customer->discount));
 }
Exemple #5
0
 public function testCustomerDeleteSource()
 {
     self::authorizeFromEnv();
     $token = Token::create(array('card' => array('number' => '4242424242424242', 'exp_month' => 5, 'exp_year' => date('Y') + 3, 'cvc' => '314')));
     $customer = $this->createTestCustomer();
     $createdSource = $customer->sources->create(array('source' => $token->id));
     $customer->save();
     $updatedCustomer = Customer::retrieve($customer->id);
     $updatedSources = $updatedCustomer->sources->all();
     $this->assertSame(count($updatedSources['data']), 2);
     $deleteStatus = $updatedCustomer->sources->retrieve($createdSource->id)->delete();
     $this->assertTrue($deleteStatus->deleted);
     $updatedCustomer->save();
     $postDeleteCustomer = Customer::retrieve($customer->id);
     $postDeleteSources = $postDeleteCustomer->sources->all();
     $this->assertSame(count($postDeleteSources['data']), 1);
 }
 public function testCustomerDeleteSource()
 {
     self::authorizeFromEnv();
     $token = Token::create(array("card" => array("number" => "4242424242424242", "exp_month" => 5, "exp_year" => date('Y') + 3, "cvc" => "314")));
     $customer = $this->createTestCustomer();
     $createdSource = $customer->sources->create(array("source" => $token->id));
     $customer->save();
     $updatedCustomer = Customer::retrieve($customer->id);
     $updatedSources = $updatedCustomer->sources->all();
     $this->assertSame(count($updatedSources["data"]), 2);
     $deleteStatus = $updatedCustomer->sources->retrieve($createdSource->id)->delete();
     $this->assertTrue($deleteStatus->deleted);
     $updatedCustomer->save();
     $postDeleteCustomer = Customer::retrieve($customer->id);
     $postDeleteSources = $postDeleteCustomer->sources->all();
     $this->assertSame(count($postDeleteSources["data"]), 1);
 }
Exemple #7
0
 public function testCustomerSubscriptionAllRetrieve()
 {
     $planID = 'gold-' . self::randomString();
     self::retrieveOrCreatePlan($planID);
     $customer = self::createTestCustomer();
     $subscription = Subscription::create(array('customer' => $customer->id, 'plan' => $planID));
     $planID_2 = 'gold-2-' . self::randomString();
     self::retrieveOrCreatePlan($planID_2);
     $subscription_2 = Subscription::create(array('customer' => $customer->id, 'plan' => $planID_2));
     $customerRetrive = Customer::retrieve($customer->id);
     $subscriptions = $customerRetrive->subscriptions->all();
     $this->assertSame($subscription_2->id, $subscriptions['data'][0]->id);
     $this->assertSame($subscription->id, $subscriptions['data'][1]->id);
     $this->assertSame(2, count($subscriptions['data']));
     $this->assertSame($customer->id, $subscriptions['data'][0]->customer);
     $this->assertSame($planID_2, $subscriptions['data'][0]->plan->id);
     $subscriptionRetrieve = $customerRetrive->subscriptions->retrieve($subscription->id);
     $this->assertSame($subscription->id, $subscriptionRetrieve->id);
     $this->assertSame($planID, $subscriptionRetrieve->plan->id);
 }
Exemple #8
0
{
    public function __construct(DIRT $dirt, $pharmacyId)
    {
        parent::__construct($dirt, 'Customer', "PharmacyId = {$pharmacyId}");
    }
}
try {
    $options = ['attributes' => [\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, \PDO::ATTR_EMULATE_PREPARES => true], 'dirt' => ['driver' => 'mysql', 'host' => 'localhost', 'dbname' => 'rxtrax', 'dsn' => 'mysql:host=localhost;dbname=rxtrax;charset=utf8', 'salt' => '45F5CF1FA4AD99F481BFD4DF5DB832F95F3667DF', 'cacheSession' => true]];
    $dirt = new DIRT('dirt', 'root', 'intrepid', $options);
} catch (\PDOException $pdoException) {
    die($pdoException->getMessage());
}
$customer = new Customer($dirt, 4);
echo "Number of columns: " . (string) $customer->getColumnCount() . "\n";
for ($i = 1; $i <= 1225; $i++) {
    $isLoaded = $customer->retrieve(['Id' => $i]);
    if ($isLoaded) {
        echo 'Pharmacy Id: ' . (string) $customer->PharmacyId . "\n";
        echo 'First Name: ' . $customer->FirstName . "\n";
        echo 'Last Name: ' . $customer->LastName . "\n";
        echo 'Email: ' . $customer->Email . "\n";
    }
}
exit;
$customer->FirstName = 'Marge';
$updateWorked = $customer->update();
echo "Update: " . (string) $updateWorked;
exit;
$customer->FirstName = 'Ralph';
$customer->LastName = 'Bednar';
echo "Last Name: " . $customer->LastName;