Skip to content

Commit f69e24d

Browse files
Allowing Address to be optional when creating a new payment recipient.
Updating Docblocks on createRecipient method to better explain the $account parameter.
1 parent 19c45e0 commit f69e24d

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

src/Resources/Payments.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,21 @@ class Payments extends AbstractResource
1313
* Create a recipient request for payment initiation.
1414
*
1515
* @param string $name
16-
* @param BacsAccount|string $account
17-
* @param RecipientAddress $address
16+
* @param BacsAccount|string $account Bacs account or IBAN.
17+
* @param RecipientAddress|null $address
1818
* @throws PlaidRequestException
1919
* @return object
2020
*/
21-
public function createRecipient(string $name, $account, RecipientAddress $address): object
21+
public function createRecipient(string $name, $account, ?RecipientAddress $address = null): object
2222
{
2323
$params = [
24-
"name" => $name,
25-
"address" => (object) $address->toArray()
24+
"name" => $name
2625
];
2726

27+
if( $address ) {
28+
$params["address"] = (object) $address->toArray();
29+
}
30+
2831
if( \is_string($account) ){
2932
$params["iban"] = $account;
3033
}

tests/PaymentsTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,24 @@ public function test_create_recipient(): void
4444
);
4545
}
4646

47+
public function test_create_recipient_with_no_address(): void
48+
{
49+
$response = $this->getPlaidClient()->payments->createRecipient(
50+
"name",
51+
"iban"
52+
);
53+
54+
$this->assertEquals("POST", $response->method);
55+
$this->assertEquals("2020-09-14", $response->version);
56+
$this->assertEquals("application/json", $response->content);
57+
$this->assertEquals("/payment_initiation/recipient/create", $response->path);
58+
$this->assertEquals("client_id", $response->params->client_id);
59+
$this->assertEquals("secret", $response->params->secret);
60+
$this->assertEquals("name", $response->params->name);
61+
$this->assertEquals("iban", $response->params->iban);
62+
$this->assertFalse(isset($response->params->address));
63+
}
64+
4765
public function test_create_recipient_with_bacs_account_entity(): void
4866
{
4967
$response = $this->getPlaidClient()->payments->createRecipient(

0 commit comments

Comments
 (0)