Skip to content

Commit

Permalink
Added: Card pre-authorization (with PayIn), ...
Browse files Browse the repository at this point in the history
PayInBankWire, get user cards & transactions, new type of documents for
KYC
  • Loading branch information
lukasz-puslecki committed Jan 29, 2014
1 parent de7826e commit 798c941
Show file tree
Hide file tree
Showing 17 changed files with 567 additions and 49 deletions.
123 changes: 123 additions & 0 deletions MangoPaySDK/entities/cardPreAuthorization.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?php
namespace MangoPay;

/**
* Pre-authorization entity
*/
class CardPreAuthorization extends EntityBase {

/**
* The user Id of the author of the pre-authorization
* @var string
*/
public $AuthorId;

/**
* It represents the amount debited on the bank account
* of the Author.DebitedFunds = Fees + CreditedFunds
* (amount received on wallet)
* @var \MangoPay\Money
*/
public $DebitedFunds;

/**
* Status of the PreAuthorization: CREATED, SUCCEEDED, FAILED
* @var string
*/
public $Status;

/**
* The status of the payment after the PreAuthorization:
* WAITING, CANCELED, EXPIRED, VALIDATED
* @var string
*/
public $PaymentStatus;

/**
* The PreAuthorization result code
* @var string
*/
public $ResultCode;

/**
* The PreAuthorization result Message explaining the result code
* @var string
*/
public $ResultMessage;

/**
* How the PreAuthorization has been executed.
* Only on value for now: CARD
* @var string
*/
public $ExecutionType;

/**
* The SecureMode correspond to '3D secure' for CB Visa and MasterCard
* or 'Amex Safe Key' for American Express.
* This field lets you activate it manualy.
* @var string
*/
public $SecureMode;

/**
* The ID of the registered card (Got through CardRegistration object)
* @var string
*/
public $CardId;

/**
* Boolean. The value is 'true' if the SecureMode was used
* @var string
*/
public $SecureModeNeeded;

/**
* This is the URL where to redirect users to proceed
* to 3D secure validation
* @var string
*/
public $SecureModeRedirectUrl;

/**
* This is the URL where users are automatically redirected
* after 3D secure validation (if activated)
* @var string
*/
public $SecureModeReturnURL;

/**
* The date when the payment is processed
* @var Timestamp
*/
public $ExpirationDate;

/**
* The Id of the associated PayIn
* @var string
*/
public $PayInId;

/**
* Get array with mapping which property is object and what type of object
* @return array
*/
public function GetSubObjects() {
return array(
'DebitedFunds' => '\MangoPay\Money'
);
}

/**
* Get array with read-only properties
* @return array
*/
public function GetReadOnlyProperties() {
$properties = parent::GetReadOnlyProperties();
array_push( $properties, 'Status' );
array_push( $properties, 'ResultCode' );
array_push( $properties, 'ResultMessage' );

return $properties;
}
}
2 changes: 2 additions & 0 deletions MangoPaySDK/entities/payIn.inc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class PayIn extends Transaction {
'PaymentType' => array(
'_property_name' => 'PaymentDetails',
'CARD' => '\MangoPay\PayInPaymentDetailsCard',
'PREAUTHORIZED' => '\MangoPay\PayInPaymentDetailsPreAuthorized',
'BANK_WIRE' => '\MangoPay\PayInPaymentDetailsBankWire',
// ...and more in future...
),
'ExecutionType' => array(
Expand Down
6 changes: 6 additions & 0 deletions MangoPaySDK/entities/transaction.inc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ class Transaction extends EntityBase {
*/
public $ResultCode;

/**
* The PreAuthorization result Message explaining the result code
* @var string
*/
public $ResultMessage;

/**
* Execution date;
* @var date
Expand Down
9 changes: 8 additions & 1 deletion MangoPaySDK/mangoPayApi.inc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ class MangoPayApi {
* Card registration methods
* @var ApiCardRegistrations
*/
public $CardRegistrations;
public $CardRegistrations;

/**
* Pre-authorization methods
* @var ApiCardPreAuthorization
*/
public $CardPreAuthorizations;

/**
* Card methods
Expand Down Expand Up @@ -116,5 +122,6 @@ class MangoPayApi {
$this->CardRegistrations = new ApiCardRegistrations($this);
$this->Cards = new ApiCards($this);
$this->Events = new ApiEvents($this);
$this->CardPreAuthorizations = new ApiCardPreAuthorizations($this);
}
}
43 changes: 13 additions & 30 deletions MangoPaySDK/tools/apiBase.inc
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ abstract class ApiBase {
'authentication_base' => array( '/api/clients/', RequestType::POST ),
'authentication_oauth' => array( '/api/oauth/token', RequestType::POST ),

'crosscurrencytransfers_create' => array( '/transfers/%s', RequestType::POST ),
'crosscurrencytransfers_get' => array( '/transfers/%s', RequestType::GET ),

'events_all' => array( '/events', RequestType::GET ),
'events_gethookcallbacks' => array( '/events/%s/hook-callbacks', RequestType::GET ),

Expand All @@ -39,47 +36,28 @@ abstract class ApiBase {
'cardregistration_get' => array( '/cardregistrations/%s', RequestType::GET ),
'cardregistration_save' => array( '/cardregistrations/%s', RequestType::PUT ),

'preauthorization_create' => array( '/preauthorizations/card/direct', RequestType::POST ),
'preauthorization_get' => array( '/preauthorizations/%s', RequestType::GET ),
'preauthorization_save' => array( '/preauthorizations/%s', RequestType::PUT ),

'card_get' => array( '/cards/%s', RequestType::GET ),

// pay ins URLs
'payins_card-web_create' => array( '/payins/card/web/', RequestType::POST ),
'payins_card-direct_create' => array( '/payins/card/direct/', RequestType::POST ),
'payins_card-preauthorized_create' => array( '/payins/card/preauthorized/', RequestType::POST ),
'payins_card-recurrentexecution_create' => array( '/payins/card/recurrent-pay-in-execution/', RequestType::POST ),

'payins_registeredcard-web_create' => array( '/payins/card/web/', RequestType::POST ),
'payins_registeredcard-direct_create' => array( '/payins/card/direct/', RequestType::POST ),
'payins_registeredcard-preauthorized_create' => array( '/payins/registered-card/preauthorized/', RequestType::POST ),
'payins_registeredcard-recurrentexecution_create' => array( '/payins/registered-card/recurrent-pay-in-execution/', RequestType::POST ),

'payins_bankwirepayin-web_create' => array( '/payins/bankwire/web/', RequestType::POST ),
'payins_bankwirepayin-direct_create' => array( '/payins/bankwire/direct/', RequestType::POST ),
'payins_bankwirepayin-preauthorized_create' => array( '/payins/bankwire/preauthorized/', RequestType::POST ),
'payins_bankwirepayin-recurrentexecution_create' => array( '/payins/bankwire/recurrent-pay-in-execution/', RequestType::POST ),

'payins_directcredit-web_create' => array( '/payins/direct-credit/web/', RequestType::POST ),
'payins_directcredit-direct_create' => array( '/payins/direct-credit/direct/', RequestType::POST ),
'payins_directcredit-preauthorized_create' => array( '/payins/direct-credit/preauthorized/', RequestType::POST ),
'payins_directcredit-recurrentexecution_create' => array( '/payins/direct-credit/recurrent-pay-in-execution/', RequestType::POST ),
'payins_preauthorized-direct_create' => array( '/payins/preauthorized/direct/', RequestType::POST ),
'payins_bankwire-direct_create' => array( '/payins/bankwire/direct/', RequestType::POST ),
'payins_get' => array( '/payins/%s', RequestType::GET ),
'payins_getrefunds' => array( '/payins/%s/refunds', RequestType::GET ),
'payins_createrefunds' => array( '/payins/%s/refunds', RequestType::POST ),

'payouts_bankwire_create' => array( '/payouts/bankwire/', RequestType::POST ),
'payouts_merchantexpense_create' => array( '/payouts/merchant-expense/', RequestType::POST ),
'payouts_amazongiftcard_create' => array( '/payouts/amazon-giftcard/', RequestType::POST ),
'payouts_get' => array( '/payouts/%s', RequestType::GET ),
'payouts_createrefunds' => array( '/payouts/%s/refunds', RequestType::POST ),
'payouts_getrefunds' => array( '/payouts/%s/refunds', RequestType::GET ),

'reccurringpayinorders_create' => array( '/reccurring-pay-in-orders', RequestType::POST ),
'reccurringpayinorders_get' => array( '/reccurring-pay-in-orders/%s', RequestType::GET ),
'reccurringpayinorders_gettransactions' => array( '/reccurring-pay-in-orders/%s/transactions', RequestType::GET ),

'refunds_get' => array( '/refunds/%s', RequestType::GET ),

'repudiations_get' => array( '/repudiations/%s', RequestType::GET ),

'transfers_create' => array( '/transfers', RequestType::POST ),
'transfers_get' => array( '/transfers/%s', RequestType::GET ),
'transfers_getrefunds' => array( '/transfers/%s/refunds', RequestType::GET ),
Expand All @@ -94,7 +72,8 @@ abstract class ApiBase {
'users_allkycrequests' => array( '/users/%s/KYC/requests', RequestType::GET ),
'users_allwallets' => array( '/users/%s/wallets', RequestType::GET ),
'users_allbankaccount' => array( '/users/%s/bankaccounts', RequestType::GET ),
'users_allpaymentcards' => array( '/users/%s/payment-cards', RequestType::GET ),
'users_allcards' => array( '/users/%s/cards', RequestType::GET ),
'users_alltransactions' => array( '/users/%s/transactions', RequestType::GET ),
'users_get' => array( '/users/%s', RequestType::GET ),
'users_getnaturals' => array( '/users/natural/%s', RequestType::GET ),
'users_getlegals' => array( '/users/legal/%s', RequestType::GET ),
Expand Down Expand Up @@ -293,7 +272,11 @@ abstract class ApiBase {

// is sub object?
if (isset($subObjects[$name])) {
$object = $this->CastResponseToEntity($value, $subObjects[$name]);
if (is_null($value))
$object = null;
else
$object = $this->CastResponseToEntity($value, $subObjects[$name]);

$entityProperty->setValue($entity, $object);
} else {
$entityProperty->setValue($entity, $value);
Expand Down
35 changes: 35 additions & 0 deletions MangoPaySDK/tools/apiCardPreAuthorizations.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
namespace MangoPay;

/**
* Class to management MangoPay API for pre-authorization process
*/
class ApiCardPreAuthorizations extends ApiBase {

/**
* Create new pre-authorization object
* @param \MangoPay\CardPreAuthorization $cardPreAuthorization PreAuthorization object to create
* @return \MangoPay\CardPreAuthorization PreAuthorization object returned from API
*/
public function Create($cardPreAuthorization) {
return $this->CreateObject('preauthorization_create', $cardPreAuthorization, '\MangoPay\CardPreAuthorization');
}

/**
* Get pre-authorization object
* @param int $cardPreAuthorizationId PreAuthorization identifier
* @return \MangoPay\CardPreAuthorization Card registration object returned from API
*/
public function Get($cardPreAuthorizationId) {
return $this->GetObject('preauthorization_get', $cardPreAuthorizationId, '\MangoPay\CardPreAuthorization');
}

/**
* Update pre-authorization object
* @param \MangoPay\CardPreAuthorization $preAuthorization PreAuthorization object to save
* @return \MangoPay\CardPreAuthorization PreAuthorization object returned from API
*/
public function Update($cardPreAuthorization) {
return $this->SaveObject('preauthorization_save', $cardPreAuthorization, '\MangoPay\CardPreAuthorization');
}
}
20 changes: 20 additions & 0 deletions MangoPaySDK/tools/apiUsers.inc
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,26 @@ class ApiUsers extends ApiBase {
public function GetWallets($userId, & $pagination = null) {
return $this->GetList('users_allwallets', $pagination, 'MangoPay\Wallet', $userId);
}

/**
* Get all transactions for user
* @param int $userId User Id
* @param \MangoPay\Pagination $pagination Pagination object
* @param \MangoPay\FilterTransactions $filter Object to filter data
* @return \MangoPay\Transaction[] Transactions for user returned from API
*/
public function GetTransactions($userId, & $pagination = null, $filter = null) {
return $this->GetList('users_alltransactions', $pagination, '\MangoPay\Transaction', $userId, $filter);
}

/**
* Get all cards for user
* @param int $userId User Id
* @return \MangoPay\Card[] Cards for user returned from API
*/
public function GetCards($userId, & $pagination = null) {
return $this->GetList('users_allcards', $pagination, '\MangoPay\Card', $userId);
}

/**
* Create new KYC document
Expand Down
3 changes: 3 additions & 0 deletions MangoPaySDK/tools/enums.inc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class EventType {
class KycDocumentType {
const IdentityProof = 'IDENTITY_PROOF';
const RegistrationProof = 'REGISTRATION_PROOF';
const ArticlesOfAssociation = 'ARTICLES_OF_ASSOCIATION';
const ShareholderDeclaration = 'SHAREHOLDER_DECLARATION';
const AddressProof = 'ADDRESS_PROOF';
}

/**
Expand Down
6 changes: 0 additions & 6 deletions MangoPaySDK/types/payInExecutionDetailsDirect.inc
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ class PayInExecutionDetailsDirect extends Dto implements PayInExecutionDetails {
*/
public $SecureMode;

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

/**
* SecureModeReturnURL
* @var string
Expand Down
44 changes: 44 additions & 0 deletions MangoPaySDK/types/payInPaymentDetailsBankWire.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
namespace MangoPay;

/**
* Class represents BankWire type for mean of payment in PayIn entity
*/
class PayInPaymentDetailsBankWire extends Dto implements PayInPaymentDetails {

/**
* Declared debited funds
* @var \MangoPay\Money
*/
public $DeclaredDebitedFunds;

/**
* Declared fees
* @var \MangoPay\Money
*/
public $DeclaredFees;

/**
* Bank account details
* @var \MangoPay\BankAccount
*/
public $BankAccount;

/**
* Wire reference
* @var string
*/
public $WireReference;

/**
* Get array with mapping which property is object and what type of object
* @return array
*/
public function GetSubObjects() {
return array(
'DeclaredDebitedFunds' => '\MangoPay\Money' ,
'DeclaredFees' => '\MangoPay\Money' ,
'BankAccount' => '\MangoPay\BankAccount'
);
}
}
6 changes: 6 additions & 0 deletions MangoPaySDK/types/payInPaymentDetailsCard.inc
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@ class PayInPaymentDetailsCard extends Dto implements PayInPaymentDetails {
* @var string
*/
public $CardType;

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

0 comments on commit 798c941

Please sign in to comment.