From 71e3226ec30419621f57c47f8eef5dfe26108ff7 Mon Sep 17 00:00:00 2001 From: SoloJr Date: Tue, 22 Mar 2022 20:06:47 +0200 Subject: [PATCH 1/2] MPSDK-1016: added comment for flag --- MangoPay/PayOutPaymentDetailsBankWire.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MangoPay/PayOutPaymentDetailsBankWire.php b/MangoPay/PayOutPaymentDetailsBankWire.php index c75661fd..2919f83b 100644 --- a/MangoPay/PayOutPaymentDetailsBankWire.php +++ b/MangoPay/PayOutPaymentDetailsBankWire.php @@ -20,7 +20,8 @@ class PayOutPaymentDetailsBankWire extends Libraries\Dto implements PayOutPaymen public $BankWireRef; /** - * The new parameter "PayoutModeRequested" can take two different values : "INSTANT_PAYMENT" or "STANDARD" + * The parameter "PayoutModeRequested" can take 3 different values : "STANDARD", "INSTANT_PAYMENT", "INSTANT_PAYMENT_ONLY" + * * @var string */ public $PayoutModeRequested; From 4e112d0f768baf35c349b280d24c11b4f45c1b19 Mon Sep 17 00:00:00 2001 From: SoloJr Date: Wed, 23 Mar 2022 21:32:52 +0200 Subject: [PATCH 2/2] MPSDK-1015: added endpoint for IP eligibility --- MangoPay/ApiPayOuts.php | 12 ++++++ MangoPay/InstantPayout.php | 16 ++++++++ MangoPay/Libraries/ApiBase.php | 1 + MangoPay/PayOutEligibilityRequest.php | 53 ++++++++++++++++++++++++++ MangoPay/PayOutEligibilityResponse.php | 14 +++++++ tests/Cases/PayOutsTest.php | 27 +++++++++++++ 6 files changed, 123 insertions(+) create mode 100644 MangoPay/InstantPayout.php create mode 100644 MangoPay/PayOutEligibilityRequest.php create mode 100644 MangoPay/PayOutEligibilityResponse.php diff --git a/MangoPay/ApiPayOuts.php b/MangoPay/ApiPayOuts.php index 85ee4774..0a4639db 100644 --- a/MangoPay/ApiPayOuts.php +++ b/MangoPay/ApiPayOuts.php @@ -18,6 +18,18 @@ public function Create($payOut, $idempotencyKey = null) return $this->CreateObject('payouts_' . $paymentKey . '_create', $payOut, '\MangoPay\PayOut', null, null, $idempotencyKey); } + /** + * This method is used to check whether or not the destination bank is eligible for instant payout. + * @param PayOutEligibilityRequest $payOutEligibility + * @param $idempotencyKey + * @return \MangoPay\PayOutEligibilityResponse Object returned for the API + */ + public function CheckInstantPayoutEligibility($payOutEligibility, $idempotencyKey = null) + { + return $this->CreateObject('payouts_check_eligibility', $payOutEligibility, + '\MangoPay\PayOutEligibilityResponse', null, null, $idempotencyKey); + } + /** * Get pay-out object * @param string $payOutId PayOut identifier diff --git a/MangoPay/InstantPayout.php b/MangoPay/InstantPayout.php new file mode 100644 index 00000000..134ba1e1 --- /dev/null +++ b/MangoPay/InstantPayout.php @@ -0,0 +1,16 @@ + ['/payouts/bankwire/', RequestType::POST], 'payouts_bankwire_get' => ['/payouts/bankwire/%s', RequestType::GET], 'payouts_get' => ['/payouts/%s', RequestType::GET], + 'payouts_check_eligibility' => ['/payouts/reachability/', RequestType::POST], 'refunds_get' => ['/refunds/%s', RequestType::GET], 'refunds_get_for_repudiation' => ['/repudiations/%s/refunds', RequestType::GET], diff --git a/MangoPay/PayOutEligibilityRequest.php b/MangoPay/PayOutEligibilityRequest.php new file mode 100644 index 00000000..532abb6f --- /dev/null +++ b/MangoPay/PayOutEligibilityRequest.php @@ -0,0 +1,53 @@ +assertInstanceOf('\MangoPay\PayOutPaymentDetailsBankWire', $payOut->MeanOfPaymentDetails); } + public function test_PayOut_CheckEligibility() + { + $payOut = $this->getJohnsPayOutForCardDirect(); + + $eligibility = new PayOutEligibilityRequest(); + $eligibility->AuthorId = $payOut->AuthorId; + $eligibility->DebitedFunds = new Money(); + $eligibility->DebitedFunds->Amount = 10; + $eligibility->DebitedFunds->Currency = CurrencyIso::EUR; + $eligibility->PayoutModeRequested = "INSTANT_PAYMENT"; + $eligibility->BankAccountId = $payOut->MeanOfPaymentDetails->BankAccountId; + $eligibility->DebitedWalletId = $payOut->DebitedWalletId; + + $result = $this->_api->PayOuts->CheckInstantPayoutEligibility($eligibility); + + $this->assertTrue($payOut->Id > 0); + $this->assertSame(\MangoPay\PayOutPaymentType::BankWire, $payOut->PaymentType); + $this->assertInstanceOf('\MangoPay\PayOutPaymentDetailsBankWire', $payOut->MeanOfPaymentDetails); + + $this->assertNotNull($result); + $this->assertInstanceOf('\MangoPay\PayOutEligibilityResponse', $result); + } + public function test_PayOut_Get() { $payOut = $this->getJohnsPayOutForCardDirect();