Skip to content

Commit d9595bf

Browse files
authored
fix(stripe): fix serialization issues on invoices (#412)
1 parent 7f10833 commit d9595bf

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

app/serializers/forest_liana/stripe_invoice_serializer.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ class StripeInvoiceSerializer
33
include JSONAPI::Serializer
44

55
attribute :amount_due
6+
attribute :amount_paid
7+
attribute :amount_remaining
8+
attribute :application_fee_amount
69
attribute :attempt_count
710
attribute :attempted
8-
attribute :closed
911
attribute :currency
10-
attribute :date
11-
attribute :forgiven
12+
attribute :due_date
1213
attribute :paid
1314
attribute :period_end
1415
attribute :period_start
16+
attribute :status
1517
attribute :subtotal
1618
attribute :total
17-
attribute :application_fee
1819
attribute :tax
19-
attribute :tax_percent
2020

2121
has_one :customer
2222

app/services/forest_liana/stripe_invoice_getter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def perform
1111
query = {}
1212
@record = ::Stripe::Invoice.retrieve(@params[:invoice_id])
1313

14-
@record.date = Time.at(@record.date).to_datetime
14+
@record.due_date = Time.at(@record.due_date).to_datetime unless @record.due_date.nil?
1515
@record.period_start = Time.at(@record.period_start).to_datetime
1616
@record.period_end = Time.at(@record.period_end).to_datetime
1717
@record.subtotal /= 100.00

app/services/forest_liana/stripe_invoices_getter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def perform
3232
end
3333

3434
@records = @invoices.data.map do |d|
35-
d.date = Time.at(d.date).to_datetime
35+
d.date = Time.at(d.created).to_datetime
3636
d.period_start = Time.at(d.period_start).to_datetime
3737
d.period_end = Time.at(d.period_end).to_datetime
3838
d.subtotal /= 100.00

app/services/forest_liana/stripe_source_getter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def perform
1212
customer = resource[field]
1313

1414
@record = ::Stripe::Customer
15-
.retrieve(customer)
15+
.retrieve({ id: customer, expand: ['sources'] })
1616
.sources.retrieve(@params[:objectId])
1717

1818
query = {}

app/services/forest_liana/stripe_sources_getter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def perform
3232

3333
def fetch_bank_accounts(customer, params)
3434
begin
35-
@cards = ::Stripe::Customer.retrieve(customer).sources.list(params)
35+
@cards = ::Stripe::Customer.retrieve({ id: customer, expand: ['sources'] }).sources.list(params)
3636
if @cards.blank?
3737
@records = []
3838
return

lib/forest_liana/bootstrapper.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,19 +430,19 @@ def setup_stripe_integration(collection_name_and_field)
430430
fields: [
431431
{ field: :id, type: 'String', is_filterable: false },
432432
{ field: :amount_due, type: 'Number', is_filterable: false },
433+
{ field: :amount_paid, type: 'Number', is_filterable: false },
434+
{ field: :amount_remaining, type: 'Number', is_filterable: false },
435+
{ field: :application_fee_amount, type: 'Number', is_filterable: false },
433436
{ field: :attempt_count, type: 'Number', is_filterable: false },
434437
{ field: :attempted, type: 'Boolean', is_filterable: false },
435-
{ field: :closed, type: 'Boolean', is_filterable: false },
436438
{ field: :currency, type: 'String', is_filterable: false },
437-
{ field: :date, type: 'Date', is_filterable: false },
438-
{ field: :forgiven, type: 'Boolean', is_filterable: false },
439+
{ field: :due_date, type: 'Date', is_filterable: false },
439440
{ field: :period_start, type: 'Date', is_filterable: false },
440441
{ field: :period_end, type: 'Date', is_filterable: false },
442+
{ field: :status, type: 'String', enums: ['draft', 'open', 'paid', 'uncollectible', 'void'], is_filterable: false },
441443
{ field: :subtotal, type: 'Number', is_filterable: false },
442444
{ field: :total, type: 'Number', is_filterable: false },
443-
{ field: :application_fee, type: 'Number', is_filterable: false },
444445
{ field: :tax, type: 'Number', is_filterable: false },
445-
{ field: :tax_percent, type: 'Number', is_filterable: false },
446446
{
447447
field: :customer,
448448
type: 'String',

0 commit comments

Comments
 (0)