Jump to content

want to put default radio button in creditcard.tpl file


sokalsondha

Recommended Posts

hello community...

i hope all are doing very well. today i came back again for a small help with an code.

basically by default now whmcs store the last 4 digit of the Credit card number of stripe gateway.

which i found less confident for our clients.

so i found an idea to modify the creditcard.tpl and make the RADIO BUTTON default to ENTER NEW CARD DETAILS

and i will hide the 2nd radio button. this way client will never see that their credit card 4 digit is stored.. basically even storing the 4 digit we can't do anything.. but you know the clients....

can someone guide me from this code what i should modify to make default to the 1st radio button even the card number is stored in the server

 

{if $remotecode}

    <div id="frmRemoteCardProcess" class="text-center" align="center">

        {$remotecode}

        <iframe name="ccframe" class="auth3d-area" width="90%" height="600" scrolling="auto" src="about:blank"></iframe>

    </div>

    <script language="javascript">
        jQuery("#frmRemoteCardProcess").find("form:first").attr('target', 'ccframe');
        setTimeout("autoSubmitFormByContainer('frmRemoteCardProcess')", 1000);
    </script>

{else}

    <form id="frmPayment" method="post" action="creditcard.php" class="form-horizontal" role="form">
        <input type="hidden" name="action" value="submit" />
        <input type="hidden" name="invoiceid" value="{$invoiceid}" />

        <div class="row">
            <div class="col-md-7">

                {if $errormessage}
                    {include file="$template/includes/alert.tpl" type="error" errorshtml=$errormessage}
                {/if}
                
                
                    <div class="col-sm-12">
                    <img width="100%" src="/templates/{$template}/img/stripelogo.png">
                </div>

                <div class="alert alert-danger text-center gateway-errors hidden"></div>

                <div class="form-group">
                    <div class="col-sm-8 col-sm-offset-4">
                        <div class="radio">
                            <label>
                                <input type="radio" name="ccinfo" value="new" onclick="showNewCardInputFields()"{if $ccinfo eq "new" || !$cardOnFile} checked{/if} /> {$LANG.creditcardenternewcard}</label>
                            </label>
                        </div>
                        <div class="radio">
                            <label>
                                <input type="radio" name="ccinfo" value="useexisting" onclick="hideNewCardInputFields()" {if $cardOnFile && $ccinfo neq "new"}checked{elseif !$cardOnFile}disabled{/if} /> {$LANG.creditcarduseexisting}{if $cardOnFile} ({$existingCardType}-{$existingCardLastFour}){/if}
                            </label>
                        </div>
                    </div>
                </div>
                <div class="form-group{if $userDetailsValidationError} hidden{/if}" id="billingAddressSummary">
                    <label for="cctype" class="col-sm-4 control-label">{$LANG.billingAddress}</label>
                    <div class="col-sm-6">
                        {if $companyname}{$companyname}{else}{$firstname} {$lastname}{/if} <button type="button" id="btnEditBillingAddress" onclick="editBillingAddress()" class="btn btn-default btn-sm"{if $cardOnFile} disabled="disabled"{/if}><i class="fa fa-edit"></i> {$LANG.change}</button><br />
                        {$address1}{if $address2}, {$address2}{/if}<br />
                        {$city}, {$state}, {$postcode}<br />
                        {$countryname}
                    </div>
                </div>
                <div class="form-group cc-billing-address{if !$userDetailsValidationError} hidden{/if}">
                    <label for="inputFirstName" class="col-sm-4 control-label">{$LANG.clientareafirstname}</label>
                    <div class="col-sm-6">
                        <input type="text" name="firstname" id="inputFirstName" value="{$firstname}" class="form-control" />
                    </div>
                </div>
                <div class="form-group cc-billing-address{if !$userDetailsValidationError} hidden{/if}">
                    <label for="inputLastName" class="col-sm-4 control-label">{$LANG.clientarealastname}</label>
                    <div class="col-sm-6">
                        <input type="text" name="lastname" id="inputLastName" value="{$lastname}" class="form-control" />
                    </div>
                </div>
                <div class="form-group cc-billing-address{if !$userDetailsValidationError} hidden{/if}">
                    <label for="inputAddress1" class="col-sm-4 control-label">{$LANG.clientareaaddress1}</label>
                    <div class="col-sm-6">
                        <input type="text" name="address1" id="inputAddress1" value="{$address1}" class="form-control" />
                    </div>
                </div>
                <div class="form-group cc-billing-address{if !$userDetailsValidationError} hidden{/if}">
                    <label for="inputAddress2" class="col-sm-4 control-label">{$LANG.clientareaaddress2}</label>
                    <div class="col-sm-6">
                        <input type="text" name="address2" id="inputAddress2" value="{$address2}" class="form-control" />
                    </div>
                </div>
                <div class="form-group cc-billing-address{if !$userDetailsValidationError} hidden{/if}">
                    <label for="inputCity" class="col-sm-4 control-label">{$LANG.clientareacity}</label>
                    <div class="col-sm-6">
                        <input type="text" name="city" id="inputCity" value="{$city}" class="form-control" />
                    </div>
                </div>
                <div class="form-group cc-billing-address{if !$userDetailsValidationError} hidden{/if}">
                    <label for="inputState" class="col-sm-4 control-label">{$LANG.clientareastate}</label>
                    <div class="col-sm-6">
                        <input type="text" name="state" id="inputState" value="{$state}" class="form-control" />
                    </div>
                </div>
                <div class="form-group cc-billing-address{if !$userDetailsValidationError} hidden{/if}">
                    <label for="inputPostcode" class="col-sm-4 control-label">{$LANG.clientareapostcode}</label>
                    <div class="col-sm-6">
                        <input type="text" name="postcode" id="inputPostcode" value="{$postcode}" class="form-control" />
                    </div>
                </div>
                <div class="form-group cc-billing-address{if !$userDetailsValidationError} hidden{/if}">
                    <label for="inputCountry" class="col-sm-4 control-label">{$LANG.clientareacountry}</label>
                    <div class="col-sm-6">
                        {$countriesdropdown}
                    </div>
                </div>
                <div class="form-group cc-billing-address{if !$userDetailsValidationError} hidden{/if}">
                    <label for="inputPhone" class="col-sm-4 control-label">{$LANG.clientareaphonenumber}</label>
                    <div class="col-sm-6">
                        <input type="text" name="phonenumber" id="inputPhone" value="{$phonenumber}" class="form-control" />
                    </div>
                </div>
                <div class="form-group cc-details{if !$addingNewCard} hidden{/if}">
                    <label for="cctype" class="col-sm-4 control-label">{$LANG.creditcardcardtype}</label>
                    <div class="col-sm-5">
                        <select name="cctype" id="cctype" class="form-control newccinfo">
                            {foreach from=$acceptedcctypes item=type}
                                <option{if $cctype eq $type} selected{/if}>
                                    {$type}
                                </option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="form-group cc-details{if !$addingNewCard} hidden{/if}">
                    <label for="inputCardNumber" class="col-sm-4 control-label">{$LANG.creditcardcardnumber}</label>
                    <div class="col-sm-7">
                        <input type="tel" name="ccnumber" id="inputCardNumber" size="30" value="{if $ccnumber}{$ccnumber}{/if}" autocomplete="off" class="form-control newccinfo" />
                    </div>
                </div>
                {if $showccissuestart}
                    <div class="form-group cc-details{if !$addingNewCard} hidden{/if}">
                        <label for="inputCardStart" class="col-sm-4 control-label">{$LANG.creditcardcardstart}</label>
                        <div class="col-sm-8">
                            <select name="ccstartmonth" id="inputCardStart" class="form-control select-inline">
                                {foreach from=$months item=month}
                                    <option{if $ccstartmonth eq $month} selected{/if}>{$month}</option>
                                {/foreach}
                            </select>
                            <select name="ccstartyear" id="inputCardStartYear" class="form-control select-inline">
                                {foreach from=$startyears item=year}
                                    <option{if $ccstartyear eq $year} selected{/if}>{$year}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                {/if}
                <div class="form-group cc-details{if !$addingNewCard} hidden{/if}">
                    <label for="inputCardExpiry" class="col-sm-4 control-label">{$LANG.creditcardcardexpires}</label>
                    <div class="col-sm-8">
                        <select name="ccexpirymonth" id="inputCardExpiry" class="form-control select-inline">
                            {foreach from=$months item=month}
                                <option{if $ccexpirymonth eq $month} selected{/if}>{$month}</option>
                            {/foreach}
                        </select>
                        <select name="ccexpiryyear" id="inputCardExpiryYear" class="form-control select-inline">
                            {foreach from=$expiryyears item=year}
                                <option{if $ccexpiryyear eq $year} selected{/if}>{$year}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                {if $showccissuestart}
                    <div class="form-group cc-details{if !$addingNewCard} hidden{/if}">
                        <label for="inputIssueNum" class="col-sm-4 control-label">{$LANG.creditcardcardissuenum}</label>
                        <div class="col-xs-2">
                            <input type="number" name="ccissuenum" id="inputIssueNum" value="{$ccissuenum}" class="form-control input-" />
                        </div>
                    </div>
                {/if}
                <div class="form-group">
                    <label for="cctype" class="col-sm-4 control-label">{$LANG.creditcardcvvnumber}</label>
                    <div class="col-sm-7">
                        <input type="number" name="cccvv" id="inputCardCvv" value="{$cccvv}" autocomplete="off" class="form-control input-inline input-inline-100" />
                        <button type="button" class="btn btn-link" data-toggle="popover" data-content="<img src='{$BASE_PATH_IMG}/ccv.gif' width='210' />">
                            {$LANG.creditcardcvvwhere}
                        </button>
                    </div>
                </div>

                {if $shownostore}
                    <div class="form-group cc-details{if !$addingNewCard} hidden{/if}">
                        <div class="col-sm-offset-4 col-sm-8">
                            <div class="checkbox">
                                <label>
                                    <input type="checkbox" name="nostore" id="inputNoStore"> {$LANG.creditcardnostore}
                                </label>
                            </div>
                        </div>
                    </div>
                {/if}
                <div class="form-group">
                    <div class="text-center">
                        <button type="submit" class="btn btn-primary btn-lg" id="btnSubmit" value="{$LANG.submitpayment}">
                            <span class="pay-text">{$LANG.submitpayment}</span>
                            <span class="click-text hidden">{$LANG.pleasewait}</span>
                        </button>
                    </div>
                </div>

            </div>
            <div class="col-md-5">

                <div id="invoiceIdSummary" class="invoice-summary">
                    <h2 class="text-center">{$LANG.invoicenumber}{$invoiceid}</h2>
                    <div class="invoice-summary-table">
                    <table class="table table-condensed">
                        <tr>
                            <td class="text-center"><strong>{$LANG.invoicesdescription}</strong></td>
                            <td width="150" class="text-center"><strong>{$LANG.invoicesamount}</strong></td>
                        </tr>
                        {foreach $invoiceitems as $item}
                            <tr>
                                <td>{$item.description}</td>
                                <td class="text-center">{$item.amount}</td>
                            </tr>
                        {/foreach}
                        <tr>
                            <td class="total-row text-right">{$LANG.invoicessubtotal}</td>
                            <td class="total-row text-center">{$invoice.subtotal}</td>
                        </tr>
                        {if $invoice.taxrate}
                            <tr>
                                <td class="total-row text-right">{$invoice.taxrate}% {$invoice.taxname}</td>
                                <td class="total-row text-center">{$invoice.tax}</td>
                            </tr>
                        {/if}
                        {if $invoice.taxrate2}
                            <tr>
                                <td class="total-row text-right">{$invoice.taxrate2}% {$invoice.taxname2}</td>
                                <td class="total-row text-center">{$invoice.tax2}</td>
                            </tr>
                        {/if}
                        <tr>
                            <td class="total-row text-right">{$LANG.invoicescredit}</td>
                            <td class="total-row text-center">{$invoice.credit}</td>
                        </tr>
                        <tr>
                            <td class="total-row text-right">{$LANG.invoicestotaldue}</td>
                            <td class="total-row text-center">{$invoice.total}</td>
                        </tr>
                    </table>
                    </div>
                    <p class="text-center">
                        {$LANG.paymentstodate}: <strong>{$invoice.amountpaid}</strong><br />
                        {$LANG.balancedue}: <strong>{$balance}</strong>
                    </p>
                </div>

            </div>
        </div>

        <div class="alert alert-warning" role="alert">
            <i class="fa fa-lock"></i> &nbsp; {$LANG.creditcardsecuritynotice}
        </div>

    </form>

{/if}

 

 

 

thanks very much to everyone for reading my post...

 

Mahim

 

Link to comment
Share on other sites

12 hours ago, sokalsondha said:

can someone guide me from this code what i should modify to make default to the 1st radio button even the card number is stored in the server

if all you want to do is hide the 4-digits, you could just remove the part below from the template... that way, they'll see they have a card stored, but not that detail.

-{$existingCardLastFour}

even if you didn't want to edit the template, you could probably null the variable with a ClientAreaPageCreditCard hook... similarly, if you wanted to give the impression that the card wasn't being stored, you could null the $cardOnFile variable and it should default to forcing the client to enter a new cc each time.

Link to comment
Share on other sites

14 minutes ago, brian! said:

if all you want to do is hide the 4-digits, you could just remove the part below from the template... that way, they'll see they have a card stored, but not that detail.


-{$existingCardLastFour}

even if you didn't want to edit the template, you could probably null the variable with a ClientAreaPageCreditCard hook... similarly, if you wanted to give the impression that the card wasn't being stored, you could null the $cardOnFile variable and it should default to forcing the client to enter a new cc each time.

thanks brian for support me again..

brian all i want hide this two radio button. and make the 1st radio button by default at any stage. even our system saved the last 4 digit of the card. but the radio button will be 1st one enabled. so clients can put CC details everytime. at least they will trust this the card is not saved anywhere.

if i make a hook can you help me with the code of hook?

or may be its more better is it possible to make a hook so the card details never saved in our whmcs server?

then i know how to hide the radio buttons..

 

please help me brian.. either with hook to not store the cards at all or edit the tpl file make the 1st radio button default all the time 🙂

Link to comment
Share on other sites

12 minutes ago, sokalsondha said:

or may be its more better is it possible to make a hook so the card details never saved in our whmcs server?

it doesn't store the card number locally - only the type, last 4 digit etc.

17 minutes ago, sokalsondha said:

then i know how to hide the radio buttons..

                <div class="form-group">
                    <div class="col-sm-8 col-sm-offset-4">
                        <div class="radio">
                            <label>
                                <input type="radio" name="ccinfo" value="new" onclick="showNewCardInputFields()"{if $ccinfo eq "new" || !$cardOnFile} checked{/if} /> {$LANG.creditcardenternewcard}</label>
                            </label>
                        </div>
                        <div class="radio">
                            <label>
                                <input type="radio" name="ccinfo" value="useexisting" onclick="hideNewCardInputFields()" {if $cardOnFile && $ccinfo neq "new"}checked{elseif !$cardOnFile}disabled{/if} /> {$LANG.creditcarduseexisting}{if $cardOnFile} ({$existingCardType}-{$existingCardLastFour}){/if}
                            </label>
                        </div>
                    </div>
                </div>

becomes...

                <div class="form-group">
                    <div class="col-sm-8 col-sm-offset-4">
                        <div class="radio">
                            <label>
                                <input type="radio" name="ccinfo" value="new" onclick="showNewCardInputFields()" checked /> {$LANG.creditcardenternewcard}
                            </label>
                        </div>
                    </div>
                </div>

i'm assuming there is an error on that creditcard.tpl template as there are an odd number of label tags - not your fault, it's WHMCS.

the best you could do with a cc hook would be to disable the second radio option, but I gather that you don't want to show it at all... so easier to edit the template... possibly you could hide that second radio button with css, but try editing the template and see if that fixes it.

Link to comment
Share on other sites

2 hours ago, brian! said:

it doesn't store the card number locally - only the type, last 4 digit etc.


                <div class="form-group">
                    <div class="col-sm-8 col-sm-offset-4">
                        <div class="radio">
                            <label>
                                <input type="radio" name="ccinfo" value="new" onclick="showNewCardInputFields()"{if $ccinfo eq "new" || !$cardOnFile} checked{/if} /> {$LANG.creditcardenternewcard}</label>
                            </label>
                        </div>
                        <div class="radio">
                            <label>
                                <input type="radio" name="ccinfo" value="useexisting" onclick="hideNewCardInputFields()" {if $cardOnFile && $ccinfo neq "new"}checked{elseif !$cardOnFile}disabled{/if} /> {$LANG.creditcarduseexisting}{if $cardOnFile} ({$existingCardType}-{$existingCardLastFour}){/if}
                            </label>
                        </div>
                    </div>
                </div>

becomes...


                <div class="form-group">
                    <div class="col-sm-8 col-sm-offset-4">
                        <div class="radio">
                            <label>
                                <input type="radio" name="ccinfo" value="new" onclick="showNewCardInputFields()" checked /> {$LANG.creditcardenternewcard}
                            </label>
                        </div>
                    </div>
                </div>

i'm assuming there is an error on that creditcard.tpl template as there are an odd number of label tags - not your fault, it's WHMCS.

the best you could do with a cc hook would be to disable the second radio option, but I gather that you don't want to show it at all... so easier to edit the template... possibly you could hide that second radio button with css, but try editing the template and see if that fixes it.

dear brian. this code worked. i can see the radio button ticked even i have save card details but unfortunately even the 1st radio button ticket my system still not showing the new card box to enter new CC. is there any chance any hook can i use so everytime customer pay with card its not even saving the last 4 digit of the card. as template file editing not helping me at all.

waiting to hear from you soon brian 🙂

Link to comment
Share on other sites

18 hours ago, sokalsondha said:

is there any chance any hook can i use so everytime customer pay with card its not even saving the last 4 digit of the card. as template file editing not helping me at all.

there's the option of Disabling Credit Card Storage from the settings... setup -> general settings -> security -> disable credit card storage

https://docs.whmcs.com/Security_Tab#Disable_Credit_Card_Storage

Quote

By default a client's credit card number is encrypted and stored in your database. Enabling this option means the number will not be stored and clients will need to re-enter their number for each invoice they pay.

read the docs page on this in full as it can have an impact on gateway use - though supposedly not Stripe.

if you enable the above feature, you won't need any template changes or hooks as it won't store the cc details and will always ask the user to enter their cc details again.

Link to comment
Share on other sites

13 hours ago, brian! said:

there's the option of Disabling Credit Card Storage from the settings... setup -> general settings -> security -> disable credit card storage

https://docs.whmcs.com/Security_Tab#Disable_Credit_Card_Storage

read the docs page on this in full as it can have an impact on gateway use - though supposedly not Stripe.

if you enable the above feature, you won't need any template changes or hooks as it won't store the cc details and will always ask the user to enter their cc details again.

thanks a million again brian.

As you can see on the DOC because of its tokenised gateway its saving last 4 digit in my WHMCS. i think something with stripe thats forcing WHMCS to store the data. because after the payment i can see in my stripe that stripe save that payment as a new cusotmer of them. so they are pulling customer email address from WHMCS.

so basically all i want any how not storing the card at all. so far i understand i need hook.

is it possible you can help me with hook? so i can put this hook and after my client pay by stripe the card number will not be saved at all

thnaks

Link to comment
Share on other sites

8 hours ago, sokalsondha said:

As you can see on the DOC because of its tokenised gateway its saving last 4 digit in my WHMCS.

it shouldn't do - once the feature is enabled, it will wipe those existing details from the WHMCS database and prevent new ones being added.

8 hours ago, sokalsondha said:

i think something with stripe thats forcing WHMCS to store the data. because after the payment i can see in my stripe that stripe save that payment as a new customer of them. so they are pulling customer email address from WHMCS.

more likely, WHMCS is sending the cc details, email etc to stripe in order to authorise the payment... it would make perfect sense for stripe to be storing these details themselves - especially for fraud/security purposes.

8 hours ago, sokalsondha said:

is it possible you can help me with hook? so i can put this hook and after my client pay by stripe the card number will not be saved at all

as I said, if Disable CC Storage is enabled, then WHMCS should not be storing any cc details locally... if you have access to phpmyadmin (or similar mysql tool), you could quickly check the tblclients database table and inspect the cardtype and cardlastfour columns - they should be empty.

I guess if using Stripe, the only thing it stores would be the token - are you saying that you want to get rid of that too?

Link to comment
Share on other sites

1 hour ago, brian! said:

it shouldn't do - once the feature is enabled, it will wipe those existing details from the WHMCS database and prevent new ones being added.

more likely, WHMCS is sending the cc details, email etc to stripe in order to authorise the payment... it would make perfect sense for stripe to be storing these details themselves - especially for fraud/security purposes.

as I said, if Disable CC Storage is enabled, then WHMCS should not be storing any cc details locally... if you have access to phpmyadmin (or similar mysql tool), you could quickly check the tblclients database table and inspect the cardtype and cardlastfour columns - they should be empty.

I guess if using Stripe, the only thing it stores would be the token - are you saying that you want to get rid of that too?

Hello Brian. Yes finally you get it correct. even i put tick or untick in the settings--> security Disable CC Storage. its not affecting anything with last 4 digit information because i am using stripe gateway. so its stripe token. and yes i want to get rid of that too.. is it possible with hook?

Link to comment
Share on other sites

50 minutes ago, sokalsondha said:

is it possible with hook?

probably using an InvoicePaid hook is your best bet - you'd want to leave it as late as possible in the payment process, so waiting until the invoice has been marked as paid makes sense to me.

that hook should give you the invoice ID - once you have that, it's simple enough to get the client ID (either using capsule, models etc).. once you know the client, then you should just need to empty the 'gatewayid' field in tblclients (again via capsule, models or possibly even API).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated