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

[Checkout] Set Payment Method and Place Order Mutation #716

Closed
pmclain opened this issue May 18, 2019 · 2 comments
Closed

[Checkout] Set Payment Method and Place Order Mutation #716

pmclain opened this issue May 18, 2019 · 2 comments

Comments

@pmclain
Copy link
Contributor

pmclain commented May 18, 2019

Preconditions (*)

The current frontend workflow allows setting payment methods and placing order in a single request.

@joni-jones notes in #392

It doesn't make sense to call SetPaymentMethodOnCart and PlaceOrder resolvers separately for Braintree (now it's done because PlaceOrder resolver doesn't set payment details). The current flow does place an order through payment-information REST API call which sets payment information and places the order.

The main problem in two separate calls that some data might be changed during these calls, like fraud fingerprints and the payment data won't be actual anymore.

A proposed schema for facilitating is below:

type Mutation {
    setPaymentandPlaceOrder(input: SetPaymentMethodOnCartInput): PlaceOrderOutput
}

Example mutation:

mutation {
  setPaymentandPlaceOrder(input:{
    cart_id:$cartId
    payment_method:{
      code:"braintree"
      braintree:{
        is_active_payment_token_enabler:false
        payment_method_nonce:"fake-valid-nonce"
      }
    }
  }) {
    order {
      order_id
    }
  }
}
@naydav
Copy link
Contributor

naydav commented Jun 21, 2019

#723

@naydav naydav added this to the Release: 2.3.3 milestone Jun 21, 2019
@joni-jones
Copy link
Contributor

@pmclain @naydav, after discussion with @paliarush, we decided to remove setPaymentAndPlaceOrder as GraphQL guarantees that multiple mutations will be executed one by one via one HTTP request https://graphql.org/learn/queries/ and the flow might look like this:

mutation {
  setPaymentMethodOnCart(
      input:{
        cart_id:$cart_id
        payment_method:{
            code:"braintree"
            braintree:{
                payment_method_nonce:"tokencc_bf_8tkr89_k5nj5d_yd3pwc_nmztby_ppz"
            }
        }
    }
  ) {
      cart {
          selected_payment_method {
              code
          }
      }
  }
  placeOrder(
      input: {
          cart_id: $cart_id
      }
  ) {
    order {
      order_id
    }
  }
}

This allows solving the potential issues related to data actualization between multiple requests. But at the same time, now, it will be a developer responsibility to define the order of mutations execution as it depends on payment integration features.

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

No branches or pull requests

3 participants