refactor(pricing): implement hybrid fee model (€0.50 + 1.5%) deducted from promoter payout

- Remove 1€ fixed fee from orders and Stripe invoices
- Add platform_fee_cents, promoter_payout_cents methods to Order model
- Update views to show clean ticket totals without added fees
- Update tests for new fee calculation logic
- Update pricing docs with implemented model
This commit is contained in:
kbe
2025-09-15 20:07:51 +02:00
parent d6184b6c84
commit 049e5505ef
9 changed files with 205 additions and 108 deletions

View File

@@ -50,7 +50,7 @@
<div>
<h3 class="font-medium text-blue-800 mb-1">Nouvelle tentative de paiement</h3>
<p class="text-blue-700 text-sm">
Tentative <%= @order.payment_attempts + 1 %> sur <%= @order.class::MAX_PAYMENT_ATTEMPTS %>.
Tentative <%= @order.payment_attempts + 1 %> sur <%= @order.class::MAX_PAYMENT_ATTEMPTS %>.
<% if @order.payment_attempts >= @order.class::MAX_PAYMENT_ATTEMPTS - 1 %>
<strong>Dernière tentative avant expiration !</strong>
<% end %>
@@ -79,7 +79,7 @@
<!-- Order Items -->
<div class="space-y-4 mb-6">
<h3 class="text-lg font-semibold text-gray-900 mb-4">Récapitulatif de votre commande</h3>
<% @tickets.each do |ticket| %>
<div class="flex items-center justify-between py-3 border-b border-gray-100 last:border-b-0">
<div class="flex-1 min-w-0">
@@ -100,16 +100,8 @@
</div>
<!-- Order Total -->
<div class="border-t border-gray-200 pt-6">
<div class=" pt-12">
<div class="space-y-2">
<div class="flex items-center justify-between">
<span class="text-gray-600">Sous-total</span>
<span class="text-gray-900"><%= @order.total_amount_euros - 1.0 %>€</span>
</div>
<div class="flex items-center justify-between">
<span class="text-gray-600">Frais de service</span>
<span class="text-gray-900">1.00€</span>
</div>
<div class="flex items-center justify-between text-lg pt-2 border-t border-gray-200">
<span class="font-medium text-gray-900">Total</span>
<span class="font-bold text-2xl text-purple-600"><%= @order.total_amount_euros %>€</span>
@@ -139,8 +131,8 @@
</div>
</div>
<button
id="checkout-button"
<button
id="checkout-button"
data-order-id="<%= @order.id %>"
data-increment-url="/api/v1/orders/<%= @order.id %>/increment_payment_attempt"
data-session-id="<%= @checkout_session.id if @checkout_session.present? %>"
@@ -179,7 +171,7 @@
console.log('Initializing Stripe with publishable key:', '<%= Rails.application.config.stripe[:publishable_key] %>');
const stripe = Stripe('<%= Rails.application.config.stripe[:publishable_key] %>');
const checkoutButton = document.getElementById('checkout-button');
if (!checkoutButton) {
console.error('Checkout button not found');
@@ -230,7 +222,7 @@
Redirection vers le paiement...
</div>
`;
// Redirect to Stripe
const sessionId = checkoutButton.dataset.sessionId;
console.log('Redirecting to Stripe with session ID:', sessionId);
@@ -290,4 +282,4 @@
</div>
</div>
</div>
</div>
</div>

View File

@@ -119,12 +119,6 @@
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 text-right"><%= "%.2f" % (tickets.count * ticket_type.price_cents / 100.0) %>€</td>
</tr>
<% end %>
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">Frais de service</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 text-right">1</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500 text-right">1.00€</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 text-right">1.00€</td>
</tr>
</tbody>
<tfoot class="bg-gray-50">
<tr>

View File

@@ -96,22 +96,12 @@
<!-- Total -->
<div class="border-t border-gray-200 pt-6 mt-6">
<div class="space-y-2">
<div class="flex items-center justify-between">
<span class="text-gray-600">Sous-total</span>
<span class="text-gray-900"><%= @order.total_amount_euros - 1.0 %>€</span>
</div>
<div class="flex items-center justify-between">
<span class="text-gray-600">Frais de service</span>
<span class="text-gray-900">1.00€</span>
</div>
<div class="flex items-center justify-between text-lg pt-2 border-t border-gray-200">
<span class="font-medium text-gray-900">Total <%= @order.status == 'paid' || @order.status == 'completed' ? 'payé' : 'à payer' %></span>
<span class="font-bold text-2xl <%= @order.status == 'paid' || @order.status == 'completed' ? 'text-green-600' : 'text-purple-600' %>">
<%= @order.total_amount_euros %>€
</span>
</div>
</div>
</div>
<!-- View Invoice -->