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();