Jump to content

custom USA ePay gateway module


k1ng440

Recommended Posts

Hello i tried to create gateway module but something always going wrong with it....

 

 


<?php
function usaepay_activate( )
{
   defineGatewayField( "usaepay", "text", "key", "", "Key", "40", "" );
defineGatewayField( "usaepay", "text", "PIN", "", "PIN", "40", "" );
   defineGatewayField( "usaepay", "yesno", "testmode", "", "Test Mode", "", "" );
}

function usaepay_securityToken($sourcekey, $pin) {
 global $remote_ip;
 $seed=mktime() . rand();
 $clear= $sourcekey . $seed . $pin;
 $hash=sha1($clear);
 $token=array(
   'SourceKey'=>$sourcekey,
   'PinHash'=>array(
      'Type'=>'sha1',
      'Seed'=>$seed,
      'HashValue'=>$hash
    ),
    'ClientIP'=>$ip,
 );  
 return $token;
}

function usaepay_capture( $params ){
$Request=array(
	'AccountHolder' => $params['clientdetails']['firstname']." ".$params['clientdetails']['lastname'],
	'Details' => array(
	  'Description' => $params['description'],
	  'Amount' => $params['amount'],
	  'Invoice' => $params['invoiceid']
	),
	'CreditCardData' => array(
	  'CardNumber' => $params['cardnum'],
	  'CardExpiration' => $params['cardexp'],
	  'AvsStreet' => $params['clientdetails']['address1'],
	  'AvsZip' => $params['clientdetails']['postcode'],
	  'CardCode' => $params['cccvv']
	),
	'IgnoreDuplicate' => 'true'
);
   if ( $params['testmode'] == "on" ){
	$wsdl='https://sandbox.usaepay.com/soap/gate/3213EA2A/usaepay.wsdl';
} else {
	$wsdl='https://www.usaepay.com/soap/gate/3213EA2A/usaepay.wsdl';
}
$token = usaepay_securityToken($params['key'], $params['PIN']);
$usaepay = new SoapClient($wsdl);

$result = (array)$usaepay->runSale($token, $Request);
if($result['Result'] == "Approved") {
    return array( "status" => "success", "transid" => $result['UMrefNum'], "rawdata" => $result );
   }
   return array( "status" => "declined", "rawdata" => $result );
}

function usaepay_refund ( $params ) {
   if ( $params['testmode'] == "on" ){
	$wsdl='https://sandbox.usaepay.com/soap/gate/3213EA2A/usaepay.wsdl';
} else {
	$wsdl='https://www.usaepay.com/soap/gate/3213EA2A/usaepay.wsdl';
}
$usaepay = new SoapClient($wsdl);
$token = usaepay_securityToken($params['key'], $params['PIN']);
$refund = (array)$usaepay->refundTransaction($token, $params['transid'], $params['amount']);
if($refund['ResultCode'] == "A") {
	return array( "status" => "success", "rawdata" => $refund, "transid" => $refund['UMrefNum']);
}
return array( "status" => "error", "rawdata" => $refund );
}

$GATEWAYMODULE['usaepayname'] = "usaepay";
$GATEWAYMODULE['usaepayvisiblename'] = "USA ePay";
$GATEWAYMODULE['usaepaytype'] = "CC";
?>

 

 

 

capture():

Invoice ID => 457738

User ID => 91

Amount => 2.95

AcsUrl =>

AuthCode => 319799

AvsResult => Address: Match & 5 Digit Zip: Match

AvsResultCode => Y

BatchNum => 572

BatchRefNum => 11136366

CardCodeResult => Match

CardCodeResultCode => M

ConversionRate => 0

ConvertedAmount => 0

ConvertedAmountCurrency => 840

CustNum => 0

Error => Approved

ErrorCode => 0

isDuplicate =>

Payload =>

RefNum => 311019959

Result => Approved

ResultCode => A

Status => Pending

StatusCode => P

VpasResultCode =>

 

 

Invoice ID => 457714

User ID => 89

Amount => 0.01

AcsUrl =>

AuthCode => 192181

AvsResult => Retry / System Unavailable

AvsResultCode => U

BatchNum => 572

BatchRefNum => 11136366

CardCodeResult => Match

CardCodeResultCode => M

ConversionRate => 0

ConvertedAmount => 0

ConvertedAmountCurrency => 840

CustNum => 0

Error => Approved

ErrorCode => 0

isDuplicate =>

Payload =>

RefNum => 311016814

Result => Approved

ResultCode => A

Status => Pending

StatusCode => P

VpasResultCode =>

 

 

 

 

refund():

Fatal error: Uncaught SoapFault exception: [sOAP-ENV:Server] 10134: Original transaction not an approved sale in

Link to comment
Share on other sites

if($result['Result'] == "Approved") {
    return array( "status" => "success", "transid" => $result['UMrefNum'], "rawdata" => $result );

 

You're passing somerthing called UMrefNum as the transid. I do not see that anywhere in the output you pasted. Perhaps you meant to use RefNum?

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.

  • 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