Skip to content

Commit

Permalink
Merge pull request #660 from Mangopay/feature/virtual-accounts
Browse files Browse the repository at this point in the history
Feature/virtual accounts
  • Loading branch information
iulian03 authored Oct 30, 2024
2 parents 21b90ee + 7e0f8a4 commit dbcdafb
Show file tree
Hide file tree
Showing 18 changed files with 428 additions and 1 deletion.
2 changes: 1 addition & 1 deletion MangoPay/ApiUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public function CreateKycPageFromFile($userId, $kycDocumentId, $filePath, $idemp
* @param string $userId User Id
* @param $year
* @param $month
* @return \MangoPay\EMoney EMoney obhect returned from API
* @return \MangoPay\EMoney EMoney object returned from API
* @throws Libraries\Exception
*/
public function GetEMoney($userId, $year = null, $month = null)
Expand Down
56 changes: 56 additions & 0 deletions MangoPay/ApiVirtualAccounts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace MangoPay;

class ApiVirtualAccounts extends Libraries\ApiBase
{
/**
* Create new Virtual Account
* @param String $walletId
* @param VirtualAccount $virtualAccount
* @return \MangoPay\VirtualAccount Virtual Account object returned from API
*/
public function Create($virtualAccount, $walletId, $idempotencyKey = null)
{
return $this->CreateObject('virtual_account_create', $virtualAccount, '\MangoPay\VirtualAccount', $walletId, $idempotencyKey);
}

/**
* @param string $walletId
* @param string $virtualAccountId
* @return \MangoPay\VirtualAccount
*/
public function Get($walletId, $virtualAccountId)
{
return $this->GetObject('virtual_account_get', '\MangoPay\VirtualAccount', $walletId, $virtualAccountId);
}

/**
* @param \MangoPay\Pagination $pagination Pagination object
* @param string $walletId
* @return \MangoPay\VirtualAccount[]
*/
public function GetAll($walletId, $pagination = null, $sorting = null)
{
return $this->GetList('virtual_account_get_all', $pagination, '\MangoPay\VirtualAccount', $walletId, $sorting);
}

/**
* @param string $walletId
* @param string $virtualAccountId
* @return \MangoPay\VirtualAccount
*/
public function Deactivate($walletId, $virtualAccountId)
{
$empty_object = new VirtualAccount();
return $this->SaveObject('virtual_account_deactivate', $empty_object, '\MangoPay\VirtualAccount', $walletId, $virtualAccountId);
}

/**
* @return \MangoPay\VirtualAccountAvailabilities
*/
public function GetAvailabilities()
{
return $this->GetObject('virtual_account_get_availabilities', '\MangoPay\VirtualAccountAvailabilities');
}
}
16 changes: 16 additions & 0 deletions MangoPay/InternationalAccount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace MangoPay;

class InternationalAccount extends Libraries\Dto
{
/**
* @var string
*/
public $Iban;

/**
* @var string
*/
public $Bic;
}
18 changes: 18 additions & 0 deletions MangoPay/InternationalAccountDetails.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace MangoPay;

class InternationalAccountDetails extends Libraries\Dto
{
/**
* Information about the address associated with the international IBAN account.
* @var VirtualAccountAddress
*/
public $Address;

/**
* The IBAN and BIC of the account.
* @var InternationalAccount
*/
public $Account;
}
7 changes: 7 additions & 0 deletions MangoPay/Libraries/ApiBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ protected function getLogger()
'get_conversion' => ['/conversions/%s', RequestType::GET],
'create_conversion_quote' => ['/conversions/quote', RequestType::POST],
'get_conversion_quote' => ['/conversions/quote/%s', RequestType::GET],

'virtual_account_create' => ['/wallets/%s/virtual-accounts', RequestType::POST],
'virtual_account_deactivate' => ['/wallets/%s/virtual-accounts/%s', RequestType::PUT],
'virtual_account_get' => ['/wallets/%s/virtual-accounts/%s', RequestType::GET],
'virtual_account_get_all' => ['/wallets/%s/virtual-accounts', RequestType::GET],
'virtual_account_get_availabilities' => ['/virtual-accounts/availability', RequestType::GET]
];

/**
Expand Down Expand Up @@ -615,6 +621,7 @@ protected function GetObjectForIdempotencyUrl($url)
'users_createbankaccounts_us' => '\MangoPay\BankAccount',
'users_createbankaccounts_ca' => '\MangoPay\BankAccount',
'users_createbankaccounts_other' => '\MangoPay\BankAccount',
'virtual_account_create' => '\MangoPay\VirtualAccount',
'kyc_documents_create' => '\MangoPay\KycDocument',
'kyc_page_create' => '',
'wallets_create' => '\MangoPay\Wallet',
Expand Down
18 changes: 18 additions & 0 deletions MangoPay/LocalAccount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace MangoPay;

class LocalAccount extends Libraries\Dto
{
/**
* The account number of the account
* @var string
*/
public $AccountNumber;

/**
* The sort code of the account.
* @var string
*/
public $SortCode;
}
18 changes: 18 additions & 0 deletions MangoPay/LocalAccountDetails.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace MangoPay;

class LocalAccountDetails extends Libraries\Dto
{
/**
* Information about the address associated with the local IBAN account.
* @var VirtualAccountAddress
*/
public $Address;

/**
* Information about the address associated with the local IBAN account.
* @var LocalAccount
*/
public $Account;
}
6 changes: 6 additions & 0 deletions MangoPay/MangoPayApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ class MangoPayApi
*/
public $Repudiations;

/**
* Provides VirtualAccount methods
* @var ApiVirtualAccounts
*/
public $VirtualAccounts;

/**
* @var LoggerInterface
Expand Down Expand Up @@ -240,6 +245,7 @@ public function __construct()
$this->Regulatory = new ApiRegulatory($this);
$this->Deposits = new ApiDeposits($this);
$this->Conversions = new ApiConversions($this);
$this->VirtualAccounts = new ApiVirtualAccounts($this);

// Setting default NullLogger
$this->logger = new NullLogger();
Expand Down
76 changes: 76 additions & 0 deletions MangoPay/VirtualAccount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

namespace MangoPay;

/**
* Virtual Account entity
*/
class VirtualAccount extends Libraries\EntityBase
{
/**
* The ID of the wallet
* @var string
*/
public $WalletId;

/**
* The credited user ID
* @var string
*/
public $CreditedUserId;

/**
* The type of the virtual account
* Allowed values: `COLLECTION`, `USER_OWNED`
* @var string
* @see \MangoPay\VirtualAccountPurpose
*/
public $VirtualAccountPurpose;

/**
* The country of the IBAN. The country must correspond to the currency of the wallet
* ISO 3166-1 alpha-2 format is expected
* @var string
*/
public $Country;

/**
* The status of the virtual account creation
* Allowed values: `COLLECTION`, `USER_OWNED`
* @var string
* @see \MangoPay\VirtualAccountStatus
*/
public $Status;

/**
* Whether the banking alias is active or not
* @var bool
*/
public $Active;

/**
* The current Status of the Virtual Account
* Allowed values: `COLLECTION`, `USER_OWNED`
* @var string
* @see \MangoPay\VirtualAccountOwner
*/
public $AccountOwner;

/**
* The current Status of the Virtual Account
* @var \MangoPay\LocalAccountDetails
*/
public $LocalAccountsDetails;

/**
* The current Status of the Virtual Account
* @var \MangoPay\InternationalAccountDetails
*/
public $InternationalAccountDetails;

/**
* The current Status of the Virtual Account
* @var \MangoPay\VirtualAccountCapabilities
*/
public $Capabilities;
}
31 changes: 31 additions & 0 deletions MangoPay/VirtualAccountAddress.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace MangoPay;

class VirtualAccountAddress extends Libraries\Dto
{
/**
* @var string
*/
public $StreetName;

/**
* @var string
*/
public $PostCode;

/**
* @var string
*/
public $TownName;

/**
* @var string
*/
public $CountrySubDivision;

/**
* @var string
*/
public $Country;
}
16 changes: 16 additions & 0 deletions MangoPay/VirtualAccountAvailabilities.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace MangoPay;

class VirtualAccountAvailabilities extends Libraries\Dto
{
/**
* * @var VirtualAccountAvailability[]
*/
public $Collection;

/**
* * @var VirtualAccountAvailability[]
*/
public $UserOwned;
}
24 changes: 24 additions & 0 deletions MangoPay/VirtualAccountAvailability.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace MangoPay;

class VirtualAccountAvailability extends Libraries\EntityBase
{
/**
* ISO 3166-1 alpha-2 format is expected
* * @var string
*/
public $Country;

/**
* Whether international bank wires can be made to this account
* @var Boolean
*/
public $Available;

/**
* List of currencies supported by the account
* @var CurrencyIso[]
* */
public $Currencies;
}
24 changes: 24 additions & 0 deletions MangoPay/VirtualAccountCapabilities.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace MangoPay;

class VirtualAccountCapabilities extends Libraries\Dto
{
/**
* Whether local bank wires can be made to this account.
* @var bool
*/
public $LocalPayInAvailable;

/**
* Whether international bank wires can be made to this account
* @var bool
*/
public $InternationalPayInAvailable;

/**
* List of currencies supported by the account
* @var CurrencyIso[]
*/
public $Currencies;
}
9 changes: 9 additions & 0 deletions MangoPay/VirtualAccountOwner.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace MangoPay;

class VirtualAccountOwner
{
const Collection = "COLLECTION";
const UserOwned = "USER_OWNED";
}
9 changes: 9 additions & 0 deletions MangoPay/VirtualAccountPurpose.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace MangoPay;

class VirtualAccountPurpose
{
const Collection = "COLLECTION";
const UserOwned = "USER_OWNED";
}
15 changes: 15 additions & 0 deletions MangoPay/VirtualAccountStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace MangoPay;

/**
* Virtual Account statuses
*/
class VirtualAccountStatus
{
const Pending = "PENDING";
const Active = "ACTIVE";
const Failed = "FAILED";
const Blocked = "BLOCKED";
const Closed = "CLOSED";
}
Loading

0 comments on commit dbcdafb

Please sign in to comment.