Skip to content

Commit

Permalink
Merge pull request #580 from Mangopay/feature/deposits
Browse files Browse the repository at this point in the history
Feature/deposits
  • Loading branch information
iulian03 authored Nov 25, 2022
2 parents 2ccbd4f + 3deea22 commit 6cabfd3
Show file tree
Hide file tree
Showing 14 changed files with 547 additions and 11 deletions.
40 changes: 40 additions & 0 deletions MangoPay/ApiDeposits.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace MangoPay;

/**
* Class to management MangoPay API for users
*/
class ApiDeposits extends Libraries\ApiBase
{
/**
* Create Deposit
* @param CreateDeposit $deposit Deposit object to save
* @return Deposit Deposit object returned from API
*/
public function Create(CreateDeposit $deposit)
{
return $this->CreateObject('deposits_create', $deposit, '\MangoPay\Deposit');
}

/**
* Get Deposit
* @param string $depositId Deposit identifier
* @return Deposit Deposit object returned from API
*/
public function Get($depositId)
{
return $this->GetObject('deposits_get', '\MangoPay\Deposit', $depositId);
}

/**
* Cancel Deposit
* @param string $depositId Deposit identifier
* @param CancelDeposit $dto Cancel deposit body
* @return Deposit Deposit object returned from API
*/
public function Cancel($depositId, CancelDeposit $dto)
{
return $this->SaveObject('deposits_cancel', $dto, '\MangoPay\Deposit', $depositId);
}
}
10 changes: 10 additions & 0 deletions MangoPay/ApiPayIns.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,14 @@ public function GetExtendedCardView($payInId)
{
return $this->GetObject('get_extended_card_view', '\MangoPay\PayInWebExtendedView', $payInId);
}

/**
* Create Card PreAuthorized Deposit PayIn
* @param CreateCardPreAuthorizedDepositPayIn $payIn PayIn object to create
* @return PayIn Deposit object returned from API
*/
public function CreateCardPreAuthorizedDepositPayIn(CreateCardPreAuthorizedDepositPayIn $payIn)
{
return $this->CreateObject('payins_create_card_pre_authorized_deposit', $payIn, '\MangoPay\PayIn');
}
}
21 changes: 21 additions & 0 deletions MangoPay/CancelDeposit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace MangoPay;

class CancelDeposit extends Libraries\Dto
{
/**
* @var string
* @see CardPreAuthorizationPaymentStatus
*/
public $PaymentStatus;

/**
* Get array with mapping which property is object and what type of object
* @return array
*/
public function GetSubObjects()
{
return parent::GetSubObjects();
}
}
49 changes: 49 additions & 0 deletions MangoPay/CreateCardPreAuthorizedDepositPayIn.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace MangoPay;

class CreateCardPreAuthorizedDepositPayIn extends Libraries\EntityBase
{
/**
* @var string
*/
public $AuthorId;

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

/**
* @var Money
*/
public $DebitedFunds;

/**
* @var Money
*/
public $Fees;

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

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

/**
* Get array with mapping which property is object and what type of object
* @return array
*/
public function GetSubObjects()
{
$subObjects = parent::GetSubObjects();
$subObjects['DebitedFunds'] = '\MangoPay\Money';
$subObjects['Fees'] = '\MangoPay\Money';

return $subObjects;
}
}
72 changes: 72 additions & 0 deletions MangoPay/CreateDeposit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

namespace MangoPay;

class CreateDeposit extends Libraries\Dto
{
/**
* @var string
*/
public $AuthorId;

/**
* @var Money
*/
public $DebitedFunds;

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

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

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

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

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

/**
* BrowserInfo
* @var BrowserInfo
*/
public $BrowserInfo;

/**
* @var Billing
*/
public $Billing;

/**
* @var Shipping
*/
public $Shipping;

/**
* Get array with mapping which property is object and what type of object
* @return array
*/
public function GetSubObjects()
{
$subObjects = parent::GetSubObjects();
$subObjects['DebitedFunds'] = '\MangoPay\Money';
$subObjects['BrowserInfo'] = '\MangoPay\BrowserInfo';
$subObjects['Billing'] = '\MangoPay\Billing';
$subObjects['Shipping'] = '\MangoPay\Shipping';

return $subObjects;
}
}
135 changes: 135 additions & 0 deletions MangoPay/Deposit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<?php

namespace MangoPay;

class Deposit extends Libraries\EntityBase
{
/**
* @var string
*/
public $AuthorId;

/**
* @var Money
*/
public $DebitedFunds;

/**
* @var string
* @see DepositStatus
*/
public $Status;

/**
* @var string
* @see CardPreAuthorizationPaymentStatus
*/
public $PaymentStatus;

/**
* @var PayinsLinked
*/
public $PayinsLinked;

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

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

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

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

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

/**
* @var boolean
*/
public $SecureModeNeeded;

/**
* @var int Unix timestamp
*/
public $ExpirationDate;

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

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

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

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

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

/**
* BrowserInfo
* @var BrowserInfo
*/
public $BrowserInfo;

/**
* @var Billing
*/
public $Billing;

/**
* @var Shipping
*/
public $Shipping;

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

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

/**
* Get array with mapping which property is object and what type of object
* @return array
*/
public function GetSubObjects()
{
$subObjects = parent::GetSubObjects();
$subObjects['PayinsLinked'] = '\MangoPay\PayinsLinked';
$subObjects['DebitedFunds'] = '\MangoPay\Money';
$subObjects['BrowserInfo'] = '\MangoPay\BrowserInfo';
$subObjects['Billing'] = '\MangoPay\Billing';
$subObjects['Shipping'] = '\MangoPay\Shipping';

return $subObjects;
}
}
14 changes: 14 additions & 0 deletions MangoPay/DepositStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace MangoPay;

final class DepositStatus
{
const Created = 'CREATED';
const Succeeded = 'SUCCEEDED';
const Failed = 'FAILED';

private function __construct()
{
}
}
8 changes: 8 additions & 0 deletions MangoPay/EventType.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,12 @@ class EventType

const InstantPayoutSucceeded = "INSTANT_PAYOUT_SUCCEEDED";
const InstantPayoutFallbacked = "INSTANT_PAYOUT_FALLBACKED";

const DepositPreAuthorizationCreated = "DEPOSIT_PREAUTHORIZATION_CREATED";
const DepositPreAuthorizationFailed = "DEPOSIT_PREAUTHORIZATION_FAILED";
const DepositPreAuthorizationPaymentWaiting = "DEPOSIT_PREAUTHORIZATION_PAYMENT_WAITING";
const DepositPreAuthorizationPaymentExpired = "DEPOSIT_PREAUTHORIZATION_PAYMENT_EXPIRED";
const DepositPreAuthorizationPaymentCancelRequest = "DEPOSIT_PREAUTHORIZATION_PAYMENT_CANCEL_REQUEST";
const DepositPreAuthorizationPaymentCanceled = "DEPOSIT_PREAUTHORIZATION_PAYMENT_CANCELED";
const DepositPreAuthorizationPaymentValidated = "DEPOSIT_PREAUTHORIZATION_PAYMENT_VALIDATED";
}
6 changes: 5 additions & 1 deletion MangoPay/Libraries/ApiBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ protected function getLogger()
'payins_recurring_registration_get' => ['/recurringpayinregistrations/%s', RequestType::GET],
'payins_recurring_registration_put' => ['/recurringpayinregistrations/%s', RequestType::PUT],
'payins_recurring_card_direct' => ['/payins/recurring/card/direct', RequestType::POST],
'payins_create_card_pre_authorized_deposit' => ['/payins/deposit-preauthorized/direct/full-capture', RequestType::POST],

'repudiation_get' => ['/repudiations/%s', RequestType::GET],

Expand Down Expand Up @@ -204,8 +205,11 @@ protected function getLogger()
'transactions_get_for_bank_account' => ['/bankaccounts/%s/transactions', RequestType::GET],

'country_authorization_get' => ['/countries/%s/authorizations', RequestType::GET],
'country_authorization_all' => ['/countries/authorizations', RequestType::GET]
'country_authorization_all' => ['/countries/authorizations', RequestType::GET],

'deposits_create' => ['/deposit-preauthorizations/card/direct', RequestType::POST],
'deposits_get' => ['/deposit-preauthorizations/%s', RequestType::GET],
'deposits_cancel' => ['/deposit-preauthorizations/%s', RequestType::PUT]
];

/**
Expand Down
Loading

0 comments on commit 6cabfd3

Please sign in to comment.