mirror of
https://github.com/bitinflow/accounts.git
synced 2026-03-13 21:45:52 +00:00
Add test implementation for charges, documents & payment intents
This commit is contained in:
62
tests/GhostZero/BitinflowAccounts/ApiChargesTest.php
Normal file
62
tests/GhostZero/BitinflowAccounts/ApiChargesTest.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GhostZero\BitinflowAccounts\Tests;
|
||||
|
||||
use GhostZero\BitinflowAccounts\Tests\TestCases\ApiTestCase;
|
||||
|
||||
/**
|
||||
* @author René Preuß <rene@preuss.io>
|
||||
*/
|
||||
class ApiChargesTest extends ApiTestCase
|
||||
{
|
||||
|
||||
public function testCaptureWithoutCapture(): void
|
||||
{
|
||||
$this->getClient()->withToken($this->getToken());
|
||||
|
||||
$result = $this->getClient()->createCharge([
|
||||
'amount' => 2000,
|
||||
'currency' => 'usd',
|
||||
'source' => 'tok_visa',
|
||||
'description' => 'Charge for jenny.rosen@example.com',
|
||||
]);
|
||||
$this->registerResult($result);
|
||||
$this->assertTrue($result->success());
|
||||
$this->assertArrayHasKey('id', $result->data());
|
||||
$this->assertEquals(2000, $result->data()->amount);
|
||||
$this->assertTrue($result->data()->captured);
|
||||
}
|
||||
|
||||
public function testChargeWithCapture(): void
|
||||
{
|
||||
$this->getClient()->withToken($this->getToken());
|
||||
|
||||
$result = $this->getClient()->createCharge([
|
||||
'amount' => 2000,
|
||||
'currency' => 'usd',
|
||||
'source' => 'tok_visa',
|
||||
'description' => 'Charge for jenny.rosen@example.com',
|
||||
'capture' => false, // default is true for instant capture
|
||||
'metadata' => [
|
||||
'foo' => 'bar',
|
||||
],
|
||||
'receipt_email' => 'rene+unittest@bitinflow.com',
|
||||
]);
|
||||
$this->registerResult($result);
|
||||
$this->assertTrue($result->success());
|
||||
$this->assertArrayHasKey('id', $result->data());
|
||||
$this->assertEquals(2000, $result->data()->amount);
|
||||
$this->assertFalse($result->data()->captured);
|
||||
|
||||
$charge = $result->data();
|
||||
|
||||
$result = $this->getClient()->captureCharge($charge->id);
|
||||
$this->registerResult($result);
|
||||
$this->assertTrue($result->success());
|
||||
$this->assertArrayHasKey('id', $result->data());
|
||||
$this->assertEquals(2000, $result->data()->amount);
|
||||
$this->assertTrue($result->data()->captured);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user