Results 1 to 13 of 13

Thread: Payment Gateway - Call Back Problem

  1. #1
    Join Date
    Apr 2012
    Posts
    10

    Default Payment Gateway - Call Back Problem

    Hi there,

    I faced some error while trying to edit from the downloaded kit.

    The transaction was done successfully. The problem occurs on the callback part.
    It was unable to returned to the page. The page keep loading or else I have to manually end the session. The payment was not updated automatically.

    Is there anyone here developed their own payment gateway module? Mind share your experience on this particular issue?

    Please help me out on my problem.... Please and thanks!

  2. #2
    Join Date
    Apr 2012
    Posts
    10

    Default

    Anyone help me out??? Please.... Thanks

  3. #3
    Join Date
    Mar 2011
    Location
    Ottawa, Ontario, CANADA
    Posts
    83

    Default

    Hi there.

    I can give you a hand for sure but not seeing any code or what gateway your using is going to make it a bit difficult.

    If you don't want to share your code publicly you can pm me and I will give you a hand.

  4. #4
    Join Date
    Apr 2012
    Posts
    10

    Default

    Hi gbrennae,

    Oh yeah! I forgot to share my code here... No wonder....

    Well, this is the gateway code... It works fine...

    <?php

    function webcash_config() {
    $configarray = array(
    "FriendlyName" => array("Type" => "System", "Value"=>"WebCash"),
    "username" => array("FriendlyName" => "WebCash Merchant ID", "Type" => "text", "Size" => "8", ),
    "transmethod" => array("FriendlyName" => "Transaction Method", "Type" => "dropdown", "Options" => "WebCash Prepaid,Internet Banking Services,Credit Card", ),
    "instructions" => array("FriendlyName" => "Payment Instructions", "Type" => "textarea", "Rows" => "5", "Description" => "The instructions you want displaying to customers who choose this payment method - the invoice number will be shown underneath the text entered above.", ),
    "testmode" => array("FriendlyName" => "Test Mode", "Type" => "yesno", "Description" => "Tick this to running in test mode.", ),
    );
    return $configarray;
    }

    function webcash_link($params) {

    # Gateway Specific Variables
    $gatewayusername = $params['username'];
    $gatewaytestmode = $params['testmode'];

    # Invoice Variables
    $invoiceid = $params['invoiceid'];
    $description = $params["description"];
    $amount = $params['amount']; # Format: ##.##
    $currency = $params['currency']; # Currency Code

    # Client Variables
    $firstname = $params['clientdetails']['firstname'];
    $lastname = $params['clientdetails']['lastname'];
    $email = $params['clientdetails']['email'];
    $address1 = $params['clientdetails']['address1'];
    $address2 = $params['clientdetails']['address2'];
    $city = $params['clientdetails']['city'];
    $state = $params['clientdetails']['state'];
    $postcode = $params['clientdetails']['postcode'];
    $country = $params['clientdetails']['country'];
    $phone = $params['clientdetails']['phonenumber'];

    # System Variables
    $companyname = $params['companyname'];
    $systemurl = $params['systemurl'];
    $currency = $params['currency'];

    # Enter your code submit to the gateway...

    $code = '<form action="https://webcash.com.my/testwebcash/wcgatewayinit.php" method="post">
    <input type="hidden" name="ord_date" value="07 April 2012">
    <input type="hidden" name="ord_shipname" value="'.$firstname.' '.$lastname.'">
    <input type="hidden" name="ord_mercref" value="'.$invoiceid.'">
    <input type="hidden" name="ord_shipcountry" value="'.$country.'">
    <input type="hidden" name="ord_totalamt" value="'.$amount.'" />
    <input type="hidden" name="ord_delcharges" value="0.00">
    <input type="hidden" name="ord_svccharges" value="0.00">
    <input type="hidden" name="ord_telephone" value="'.$phone.'">
    <input type="hidden" name="ord_email" value="'.$email.'">
    <input type="hidden" name="ord_returnURL" value="http://billing.hostsurf.com.my/gateways/callback/webcash.php">
    <input type="hidden" name="ord_mercID" value="'.$gatewayusername.'">
    <input type="submit" name="submit" value="Pay with Webcash">
    </form>';

    return $code;
    }

    ?>

  5. #5
    Join Date
    Apr 2012
    Posts
    10

    Default

    This is the returning parameters from the gateway merchants...

    Array
    (
    [ord_date] => 11 November 2010
    [ord_totalamt] => 100.00
    [ord_shipname] => John Doe
    [ord_shipcountry] => Malaysia
    [ord_mercref] => Order 32212
    [ord_telephone] => 0172222222
    [ord_email] => [email protected]
    [ord_delcharges] => 0.00
    [ord_svccharges] => 0.00
    [ord_key] => OFl>lBZ}alBT`3e+jtM%h_7
    [ord_mercID] => 80000321
    [wcID] => 20000030
    [returncode] => 100-20000030
    )


    There're query parameters which could be retrieve from https://webcash.com.my/testwebcash/enquiry.php

    These are returning value...
    ord_mercID = Merchant ID
    ord_mercref = Order Reference which is my Invoice ID
    ord_totalamt = Order Total

    The query reply should be :
    S = Success (Payment Received)
    P = Transaction Incomplete (Pending)
    A = User Abort Transaction (Fail)
    Invalid Parameters = Invalid Parameters
    Record Not Found = Record Not Found

  6. #6
    Join Date
    Feb 2009
    Location
    Atlanta, GA
    Posts
    1,683

    Default

    Are you sure the variables are properly being returned to the callback script? I'd add some additional log functions in there to get the values of all the POST vars you're using.

    Also, make sure you do not have any blank spaces or blank lines after the closing ?>, that will break stuff as well.

  7. #7
    Join Date
    Apr 2012
    Posts
    10

    Default

    Quote Originally Posted by laszlof View Post
    Are you sure the variables are properly being returned to the callback script? I'd add some additional log functions in there to get the values of all the POST vars you're using.

    Also, make sure you do not have any blank spaces or blank lines after the closing ?>, that will break stuff as well.
    I believes the problem happens at the status part...

    $status = $_POST["returncode"];

    The gateway provider don't offer me the SUCCESSFUL vars for me to use in the $status...

    I have no idea how the gateway query works, but I was given two URL...
    One is for where the payment system works...
    and another one was for query, and the Successful returning code is "S"...

    But I have no idea how to make two URL works where one is the Returning Transaction Code value, and one is the Query of Successful Value...

  8. #8
    Join Date
    Mar 2011
    Location
    Ottawa, Ontario, CANADA
    Posts
    83

    Default

    Thanks for posting the code.

    I think I see your problem... Your $status and $transid are both getting the same $_POST['returncode'] value.

    Since a status code is a CONSTANT value and is not unique to the transaction itself when the checkCbTransID($transid); function is called it checks to see if the transaction has already been entered as paid based on the unique transaction ID. if "s" is being passed to the checkCbTransID function and a previous transaction already exists with the value "s" as the, WHMCS will not allow a duplicate entry.

    Also, it may be possible that the gateway is not returning you a $_POST but a $_GET. To be sure, either check the documentation from the gateway provider or $_REQUEST which is $_GET, $_POST and $_COOKIE all in one array.

    Not having documentation for the gateway is going to make things a bit tricky... As a customer do you not have access to WebCash's API documentation?

    If this doesn't help, here's a little more:

    A WHMCS gateway module that uses a callback feature consists of two files.

    • The actual module itself is stored in /modules/gateways/ of your WHMCS installation.
    • A callback script which should be stored in /modules/gateways/callback/ of your WHMCS installation.


    Let's make the assumption that your module is Web Cash, you should have two files as such:
    • /modules/gateways/webcash.php
    • /modules/gateways/callback/webcash.php


    Now, you need to make sure that the function in the /modules/gateways/webcash.php has a function defined in it that matches the filename so that WHMCS can detect it properly. Therefore if your module filename is webcash.php you must have a function contained within that file called webcash_link($params). The _link portion of the function name indicates to WHMCS that this is a gateway that requires a callback.

    In your callback script you should abide by the same naming, meaning you should have a /modules/gateways/callback/webcash.php file. In the callback file you have a line $gatewaymodule = "WebCash"; the CamelCase of the module name could be causing you issues if you are naming your module just webcash elsewhere, check the case.

    If all fails, pm me your two files and I'll dig deeper for you. Again, I can only speculate without all the details.

  9. #9
    Join Date
    Feb 2009
    Location
    Atlanta, GA
    Posts
    1,683

    Default

    Quote Originally Posted by gbrennae View Post

    In your callback script you should abide by the same naming, meaning you should have a /modules/gateways/callback/webcash.php file. In the callback file you have a line $gatewaymodule = "WebCash"; the CamelCase of the module name could be causing you issues if you are naming your module just webcash elsewhere, check the case.
    Thats actually not required in the callback. The callback script works independently from the main portion of the module, and as such, doesnt need to report back to WHMCS as to what module its for. However, since it does update the database with transaction details, you'll need to make sure it uses the same modulename as what you have defined in the module code itself. It also doesnt HAVE to live in the callback directory, thats just the most logical place to store it. I've built some gateway modules that had their own subdirectory for SDK files, and it was easier for management just to put the callback file in there.

  10. #10
    Join Date
    Apr 2012
    Posts
    10

    Default

    Hi gbrennae,
    I will try to check again with the payment provider for the status parameter.
    Thanks for your help!

    Thanks laszlof for concerning =)

  11. #11
    Join Date
    Apr 2012
    Posts
    10

    Default

    Quote Originally Posted by gbrennae View Post
    Thanks for posting the code.

    I think I see your problem... Your $status and $transid are both getting the same $_POST['returncode'] value.
    .................................................. ...............
    If all fails, pm me your two files and I'll dig deeper for you. Again, I can only speculate without all the details.
    Hi gbrennae,
    I had just check with my payment provider....
    They told me only ['returncode'] for "E2" is Unsuccessful, else all returning code is Successful.

    So, I wrote it in this way...


    Code:
    <?php
    
    # Required File Includes
    include("../../../dbconnect.php");
    include("../../../includes/functions.php");
    include("../../../includes/gatewayfunctions.php");
    include("../../../includes/invoicefunctions.php");
    
    $gatewaymodule = "webcash"; # Enter your gateway module name here replacing template
    
    $GATEWAY = getGatewayVariables($gatewaymodule);
    if (!$GATEWAY["type"]) die("Module Not Activated"); # Checks gateway module is active before accepting callback
    
    # Get Returned Variables - Adjust for Post Variable Names from your Gateway's Documentation
    $status = $_POST["returncode"];
    $invoiceid = $_POST["ord_mercref"];
    $transid = $_POST["returncode"];
    $amount = $_POST["ord_totalamt"];
    
    $invoiceid = checkCbInvoiceID($invoiceid,$GATEWAY["name"]); # Checks invoice ID is a valid invoice number or ends processing
    
    checkCbTransID($transid); # Checks transaction number isn't already in the database and ends processing if it does
    
    if ($status=="E2") {
    	# Unsuccessful
        logTransaction($GATEWAY["name"],$_POST,"Unsuccessful"); # Save to Gateway Log: name, data array, status
    } else {
        # Successful
        addInvoicePayment($invoiceid,$transid,$amount,$gatewaymodule); # Apply Payment to Invoice: invoiceid, transactionid, amount paid, modulename
    	logTransaction($GATEWAY["name"],$_POST,"Successful"); # Save to Gateway Log: name, data array, status}
    }
    ?>
    But I ended up with Error 310 (net::ERR_TOO_MANY_REDIRECTS)

  12. #12
    Join Date
    Mar 2011
    Location
    Ottawa, Ontario, CANADA
    Posts
    83

    Default

    What server is issuing the Error 310? Your's after the callback or the gateway server? Check the URL to find out.

  13. #13
    Join Date
    Apr 2012
    Posts
    10

    Default

    Quote Originally Posted by gbrennae View Post
    What server is issuing the Error 310? Your's after the callback or the gateway server? Check the URL to find out.
    Hi gbrennae,

    It's after the call back. So my server is issuing the Error 310.

    But after few days back, I check my gateway log.
    It does records one transaction with the results "Unsuccessful".
    But why the callback doesn't automatically update it and shows me Error 310 with too many redirects?

Similar Threads

  1. Request a call back
    By tk16 in forum Feature Requests
    Replies: 4
    Last Post: 11-07-07, 01:34 PM