Forums

Using 2 submit buttons for payment gateway

ebbstar 30 Mar, 2014
[attachment=0]Screen Shot 2014-03-30 at 4.36.04 pm.png[/attachment]Hi

My client's payment modes with the local payment gateway are Credit Card and Direct Debit.

Each mode has its own merchant ID code (the "mid" field).

So what I have done is use Custom Element and Submit button for each option (as in screencap)

Sorry I can't post links to the form here as it can't be made public yet.

<input type="hidden" name="amount" value="100.00">
<input type="hidden" name="txnRef" value="">
<input type="hidden" name="mid" value="12345678">
<input type="hidden" name="umapiType" value="lite"><div class="ccms_form_element cfdiv_submit" id="credit_container_div" style="text-align:left"><input name="MEMBERSHIP" id="CREDIT" class="" value="CREDIT CARD" type="submit" />
<div class="clear"></div><div id="error-message-MEMBERSHIP"></div></div><input type="hidden" name="amount" value="100.00">
<input type="hidden" name="txnRef" value="">
<input type="hidden" name="mid" value="23456789">
<input type="hidden" name="umapiType" value="lite"><div class="ccms_form_element cfdiv_submit" id="debit_container_div" style="text-align:left"><input name="MEMBERSHIP" id="DEBIT" class="" value="DIRECT DEBIT" type="submit" />
<div class="clear"></div><div id="error-message-MEMBERSHIP"></div></div><div class="ccms_form_element cfdiv_header" id="id2_container_div" style="">


The integration works fine, except that when passed to the payment gateway, only the first submit button's data will be sent. In this case, Credit Card is the first submit button and clicking on the Credit Card submit button will work. Clicking the Debit submit button will only show Credit Card on the payment capture page.

I guess my question is how to make each submit work as it should.

Read up on the forums and it seems to be a thing with using Event Switcher which I have installed but haven't a clue how to use it for this purpose.

Could someone kindly advise on how I can make the 2 buttons work please?

Appreciate your kind assistance and time.

Thank you so much.
GreyHead 30 Mar, 2014
Hi ebbstar,

I think that is one of those 'stand back and look at it' problems.

You seem to be trying to bundle two forms into one - and, while you can have tow submit buttons, you can't mash two forms together.

If you have two inputs with the same name, only the last one will be submitted. That's how HTML forms work.

Also you don't need to add fixed data into hidden inputs, you can just add it to the $form->data array after the form is submitted. This is tidier and more secure.

Is there a good reason for using two submit buttons instead of say, a radio button, to choose between the payment routes? (Either will work).

If you stay with two submit buttons then you need to check the value after the form submits and set the value of $form->data['mid'] to match. Use the Debugger action temporarily so that you can see what is being submitted and add a couple of lines of PHP in a Custom Code action to set the values you need.

Bob
ebbstar 30 Mar, 2014
Hey Bob

Actually I emailed you about helping me with this for a fee prior to posting.

Do you think you could find some time to take a look at my email please? It explains the entire flow (unique ID + confirmation dummy form and passing data btwn 2 forms).

I really don't quite understand the use of $form->data array and honestly, for a newbie, getting this far with your tutorials is a miracle as it is, I'm not sure how much more lucky I can move ahead beyond what's already done.

Please please? Hope you can help me tidy this up.
GreyHead 31 Mar, 2014
Hi ebbstar,

I replied to your email, sorry for the delay.

Bob
This topic is locked and no more replies can be posted.