5

Can anyone explain what does /rest/default/V1/carts/mine/payment-information it mean?

I want to hide Cash payment option. By using jquery I am able to hide cash payment option but when page get refreshed through order summary page, then Cash payment option get displayed.

2 Answers 2

8

/rest/default/V1/carts/mine/payment-information Is the rest api which map to PaymentInformationManagementInterface. Here mine means you are logged in customer.

Open vendor/magento/module-checkout/etc/webapi.xml here actually map.

When you click Place Order button, magento call vendor/magento/module-checkout/Model/PaymentInformationManagement.php

savePaymentInformationAndPlaceOrder


/**
 * {@inheritDoc}
 */
public function savePaymentInformationAndPlaceOrder(
    $cartId,
    \Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
    \Magento\Quote\Api\Data\AddressInterface $billingAddress = null
) {
    $this->savePaymentInformation($cartId, $paymentMethod, $billingAddress);
    try {
        $orderId = $this->cartManagement->placeOrder($cartId);
    } catch (\Magento\Framework\Exception\LocalizedException $e) {
        throw new CouldNotSaveException(
            __($e->getMessage()),
            $e
        );
    } catch (\Exception $e) {
        $this->getLogger()->critical($e);
        throw new CouldNotSaveException(
            __('An error occurred on the server. Please try to place the order again.'),
            $e
        );
    }
    return $orderId;
}
5
  • thanks for the valuable information. Can u tell me, Is it possible to hide Cash payment option on onclick of Check payment option?
    – jassi
    Nov 19, 2017 at 5:23
  • Yes, you need to do with js stuff
    – Sohel Rana
    Nov 19, 2017 at 5:25
  • using jquery I am able to hide cash payment option but when page get refreshed through order summary page, then Cash payment option get displayed
    – jassi
    Nov 19, 2017 at 5:27
  • 1
    as a complement alanstorm.com/magento-2-checkout-application-order-placing
    – medmek
    Jul 17, 2018 at 14:36
  • 1
    What is the solution ? I am getting the same error. Sep 21, 2018 at 11:50
0

Agreements are validated before saving payment information. I have researched and found this

vendor/magento/module-checkout-agreements/Model/Checkout/Plugin/Validation.php

public function beforeSavePaymentInformation(
    \Magento\Checkout\Api\PaymentInformationManagementInterface $subject,
    $cartId,
    \Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
    \Magento\Quote\Api\Data\AddressInterface $billingAddress = null
) {
    $quote = $this->quoteRepository->getActive($cartId);
    if ($this->isAgreementEnabled() && !$quote->getIsMultiShipping()) {
        $this->validateAgreements($paymentMethod);
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.