public function testCreate() { authorizeFromEnv(); $c = Stripe_Coupon::create(array('percent_off' => 25, 'duration' => 'repeating', 'duration_in_months' => 5, 'id' => 'test_coupon')); $this->assertEqual('test_coupon', $c->id); $this->assertEqual(25, $c->percent_off); }
public function testRetrieve() { authorizeFromEnv(); $c = Stripe_Charge::create(array('amount' => 100, 'currency' => 'usd', 'card' => array('number' => '4242424242424242', 'exp_month' => 5, 'exp_year' => 2015))); $d = Stripe_Charge::retrieve($c->id); $this->assertEqual($d->id, $c->id); }
public function testRefund() { authorizeFromEnv(); $c = Conekta_Charge::create(array('amount' => 2000, 'currency' => 'mxn', 'description' => 'Some desc', 'card' => array('number' => '4242424242424242', 'exp_month' => 5, 'exp_year' => 2015, 'cvc' => 123, 'name' => 'Mario Moreno'))); $c->refund(); $this->assertTrue($c->status == "refunded"); }
public function testCreate() { authorizeFromEnv(); $id = 'test_coupon-' . self::randomString(); $c = Conekta_Coupon::create(array('percent_off' => 25, 'duration' => 'repeating', 'duration_in_months' => 5, 'id' => $id)); $this->assertEqual($id, $c->id); $this->assertEqual(25, $c->percent_off); }
public function testRetrieve() { authorizeFromEnv(); $d = Stripe_Balance::retrieve(); $this->assertEqual($d->object, "balance"); $this->assertTrue(Stripe_Util::isList($d->available)); $this->assertTrue(Stripe_Util::isList($d->pending)); }
public function testRetrieve() { $recipient = self::createTestRecipient(); authorizeFromEnv(); $transfer = Conekta_Transfer::create(array('amount' => 100, 'currency' => 'usd', 'recipient' => $recipient->id)); $reloaded = Conekta_Transfer::retrieve($transfer->id); $this->assertEqual($reloaded->id, $transfer->id); }
public function testRetrieve() { authorizeFromEnv(); $d = Stripe_Account::retrieve(); $this->assertEqual($d->email, "*****@*****.**"); $this->assertEqual($d->charge_enabled, false); $this->assertEqual($d->details_submitted, false); }
public function testUpcoming() { authorizeFromEnv(); $c = Stripe_Customer::create(array('card' => array('number' => '4242424242424242', 'exp_month' => 5, 'exp_year' => 2015))); $invoice = Stripe_Invoice::upcoming(array('customer' => $c->id)); $this->assertEqual($invoice->customer, $c->id); $this->assertEqual($invoice->attempted, false); }
public function testBadData() { authorizeFromEnv(); try { CleverDistrict::all(array('asdf' => 25)); } catch (CleverInvalidRequestError $e) { $this->assertEquals(400, $e->getHttpStatus()); } }
public function testUpdateMetadataAll() { authorizeFromEnv(); $charge = Stripe_Charge::create(array('amount' => 100, 'currency' => 'usd', 'card' => array('number' => '4242424242424242', 'exp_month' => 5, 'exp_year' => 2015))); $charge->metadata = array('test' => 'foo bar'); $charge->save(); $updatedCharge = Stripe_Charge::retrieve($charge->id); $this->assertEqual('foo bar', $updatedCharge->metadata['test']); }
/** * Verify that a coupon with a given ID exists, or create a new one if it does * not. */ protected static function retrieveOrCreateCoupon($id) { authorizeFromEnv(); try { $coupon = Stripe_Coupon::retrieve($id); } catch (Stripe_InvalidRequestError $exception) { $coupon = Stripe_Coupon::create(array('id' => $id, 'duration' => 'forever', 'percent_off' => 25)); } }
public function testBadData() { authorizeFromEnv(); try { Stripe_Charge::create(); } catch (Stripe_InvalidRequestError $e) { $this->assertEqual(400, $e->getHttpStatus()); } }
public function testCount() { authorizeFromEnv(); $validQueries = array(array('count' => 'true'), array('count' => true)); foreach ($validQueries as $query) { $resp = CleverStudent::all($query); $this->assertEquals($resp['count'] > 0, 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 = Plan::retrieve($id); } catch (InvalidRequestError $exception) { $plan = Plan::create(array('id' => $id, 'amount' => 0, 'currency' => 'usd', 'interval' => 'month', 'name' => 'Gold Test Plan')); } }
public function testUpcoming() { authorizeFromEnv(); $customer = self::createTestCustomer(); Stripe_InvoiceItem::create(array('customer' => $customer->id, 'amount' => 0, 'currency' => 'usd')); $invoice = Stripe_Invoice::upcoming(array('customer' => $customer->id)); $this->assertEqual($invoice->customer, $customer->id); $this->assertEqual($invoice->attempted, false); }
public function testCancelSubscription() { authorizeFromEnv(); $c = Stripe_Customer::create(array('card' => array('number' => '4242424242424242', 'exp_month' => 5, 'exp_year' => 2015), 'plan' => 'gold')); $c->cancelSubscription(array('at_period_end' => true)); $this->assertEqual($c->subscription->status, 'active'); $this->assertTrue($c->subscription->cancel_at_period_end); $c->cancelSubscription(); $this->assertEqual($c->subscription->status, 'canceled'); }
public function testCreate() { authorizeFromEnv(); $id = 'test_coupon-' . self::randomString(); $c = Stripe_Coupon::create(array('percent_off' => 25, 'duration' => 'repeating', 'duration_in_months' => 5, 'id' => $id)); $this->assertEqual($id, $c->id); // @codingStandardsIgnoreStart $this->assertEqual(25, $c->percent_off); // @codingStandardsIgnoreEnd }
public function testTransferUpdateMetadataAll() { $recipient = self::createTestRecipient(); authorizeFromEnv(); $transfer = Stripe_Transfer::create(array('amount' => 100, 'currency' => 'usd', 'recipient' => $recipient->id)); $transfer->metadata = array('test' => 'foo bar'); $transfer->save(); $updatedTransfer = Stripe_Transfer::retrieve($transfer->id); $this->assertEqual('foo bar', $updatedTransfer->metadata['test']); }
public function testRetrieve() { authorizeFromEnv(); $d = Stripe_Account::retrieve(); $this->assertEqual($d->id, "cuD9Rwx8pgmRZRpVe02lsuR9cwp2Bzf7"); $this->assertEqual($d->email, "*****@*****.**"); // @codingStandardsIgnoreStart $this->assertEqual($d->charge_enabled, false); $this->assertEqual($d->details_submitted, false); // @codingStandardsIgnoreEnd }
public function testSave() { authorizeFromEnv(); $planId = 'gold-' . self::randomString(); $p = Stripe_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 = Stripe_Plan::retrieve($planId); $this->assertEqual($p->name, $p2->name); }
public function testDecline() { authorizeFromEnv(); try { Stripe_Charge::create(array('amount' => 100, 'currency' => 'usd', 'card' => array('number' => '4000000000000002', 'exp_month' => '3', 'exp_year' => '2020'))); } catch (Stripe_CardError $e) { $this->assertEqual(402, $e->getHttpStatus()); $body = $e->getJsonBody(); $this->assertTrue($body['error']); } }
public function testDecline() { authorizeFromEnv(); try { Conekta_Charge::create(array('amount' => 2000, 'currency' => 'mxn', 'description' => 'Some desc', 'card' => array('number' => '4000000000000002', 'exp_month' => 5, 'exp_year' => 2015, 'cvc' => 123, 'name' => 'Mario Moreno'))); } catch (Conekta_CardError $e) { $this->assertEqual(402, $e->getHttpStatus()); $body = $e->getJsonBody(); $this->assertTrue($body['object'] == 'error'); $this->assertTrue($body['message'] == 'The card was declined'); } }
public function testDeletion() { authorizeFromEnv(); $id = 'test-coupon-' . self::randomString(); $coupon = Stripe_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->assertEqual($id, $customer->discount->coupon->id); $customer->deleteDiscount(); $this->assertFalse(isset($customer->discount)); $customer = Stripe_Customer::retrieve($customer->id); $this->assertFalse(isset($customer->discount)); }
public function testTransactionWithBoleto() { authorizeFromEnv(); $t1 = self::createTestTransaction(); $t1->setPaymentMethod('boleto'); $t1->charge(); $this->validateTransactionResponse($t1); $t2 = self::createTestTransactionWithCustomer(); $t2->setPaymentMethod('boleto'); $t2->charge(); $this->validateTransactionResponse($t2); $this->assertEqual($t2->getPaymentMethod(), 'boleto'); $this->assertEqual($t2->getBoletoUrl(), 'https://pagar.me'); $this->assertTrue($t2->getBoletoBarcode()); }
public function testCanPaginateWithFirstAndLastIDsOfCollection() { authorizeFromEnv(); $students = CleverStudent::all(array("limit" => 2)); $page_1_handle = array('oldest' => $students[0], 'newest' => end($students)); reset($students); # Request two students occuring after our last request $students_page_2 = CleverStudent::all(array("limit" => 2, "starting_after" => $page_1_handle['newest'])); $this->assertInternalType('array', $students_page_2); $page_2_handle = array('oldest' => $students_page_2[0], 'newest' => end($students_page_2)); reset($students_page_2); # Request the first two students again, or the ones before our last request $students_page_1_again = CleverStudent::all(array("limit" => 2, "ending_before" => $page_2_handle['oldest'])); $this->assertInternalType('array', $students_page_1_again); for ($i = 0; $i < count($students_page_1_again); $i++) { $this->assertEquals($students_page_1_again[$i], $students[$i]); } $this->assertEquals($students, $students_page_1_again); }
public function testList() { authorizeFromEnv(); $d = Stripe_BalanceTransaction::all(); $this->assertEqual($d->url, '/v1/balance/history'); }
protected function validateTransactionResponse($transaction) { authorizeFromEnv(); $this->assertTrue($transaction->getId()); if ($transaction->getPaymentMethod() == 'credit_card') { $this->assertEqual($transaction->getCardHolderName(), 'Jose da Silva'); } $this->assertTrue($transaction->getDateCreated()); $this->assertEqual($transaction->getAmount(), 1000); $this->assertEqual($transaction->getInstallments(), '1'); // $this->assertEqual($transaction->getStatus(), 'paid'); $this->assertFalse($transaction->getRefuseReason()); if ($transaction->getCustomer()) { $customer = $transaction->getCustomer(); $this->validateCustomerResponse($customer); } if ($transaction->getAddress()) { $this->validateAddress($transaction->getAddress()); } if ($transaction->getPhone()) { $this->validatePhone($transaction->getPhone()); } }
public function testAll() { authorizeFromEnv(); $invoices = Stripe_Invoice::all(); $this->assertTrue(count($invoices) > 0); }
public function testAllLimit() { authorizeFromEnv(); $districts = CleverDistrict::all(array("limit" => 1)); $this->assertEquals(count($districts), 1); }
public function testAllLimit() { authorizeFromEnv(); $schools = CleverSchool::all(array("limit" => 1)); $this->assertEquals(count($schools), 1); }