File tree Expand file tree Collapse file tree 2 files changed +26
-5
lines changed
Expand file tree Collapse file tree 2 files changed +26
-5
lines changed Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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 (
You can’t perform that action at this time.
0 commit comments