Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orders api view not respecting other payment sources #2512

Closed
skukx opened this issue Jan 18, 2018 · 0 comments
Closed

Orders api view not respecting other payment sources #2512

skukx opened this issue Jan 18, 2018 · 0 comments

Comments

@skukx
Copy link
Contributor

skukx commented Jan 18, 2018

Steps to reproduce

  • Create an order with a payment from a non-traditional payment source
  • Go back to cart page
  • Open debugger in browser
  • Refresh page

You should see an api request which returns a 500 status code in the response. This also causes the page to not load entirely (Add Item button greyed out).

The error is as follows:

ActionView::Template::Error (undefined method `month' for #<Spree::GiftCard:0x00007fcdb9bee298>):
    25:   json.payment_method { json.(payment.payment_method, :id, :name) }
    26:   json.source do
    27:     if payment.source
    28:       json.(payment.source, *payment_source_attributes)
    29: 
    30:       if @current_user_roles.include?("admin")
    31:         json.(payment.source, :gateway_customer_profile_id, :gateway_payment_profile_id)

The reason this happens is due to the view trying to render attributes for payment sources which not all payment sources might have.

See: https://github.com/solidusio/solidus/blob/master/api/app/views/spree/api/orders/_big.json.jbuilder#L28-L32L144

See: https://github.com/solidusio/solidus/blob/master/api/app/helpers/spree/api/api_helpers.rb#L142-L144

System configuration

Solidus Version:
2.4

Possible Resolution

I think what should be done is much like what is done on the frontend.

See: https://github.com/solidusio/solidus/tree/master/frontend/app/views/spree/checkout/payment
See: https://github.com/solidusio/solidus/blob/master/frontend/app/views/spree/checkout/_payment.html.erb#L53

Where each payment source is given a partial which is rendered based on the payment source type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant