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

Deprecate setPaymentMethodAndPlaceOrderMutation #916

Merged
merged 1 commit into from
Sep 10, 2019
Merged
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 @@ -20,7 +20,11 @@
use Magento\Sales\Api\OrderRepositoryInterface;

/**
* @inheritdoc
* Resolver for setting payment method and placing order
*
* @deprecated Should use setPaymentMethodOnCart and placeOrder mutations in single request.
* @see \Magento\QuoteGraphQl\Model\Resolver\SetPaymentMethodOnCart
* @see \Magento\QuoteGraphQl\Model\Resolver\PlaceOrder
*/
class SetPaymentAndPlaceOrder implements ResolverInterface
{
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/QuoteGraphQl/etc/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Mutation {
setShippingMethodsOnCart(input: SetShippingMethodsOnCartInput): SetShippingMethodsOnCartOutput @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\SetShippingMethodsOnCart")
setPaymentMethodOnCart(input: SetPaymentMethodOnCartInput): SetPaymentMethodOnCartOutput @resolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\SetPaymentMethodOnCart")
setGuestEmailOnCart(input: SetGuestEmailOnCartInput): SetGuestEmailOnCartOutput @resolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\SetGuestEmailOnCart")
setPaymentMethodAndPlaceOrder(input: SetPaymentMethodAndPlaceOrderInput): PlaceOrderOutput @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\SetPaymentAndPlaceOrder")
setPaymentMethodAndPlaceOrder(input: SetPaymentMethodAndPlaceOrderInput): PlaceOrderOutput @deprecated(reason: "Should use setPaymentMethodOnCart and placeOrder mutations in single request.") @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\SetPaymentAndPlaceOrder")
placeOrder(input: PlaceOrderInput): PlaceOrderOutput @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\PlaceOrder")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,14 @@ public function testSetPaymentOnCartWithSimpleProduct()
$query = $this->getQuery($maskedQuoteId, $methodCode);
$response = $this->graphQlMutation($query, [], '', $this->getHeaderMap());

self::assertArrayHasKey('setPaymentMethodAndPlaceOrder', $response);
self::assertArrayHasKey('order', $response['setPaymentMethodAndPlaceOrder']);
self::assertArrayHasKey('order_id', $response['setPaymentMethodAndPlaceOrder']['order']);
self::assertArrayHasKey('setPaymentMethodOnCart', $response);
self::assertArrayHasKey('cart', $response['setPaymentMethodOnCart']);
self::assertArrayHasKey('selected_payment_method', $response['setPaymentMethodOnCart']['cart']);
self::assertArrayHasKey('code', $response['setPaymentMethodOnCart']['cart']['selected_payment_method']);
self::assertEquals($methodCode, $response['setPaymentMethodOnCart']['cart']['selected_payment_method']['code']);

self::assertArrayHasKey('order', $response['placeOrder']);
self::assertArrayHasKey('order_id', $response['placeOrder']['order']);
}

/**
Expand Down Expand Up @@ -116,9 +121,14 @@ public function testSetPaymentOnCartWithVirtualProduct()
$query = $this->getQuery($maskedQuoteId, $methodCode);
$response = $this->graphQlMutation($query, [], '', $this->getHeaderMap());

self::assertArrayHasKey('setPaymentMethodAndPlaceOrder', $response);
self::assertArrayHasKey('order', $response['setPaymentMethodAndPlaceOrder']);
self::assertArrayHasKey('order_id', $response['setPaymentMethodAndPlaceOrder']['order']);
self::assertArrayHasKey('setPaymentMethodOnCart', $response);
self::assertArrayHasKey('cart', $response['setPaymentMethodOnCart']);
self::assertArrayHasKey('selected_payment_method', $response['setPaymentMethodOnCart']['cart']);
self::assertArrayHasKey('code', $response['setPaymentMethodOnCart']['cart']['selected_payment_method']);
self::assertEquals($methodCode, $response['setPaymentMethodOnCart']['cart']['selected_payment_method']['code']);

self::assertArrayHasKey('order', $response['placeOrder']);
self::assertArrayHasKey('order_id', $response['placeOrder']['order']);
}

/**
Expand Down Expand Up @@ -224,12 +234,25 @@ private function getQuery(
) : string {
return <<<QUERY
mutation {
setPaymentMethodAndPlaceOrder(input: {
cart_id: "$maskedQuoteId"
setPaymentMethodOnCart(
input: {
cart_id: "{$maskedQuoteId}"
payment_method: {
code: "$methodCode"
code: "{$methodCode}"
}
}
) {
cart {
selected_payment_method {
code
}
}) {
}
}
placeOrder(
input: {
cart_id: "{$maskedQuoteId}"
}
) {
order {
order_id
}
Expand Down