| @@ -8,9 +8,8 @@ | ||
| 8 | 8 | use FluentCart\App\Helpers\StatusHelper; |
| 9 | 9 | use FluentCart\App\Models\Cart; |
| 10 | 10 | use FluentCart\App\Modules\Subscriptions\Services\SubscriptionService; |
| 11 | 11 | use FluentCart\App\Services\DateTime\DateTime; |
| 12 | -use FluentCart\App\Services\Payments\PaymentHelper; | |
| 13 | 12 | use FluentCart\App\Models\Subscription; |
| 14 | 13 | |
| 15 | 14 | class CodHandler { |
| 16 | 15 | |
| @@ -53,13 +52,15 @@ | ||
| 53 | 52 | 'customer' => $paymentInstance->order->customer ?? [], |
| 54 | 53 | 'transaction' => $paymentInstance->transaction ?? [] |
| 55 | 54 | ]; |
| 56 | 55 | |
| 57 | - do_action('fluent_cart/order_placed_offline', $data); | |
| 56 | + // Renewal invoices are not new orders — skip placement emails. | |
| 57 | + // SubscriptionRenewed fires separately once the invoice is paid. | |
| 58 | + if ($paymentInstance->order->type !== Status::ORDER_TYPE_RENEWAL) { | |
| 59 | + do_action('fluent_cart/order_placed_offline', $data); | |
| 60 | + } | |
| 58 | 61 | } |
| 59 | 62 | |
| 60 | - $paymentHelper = new PaymentHelper('offline_payment'); | |
| 61 | - | |
| 62 | 63 | $relatedCart = Cart::query()->where('order_id', $order->id) |
| 63 | 64 | ->where('stage', '!=', 'completed') |
| 64 | 65 | ->first(); |
| 65 | 66 | |
| @@ -68,9 +69,9 @@ | ||
| 68 | 69 | $relatedCart->completed_at = DateTime::now()->format('Y-m-d H:i:s'); |
| 69 | 70 | $relatedCart->save(); |
| 70 | 71 | } |
| 71 | 72 | |
| 72 | - return $paymentHelper->successUrl($paymentInstance->transaction->uuid); | |
| 73 | + return $paymentInstance->transaction->getSuccessUrl(); | |
| 73 | 74 | } |
| 74 | 75 | |
| 75 | 76 | public function handleZeroTotalPayment($paymentInstance) |
| 76 | 77 | { |
| @@ -100,8 +101,7 @@ | ||
| 100 | 101 | } |
| 101 | 102 | } |
| 102 | 103 | } |
| 103 | 104 | |
| 104 | - $paymentHelper = new PaymentHelper('offline_payment'); | |
| 105 | - return $paymentHelper->successUrl($transaction->uuid); | |
| 105 | + return $transaction->getSuccessUrl(); | |
| 106 | 106 | } |
| 107 | 107 | } |