feat(payments): Express-Kauf aus dem Warenkorb (PayPal v2): Start ohne Bestellung, Adresse von PayPal, Kasse vorbelegt, Capture ohne zweiten Besuch
This commit is contained in:
@@ -76,7 +76,20 @@ class Paypal_v2PaymentMethod
|
||||
if (!$provider) {
|
||||
throw new \RuntimeException('Provider paypal_v2 nicht installiert');
|
||||
}
|
||||
$url = $provider->start((int) $this->order_id, $amount);
|
||||
|
||||
// Express aus dem Warenkorb: der Kunde war schon bei PayPal, Adresse liegt vor.
|
||||
// Betrag nachziehen und einziehen -- ohne zweiten PayPal-Besuch.
|
||||
$express = $_SESSION['easyshop']['payment_express'] ?? null;
|
||||
if (\is_array($express) && ($express['module'] ?? '') === self::MODULE && !empty($express['reference'])) {
|
||||
$url = $provider->finishExpress((int) $this->order_id, $amount, (string) $express['reference']);
|
||||
unset($_SESSION['easyshop']['payment_express']);
|
||||
if ($url === '') {
|
||||
\header('Location: /Kasse/?success=1&order=' . \rawurlencode($this->resolve_order_number((int) $this->order_id)));
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$url = $provider->start((int) $this->order_id, $amount);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
\error_log('PayPal v2 after_order (Order ' . $this->order_id . '): ' . $e->getMessage());
|
||||
if (\function_exists('shop_event')) {
|
||||
@@ -108,4 +121,11 @@ class Paypal_v2PaymentMethod
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
private function resolve_order_number(int $orderId): string
|
||||
{
|
||||
$res = $this->base_object->db->query('SELECT order_number FROM orders WHERE id=' . $orderId . ' LIMIT 1');
|
||||
$row = $res ? $res->fetch_object() : null;
|
||||
return $row ? (string) $row->order_number : (string) $orderId;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user