Skip to content

Commit

Permalink
Merge pull request #608 from Mangopay/rel/3.22.0
Browse files Browse the repository at this point in the history
Rel/3.22.0
  • Loading branch information
iulian03 authored Sep 15, 2023
2 parents 3232469 + d3896b7 commit 5af271e
Show file tree
Hide file tree
Showing 21 changed files with 683 additions and 59 deletions.
4 changes: 2 additions & 2 deletions MangoPay/ApiCards.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public function GetTransactions($cardId, & $pagination = null, $filter = null, $
* @return \MangoPay\Card
* @throws Libraries\Exception
*/
public function ValidateCard($cardId)
public function ValidateCard($cardId, $cardValidation)
{
return $this->GetObject('card_validate', '\MangoPay\Card', $cardId);
return $this->ExecutePostRequest('card_validate', $cardValidation, '\MangoPay\CardValidation', $cardId);
}
}
20 changes: 20 additions & 0 deletions MangoPay/ApiPayIns.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,24 @@ public function CreateCardPreAuthorizedDepositPayIn(CreateCardPreAuthorizedDepos
{
return $this->CreateObject('payins_create_card_pre_authorized_deposit', $payIn, '\MangoPay\PayIn');
}

/**
* Create new PayPal Web pay-in object
* @param \MangoPay\PayIn $payIn \MangoPay\PayIn object
* @return \MangoPay\PayIn Object returned from API
*/
public function CreatePayPal($payIn, $idempotencyKey = null)
{
return $this->CreateObject('payins_paypal-web_create_v2', $payIn, '\MangoPay\PayIn', null, null, $idempotencyKey);
}

/**
* Create new GooglePay Direct pay-in object
* @param \MangoPay\PayIn $payIn \MangoPay\PayIn object
* @return \MangoPay\PayIn Object returned from API
*/
public function CreateGooglePay($payIn, $idempotencyKey = null)
{
return $this->CreateObject('payins_googlepay-direct_create_v2', $payIn, '\MangoPay\PayIn', null, null, $idempotencyKey);
}
}
92 changes: 92 additions & 0 deletions MangoPay/CardValidation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php

namespace MangoPay;

class CardValidation extends Libraries\EntityBase
{
/**
* Author Id
* @var string
*/
public $AuthorId;

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

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

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

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

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

/**
* Validity. For allowed values, see constants in MangoPay\CardValidity
* @var string
*/
public $Validity;

/**
* @var string
* @see \MangoPay\TransactionType
*/
public $Type;

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

/**
* The current status of the card validation
* @var string
* @see \MangoPay\CardValidationStatus
*/
public $Status;

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

/**
* The mandate result Message
* @var string
*/
public $ResultMessage;

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

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

namespace MangoPay;

class CardValidationStatus
{
const Created = 'CREATED';
const Succeeded = 'SUCCEEDED';
const Failed = 'FAILED';
}
4 changes: 4 additions & 0 deletions MangoPay/EventType.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,8 @@ class EventType
const DepositPreAuthorizationPaymentCancelRequest = "DEPOSIT_PREAUTHORIZATION_PAYMENT_CANCEL_REQUEST";
const DepositPreAuthorizationPaymentCanceled = "DEPOSIT_PREAUTHORIZATION_PAYMENT_CANCELED";
const DepositPreAuthorizationPaymentValidated = "DEPOSIT_PREAUTHORIZATION_PAYMENT_VALIDATED";
const CardValidationCreated = "CARD_VALIDATION_CREATED";
const CardValidationFailed= "CARD_VALIDATION_FAILED";
const CardValidationSucceeded = "CARD_VALIDATION_SUCCEEDED";

}
56 changes: 42 additions & 14 deletions MangoPay/Libraries/ApiBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,29 @@ protected function getLogger()
'card_get' => ['/cards/%s', RequestType::GET],
'cards_get_by_fingerprint' => ['/cards/fingerprints/%s', RequestType::GET],
'card_save' => ['/cards/%s', RequestType::PUT],
'card_validate' => ['/cards/%s/validate', RequestType::POST],
'card_validate' => ['/cards/%s/validation', RequestType::POST],

// pay ins URLs
'payins_card-web_create' => [ '/payins/card/web/', RequestType::POST ],
'payins_card-direct_create' => [ '/payins/card/direct/', RequestType::POST ],
'payins_preauthorized-direct_create' => [ '/payins/preauthorized/direct/', RequestType::POST ],
'payins_bankwire-direct_create' => [ '/payins/bankwire/direct/', RequestType::POST ],
'payins_directdebit-web_create' => [ '/payins/directdebit/web', RequestType::POST ],
'payins_directdebit-direct_create' => [ '/payins/directdebit/direct', RequestType::POST ],
'payins_directdebitdirect-direct_create' => [ '/payins/directdebit/direct', RequestType::POST ],
'payins_paypal-web_create' => [ '/payins/paypal/web', RequestType::POST ],
'payins_payconiq-web_create' => [ '/payins/payconiq/web', RequestType::POST ],
'payins_get' => [ '/payins/%s', RequestType::GET ],
'payins_createrefunds' => [ '/payins/%s/refunds', RequestType::POST ],
'payins_card-web_create' => ['/payins/card/web/', RequestType::POST],
'payins_card-direct_create' => ['/payins/card/direct/', RequestType::POST],
'payins_preauthorized-direct_create' => ['/payins/preauthorized/direct/', RequestType::POST],
'payins_bankwire-direct_create' => ['/payins/bankwire/direct/', RequestType::POST],
'payins_directdebit-web_create' => ['/payins/directdebit/web', RequestType::POST],
'payins_directdebit-direct_create' => ['/payins/directdebit/direct', RequestType::POST],
'payins_directdebitdirect-direct_create' => ['/payins/directdebit/direct', RequestType::POST],
'payins_paypal-web_create' => ['/payins/paypal/web', RequestType::POST],
'payins_paypal-web_create_v2' => ['/payins/payment-methods/paypal', RequestType::POST],
'payins_payconiq-web_create' => ['/payins/payconiq/web', RequestType::POST],
'payins_get' => ['/payins/%s', RequestType::GET],
'payins_createrefunds' => ['/payins/%s/refunds', RequestType::POST],
'payins_applepay-direct_create' => ['/payins/applepay/direct', RequestType::POST],
'payins_googlepay-direct_create' => ['/payins/googlepay/direct', RequestType::POST],
'payins_mbway-direct_create' => ['/payins/payment-methods/mbway', RequestType::POST],
'payins_paypal-direct_create' => ['/payins/payment-methods/paypal', RequestType::POST],
'payins_googlepay-direct_create_v2' => ['/payins/payment-methods/googlepay', RequestType::POST],
'payins_mbway-web_create' => ['/payins/payment-methods/mbway', RequestType::POST],
'payins_multibanco-web_create' => ['/payins/payment-methods/multibanco', RequestType::POST],
'payins_satispay-web_create' => ['/payins/payment-methods/satispay', RequestType::POST],
'payins_blik-web_create' => ['/payins/payment-methods/blik', RequestType::POST],
'payins_klarna-web_create' => ['/payins/payment-methods/klarna', RequestType::POST],

'payins_recurring_registration' => ['/recurringpayinregistrations', RequestType::POST],
'payins_recurring_registration_get' => ['/recurringpayinregistrations/%s', RequestType::GET],
Expand Down Expand Up @@ -381,6 +386,29 @@ protected function SaveObject($methodKey, $entity, $responseClassName = null, $s
return $response;
}

/**
* Executes a POST request
* @param $methodKey Key with request data
* @param $entity Entity object
* @param $responseClassName Name of entity class from response
* @param $entityId Entity identifier
* @return object Response data
*/
protected function ExecutePostRequest($methodKey, $entity, $responseClassName, $entityId)
{
$urlMethod = sprintf($this->GetRequestUrl($methodKey), $entityId);
$requestData = $this->BuildRequestData($entity);

$rest = new RestTool($this->_root, true);
$response = $rest->Request($urlMethod, $this->GetRequestType($methodKey), $requestData, null);

if(!is_null($responseClassName)){
return $this->CastResponseToEntity($response, $responseClassName);
}

return $response;
}

/**
* Cast response object to entity object
* @param object $response Object from API response
Expand Down
2 changes: 1 addition & 1 deletion MangoPay/Libraries/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Configuration
/**
* Set the cURL response timeout limit (in seconds)
*/
public $CurlResponseTimeout = 80;
public $CurlResponseTimeout = 30;

/**
* Set the proxy host
Expand Down
7 changes: 6 additions & 1 deletion MangoPay/PayIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,13 @@ public function GetDependsObjects()
PayInPaymentType::PayPal => '\MangoPay\PayInPaymentDetailsPaypal',
PayInPaymentType::ApplePay => 'MangoPay\PayInPaymentDetailsApplePay',
PayInPaymentType::GooglePay => 'MangoPay\PayInPaymentDetailsGooglePay',
PayInPaymentType::GooglePayV2 => 'MangoPay\PayInPaymentDetailsGooglePay',
PayInPaymentType::Payconiq => 'MangoPay\PayInPaymentDetailsPayconiq',
PayInPaymentType::Mbway => 'MangoPay\PayInPaymentDetailsMbway'
PayInPaymentType::Mbway => 'MangoPay\PayInPaymentDetailsMbway',
PayInPaymentType::Multibanco => 'MangoPay\PayInPaymentDetailsMultibanco',
PayInPaymentType::Satispay => 'MangoPay\PayInPaymentDetailsSatispay',
PayInPaymentType::Blik => 'MangoPay\PayInPaymentDetailsBlik',
PayInPaymentType::Klarna => 'MangoPay\PayInPaymentDetailsKlarna',

// ...and more in future...
],
Expand Down
13 changes: 13 additions & 0 deletions MangoPay/PayInPaymentDetailsBlik.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace MangoPay;

class PayInPaymentDetailsBlik extends Libraries\Dto implements PayInPaymentDetails
{
/**
* Custom description to show on the user's bank statement.
* It can be up to 10 char alphanumeric and space.
* @var string
*/
public $StatementDescriptor;
}
33 changes: 31 additions & 2 deletions MangoPay/PayInPaymentDetailsGooglePay.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class PayInPaymentDetailsGooglePay extends Libraries\Dto implements PayInPayment
{
/**
* Payment information returned by Google Pay payment
* @var \MangoPay\PaymentData
* @var string
*/
public $PaymentData;

Expand All @@ -17,11 +17,40 @@ class PayInPaymentDetailsGooglePay extends Libraries\Dto implements PayInPayment
*/
public $StatementDescriptor;

/// V2 ///

/**
* Information about the browser used by the end user (author)
* to perform the payment.
* @return string
*/
public $IpAddress;

/**
* The IP address of the end user initiating the transaction,
* in IPV4 or IPV6 format.
* @var BrowserInfo
*/
public $BrowserInfo;

/**
* Information about the end user shipping address.
* @var Shipping
*/
public $Shipping;

/**
* Return URL
* @var string
*/
public $ReturnURL;

public function GetSubObjects()
{
$subObjects = parent::GetSubObjects();

$subObjects['PaymentData'] = '\Mangopay\PaymentData';
$subObjects['BrowserInfo'] = '\MangoPay\BrowserInfo';
$subObjects['Shipping'] = '\MangoPay\Shipping';

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

namespace MangoPay;

/**
* Class represents Klarna type for mean of payment in Klarna entity
*/
class PayInPaymentDetailsKlarna extends Libraries\Dto implements PayInPaymentDetails
{

/**
* Information about the order items (basket)
* Note : The LineItems total amount must match the declared DebitedFunds
* @var array
*/
public $LineItems;

/**
* The end-user residency country
* @var string
*/
public $Country;

/**
* The language in which the Klarna payment page is to be displayed - Alpha-2 format (default US)
* @var string
*/
public $Culture;

/**
* The end-user mobile phone number
* @var string
*/
public $Phone;

/**
* The end-user email address
* @var string
*/
public $Email;

/**
* Klarna custom data that you can add to this item
* @var string
*/
public $AdditionalData;

/**
* Information about the shipping address
* @var Shipping
*/
public $Shipping;

/**
* The Klarna option that the end-user has chosen at checkout
* @var string
*/
public $PaymentMethod;

/**
* The merchant order reference
* @var string
*/
public $MerchantOrderId;

public function GetSubObjects()
{
$subObjects = parent::GetSubObjects();
$subObjects['Shipping'] = '\MangoPay\Shipping';

return $subObjects;
}
}
Loading

0 comments on commit 5af271e

Please sign in to comment.