CaptureTest.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. require_once('TestAutoLoad.php');
  3. use Culqi\Culqi;
  4. class CaptureTest extends PHPUnit_Framework_TestCase {
  5. protected $API_KEY;
  6. protected $PUBLIC_API_KEY;
  7. protected function setUp() {
  8. $this->PUBLIC_API_KEY = getenv("PUBLIC_API_KEY");
  9. $this->API_KEY = getenv("API_KEY");
  10. $this->culqi_token = new Culqi(array("api_key" => $this->PUBLIC_API_KEY ));
  11. $this->culqi = new Culqi(array("api_key" => $this->API_KEY ));
  12. }
  13. protected function createToken() {
  14. $token = $this->culqi_token->Tokens->create(
  15. array(
  16. "card_number" => "4111111111111111",
  17. "cvv" => "123",
  18. "email" => "wmuro".uniqid()."@me.com",
  19. "expiration_month" => 9,
  20. "expiration_year" => 2020,
  21. "fingerprint" => "q352454534"
  22. )
  23. );
  24. return $token;
  25. }
  26. public function testVerifyToken() {
  27. $this->assertEquals('token', $this->createToken()->object);
  28. }
  29. public function createCharge() {
  30. $charge = $this->culqi->Charges->create(
  31. array(
  32. "amount" => 1000,
  33. "capture" => false,
  34. "currency_code" => "PEN",
  35. "description" => "Venta de prueba",
  36. "email" => "test@culqi.com",
  37. "installments" => 0,
  38. "source_id" => $this->createToken()->id
  39. )
  40. );
  41. return $charge;
  42. }
  43. public function testCreateCharge() {
  44. $this->assertEquals('charge', $this->createCharge()->object);
  45. }
  46. public function testCaptureCharge() {
  47. $captureCharge = $this->culqi->Charges->capture($this->createCharge()->id);
  48. $this->assertEquals('charge', $captureCharge->object);
  49. }
  50. }