← All changes
|
app/Modules/PaymentMethods/PayPalGateway/PayPal.php
+19
-5
1.6.2
→
1.7.1
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 | { |
| @@ -1056,8 +1060,15 @@ | ||
| 1056 | 1060 | 'schema' => $testSchema |
| 1057 | 1061 | ] |
| 1058 | 1062 | ] |
| 1059 | 1063 | ], |
| 1064 | + 'brand_name' => [ | |
| 1065 | + 'value' => '', | |
| 1066 | + 'label' => __('Brand name', 'fluent-cart'), | |
| 1067 | + 'placeholder' => __('Shown on the PayPal checkout instead of your business name', 'fluent-cart'), | |
| 1068 | + 'tooltip' => __('Optional. Up to 127 characters. Leave empty to show the name on your PayPal business account.', 'fluent-cart'), | |
| 1069 | + 'type' => 'text', | |
| 1070 | + ], | |
| 1060 | 1071 | 'provider' => array( |
| 1061 | 1072 | 'value' => $this->settings->getProviderType(), |
| 1062 | 1073 | 'label' => __('Provider', 'fluent-cart'), |
| 1063 | 1074 | 'type' => 'provider' |
| @@ -1216,8 +1227,9 @@ | ||
| 1216 | 1227 | 'No Subscription ID' => __('No Subscription ID', 'fluent-cart'), |
| 1217 | 1228 | 'no processing' => __('no processing', 'fluent-cart'), |
| 1218 | 1229 | 'not proper order handler' => __('not proper order handler', 'fluent-cart'), |
| 1219 | 1230 | 'Payment confirmation failed' => __('Payment confirmation failed', 'fluent-cart'), |
| 1231 | + '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 | 1232 | ] |
| 1221 | 1233 | ] |
| 1222 | 1234 | ]; |
| 1223 | 1235 | } |
| @@ -1254,12 +1266,14 @@ | ||
| 1254 | 1266 | } |
| 1255 | 1267 | |
| 1256 | 1268 | $paymentArgs['public_key'] = $clientId; |
| 1257 | 1269 | |
| 1270 | + $currency = strtoupper(CurrencySettings::get('currency')); | |
| 1271 | + | |
| 1258 | 1272 | $paymentDetails = [ |
| 1259 | 1273 | 'mode' => 'payment', |
| 1260 | - 'amount' => number_format(Helper::toDecimalWithoutComma($totalPrice), 2, '.', ''), | |
| 1261 | - 'currency' => strtoupper(CurrencySettings::get('currency')), | |
| 1274 | + 'amount' => PayPalHelper::formatAmount($totalPrice, $currency), | |
| 1275 | + 'currency' => $currency, | |
| 1262 | 1276 | ]; |
| 1263 | 1277 | |
| 1264 | 1278 | $renderAsSubscription = $this->shouldRenderAsSubscriptionMode($hasSubscription); |
| 1265 | 1279 | |