diff --git a/app/serializers/payment_serializer.rb b/app/serializers/payment_serializer.rb index b553cf1..b1fe2c7 100644 --- a/app/serializers/payment_serializer.rb +++ b/app/serializers/payment_serializer.rb @@ -1,7 +1,13 @@ # frozen_string_literal: true class PaymentSerializer < ApplicationSerializer - attributes :payment_intent_id, :receipt_email, :url, :created_at_age, :amount, :amount_currency + attributes :payment_intent_id, + :receipt_email, + :url, + :created_at_age, + :amount, + :amount_currency, + :username def created_at_age Time.now - object.created_at @@ -9,14 +15,26 @@ class PaymentSerializer < ApplicationSerializer def amount_currency ActiveSupport::NumberHelper.number_to_currency( - object.amount/100, + object.amount / 100, precision: 2, unit: currency_unit ) end + def username + user&.username + end + private + def user + begin + User.find(object.user_id) + rescue + nil + end + end + def currency_unit case object.currency when "eur" diff --git a/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons.hbs b/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons.hbs index a1701c9..187a8af 100644 --- a/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons.hbs +++ b/assets/javascripts/discourse/templates/admin/plugins-discourse-patrons.hbs @@ -1,5 +1,5 @@ -
{{payment.user_id}} | +{{payment.username}} | {{{stripe-payment-link payment}}} | {{payment.receipt_email}} | {{{format-duration payment.created_at_age}}} |