Skip to content

Commit

Permalink
charge create should return a payment object
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared King committed Dec 6, 2020
1 parent 1869b12 commit e2c742a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/Charge.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,20 @@ class Charge extends BaseObject
use Operations\Create;

protected $_endpoint = '/charges';

/**
* Creates an object.
*
* @param array<mixed> $params
* @param array<mixed> $opts
*
* @return Payment newly created object
*/
public function create(array $params = [], array $opts = [])
{
$response = $this->_client->request('post', $this->getEndpoint(), $params, $opts);
$payment = new Payment($this->_client);

return Util::convertToObject($payment, $response['body']); /* @phpstan-ignore-line */
}
}
2 changes: 1 addition & 1 deletion tests/ChargeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testCreate()
{
$charge = self::$invoiced->Charge->create(['customer' => 123]);

$this->assertInstanceOf('Invoiced\\Charge', $charge);
$this->assertInstanceOf('Invoiced\\Payment', $charge);
$this->assertEquals(123, $charge->id);
$this->assertEquals(100, $charge->amount);
}
Expand Down

0 comments on commit e2c742a

Please sign in to comment.