www.webdeveloper.com
Results 1 to 9 of 9

Thread: Help Installing Payment Processor script

Hybrid View

  1. #1
    Join Date
    Jan 2008
    Posts
    45

    Help Installing Payment Processor script

    Hello everyone,
    I have a payment processor script much like paypal.

    I am now having problem getting it to work. I have done what the vendor says in the install instruction except this one "Configure cron script from script 'cron/rcharge.php'." The vendor is unwilling to help me. My server is PHP. Someone help please. Thanks

    Here is the content of rcharge.php:
    <?
    #!/usr/bin/php

    @set_time_limit(0);
    include('../config.htm');
    ###############################################################################
    function out($str=''){
    print "$str\r\n";
    flush();
    }
    ###############################################################################
    function SendEmailNotification($UserId, $ProductId, $SubscriptActive){
    global $sitename, $data;
    $name="";
    $email="";
    $productname="";
    $sql="SELECT email, fname, lname FROM {$data['DbPrefix']}members WHERE id=$UserId";
    $res=mysql_query($sql);
    if ($res) if (mysql_num_rows($res) > 0) {
    $row=mysql_fetch_array($res);
    $email=$row['email'];
    $name=$row['fname'] . " " . $row['lname'];
    }
    $sql="SELECT name FROM {$data['DbPrefix']}products WHERE id=$ProductId";
    $res=mysql_query($sql);
    if ($res) if (mysql_num_rows($res) > 0) {
    $row=mysql_fetch_array($res);
    $productname=$row['name'];
    }
    if ($SubscriptActive) {
    $key="SUBSCRIPTION-RESUMED";
    }
    else {
    $key="SUBSCRIPTION-STOPPED";
    }
    if (!empty($email)) {
    $post['username']=$name;
    $post['product']=$productname;
    $post['email']=$email;
    send_email($key, $post);
    }
    else out("Can not send e-mail notification to user $name, email field is empty.");
    }
    ###############################################################################
    function Main(){
    global $data;
    $sql="SELECT
    subs.*, subs.id as subscriptionid, (TO_DAYS(NOW()) - TO_DAYS(subs.sdate)) as daystopay, subs.member as payerid,
    prod.type, prod.type, prod.price, prod.period, prod.trial, prod.tax, prod.shipping, prod.name as productname, prod.owner as payeeid,
    memb.fname as userfname, memb.lname as userlname
    FROM
    {$data['DbPrefix']}subscriptions subs LEFT JOIN {$data['DbPrefix']}products prod ON subs.product=prod.id,
    {$data['DbPrefix']}subscriptions subs2 LEFT JOIN {$data['DbPrefix']}members memb ON subs.owner=memb.id
    WHERE subs2.id=subs.id AND subs.sdate < NOW()";
    $res=mysql_query($sql);
    if ($res) if (mysql_num_rows($res) > 0){
    out("Subscriptions to process: " . mysql_num_rows($res));
    out("Working...");
    while ($row=mysql_fetch_array($res)){
    $amount=$row['shipping'] + $row['tax'] + $row['price'];
    $payrounds=floor ($row['daystopay'] / $row['period']);
    $unpaiddays=$row['daystopay'] - (floor($row['daystopay'] / $row['period']) * $row['period']);
    $amount=$amount * $payrounds;
    if ($payrounds > 0){
    if (select_balance($row['payerid']) >= $amount){
    $sql="UPDATE {$data['DbPrefix']}subscriptions SET ";
    if ($row['holded'] == 1){
    $paydate=date("Y-m-d", mktime (0,0,0, date("m"), date("d") - $unpaiddays, date("Y")));
    $sql .= " sdate='$paydate',holded=0";
    SendEmailNotification($row['payerid'], $row['product'], true);
    }else{
    $paydate=date("Y-m-d", mktime (0,0,0, date("m"), date("d") - $unpaiddays, date("Y")));
    $sql .= " sdate='$paydate'";
    }
    $sql .= " WHERE id={$row['subscriptionid']}";
    $rslt=mysql_query($sql);
    if ($rslt) {
    $fees=($amount * $data['PaymentPercent']/100) + $data['PaymentFees'];
    transaction($row['payerid'], $row['payeeid'], $amount, $fees, 0, 1, 'Payment for subscription ' . $row['productname'] . ' for ' . $row['userfname'] . " " . $row['userlname'] . ", " . ($payrounds*$row['period']) . ' days', '');
    }
    } else {
    $sql="UPDATE {$data['DbPrefix']}subscriptions SET holded=1 WHERE id={$row['subscriptionid']}";
    mysql_query($sql);
    SendEmailNotification($row['payerid'], $row['product'], false);
    }
    }
    }
    }
    out("Done.");
    }
    ###############################################################################
    Main();
    ###############################################################################
    ?>

  2. #2
    Join Date
    Jul 2009
    Location
    Falls Church, Va.
    Posts
    780
    The script needs to be run via crontab, which is your server's task scheduler, i.e. it'll run at say 4am every day as part of maintenance for your payment processing. Information provided in link below:

    What is cron and how do I schedule scripts to run at a certain time?

    Just looking at the script I don't see any special configuration within itself, so I assume you need an example of how to setup a cron job? If your webhost supplies a web GUI to configure cron, use it. Otherwise...

    Following the help above and using 4am every day as an example, you'd do this via shell (command line Linux):

    1) "crontab -e"
    2) Using the editor insert a line similar to this (edit path and time):

    # Payment processor script, runs every day at 4:00am local server time...
    0 4 * * * /path_to/php /path_to/rcharge.php

    3) Save and exit
    4) Check your work - use "crontab -l" to list the current cron scheduler.

    Notes (Very Important):

    You must have a command line version of PHP installed on the server (known as the CLI version). Most servers have this, some don't. To determine if you have it in Linux type in "which php" and use that path. If nothing comes back, compile and install the CLI version (consult webhost). Also, use full paths in cron setup to avoid alot of pitfalls. Finally, you can pass parameters to any script or daemon in cron. Looking at your script, nothing is obvious you need to do that, but of course it's your script so check docs.

    -jim
    Last edited by SrWebDeveloper; 02-05-2010 at 09:23 AM. Reason: fixed minor typo

  3. #3
    Join Date
    Jan 2008
    Posts
    45
    Hi Jim,
    Thanks for your help. In my script same folder with the rcharge.php are two other files; the one is crontab.cron and the second is crontab.sh, I open them in notepad to see the content of crontab.cron is:
    0 0 * * * path/rcharge.php #run at 0:00
    while the content of crontab.sh is:
    crontab crontab.cron
    My webhost is Godaddy.com Linux. I also read from godaddy help center that i can create a cron job in my hosting account.

    Now i need to know these three things:
    1. Do i need to modify my crontab.cron
    2. Do i need to also create cron job at my godaddy hosting account
    3. What should i enter as the "path_to" in your example: 0 4 * * * /path_to/php /path_to/rcharge.php, or "path" in the crontab.cron: 0 0 * * * path/rcharge.php #run at 0:00

    Please help. Thanks.

  4. #4
    Join Date
    Feb 2010
    Posts
    10
    i ahve godaddy, there is a cron manager. its a GUI. i guess you can just select the script in your folder, and u can pick times etc.

    cron mananger is i think under the content tab at the top. not sure where, but its in there.

    *i have godaddy linux as well*
    just go in, find where it is - one of the choices in top bar.

    you can choose script path, and set date/times to run it.

    hope this helps
    jt

  5. #5
    Join Date
    Jul 2009
    Location
    Falls Church, Va.
    Posts
    780
    Quote Originally Posted by akluch2 View Post
    3. What should i enter as the "path_to" in your example: 0 4 * * * /path_to/php /path_to/rcharge.php, or "path" in the crontab.cron: 0 0 * * * path/rcharge.php #run at 0:00
    Please help. Thanks.
    I addressed this in reply #2 in my notes or simply ask GoDaddy. I cannot answer any proprietary questions about Godaddy because I never used their service. My advice so far has been generic Linux based.

    In Linux it's best to use the real physical path (from the actual root dir of the server) but on virtual hosted servers sometimes you can use relative paths from your document root. 1337hovie can help you beyond this.

    -jim

  6. #6
    Join Date
    Jan 2008
    Posts
    45
    Hello Guys,
    With your help i have been able to create a cron job using the Godaddy GUI cron manager, many thanks.

    But i am still having the problem of the script not working. I have uploaded all script files to my hosting server via FTP as the vendor's instruction but when i logon to my site, instead of showing the home page, it shows a dialog box like it want to download and save it to my computer.

    The vendor's demo URL is: While my site not working is : Can anyone look at it and tell me what is wrong. Attached is a zip folder containing the script index page. The index refences three other script also included, these are config, common, and consts. There are also the template folder containing the template files, these are menu, header, footer, and index.

    Please see the attachment.
    Attached Files Attached Files

  7. #7
    Join Date
    Jan 2008
    Posts
    45
    Hi,
    Please i am waiting for help. Someone tell me what to do to make this script display like a web page. Below is the index page, i have uploaded all scripts to my host server as instructed, but no luck. I attached a zip file (pay processor) above for anyone to see all scripts contents. See what this index page does at www.semicashepay.com. Someone help. Thanks.
    PHP Code:
    <?

    $data
    ['PageName']='WELCOME TO PAYMENT PROCESSOR SCRIPT';
    $data['PageFile']='index';
    ###############################################################################
    include('config.htm');
    ###############################################################################
    $data['IsLogin']=true;
    $data['IsSignup']=true;
    ###############################################################################
    display();
    ###############################################################################
    ?>

  8. #8
    Join Date
    May 2013
    Posts
    1
    hi akluch2,
    Have you solved the issue ?

  9. #9
    Join Date
    Jan 2008
    Posts
    45
    The issue has been solved. I discovered that the problem was that my server is PHP, but the files on the script has a .htm extension. So I changed all the script files from .htm to .php and it worked. Thanks for your concern.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles