From 4e00c45782ac9ffee3bb0e3d8a7e3df5bf74d99b Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Wed, 15 Jul 2020 16:46:09 +0200 Subject: [PATCH] Doc defensive coding needed by pin payments [skip ci] --- app/services/checkout/form_data_adapter.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/services/checkout/form_data_adapter.rb b/app/services/checkout/form_data_adapter.rb index 273a978a55..1333ed5dbd 100644 --- a/app/services/checkout/form_data_adapter.rb +++ b/app/services/checkout/form_data_adapter.rb @@ -33,6 +33,11 @@ module Checkout @params[:order][:payments_attributes].first[:source_attributes] = payment_source_params end + # Ensures cc_type is always passed to the model by inferring the type when + # the frontend didn't provide it. This fixes Pin Payments specifically + # although it might be useful for future payment gateways. + # + # More details: app/assets/javascripts/darkswarm/services/checkout.js.coffee#L70-L98 def fill_in_card_type return unless payment_source_attributes