k1ng440 Posted March 23, 2012 Share Posted March 23, 2012 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 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted March 24, 2012 Share Posted March 24, 2012 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? 0 Quote Link to comment Share on other sites More sharing options...
k1ng440 Posted March 24, 2012 Author Share Posted March 24, 2012 Wow mate, Thank you very much. that solved my problem 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.