Skip to content

GraphQL integration

Frank Tiggelman edited this page Nov 23, 2020 · 16 revisions

GraphQL allows you to query data from an external system in the format your application requires. This allows you to build a complete custom frontend for your Magento store, but still manage all products, categories, orders, etc. within Magento. The implementation of Mollie allows you to place an order within Magento using one of the Mollie payment methods.

To create an order using GraphQL you normally should roughly follow these steps:

  • Create a shopping cart
  • Add products
  • Select Shipping method
  • Get payment methods
  • Select a Payment method
  • Place order

When placing an order using Mollie the method should look like this (bold = changed/new):

  • Create a shopping cart
  • Add products
  • Select Shipping method
  • Get payment methods (and retrieve a list of available issuers)
  • Select a Payment method
  • Place order (but add mollie_payment_token in your request)
  • Start the mollie transaction by calling createMollieTransaction (add the value of mollie_payment_token and issuers in your request)
  • This last step will return the checkout URL. You need to redirect your customer to this URL so the payment can be handled by Mollie.

The Mollie extension also allows you to retrieve the order details using the generated payment token.

Example request

Request the available issuers

query {
  cart(cart_id: "{{cart_token}}") {
    available_payment_methods {
      code
      title
    }
    mollie_available_issuers {
      name
      code
      image
      svg
    }
  }
}

Place order request

mutation {
  placeOrder(input: {
      cart_id: "{{cart_token}}"
  }) {
    order {
      order_id
      mollie_payment_token
    }
  }
}

Create Mollie Transaction request

mutation {
  createMollieTransaction(input: {
      payment_token: "{{payment_token}}"
      issuer: "{{issuer}}"
  }) {
    checkout_url
  }
}

Retrieve the customer order

type Query {
    mollieCustomerOrder (
        hash: "{{payment_token}}"
    ) {
        id
        increment_id
        created_at
        grand_total
        status
    }
}