Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Prevent Error When Getting Payment Method Before Setting #665

Merged
merged 1 commit into from
May 10, 2019

Conversation

pmclain
Copy link
Contributor

@pmclain pmclain commented May 3, 2019

Description (*)

Calling Magento\Quote\Model\Quote\Payment::getMethodInstance
throws an exception when the method is not set. This would trigger and error
when requsting the selected_payment_method cart property. This commit returns
an empty string instead.

Fixed Issues (if relevant)

  1. Internal server error "The payment method you requested is not available." for empty guest cart #667

Manual testing scenarios (*)

  1. Create empty cart
mutation {
   createEmptyCart
}
  1. Query cart for selected payment method
query getCart($cart_id:String!) {
  cart(cart_id:$cart_id) {
    selected_payment_method {
      code
      title
    }
  }
}

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

Calling [`Magento\Quote\Model\Quote\Payment::getMethodInstance`](https://github.com/magento/graphql-ce/blob/b2ce2a37d921b5ad88fc38663fc0ff3dd6c582d1/app/code/Magento/Payment/Model/Info.php#L105)
throws an exception when the method is not set. This would trigger and error
when requsting the `selected_payment_method` cart property. This commit returns
an empty string instead.
@naydav
Copy link
Contributor

naydav commented May 3, 2019

@pmclain Good point!

@TomashKhamlai, please, check the same behavior with shipping methods
thanks

@pmclain
Copy link
Contributor Author

pmclain commented May 3, 2019

This should resolve #667

@ghost
Copy link

ghost commented May 10, 2019

Hi @pmclain, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

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

Successfully merging this pull request may close these issues.

3 participants