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

Prototype: setPaymentMethodOnCart #330

Merged
merged 9 commits into from
Feb 27, 2019

Conversation

pmclain
Copy link
Contributor

@pmclain pmclain commented Jan 29, 2019

Description (*)

Implements mutation for setting cart payment method. Additionally provides a convention for handling the dynamic additional_data object currently sent with REST payment information.

The input PaymentMethodInput provides payment integrators the ability to define additional inputs for populating additional_data. I've included a partial example using the Braintree integration https://github.com/magento/graphql-ce/compare/2.3-develop...pmclain:issue/293?expand=1#diff-9cca29ccf0ab73e1ac28e56811a208a8.

Custom input types can converted to additional_data by registering a Magento\QuoteGraphQl\Model\Cart\Payment\AdditionalDataBuilderInterface for the payment method with the Magento\QuoteGraphQl\Model\Cart\Payment\AdditionalDataBuilderPool. The default assumption is a one-to-one match of input property to the desired array set as the payment method additional data.

Payment methods like Check/MO that do not have a dependency on the additional_data property work as-is and do not require registering an AdditionalDataBuilderInterface

Fixed Issues (if relevant)

  1. [Payment methods] Set Payment Method on Cart #293
    Add support for Payment Methods:
    [Payment methods] Support of "Check / Money Order" payment method #286 - Check/Money Order
    [Payment methods] Support of "Bank Transfer Payment" method #287 - Bank Transfer
    [Payment methods] Support of "Cash On Delivery Payment" method #288 - Cash on Delivery
    [Payment methods] Support of "Purchase Order" payment method #290 - Purchase Order
    Braintree and Braintree Vault (requires test coverage)

Manual testing scenarios (*)

  1. Create customer token
  2. Create empty cart for customer
  3. Using the customer token and masked quote id set payment method on cart with the mutation below:
mutation {
  setPaymentMethodOnCart(input: 
    {
      cart_id: "{{maskedQuoteId}}", 
      payment_method: {
          method: "{{methodCode}}"
        }
      }) {
    
    cart {
      cart_id,
      payment_method {
        method
      }
    }
  }
}

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)

@naydav naydav changed the title Proposal For setPaymentMethodOnCart Prototype: setPaymentMethodOnCart Jan 30, 2019
@pmclain pmclain force-pushed the issue/293 branch 3 times, most recently from 5b73616 to 3f72001 Compare February 7, 2019 05:51
# Conflicts:
#	app/code/Magento/QuoteGraphQl/etc/schema.graphqls
#	composer.lock
# Conflicts:
#	app/code/Magento/QuoteGraphQl/etc/schema.graphqls

input PaymentMethodInput {
code: String! @doc(description:"Payment method code")
po_number: String! @doc(description:"Purchase order number")
Copy link
Contributor

@paliarush paliarush Feb 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to use full field name "purchase_order_number". Is there a reason to shorten it here?
Same on line 206

@ghost
Copy link

ghost commented Feb 27, 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.

@keharper
Copy link
Contributor

Documented as part of magento/devdocs#4502

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.

5 participants