Skip to content
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

Exception when process checkout through API without passing an address #12

Open
emastyle opened this issue Jun 14, 2019 · 0 comments
Open

Comments

@emastyle
Copy link

emastyle commented Jun 14, 2019

When try to process an order via API during checkout, if no address is set an exception error occurred:

PHP message: PHP Fatal error: Uncaught TypeError: Argument 4 passed to Experius\ExtraCheckoutAddressFields\Plugin\Magento\Checkout\Model\PaymentInformationManagement::beforeSavePaymentInformation() must implement interface Magento\Quote\Api\Data\AddressInterface, null given ...

This happen because no default null value is set of fourth parameter, and also check if address is null.

The code method beforeSavePaymentInformation in Experius\ExtraCheckoutAddressFields\Plugin\Magento\Checkout\Model\PaymentInformationManagement should be modified as:

public function beforeSavePaymentInformation(
        \Magento\Checkout\Model\PaymentInformationManagement $subject,
        $cartId,
        \Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
        \Magento\Quote\Api\Data\AddressInterface $address = null
    ) {
        
if (is_null($address))
            return;
        $extAttributes = $address->getExtensionAttributes();
        if (!empty($extAttributes)) {
            $this->helper->transportFieldsFromExtensionAttributesToObject(
                $extAttributes,
                $address,
                'extra_checkout_billing_address_fields'
            );
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant