peachpayments/magento2-graphql-plugin

PeachPayments Hosted module, for Magento 2 GraphQl support.

Installs: 3 082

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Forks: 0

Type:magento2-module

1.0.0 2023-04-13 07:59 UTC

This package is auto-updated.

Last update: 2024-04-17 09:31:18 UTC


README

Installation

Install this module alongside the Peach Payments hosted payments module by running:

composer require peachpayments/magento2-graphql-plugin

GraphQL

To allow for a GraphQL flow, use the core Magento setPaymentMethodOnCart and placeOrder methods.

After a successful order ID has been returned, use the getPeachHostedRedirectUrl method to redirect the customer to the Checkout page. At this stage, the order should be in the pending state. Deconstruct the JSON object from form_data and submit it as _POST parameters to the specified form_link URL.

After the customer has returned to the return_url you specified, call the getPeachHostedOrderStatus method to get a success (1) or declined (2) status. If the status code is 3, retry regularly.

Examples


# Set Peach Payments as payment method
mutation setPaymentMethodOnCart($cartId: String!){
  setPaymentMethodOnCart(input: {
      cart_id: $cartId
      payment_method: {
          code: "peachpayments_hosted_card"
      }
  }) {
    cart {
      selected_payment_method {
        code
      }
    }
  }
}

# Place order
mutation placeOrder($cartId: String!) {
  placeOrder(input: {cart_id: $cartId}) {
    order {
      order_number
    }
  }
}

# Get redirect URL and data
query getPeachHostedRedirectUrl($cartId: String!){
  getPeachHostedRedirectUrl(input: {
    cart_id: $cartId,
    return_url: "https://my.app.pwa/payment/welcome-back.html"
  }) {
    form_data
    form_link
  }
}

# Get status by order increment ID
query getPeachHostedOrderStatus($orderNumber: String!){
  getPeachHostedOrderStatus(input: { order_number: $orderNumber }) {
    status
  }
}

# Get order details, used for confirmation page
query getPeachHostedOrderDetailsData($cartId: String!) {
    getPeachHostedOrderDetailsData(cart_id: $cartId) {
        id
        ...OrderConfirmationPageFragment
    }
}