Skip to content

Commit dbcdafb

Browse files
authored
Merge pull request #660 from Mangopay/feature/virtual-accounts
Feature/virtual accounts
2 parents 21b90ee + 7e0f8a4 commit dbcdafb

18 files changed

+428
-1
lines changed

MangoPay/ApiUsers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ public function CreateKycPageFromFile($userId, $kycDocumentId, $filePath, $idemp
337337
* @param string $userId User Id
338338
* @param $year
339339
* @param $month
340-
* @return \MangoPay\EMoney EMoney obhect returned from API
340+
* @return \MangoPay\EMoney EMoney object returned from API
341341
* @throws Libraries\Exception
342342
*/
343343
public function GetEMoney($userId, $year = null, $month = null)

MangoPay/ApiVirtualAccounts.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
namespace MangoPay;
4+
5+
class ApiVirtualAccounts extends Libraries\ApiBase
6+
{
7+
/**
8+
* Create new Virtual Account
9+
* @param String $walletId
10+
* @param VirtualAccount $virtualAccount
11+
* @return \MangoPay\VirtualAccount Virtual Account object returned from API
12+
*/
13+
public function Create($virtualAccount, $walletId, $idempotencyKey = null)
14+
{
15+
return $this->CreateObject('virtual_account_create', $virtualAccount, '\MangoPay\VirtualAccount', $walletId, $idempotencyKey);
16+
}
17+
18+
/**
19+
* @param string $walletId
20+
* @param string $virtualAccountId
21+
* @return \MangoPay\VirtualAccount
22+
*/
23+
public function Get($walletId, $virtualAccountId)
24+
{
25+
return $this->GetObject('virtual_account_get', '\MangoPay\VirtualAccount', $walletId, $virtualAccountId);
26+
}
27+
28+
/**
29+
* @param \MangoPay\Pagination $pagination Pagination object
30+
* @param string $walletId
31+
* @return \MangoPay\VirtualAccount[]
32+
*/
33+
public function GetAll($walletId, $pagination = null, $sorting = null)
34+
{
35+
return $this->GetList('virtual_account_get_all', $pagination, '\MangoPay\VirtualAccount', $walletId, $sorting);
36+
}
37+
38+
/**
39+
* @param string $walletId
40+
* @param string $virtualAccountId
41+
* @return \MangoPay\VirtualAccount
42+
*/
43+
public function Deactivate($walletId, $virtualAccountId)
44+
{
45+
$empty_object = new VirtualAccount();
46+
return $this->SaveObject('virtual_account_deactivate', $empty_object, '\MangoPay\VirtualAccount', $walletId, $virtualAccountId);
47+
}
48+
49+
/**
50+
* @return \MangoPay\VirtualAccountAvailabilities
51+
*/
52+
public function GetAvailabilities()
53+
{
54+
return $this->GetObject('virtual_account_get_availabilities', '\MangoPay\VirtualAccountAvailabilities');
55+
}
56+
}

MangoPay/InternationalAccount.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace MangoPay;
4+
5+
class InternationalAccount extends Libraries\Dto
6+
{
7+
/**
8+
* @var string
9+
*/
10+
public $Iban;
11+
12+
/**
13+
* @var string
14+
*/
15+
public $Bic;
16+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace MangoPay;
4+
5+
class InternationalAccountDetails extends Libraries\Dto
6+
{
7+
/**
8+
* Information about the address associated with the international IBAN account.
9+
* @var VirtualAccountAddress
10+
*/
11+
public $Address;
12+
13+
/**
14+
* The IBAN and BIC of the account.
15+
* @var InternationalAccount
16+
*/
17+
public $Account;
18+
}

MangoPay/Libraries/ApiBase.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,12 @@ protected function getLogger()
233233
'get_conversion' => ['/conversions/%s', RequestType::GET],
234234
'create_conversion_quote' => ['/conversions/quote', RequestType::POST],
235235
'get_conversion_quote' => ['/conversions/quote/%s', RequestType::GET],
236+
237+
'virtual_account_create' => ['/wallets/%s/virtual-accounts', RequestType::POST],
238+
'virtual_account_deactivate' => ['/wallets/%s/virtual-accounts/%s', RequestType::PUT],
239+
'virtual_account_get' => ['/wallets/%s/virtual-accounts/%s', RequestType::GET],
240+
'virtual_account_get_all' => ['/wallets/%s/virtual-accounts', RequestType::GET],
241+
'virtual_account_get_availabilities' => ['/virtual-accounts/availability', RequestType::GET]
236242
];
237243

238244
/**
@@ -615,6 +621,7 @@ protected function GetObjectForIdempotencyUrl($url)
615621
'users_createbankaccounts_us' => '\MangoPay\BankAccount',
616622
'users_createbankaccounts_ca' => '\MangoPay\BankAccount',
617623
'users_createbankaccounts_other' => '\MangoPay\BankAccount',
624+
'virtual_account_create' => '\MangoPay\VirtualAccount',
618625
'kyc_documents_create' => '\MangoPay\KycDocument',
619626
'kyc_page_create' => '',
620627
'wallets_create' => '\MangoPay\Wallet',

MangoPay/LocalAccount.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace MangoPay;
4+
5+
class LocalAccount extends Libraries\Dto
6+
{
7+
/**
8+
* The account number of the account
9+
* @var string
10+
*/
11+
public $AccountNumber;
12+
13+
/**
14+
* The sort code of the account.
15+
* @var string
16+
*/
17+
public $SortCode;
18+
}

MangoPay/LocalAccountDetails.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace MangoPay;
4+
5+
class LocalAccountDetails extends Libraries\Dto
6+
{
7+
/**
8+
* Information about the address associated with the local IBAN account.
9+
* @var VirtualAccountAddress
10+
*/
11+
public $Address;
12+
13+
/**
14+
* Information about the address associated with the local IBAN account.
15+
* @var LocalAccount
16+
*/
17+
public $Account;
18+
}

MangoPay/MangoPayApi.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ class MangoPayApi
169169
*/
170170
public $Repudiations;
171171

172+
/**
173+
* Provides VirtualAccount methods
174+
* @var ApiVirtualAccounts
175+
*/
176+
public $VirtualAccounts;
172177

173178
/**
174179
* @var LoggerInterface
@@ -240,6 +245,7 @@ public function __construct()
240245
$this->Regulatory = new ApiRegulatory($this);
241246
$this->Deposits = new ApiDeposits($this);
242247
$this->Conversions = new ApiConversions($this);
248+
$this->VirtualAccounts = new ApiVirtualAccounts($this);
243249

244250
// Setting default NullLogger
245251
$this->logger = new NullLogger();

MangoPay/VirtualAccount.php

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
3+
namespace MangoPay;
4+
5+
/**
6+
* Virtual Account entity
7+
*/
8+
class VirtualAccount extends Libraries\EntityBase
9+
{
10+
/**
11+
* The ID of the wallet
12+
* @var string
13+
*/
14+
public $WalletId;
15+
16+
/**
17+
* The credited user ID
18+
* @var string
19+
*/
20+
public $CreditedUserId;
21+
22+
/**
23+
* The type of the virtual account
24+
* Allowed values: `COLLECTION`, `USER_OWNED`
25+
* @var string
26+
* @see \MangoPay\VirtualAccountPurpose
27+
*/
28+
public $VirtualAccountPurpose;
29+
30+
/**
31+
* The country of the IBAN. The country must correspond to the currency of the wallet
32+
* ISO 3166-1 alpha-2 format is expected
33+
* @var string
34+
*/
35+
public $Country;
36+
37+
/**
38+
* The status of the virtual account creation
39+
* Allowed values: `COLLECTION`, `USER_OWNED`
40+
* @var string
41+
* @see \MangoPay\VirtualAccountStatus
42+
*/
43+
public $Status;
44+
45+
/**
46+
* Whether the banking alias is active or not
47+
* @var bool
48+
*/
49+
public $Active;
50+
51+
/**
52+
* The current Status of the Virtual Account
53+
* Allowed values: `COLLECTION`, `USER_OWNED`
54+
* @var string
55+
* @see \MangoPay\VirtualAccountOwner
56+
*/
57+
public $AccountOwner;
58+
59+
/**
60+
* The current Status of the Virtual Account
61+
* @var \MangoPay\LocalAccountDetails
62+
*/
63+
public $LocalAccountsDetails;
64+
65+
/**
66+
* The current Status of the Virtual Account
67+
* @var \MangoPay\InternationalAccountDetails
68+
*/
69+
public $InternationalAccountDetails;
70+
71+
/**
72+
* The current Status of the Virtual Account
73+
* @var \MangoPay\VirtualAccountCapabilities
74+
*/
75+
public $Capabilities;
76+
}

MangoPay/VirtualAccountAddress.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace MangoPay;
4+
5+
class VirtualAccountAddress extends Libraries\Dto
6+
{
7+
/**
8+
* @var string
9+
*/
10+
public $StreetName;
11+
12+
/**
13+
* @var string
14+
*/
15+
public $PostCode;
16+
17+
/**
18+
* @var string
19+
*/
20+
public $TownName;
21+
22+
/**
23+
* @var string
24+
*/
25+
public $CountrySubDivision;
26+
27+
/**
28+
* @var string
29+
*/
30+
public $Country;
31+
}

0 commit comments

Comments
 (0)