Skip to content

Added order_place_redirect_url to SelectedPaymentMethod and OrderPaymentMethod result #39896

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 2.4-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function resolve(Field $field, $context, ResolveInfo $info, ?array $value
return [
'code' => $payment->getMethod() ?? '',
'title' => $methodTitle,
'order_place_redirect_url' => $payment->getOrderPlaceRedirectUrl(),
'purchase_order_number' => $payment->getPoNumber(),
];
}
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/QuoteGraphQl/etc/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ type AvailablePaymentMethod @doc(description: "Describes a payment method that t
type SelectedPaymentMethod @doc(description: "Describes the payment method the shopper selected.") {
code: String! @doc(description: "The payment method code.")
title: String! @doc(description: "The payment method title.")
order_place_redirect_url: String @doc(description: "Checkout order place redirect URL")
purchase_order_number: String @doc(description: "The purchase order number.")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\SalesGraphQl\Model\Resolver\Order\OrderPayments;

use Magento\Sales\Api\Data\OrderInterface;
use Magento\Quote\Model\QuoteRepository;
use Magento\Quote\Model\Quote;

/**
* @inheritdoc
*/
class QuoteOrderPlaceRedirectUrl implements ResolverInterface
{
/**
* @param QuoteRepository $quoteRepository
*/
public function __construct(
private readonly QuoteRepository $quoteRepository,
) {
}

/**
* @inheritdoc
*/
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
{
if (!isset($value['model']) || !($value['model'] instanceof OrderInterface)) {
throw new LocalizedException(__('"model" value should be specified'));
}
/** @var OrderInterface $order */
$order = $value['model'];

if (!$order->getQuoteId()) {
return;
}

/** @var ?Quote $quote */
$quote = $this->quoteRepository->get($order->getQuoteId())

if (!$quote) {
return;
}

return $quote->getPayment()->getOrderPlaceRedirectUrl();
}
}

1 change: 1 addition & 0 deletions app/code/Magento/SalesGraphQl/etc/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ type ShipmentTracking @doc(description: "Contains order shipment tracking detail
type OrderPaymentMethod @doc(description: "Contains details about the payment method used to pay for the order.") {
name: String! @doc(description: "The label that describes the payment method.")
type: String! @doc(description: "The payment method code that indicates how the order was paid for.")
order_place_redirect_url: String @doc(description: "Checkout order place redirect URL") @resolver(class: "Magento\\SalesGraphQl\\Model\\Resolver\\Order\\OrderPayments\\QuoteOrderPlaceRedirectUrl")
additional_data: [KeyValue] @doc(description: "Additional data per payment method type.")
}

Expand Down