magento2: magento from 2.0.4 to 2.0.7 custom payment error with valid input data "message":"Please enter a valid credit card expiration date."

I made custom payment similar to this https://github.com/Inchoo/magento2-Inchoo_Stripe (but not Stripe - Onpex payment, if it is important) After “composer update” my core changes from 2.0.4 to 2.0.7. Testing payment at newer version showed me error. I entered test credit card, valid expiration date and cvv and got payment error “Please enter a valid credit card expiration date.” REST query sended to http://XXX.XXX.XXX.XXX/rest/default/V1/guest-carts/54fce3777572e7f79df94bb4a25da69f/payment-information gave response with that message and stack trace.

{“message”:“Please enter a valid credit card expiration date.”, “trace”:“#0 /srv/xxx/web/vendor/magento/module-quote/Model/Quote/Payment.php(176): Magento\Payment\Model\Method\Cc->validate()\n#1 /srv/xxx/web/vendor/magento/module-quote/Model/PaymentMethodManagement.php(64): Magento\Quote\Model\Quote\Payment->importData(Object(Magento\Framework\DataObject))\n#2 /srv/xxx/web/vendor/magento/module-quote/Model/GuestCart/GuestPaymentMethodManagement.php(49): Magento\Quote\Model\PaymentMethodManagement->set(‘3’, Object(Magento\Quote\Model\Quote\Payment))\n#3 /srv/xxx/web/vendor/magento/module-checkout/Model/GuestPaymentInformationManagement.php(99): Magento\Quote\Model\GuestCart\GuestPaymentMethodManagement->set(‘54fce3777572e7f…’, Object(Magento\Quote\Model\Quote\Payment))\n#4 /srv/xxx/web/vendor/magento/module-checkout/Model/GuestPaymentInformationManagement.php(78): Magento\Checkout\Model\GuestPaymentInformationManagement->savePaymentInformation(‘54fce3777572e7f…’, ‘example@example.co…’, Object(Magento\Quote\Model\Quote\Payment), Object(Magento\Quote\Model\Quote\Address))\n#5 [internal function]: Magento\Checkout\Model\GuestPaymentInformationManagement->savePaymentInformationAndPlaceOrder(‘54fce3777572e7f…’, ‘example@example.co…’, Object(Magento\Quote\Model\Quote\Payment), Object(Magento\Quote\Model\Quote\Address))\n#6 /srv/xxx/web/vendor/magento/module-webapi/Controller/Rest.php(265): call_user_func_array(Array, Array)\n#7 /srv/xxx/web/vendor/magento/module-webapi/Controller/Rest.php(160): Magento\Webapi\Controller\Rest->processApiRequest()\n#8 /srv/xxx/web/var/generation/Magento/Webapi/Controller/Rest/Interceptor.php(24): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))\n#9 /srv/xxx/web/vendor/magento/framework/App/Http.php(115): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))\n#10 /srv/xxx/web/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()\n#11 /srv/xxx/web/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))\n#12 {main}”}

I checked this twice and twice (one time windows, second time linux) updates made from 2.0.4 to 2.0.7

Magento\Payment\Model\Method\Cc.php has method validate() containiing following code if ($ccType != 'SS' && !$this->_validateExpDate($info->getCcExpYear(), $info->getCcExpMonth())) where $info->getCcExpYear() and $info->getCcExpMonth() == NULL.

How is that possible? What changes should I do to fix that and pass my payment method?

UPD: site is on http

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 18 (1 by maintainers)

Commits related to this issue

Most upvoted comments

HI @mauromm,

Thanks! Your code work. Save me a lot of times. I’m made my module base on the same example from Inchoo.

Hi, @mauromm ! Thanx!

@dkvashninbay, I’ve updated to 2.1.0. Now I got error “Unable to place order. Please try again later.” but payment system says that transaction passed successfully. So I assume that something in my code is wrong and I need to pass credit card data correct to complete payment inside magento. Would you look at this module https://github.com/Inchoo/magento2-Inchoo_Stripe (I made my module similar to this) and tell me how to pass and read data through additional_data right, please?

@antonlazarchenko, @schogini This is a bug in general CC model (created internal ticket to fix in next patch), as it depends on wrong DataObject structure (raw request, security vulnerable), instead of \Magento\Quote\Api\Data\PaymentInterface which gets passed to Checkout service.

All Payment Integrations which have own payload on checkout, should pass it in additional_data field and read this data from additional_data field of DataObject.

That was a mistake in our local repo. This code has been corrected. Thanks! The correct code was pushed to another branch in our repo (branch2.0.7) We have corrected the develop branch too now.