← All changes
|
app/Modules/PaymentMethods/PayPalGateway/PayPal.php
+12
-5
1.6.3
→
1.6.6
View file →
| @@ -65,8 +65,10 @@ | ||
| 65 | 65 | public function boot() |
| 66 | 66 | { |
| 67 | 67 | (new IPN())->init(); |
| 68 | 68 | |
| 69 | + add_action('fluent_cart_action_paypal_connect', [ConnectConfig::class, 'handleConnect']); | |
| 70 | + | |
| 69 | 71 | add_action('wp_ajax_nopriv_fluent_cart_confirm_paypal_payment', [$this, 'confirmPayPalSinglePayment']); |
| 70 | 72 | add_action('wp_ajax_fluent_cart_confirm_paypal_payment', [$this, 'confirmPayPalSinglePayment']); |
| 71 | 73 | |
| 72 | 74 | add_action('wp_ajax_nopriv_fluent_cart_confirm_paypal_subscription', [$this, 'confirmPayPalSubscription']); |
| @@ -393,15 +395,17 @@ | ||
| 393 | 395 | $paidCurrency = strtoupper(Arr::get($unit, 'amount.currency_code', '')); |
| 394 | 396 | } |
| 395 | 397 | } |
| 396 | 398 | |
| 397 | - if ($paidAmount != $transaction->total) { | |
| 399 | + $expectedAmount = PayPalHelper::wireCents($transaction->total, $transaction->currency); | |
| 400 | + | |
| 401 | + if ($paidAmount != $expectedAmount) { | |
| 398 | 402 | fluent_cart_warning_log( |
| 399 | 403 | __('PayPal Amount Mismatch Attempt', 'fluent-cart'), |
| 400 | 404 | sprintf( |
| 401 | 405 | /* translators: %1$s: expected amount, %2$s: received amount */ |
| 402 | 406 | __('Payment amount mismatch detected. Expected: %1$s, Received: %2$s. This may indicate payment tampering.', 'fluent-cart'), |
| 403 | - Helper::toDecimal($transaction->total), | |
| 407 | + Helper::toDecimal($expectedAmount), | |
| 404 | 408 | Helper::toDecimal($paidAmount) |
| 405 | 409 | ), |
| 406 | 410 | [ |
| 407 | 411 | 'module_name' => 'order', |
| @@ -897,10 +901,10 @@ | ||
| 897 | 901 | if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') { |
| 898 | 902 | return; |
| 899 | 903 | } |
| 900 | 904 | |
| 905 | + // Sends the HTTP status via status_header() and exits — never returns. | |
| 901 | 906 | (new IPN())->processWebhook(); |
| 902 | - exit(200); | |
| 903 | 907 | } |
| 904 | 908 | |
| 905 | 909 | public function getTransactionUrl($url, $data) |
| 906 | 910 | { |
| @@ -1216,8 +1220,9 @@ | ||
| 1216 | 1220 | 'No Subscription ID' => __('No Subscription ID', 'fluent-cart'), |
| 1217 | 1221 | 'no processing' => __('no processing', 'fluent-cart'), |
| 1218 | 1222 | 'not proper order handler' => __('not proper order handler', 'fluent-cart'), |
| 1219 | 1223 | 'Payment confirmation failed' => __('Payment confirmation failed', 'fluent-cart'), |
| 1224 | + 'Your payment is being reviewed. We will confirm your order once it completes.' => __('Your payment is being reviewed. We will confirm your order once it completes.', 'fluent-cart'), | |
| 1220 | 1225 | ] |
| 1221 | 1226 | ] |
| 1222 | 1227 | ]; |
| 1223 | 1228 | } |
| @@ -1254,12 +1259,14 @@ | ||
| 1254 | 1259 | } |
| 1255 | 1260 | |
| 1256 | 1261 | $paymentArgs['public_key'] = $clientId; |
| 1257 | 1262 | |
| 1263 | + $currency = strtoupper(CurrencySettings::get('currency')); | |
| 1264 | + | |
| 1258 | 1265 | $paymentDetails = [ |
| 1259 | 1266 | 'mode' => 'payment', |
| 1260 | - 'amount' => number_format(Helper::toDecimalWithoutComma($totalPrice), 2, '.', ''), | |
| 1261 | - 'currency' => strtoupper(CurrencySettings::get('currency')), | |
| 1267 | + 'amount' => PayPalHelper::formatAmount($totalPrice, $currency), | |
| 1268 | + 'currency' => $currency, | |
| 1262 | 1269 | ]; |
| 1263 | 1270 | |
| 1264 | 1271 | $renderAsSubscription = $this->shouldRenderAsSubscriptionMode($hasSubscription); |
| 1265 | 1272 | |