Skip to content

Commit 798c941

Browse files
Added: Card pre-authorization (with PayIn), ...
PayInBankWire, get user cards & transactions, new type of documents for KYC
1 parent de7826e commit 798c941

17 files changed

+567
-49
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?php
2+
namespace MangoPay;
3+
4+
/**
5+
* Pre-authorization entity
6+
*/
7+
class CardPreAuthorization extends EntityBase {
8+
9+
/**
10+
* The user Id of the author of the pre-authorization
11+
* @var string
12+
*/
13+
public $AuthorId;
14+
15+
/**
16+
* It represents the amount debited on the bank account
17+
* of the Author.DebitedFunds = Fees + CreditedFunds
18+
* (amount received on wallet)
19+
* @var \MangoPay\Money
20+
*/
21+
public $DebitedFunds;
22+
23+
/**
24+
* Status of the PreAuthorization: CREATED, SUCCEEDED, FAILED
25+
* @var string
26+
*/
27+
public $Status;
28+
29+
/**
30+
* The status of the payment after the PreAuthorization:
31+
* WAITING, CANCELED, EXPIRED, VALIDATED
32+
* @var string
33+
*/
34+
public $PaymentStatus;
35+
36+
/**
37+
* The PreAuthorization result code
38+
* @var string
39+
*/
40+
public $ResultCode;
41+
42+
/**
43+
* The PreAuthorization result Message explaining the result code
44+
* @var string
45+
*/
46+
public $ResultMessage;
47+
48+
/**
49+
* How the PreAuthorization has been executed.
50+
* Only on value for now: CARD
51+
* @var string
52+
*/
53+
public $ExecutionType;
54+
55+
/**
56+
* The SecureMode correspond to '3D secure' for CB Visa and MasterCard
57+
* or 'Amex Safe Key' for American Express.
58+
* This field lets you activate it manualy.
59+
* @var string
60+
*/
61+
public $SecureMode;
62+
63+
/**
64+
* The ID of the registered card (Got through CardRegistration object)
65+
* @var string
66+
*/
67+
public $CardId;
68+
69+
/**
70+
* Boolean. The value is 'true' if the SecureMode was used
71+
* @var string
72+
*/
73+
public $SecureModeNeeded;
74+
75+
/**
76+
* This is the URL where to redirect users to proceed
77+
* to 3D secure validation
78+
* @var string
79+
*/
80+
public $SecureModeRedirectUrl;
81+
82+
/**
83+
* This is the URL where users are automatically redirected
84+
* after 3D secure validation (if activated)
85+
* @var string
86+
*/
87+
public $SecureModeReturnURL;
88+
89+
/**
90+
* The date when the payment is processed
91+
* @var Timestamp
92+
*/
93+
public $ExpirationDate;
94+
95+
/**
96+
* The Id of the associated PayIn
97+
* @var string
98+
*/
99+
public $PayInId;
100+
101+
/**
102+
* Get array with mapping which property is object and what type of object
103+
* @return array
104+
*/
105+
public function GetSubObjects() {
106+
return array(
107+
'DebitedFunds' => '\MangoPay\Money'
108+
);
109+
}
110+
111+
/**
112+
* Get array with read-only properties
113+
* @return array
114+
*/
115+
public function GetReadOnlyProperties() {
116+
$properties = parent::GetReadOnlyProperties();
117+
array_push( $properties, 'Status' );
118+
array_push( $properties, 'ResultCode' );
119+
array_push( $properties, 'ResultMessage' );
120+
121+
return $properties;
122+
}
123+
}

MangoPaySDK/entities/payIn.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class PayIn extends Transaction {
4545
'PaymentType' => array(
4646
'_property_name' => 'PaymentDetails',
4747
'CARD' => '\MangoPay\PayInPaymentDetailsCard',
48+
'PREAUTHORIZED' => '\MangoPay\PayInPaymentDetailsPreAuthorized',
49+
'BANK_WIRE' => '\MangoPay\PayInPaymentDetailsBankWire',
4850
// ...and more in future...
4951
),
5052
'ExecutionType' => array(

MangoPaySDK/entities/transaction.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ class Transaction extends EntityBase {
4949
*/
5050
public $ResultCode;
5151

52+
/**
53+
* The PreAuthorization result Message explaining the result code
54+
* @var string
55+
*/
56+
public $ResultMessage;
57+
5258
/**
5359
* Execution date;
5460
* @var date

MangoPaySDK/mangoPayApi.inc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ class MangoPayApi {
8181
* Card registration methods
8282
* @var ApiCardRegistrations
8383
*/
84-
public $CardRegistrations;
84+
public $CardRegistrations;
85+
86+
/**
87+
* Pre-authorization methods
88+
* @var ApiCardPreAuthorization
89+
*/
90+
public $CardPreAuthorizations;
8591

8692
/**
8793
* Card methods
@@ -116,5 +122,6 @@ class MangoPayApi {
116122
$this->CardRegistrations = new ApiCardRegistrations($this);
117123
$this->Cards = new ApiCards($this);
118124
$this->Events = new ApiEvents($this);
125+
$this->CardPreAuthorizations = new ApiCardPreAuthorizations($this);
119126
}
120127
}

MangoPaySDK/tools/apiBase.inc

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ abstract class ApiBase {
2020
'authentication_base' => array( '/api/clients/', RequestType::POST ),
2121
'authentication_oauth' => array( '/api/oauth/token', RequestType::POST ),
2222

23-
'crosscurrencytransfers_create' => array( '/transfers/%s', RequestType::POST ),
24-
'crosscurrencytransfers_get' => array( '/transfers/%s', RequestType::GET ),
25-
2623
'events_all' => array( '/events', RequestType::GET ),
2724
'events_gethookcallbacks' => array( '/events/%s/hook-callbacks', RequestType::GET ),
2825

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

39+
'preauthorization_create' => array( '/preauthorizations/card/direct', RequestType::POST ),
40+
'preauthorization_get' => array( '/preauthorizations/%s', RequestType::GET ),
41+
'preauthorization_save' => array( '/preauthorizations/%s', RequestType::PUT ),
42+
4243
'card_get' => array( '/cards/%s', RequestType::GET ),
4344

4445
// pay ins URLs
4546
'payins_card-web_create' => array( '/payins/card/web/', RequestType::POST ),
4647
'payins_card-direct_create' => array( '/payins/card/direct/', RequestType::POST ),
47-
'payins_card-preauthorized_create' => array( '/payins/card/preauthorized/', RequestType::POST ),
48-
'payins_card-recurrentexecution_create' => array( '/payins/card/recurrent-pay-in-execution/', RequestType::POST ),
49-
50-
'payins_registeredcard-web_create' => array( '/payins/card/web/', RequestType::POST ),
51-
'payins_registeredcard-direct_create' => array( '/payins/card/direct/', RequestType::POST ),
52-
'payins_registeredcard-preauthorized_create' => array( '/payins/registered-card/preauthorized/', RequestType::POST ),
53-
'payins_registeredcard-recurrentexecution_create' => array( '/payins/registered-card/recurrent-pay-in-execution/', RequestType::POST ),
54-
55-
'payins_bankwirepayin-web_create' => array( '/payins/bankwire/web/', RequestType::POST ),
56-
'payins_bankwirepayin-direct_create' => array( '/payins/bankwire/direct/', RequestType::POST ),
57-
'payins_bankwirepayin-preauthorized_create' => array( '/payins/bankwire/preauthorized/', RequestType::POST ),
58-
'payins_bankwirepayin-recurrentexecution_create' => array( '/payins/bankwire/recurrent-pay-in-execution/', RequestType::POST ),
59-
60-
'payins_directcredit-web_create' => array( '/payins/direct-credit/web/', RequestType::POST ),
61-
'payins_directcredit-direct_create' => array( '/payins/direct-credit/direct/', RequestType::POST ),
62-
'payins_directcredit-preauthorized_create' => array( '/payins/direct-credit/preauthorized/', RequestType::POST ),
63-
'payins_directcredit-recurrentexecution_create' => array( '/payins/direct-credit/recurrent-pay-in-execution/', RequestType::POST ),
48+
'payins_preauthorized-direct_create' => array( '/payins/preauthorized/direct/', RequestType::POST ),
49+
'payins_bankwire-direct_create' => array( '/payins/bankwire/direct/', RequestType::POST ),
6450
'payins_get' => array( '/payins/%s', RequestType::GET ),
6551
'payins_getrefunds' => array( '/payins/%s/refunds', RequestType::GET ),
6652
'payins_createrefunds' => array( '/payins/%s/refunds', RequestType::POST ),
6753

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

75-
'reccurringpayinorders_create' => array( '/reccurring-pay-in-orders', RequestType::POST ),
76-
'reccurringpayinorders_get' => array( '/reccurring-pay-in-orders/%s', RequestType::GET ),
77-
'reccurringpayinorders_gettransactions' => array( '/reccurring-pay-in-orders/%s/transactions', RequestType::GET ),
78-
7959
'refunds_get' => array( '/refunds/%s', RequestType::GET ),
8060

81-
'repudiations_get' => array( '/repudiations/%s', RequestType::GET ),
82-
8361
'transfers_create' => array( '/transfers', RequestType::POST ),
8462
'transfers_get' => array( '/transfers/%s', RequestType::GET ),
8563
'transfers_getrefunds' => array( '/transfers/%s/refunds', RequestType::GET ),
@@ -94,7 +72,8 @@ abstract class ApiBase {
9472
'users_allkycrequests' => array( '/users/%s/KYC/requests', RequestType::GET ),
9573
'users_allwallets' => array( '/users/%s/wallets', RequestType::GET ),
9674
'users_allbankaccount' => array( '/users/%s/bankaccounts', RequestType::GET ),
97-
'users_allpaymentcards' => array( '/users/%s/payment-cards', RequestType::GET ),
75+
'users_allcards' => array( '/users/%s/cards', RequestType::GET ),
76+
'users_alltransactions' => array( '/users/%s/transactions', RequestType::GET ),
9877
'users_get' => array( '/users/%s', RequestType::GET ),
9978
'users_getnaturals' => array( '/users/natural/%s', RequestType::GET ),
10079
'users_getlegals' => array( '/users/legal/%s', RequestType::GET ),
@@ -293,7 +272,11 @@ abstract class ApiBase {
293272

294273
// is sub object?
295274
if (isset($subObjects[$name])) {
296-
$object = $this->CastResponseToEntity($value, $subObjects[$name]);
275+
if (is_null($value))
276+
$object = null;
277+
else
278+
$object = $this->CastResponseToEntity($value, $subObjects[$name]);
279+
297280
$entityProperty->setValue($entity, $object);
298281
} else {
299282
$entityProperty->setValue($entity, $value);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
namespace MangoPay;
3+
4+
/**
5+
* Class to management MangoPay API for pre-authorization process
6+
*/
7+
class ApiCardPreAuthorizations extends ApiBase {
8+
9+
/**
10+
* Create new pre-authorization object
11+
* @param \MangoPay\CardPreAuthorization $cardPreAuthorization PreAuthorization object to create
12+
* @return \MangoPay\CardPreAuthorization PreAuthorization object returned from API
13+
*/
14+
public function Create($cardPreAuthorization) {
15+
return $this->CreateObject('preauthorization_create', $cardPreAuthorization, '\MangoPay\CardPreAuthorization');
16+
}
17+
18+
/**
19+
* Get pre-authorization object
20+
* @param int $cardPreAuthorizationId PreAuthorization identifier
21+
* @return \MangoPay\CardPreAuthorization Card registration object returned from API
22+
*/
23+
public function Get($cardPreAuthorizationId) {
24+
return $this->GetObject('preauthorization_get', $cardPreAuthorizationId, '\MangoPay\CardPreAuthorization');
25+
}
26+
27+
/**
28+
* Update pre-authorization object
29+
* @param \MangoPay\CardPreAuthorization $preAuthorization PreAuthorization object to save
30+
* @return \MangoPay\CardPreAuthorization PreAuthorization object returned from API
31+
*/
32+
public function Update($cardPreAuthorization) {
33+
return $this->SaveObject('preauthorization_save', $cardPreAuthorization, '\MangoPay\CardPreAuthorization');
34+
}
35+
}

MangoPaySDK/tools/apiUsers.inc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,26 @@ class ApiUsers extends ApiBase {
132132
public function GetWallets($userId, & $pagination = null) {
133133
return $this->GetList('users_allwallets', $pagination, 'MangoPay\Wallet', $userId);
134134
}
135+
136+
/**
137+
* Get all transactions for user
138+
* @param int $userId User Id
139+
* @param \MangoPay\Pagination $pagination Pagination object
140+
* @param \MangoPay\FilterTransactions $filter Object to filter data
141+
* @return \MangoPay\Transaction[] Transactions for user returned from API
142+
*/
143+
public function GetTransactions($userId, & $pagination = null, $filter = null) {
144+
return $this->GetList('users_alltransactions', $pagination, '\MangoPay\Transaction', $userId, $filter);
145+
}
146+
147+
/**
148+
* Get all cards for user
149+
* @param int $userId User Id
150+
* @return \MangoPay\Card[] Cards for user returned from API
151+
*/
152+
public function GetCards($userId, & $pagination = null) {
153+
return $this->GetList('users_allcards', $pagination, '\MangoPay\Card', $userId);
154+
}
135155

136156
/**
137157
* Create new KYC document

MangoPaySDK/tools/enums.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ class EventType {
4949
class KycDocumentType {
5050
const IdentityProof = 'IDENTITY_PROOF';
5151
const RegistrationProof = 'REGISTRATION_PROOF';
52+
const ArticlesOfAssociation = 'ARTICLES_OF_ASSOCIATION';
53+
const ShareholderDeclaration = 'SHAREHOLDER_DECLARATION';
54+
const AddressProof = 'ADDRESS_PROOF';
5255
}
5356

5457
/**

MangoPaySDK/types/payInExecutionDetailsDirect.inc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ class PayInExecutionDetailsDirect extends Dto implements PayInExecutionDetails {
1212
*/
1313
public $SecureMode;
1414

15-
/**
16-
* CardId
17-
* @var string
18-
*/
19-
public $CardId;
20-
2115
/**
2216
* SecureModeReturnURL
2317
* @var string
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
namespace MangoPay;
3+
4+
/**
5+
* Class represents BankWire type for mean of payment in PayIn entity
6+
*/
7+
class PayInPaymentDetailsBankWire extends Dto implements PayInPaymentDetails {
8+
9+
/**
10+
* Declared debited funds
11+
* @var \MangoPay\Money
12+
*/
13+
public $DeclaredDebitedFunds;
14+
15+
/**
16+
* Declared fees
17+
* @var \MangoPay\Money
18+
*/
19+
public $DeclaredFees;
20+
21+
/**
22+
* Bank account details
23+
* @var \MangoPay\BankAccount
24+
*/
25+
public $BankAccount;
26+
27+
/**
28+
* Wire reference
29+
* @var string
30+
*/
31+
public $WireReference;
32+
33+
/**
34+
* Get array with mapping which property is object and what type of object
35+
* @return array
36+
*/
37+
public function GetSubObjects() {
38+
return array(
39+
'DeclaredDebitedFunds' => '\MangoPay\Money' ,
40+
'DeclaredFees' => '\MangoPay\Money' ,
41+
'BankAccount' => '\MangoPay\BankAccount'
42+
);
43+
}
44+
}

0 commit comments

Comments
 (0)