Commit 78d62ce0 authored by Andy J's avatar Andy J

Handle PAYER_ACTION_REQUIRED

parent a623d7bf
......@@ -712,6 +712,7 @@ class PayPalFinance extends PaymentMethod
$execution = new PaymentExecution();
$execution->setPayerId($payerId);
/*
$details = new Details();
$details->setShipping($basket->shipping[WarenkorbHelper::GROSS])
->setSubtotal($basket->article[WarenkorbHelper::GROSS] - $basket->discount[WarenkorbHelper::GROSS])
......@@ -727,11 +728,12 @@ class PayPalFinance extends PaymentMethod
$transaction->setAmount($amount);
$execution->addTransaction($transaction);
*/
$payment->execute($execution, $apiContext);
$this->logResult('ExecutePayment', $execution, $payment);
if ($payment->getState() !== 'approved') {
if ($payment->getState() === 'failed') {
throw new Exception('Unhandled payment state', $payment->getState());
}
......@@ -739,6 +741,8 @@ class PayPalFinance extends PaymentMethod
->getRelatedResources()[0]
->getSale();
$amount = $sale->getAmount();
/*
* TODO
* Create new Option "Seller Protection"
......
......@@ -634,6 +634,22 @@ class PayPalPlus extends PaymentMethod
header("location: {$returnUrl}");
exit;
} catch (PayPal\Exception\PayPalConnectionException $exp) {
if ($data = $exp->getData()) {
$error = new PayPal\Api\Error($data);
if ($error->getName() === 'PAYER_ACTION_REQUIRED') {
foreach ($error->getLinks() as $link) {
if ($link->getMethod() === 'REDIRECT') {
$redirect = $link->getHref();
header("location: {$redirect}");
exit;
}
}
}
}
$this->handleException('ExecutePayment', $payment, $exp);
Shop::Smarty()->assign('error', $exp->getMessage());
} catch (Exception $ex) {
$this->handleException('ExecutePayment', $payment, $ex);
Shop::Smarty()->assign('error', $ex->getMessage());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment