Thanks for that Philip - much appreciated
Rick
Printable View
Thanks for that Philip - much appreciated
Rick
Hi Everyone,
I am new to Zencart and enjoy the colloborative sharing that goes into this product.
In that spirit, I have created a slight modification to Philips great addon to allow the user to pick a credit card type before sending the order to Worldpay (See attached screenshot).
As you all know, the more screens the user has to enter information, the less likely he/she is to buy so this at least eliminates one screen (assuming you only want to accept payment in one currency)
There are only two files to change:
1. \includes\templates\YOUR TEMPLATE\templates\tpl_checkout_payment_default.php
2. \includes\modules\payment\worldpay.php
File#1
LOOK for the first line in the snippet below then add everything after <!-- BOF Draw CC dropdown box -->
NOTE: This assumes that Worldpay is the FIRST payment module in your sort order. If not then change the value of $i (see comments)
File#2PHP Code:
<label for="pmt-<?php echo $selection[$i]['id']; ?>" class="radioButtonLabel"><?php echo $selection[$i]['module']; ?></label>
<!-- BOF Draw CC dropdown box -->
<?php
//This assumes that the Worldpay is your FIRST in your sort order in the ADMIN > Payment > Modules
//If not then change the value of $i to match where in the order you want it
if ($i==0)
{
//Create the array of credit cards as per Worldpay documentation
$cc1[] = array('id' => 'VISA', 'text' => 'Visa');
$cc1[] = array('id' => 'MSCD', 'text' => 'MasterCard');
echo zen_draw_pull_down_menu("paymentType", $cc1,'','','');
}
?>
<!-- EOF Draw CC dropdown box -->
There are two spots you need to add code.
1. LOOK for the first line of code then add the code following it:
2. In the variable $process_button_string add this line. I put it after this:PHP Code:
$OrderAmt = number_format($order->info['total'] * $currencies->get_value($currency), $currencies->get_decimal_places($currency), '.', '') ;
//**************************************
// Credit card Drop down
//**************************************
//Get the CC type
$CCpaymentType = $_POST["paymentType"];
//**************************************
And that's basically it. You can add more cards by adding it to the array.PHP Code:
zen_draw_hidden_field('currency', $currency) .
//**************************************
// Credit card Drop down
//**************************************
zen_draw_hidden_field('paymentType', $CCpaymentType) .
Now please bear in mind I am new to Zencart and relatively new to PHP, but I do have 25+ years in coding so I am not completely green but it doesnt mean I couldnt have overlooked something. So go easy on me. But so far it appears to work as planned.
Hopefully Philip will include this in his new version. His work has saved me a lot of time, so thanks Philip!
There is a "small problem" not all merchant are authorised to take all credit or debit cards, e.g. USA people don't do maestro I believe, not what could be a better way is to incorporate the above code but to make it so that the shop owner selects which card types they do accept from a list in the admin sections by ticking the boxes. I can't find the paymentType parameter in the worldpay documentation either. Here:
http://www.worldpay.com/support/kb/m...rhtml5902.html
although it is documented here
http://www.worldpay.com/support/kb/m...custa9102.html
so good spotting, that also then gives me an entire list of possible options and it does mention that which I wrote above:
Note that you may need to modify this HTML fragment, so that it displays only the payment methods that our Payment Service can accept for your installation.
so integrating your code with an admin selectable list would work and I'll schedule it in for the next release.
Philip.
Yes, I agree that putting it the admin would probably be best. I was looking for someone quick and easy, so hence adding it to the payment template.
As a Canadian, we too cannot take a lot of those cards which is why I wanted to limit it to Visa and Mastercard. As you stated, you can add whatever card you like as per the Worldpay documentation.
Since I have your ear, do you have any idea why I would get a "This page contains both secure and nonsecure items" when my callback page is called?
Since I am not using SSL (yet), I put the url in Worldpay as http://<wpdisplay item="MC_callback"> as per the install text.
I did notice the resultant url is:
https://select-test.worldpay.com/wcc/card?xxxxx
Is there something I am missing in the config?
Thanks,
Khalil
Nothing missing in the config, the error is browser generated because your images or style sheets that are linked into the secure "worldpay page" URI are not coming from an SSL server so IE flags it up because the main paige URL is SSL.
I'll incorperate those mods as they do seem like a good idea, I'm a fan of speeding up the shopping process and was asked recently if there was a way of doing a shop where the user would not be requried to create an account. The answer to that question is "no" at the moment because of the way worldpay tries to re-establish a session to mark the item as paid, in theory a temporary "guest" cart could be created then when the user fills in the details at worldpay, the information sent back could be joined to the "guest" cart and then create a new user, then an order, but it's a lot of work as worldpay does need a different templating system to that which ZC already uses.
Philip.
Hi - I've fallen at the first post when trying to install the WorldPay module in Admin. When I click to Install I get the following error message:
1364 Field 'configuration_title' doesn't have a default value
in:
[REPLACE INTO configuration (configuration_key, configuration_value, configuration_group_id, date_added) VALUES ('MODULE_PAYMENT_WORLDPAY_VERSION', '2.04', '6', now())]
If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.
Any help appreciated
PS I also noticed that the payment module name (in Payment Modules in Admin) says it's version 2.04 even though I downloaded v2.05. Is this relevant/does it matter?
Thanks!
Hmm now that's interesting you appear to have a very strict version of mysql. in your admin section go onto tools > install SQL patches and enter
ALTER TABLE configuration MODIFY COLUMN configuration_title text DEFAULT NULL;
in the Enter the query
to be executed: box, and that should sort that out, BUT it's not a worldpay problem per se that's a problem with your setup and zen cart in general and I'm rather surprised that things haven't fallen to pieces in other places.
And yes, I know about the 2.04 problem, it's been fixed for 2.06 which comes out this week.
Oh and you may also have to enter
delete from configuration where configuration_key like 'MODULE_PAYMENT_WORLDPAY%';
into that SQL box to clear all the worldpay values out, sine it may have half installed.
Philip - thanks for your lightning quick response.
Have done as you said (had to do it for some other fields as well) and all is well now. THANK YOU :)
Erm, unless you knew what column types that were set in the original table creation, you probably shouldn't have modified any columns as they could have been varchar, float or int. If you need to please PM me to confirm the column types of the values you have changed.
Philip.