← All changes
|
app/Modules/PaymentMethods/PayPalGateway/Processor.php
+36
-6
1.6.6
→
1.7.1
View file →
| @@ -244,8 +244,21 @@ | ||
| 244 | 244 | ], |
| 245 | 245 | ]; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | + $brandName = (new PayPalSettingsBase())->getBrandName([ | |
| 249 | + 'order' => $order, | |
| 250 | + 'subscription' => $paymentInstance->subscription, | |
| 251 | + ]); | |
| 252 | + | |
| 253 | + if ($brandName !== '') { | |
| 254 | + if (isset($extraBody['payment_source'])) { | |
| 255 | + $extraBody['payment_source']['paypal']['experience_context']['brand_name'] = $brandName; | |
| 256 | + } else { | |
| 257 | + $extraBody['application_context'] = ['shipping_preference' => 'NO_SHIPPING', 'brand_name' => $brandName]; | |
| 258 | + } | |
| 259 | + } | |
| 260 | + | |
| 248 | 261 | $paypalOrder = API::createOrder($purchaseUnits, $extraBody); |
| 249 | 262 | |
| 250 | 263 | // Vaulting is a convenience; the purchase is the point. A merchant account |
| 251 | 264 | // not approved for vaulting can reject the order outright because of the |
| @@ -313,18 +326,29 @@ | ||
| 313 | 326 | { |
| 314 | 327 | $order = $paymentInstance->order; |
| 315 | 328 | $transaction = $paymentInstance->transaction; |
| 316 | 329 | |
| 330 | + $experienceContext = [ | |
| 331 | + 'return_url' => PaymentHelper::getCustomPaymentLink($order->uuid), | |
| 332 | + 'cancel_url' => \FluentCart\App\Modules\PaymentMethods\Core\AbstractPaymentGateway::getCancelUrl(), | |
| 333 | + 'shipping_preference' => 'NO_SHIPPING', | |
| 334 | + ]; | |
| 335 | + | |
| 336 | + $brandName = (new PayPalSettingsBase())->getBrandName([ | |
| 337 | + 'order' => $order, | |
| 338 | + 'subscription' => $paymentInstance->subscription, | |
| 339 | + ]); | |
| 340 | + | |
| 341 | + if ($brandName !== '') { | |
| 342 | + $experienceContext['brand_name'] = $brandName; | |
| 343 | + } | |
| 344 | + | |
| 317 | 345 | $setupToken = API::makeRequest('vault/setup-tokens', 'v3', 'POST', [ |
| 318 | 346 | 'payment_source' => [ |
| 319 | 347 | 'paypal' => [ |
| 320 | 348 | 'usage_type' => 'MERCHANT', |
| 321 | 349 | 'customer_type' => 'CONSUMER', |
| 322 | - 'experience_context' => [ | |
| 323 | - 'return_url' => PaymentHelper::getCustomPaymentLink($order->uuid), | |
| 324 | - 'cancel_url' => \FluentCart\App\Modules\PaymentMethods\Core\AbstractPaymentGateway::getCancelUrl(), | |
| 325 | - 'shipping_preference' => 'NO_SHIPPING', | |
| 326 | - ], | |
| 350 | + 'experience_context' => $experienceContext, | |
| 327 | 351 | ], |
| 328 | 352 | ], |
| 329 | 353 | ]); |
| 330 | 354 | |
| @@ -560,9 +584,13 @@ | ||
| 560 | 584 | 'uuid' => $subscription->uuid, |
| 561 | 585 | ] |
| 562 | 586 | ], |
| 563 | 587 | 'response' => [ |
| 564 | - 'planId' => Arr::get($paypalPlan, 'id') | |
| 588 | + 'planId' => Arr::get($paypalPlan, 'id'), | |
| 589 | + 'brandName' => (new PayPalSettingsBase())->getBrandName([ | |
| 590 | + 'order' => $paymentInstance->order, | |
| 591 | + 'subscription' => $subscription, | |
| 592 | + ]), | |
| 565 | 593 | ] |
| 566 | 594 | ]; |
| 567 | 595 | } |
| 568 | 596 | |
| @@ -778,8 +806,10 @@ | ||
| 778 | 806 | // This can be a trialing subscription |
| 779 | 807 | if ($subscriptionModel->trial_days > 0) { |
| 780 | 808 | $subscriptionUpdateData['status'] = Status::SUBSCRIPTION_TRIALING; |
| 781 | 809 | } |
| 810 | + | |
| 811 | + $subscriptionUpdateData['bill_count'] = $subscriptionModel->calculateBillCount(); | |
| 782 | 812 | |
| 783 | 813 | // Atomic conditional update: only the caller that actually flips status out of a |
| 784 | 814 | // pre-active state wins the transition, so concurrent AJAX-return + webhook calls |
| 785 | 815 | // can't both dispatch SubscriptionActivated. |