コード例 #1
0
 public function testHelperInstances()
 {
     $chargify = ClientHelper::getInstance();
     $adjustment = $chargify->adjustment();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Adjustment', $adjustment);
     $charge = $chargify->charge();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Charge', $charge);
     $component = $chargify->component();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Component', $component);
     $coupon = $chargify->coupon();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Coupon', $coupon);
     $customer = $chargify->customer();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Customer', $customer);
     $event = $chargify->event();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Event', $event);
     $product = $chargify->product();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Product', $product);
     $refund = $chargify->refund();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Refund', $refund);
     $statement = $chargify->statement();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Statement', $statement);
     $stats = $chargify->stats();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Stats', $stats);
     $subscription = $chargify->subscription();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Subscription', $subscription);
     $transaction = $chargify->transaction();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Transaction', $transaction);
     $webhook = $chargify->webhook();
     $this->assertInstanceOf('Crucial\\Service\\Chargify\\Webhook', $webhook);
 }
コード例 #2
0
 public function testReadByChargifyId()
 {
     $chargify = ClientHelper::getInstance('customer.readByChargifyId.success');
     $customer = $chargify->customer()->readByChargifyId(12345);
     $response = $customer->getService()->getLastResponse();
     $this->assertFalse($customer->isError(), '$customer has an error');
     $this->assertEquals(200, $response->getStatusCode(), 'Expected status code 200');
 }
コード例 #3
0
 public function testFindNonExistentCodeIsError()
 {
     $chargify = ClientHelper::getInstance('coupon.find.error');
     $coupon = $chargify->coupon()->setCode('THIS_CODE_DOESNT_EXIST')->find(1234);
     $response = $coupon->getService()->getLastResponse();
     // $component object should indicate an error
     $this->assertTrue($coupon->isError(), '$coupon was not en error');
     $this->assertEquals(404, $response->getStatusCode(), 'Expected status code 404');
 }
コード例 #4
0
 public function testReadByChargifyId()
 {
     $chargify = ClientHelper::getInstance();
     // set a mock response on the client
     $mock = new Mock([MockResponse::read('customer.readByChargifyId.success')]);
     $chargify->getHttpClient()->getEmitter()->attach($mock);
     $customer = $chargify->customer()->readByChargifyId(12345);
     $response = $customer->getService()->getLastResponse();
     $this->assertFalse($customer->isError(), '$customer has an error');
     $this->assertEquals(200, $response->getStatusCode(), 'Expected status code 200');
 }
コード例 #5
0
 public function testNoAmountCreatesError()
 {
     $chargify = ClientHelper::getInstance('adjustment.create.error.no_amount');
     $adjustment = $chargify->adjustment()->create(123);
     $response = $adjustment->getService()->getLastResponse();
     // $adjustment object should indicate an error
     $this->assertTrue($adjustment->isError(), '$adjustment was not en error');
     $this->assertEquals(422, $response->getStatusCode(), 'Expected status code 422');
     // get errors from $adjustment
     $errors = $adjustment->getErrors();
     // check for error messages
     $this->assertContains('Amount: is not a number.', $errors);
 }
コード例 #6
0
 public function testNoShippingCreatesError()
 {
     $chargify = ClientHelper::getInstance('subscription.error.no_shipping');
     $subscription = $chargify->subscription()->setProductId(123)->setCustomerAttributes(array('first_name' => 'Darryl', 'last_name' => 'Strawberry', 'email' => '*****@*****.**', 'organization' => 'Mets'))->setPaymentProfileAttributes(array('first_name' => 'Darryl2', 'last_name' => 'Strawberry2', 'full_number' => '1', 'expiration_month' => '03', 'expiration_year' => '16', 'cvv' => '123', 'billing_address' => '600 N', 'billing_city' => 'Chicago', 'billing_state' => 'IL', 'billing_zip' => '60610', 'billing_country' => 'US'))->create();
     $response = $subscription->getService()->getLastResponse();
     // $subscription object should be in an error state
     $this->assertTrue($subscription->isError());
     $this->assertEquals(422, $response->getStatusCode(), 'Expected status code 422');
     // get errors from $subscription
     $errors = $subscription->getErrors();
     // check for error messages
     $this->assertContains('Shipping Address: cannot be blank.', $errors);
 }
コード例 #7
0
 public function testCreateMeteredStairstepError()
 {
     $chargify = ClientHelper::getInstance('adjustment.createMeteredStairstep.error.no_prices');
     $component = $chargify->component()->setName('Text Messages')->setUnitName('message')->setUnitPrice('0.0012')->setPricingScheme('stairstep')->createComponent(1234, 'metered_components');
     $response = $component->getService()->getLastResponse();
     // $component object should indicate an error
     $this->assertTrue($component->isError(), '$adjustment was not en error');
     $this->assertEquals(422, $response->getStatusCode(), 'Expected status code 422');
     // get errors from $adjustment
     $errors = $component->getErrors();
     // check for error messages
     $this->assertContains('At least 1 price bracket must be defined', $errors);
 }