buckaroo/magento2graphql

Buckaroo Magento2 GraphQL 支持

安装数: 4,428

依赖者: 0

建议者: 0

安全性: 0

星标: 1

关注者: 11

分支: 1

类型:magento2-module

1.0.0 2023-03-27 11:49 UTC

README

Buckaroo Magento2 GraphQL 扩展

我们为我们的 Buckaroo Magento 2 支付插件 创建了一个额外的 GraphQL 扩展。
此插件是我们 Hÿva React 结账扩展 所必需的。

什么是 GraphQL?
GraphQL 是一种用于 API 的查询语言,以及用于使用现有数据满足这些查询的运行时。GraphQL 提供了对 API 中数据的完整和可理解的描述,赋予客户端请求所需数据的权力,而不需要更多,使 API 随时间演变变得更容易,并启用强大的开发工具。

索引

要求

要使用此插件,您必须使用

  • Magento Open Source 版本 2.4.x
  • Buckaroo Magento 2 支付模块 1.43.0 或更高版本。

安装

  • 运行以下命令安装模块 composer: composer require buckaroo/magento2graphql
  • 运行以下命令启用模块: php bin/magento module:enable Buckaroo_Magento2Graphql
  • 运行以下命令应用数据库更新: php bin/magento setup:upgrade
  • 运行以下命令清除缓存: php bin/magento cache:flush

使用方法

示例请求

  • 获取带有网关附加数据的可用支付方式
query {
    cart(cart_id: "{ CART_ID }") {
        available_payment_methods {
            code
            title
            buckaroo_additional {
                key
                values {
                    name
                    code
                    img
                }
                value
            }
        }
    }
}
  • 下订单请求示例:为了下订单,您需要执行以下 3 个步骤
    • 使用默认的 setPaymentMethodOnCartbuckaroo_additional 属性,在购物车中设置所需的附加参数的支付方式
    • 使用我们定制的迁移 setBuckarooReturnUrl 设置返回 URL,这是支付引擎在支付完成后/取消/失败后重定向回您的应用程序所必需的
    • 最后,执行默认的 placeOrder,这将返回支付引擎完成支付的跳转 URL

对于 iDEAL,我们有以下示例

  mutation doBuckarooPayment(
  $cartId: String!
  $returnUrl: String!
  $methodCode: String!
) {
  setPaymentMethodOnCart(
    input: {
      cart_id: $cartId
      payment_method: {
        code: $methodCode
        buckaroo_additional: { buckaroo_magento2_ideal: { issuer: "ABNANL2A" } }
      }
    }
  ) {
    cart {
      items {
        product {
          name
          sku
        }
      }
    }
  }
  setBuckarooReturnUrl(input: { return_url: $returnUrl, cart_id: $cartId }) {
    success
  }
  placeOrder(input: { cart_id: $cartId }) {
    order {
      order_number
      buckaroo_additional {
        redirect
        transaction_id
        data {
          key
          value
        }
      }
    }
  }
}

在此迁移执行后,您需要存储 buckaroo 的 transaction_id 并将用户重定向到完成支付

检索支付状态

为了在用户返回后获取支付状态,我们将使用我们定制的迁移 buckarooPaymentTransactionStatus,它需要存储的 transaction_id

mutation buckarooPaymentTransactionStatus(input: { transaction_id: "E397CF4C24E64AA299F45246F9906F45" }) {
  payment_status,
  status_code
}
  • 获取带有网关附加数据的可用支付方式
query {
    cart(cart_id: "{ CART_ID }") {
        available_payment_methods {
            code
            title
            buckaroo_additional {
                key
                values {
                    name
                    code
                    img
                }
                value
            }
        }
    }
}
  • 下订单请求示例:为了下订单,您需要执行以下 3 个步骤
    • 使用默认的 setPaymentMethodOnCartbuckaroo_additional 属性,在卡片上设置所需的附加参数的支付方式
    • 使用我们定制的迁移 setBuckarooReturnUrl 设置返回 URL,这是支付引擎在支付完成后/取消/失败后重定向回您的应用程序所必需的
    • 最后,执行默认的 placeOrder,这将返回支付引擎完成支付的跳转 URL

对于 iDEAL,我们有以下示例

  mutation doBuckarooPayment(
  $cartId: String!
  $returnUrl: String!
  $methodCode: String!
) {
  setPaymentMethodOnCart(
    input: {
      cart_id: $cartId
      payment_method: {
        code: $methodCode
        buckaroo_additional: { buckaroo_magento2_ideal: { issuer: "ABNANL2A" } }
      }
    }
  ) {
    cart {
      items {
        product {
          name
          sku
        }
      }
    }
  }
  setBuckarooReturnUrl(input: { return_url: $returnUrl, cart_id: $cartId }) {
    success
  }
  placeOrder(input: { cart_id: $cartId }) {
    order {
      order_number
      buckaroo_additional {
        redirect
        transaction_id
        data {
          key
          value
        }
      }
    }
  }
}

在此迁移执行后,您需要存储 buckaroo 的 transaction_id 并将用户重定向到完成支付

为了在用户返回后获取支付状态,我们将使用我们定制的迁移 buckarooPaymentTransactionStatus,它需要存储的 transaction_id

mutation buckarooPaymentTransactionStatus(input: { transaction_id: "E397CF4C24E64AA299F45246F9906F45" }) {
  payment_status,
  status_code
}

附加信息

贡献

我们非常感激开发者为改进 Buckaroo 插件做出的贡献。如果您也想做出贡献,请遵循我们的 贡献指南

版本控制

请注意
此文件已尽最大努力准备,可能存在语言和/或拼写错误。