Jump to content

Custom Gateway help!!


WoofHosting

Recommended Posts

im building a Intuit Payment gateway add on and when i click on pay now it ask for the card info and then goto /creditcard.php and the screen is empty. but it work on the admin portal any ideals?

function intuit_link($params) {
$code='<form method="post" action="https://client.woofhosting.com/creditcard.php" name="paymentfrm">
<input type="hidden" name="invoiceid" value="9">
<input type="submit" value="Pay Now">
</form>';
return $code;
}

function intuit_capture($params) {

# Card Details
$cardtype = $params['cardtype'];
$cardnumber = $params['cardnum'];
$cardexpiry = $params['cardexp']; # Format: MMYY
$month=substr($cardexpiry, 0, 2);
$year="20".substr($cardexpiry, 2, 2);
$cardstart = $params['cardstart']; # Format: MMYY
$cardissuenum = $params['cardissuenum'];
//$cardnumber="4111111111111111";
# PERFORM TRANSACTION HERE
   $qbmsurl = 'https://merchantaccount.ptc.quickbooks.com/j/AppGateway';
$timestamp=time();
	$xml = '<?xml version="1.0"?>
           <?qbmsxml version="2.0"?>
           <QBMSXML>
             <SignonMsgsRq>
                <SignonDesktopRq>
                  <ClientDateTime>'.date('Y',$timestamp).'-'.date('m',$timestamp).'-'.date('d',$timestamp).'T'.date('H',$timestamp).':'.date('i',$timestamp).':'.date('s',$timestamp).'</ClientDateTime>
                  <ApplicationLogin>whmcs.client.woofhosting.com</ApplicationLogin>
                  <ConnectionTicket>'.$gatewayusername.'</ConnectionTicket>
                  <Language>English</Language>
                  <AppID>107758279</AppID>
                  <AppVer>1.0</AppVer>
                </SignonDesktopRq>
             </SignonMsgsRq>
             <QBMSXMLMsgsRq>
             <CustomerCreditCardAuthRq>
                 <TransRequestID>ef_'.$invoiceid.'_'.time().'</TransRequestID>
                 <CreditCardNumber>'.$cardnumber.'</CreditCardNumber>
                 <ExpirationMonth>'.$month.'</ExpirationMonth>
                 <ExpirationYear>'.$year.'</ExpirationYear>
                 <IsCardPresent>false</IsCardPresent>
                 <Amount>'.$amount.'</Amount>
                 <NameOnCard>'.$firstname.' '.$lastname.'</NameOnCard>
                 <CreditCardAddress>'.$address1.'</CreditCardAddress>
                 <CreditCardPostalCode>'.$postcode.'</CreditCardPostalCode>
                 <SalesTaxAmount>0.0</SalesTaxAmount>
               </CustomerCreditCardAuthRq>
             </QBMSXMLMsgsRq>
           </QBMSXML>';
    //$xml = getTransRequestID($xml);
 $mystring = date('Y-m-d');
    $searchtext = "<TransRequestID>";
    $replacetext = "<TransRequestID>" . $mystring;
    $xml = str_replace ($searchtext, $replacetext, $xml);
    $header[] = "Content-type: application/x-qbmsxml";
    $header[] = "Content-length: ".strlen($xml);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $qbmsurl);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 500);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
    $data = curl_exec($ch);
 if (curl_errno($ch)) {
        print curl_error($ch);
    } else {
        curl_close($ch);
	 $xml = simplexml_load_string($data);
	 $gettransid=$xml->QBMSXMLMsgsRs->CustomerCreditCardAuthRs->CreditCardTransID;
    }

# PUT TRANSACTION ID INTO $transid
$transid = $gettransid;
# PUT DEBUG DATE into $desc
$debugdata = "Response Code => 1\nResult => Successful\nAVS Result => 0";
# Check Result
foreach($xml->QBMSXMLMsgsRs->CustomerCreditCardAuthRs->attributes() as $a => $b) {
if ( $a == "statusMessage" ) $statusMessage = $b;
   }
if($statusMessage=="Status OK") {
	addInvoicePayment($invoiceid,$transid,$amount,$fees,"intuit","on");
	logTransaction("intuit",$debugdata,"Successful");
	sendMessage("Credit Card Payment Confirmation",$invoiceid);
	$result="success";
} else {
	logTransaction("intuit",$debugdata,"Declined");
	sendMessage("Credit Card Payment Failed",$invoiceid);
	$result="declined";
}

return $result;
}

Link to comment
Share on other sites

  • 3 years later...
  • 1 year later...

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • 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