Creating a custom payment method with conditional field

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite
1












So I understand that you can assign a payment processor any payment method - however - I am trying to create payment methods that replicate the behavior of Credit Card and Check. For example - when manually adding Check or Credit Card contributions - you will then get a field for check number or last 4 digits of the card respectively.



If I make a payment method called credit card - other, I would want those credit card fields to also populate.



Is this hard coded?










share|improve this question



























    up vote
    3
    down vote

    favorite
    1












    So I understand that you can assign a payment processor any payment method - however - I am trying to create payment methods that replicate the behavior of Credit Card and Check. For example - when manually adding Check or Credit Card contributions - you will then get a field for check number or last 4 digits of the card respectively.



    If I make a payment method called credit card - other, I would want those credit card fields to also populate.



    Is this hard coded?










    share|improve this question

























      up vote
      3
      down vote

      favorite
      1









      up vote
      3
      down vote

      favorite
      1






      1





      So I understand that you can assign a payment processor any payment method - however - I am trying to create payment methods that replicate the behavior of Credit Card and Check. For example - when manually adding Check or Credit Card contributions - you will then get a field for check number or last 4 digits of the card respectively.



      If I make a payment method called credit card - other, I would want those credit card fields to also populate.



      Is this hard coded?










      share|improve this question















      So I understand that you can assign a payment processor any payment method - however - I am trying to create payment methods that replicate the behavior of Credit Card and Check. For example - when manually adding Check or Credit Card contributions - you will then get a field for check number or last 4 digits of the card respectively.



      If I make a payment method called credit card - other, I would want those credit card fields to also populate.



      Is this hard coded?







      civicontribute payment






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 1 hour ago

























      asked 1 hour ago









      themak

      830116




      830116




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          Themak, Nice question. This are hardcoded in core file but you can create your own field for each payment method using buildform hook. Here is the snippet on how to do that



          function custom_civicrm_buildForm($formName, &$form) 
          if ($formName == 'CRM_Financial_Form_Payment' && !empty($form->paymentInstrumentID))
          if ($form->paymentInstrumentID == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', 'Test'))
          $form->assign('paymentFields', array('source'));
          $form->add('text', 'source', ts('Source'));






          Note: The above snippet is not fully tested i have just created blindly, but i am 100% sure it should work







          share|improve this answer




















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "605"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            noCode: true, onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcivicrm.stackexchange.com%2fquestions%2f26874%2fcreating-a-custom-payment-method-with-conditional-field%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            3
            down vote



            accepted










            Themak, Nice question. This are hardcoded in core file but you can create your own field for each payment method using buildform hook. Here is the snippet on how to do that



            function custom_civicrm_buildForm($formName, &$form) 
            if ($formName == 'CRM_Financial_Form_Payment' && !empty($form->paymentInstrumentID))
            if ($form->paymentInstrumentID == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', 'Test'))
            $form->assign('paymentFields', array('source'));
            $form->add('text', 'source', ts('Source'));






            Note: The above snippet is not fully tested i have just created blindly, but i am 100% sure it should work







            share|improve this answer
























              up vote
              3
              down vote



              accepted










              Themak, Nice question. This are hardcoded in core file but you can create your own field for each payment method using buildform hook. Here is the snippet on how to do that



              function custom_civicrm_buildForm($formName, &$form) 
              if ($formName == 'CRM_Financial_Form_Payment' && !empty($form->paymentInstrumentID))
              if ($form->paymentInstrumentID == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', 'Test'))
              $form->assign('paymentFields', array('source'));
              $form->add('text', 'source', ts('Source'));






              Note: The above snippet is not fully tested i have just created blindly, but i am 100% sure it should work







              share|improve this answer






















                up vote
                3
                down vote



                accepted







                up vote
                3
                down vote



                accepted






                Themak, Nice question. This are hardcoded in core file but you can create your own field for each payment method using buildform hook. Here is the snippet on how to do that



                function custom_civicrm_buildForm($formName, &$form) 
                if ($formName == 'CRM_Financial_Form_Payment' && !empty($form->paymentInstrumentID))
                if ($form->paymentInstrumentID == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', 'Test'))
                $form->assign('paymentFields', array('source'));
                $form->add('text', 'source', ts('Source'));






                Note: The above snippet is not fully tested i have just created blindly, but i am 100% sure it should work







                share|improve this answer












                Themak, Nice question. This are hardcoded in core file but you can create your own field for each payment method using buildform hook. Here is the snippet on how to do that



                function custom_civicrm_buildForm($formName, &$form) 
                if ($formName == 'CRM_Financial_Form_Payment' && !empty($form->paymentInstrumentID))
                if ($form->paymentInstrumentID == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', 'Test'))
                $form->assign('paymentFields', array('source'));
                $form->add('text', 'source', ts('Source'));






                Note: The above snippet is not fully tested i have just created blindly, but i am 100% sure it should work








                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 56 mins ago









                Pradeep Nayak

                9,0321418




                9,0321418



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcivicrm.stackexchange.com%2fquestions%2f26874%2fcreating-a-custom-payment-method-with-conditional-field%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    Long meetings (6-7 hours a day): Being “babysat” by supervisor

                    What does second last employer means? [closed]

                    One-line joke