Note that there are some explanatory texts on larger screens.

plurals
  1. POPayment Gateway ACH Integration, Getting error "INVALID MERCH OR PASSWD" in PHP on TESTMODE
    primarykey
    data
    text
    <p>I'm integrating ACH using "Payments Gateway (Forte) <a href="http://www.forte.net/Developers" rel="nofollow">http://www.forte.net/Developers</a> ". I have download API from here "<a href="http://www.phpclasses.org/browse/file/42423.html" rel="nofollow">http://www.phpclasses.org/browse/file/42423.html</a>" .</p> <p>I'm getting following error response "INVALID MERCH OR PASSWD". Not sure what exactly going wrong. I have put merchant Id correct it is same which is provided by PaymentGateways sandbox account following is demo terminal link.</p> <p><a href="https://sandbox.paymentsgateway.net/vt3/login.aspx" rel="nofollow">https://sandbox.paymentsgateway.net/vt3/login.aspx</a></p> <p>However I'm not sure which password to be used, So I'm using default provided for demo terminal login.</p> <p>Any help will really appreciated.</p> <p>Here is my Code : </p> <pre><code>&lt;?php **// FILE NAME : test_pg_webservice.php** require_once('pg_webservice.php'); $client = new ClientRecord; $client-&gt;FirstName = "Mahendra"; $client-&gt;LastName = "Kshirsagar"; $client-&gt;CompanyName = "Test company"; $client-&gt;Address1 = "123 avenue street"; $client-&gt;City = 'Miami'; $client-&gt;State = "FL"; $client-&gt;PostalCode = "12434"; $client-&gt;PhoneNumber = '789-987-7899'; $client-&gt;EmailAddress = 'mahendra008@gmail.com'; $client-&gt;ShiptoFirstName = ''; $client-&gt;ShiptoLastName = ''; $client-&gt;ShiptoCompanyName = ""; $client-&gt;ShiptoAddress1 = ""; $client-&gt;ShiptoPhoneNumber = ""; $client-&gt;ConsumerID = uniqid(); //$client-&gt;Status = '1'; $ticket = new Authentication; $webServ = new PG_WebService; $webServ-&gt;insertNewClient($client); $client_id = $webServ-&gt;insertNewClient($client); //echo "Client id: ".$client_id; //echo "\n\n\n\n\n\nError array: "; //print_r($webServ-&gt;getError()); //echo "\n\n\n\n\n\n"; $paymentMethod = new PaymentMethod; $paymentMethod-&gt;AcctHolderName = "Mahendra Kshirsagar"; $paymentMethod-&gt;ClientID = $client_id;//$client_id; $paymentMethod-&gt;EcAccountNumber = '12345678'; $paymentMethod-&gt;EcAccountTRN = '021000021'; $paymentMethod-&gt;EcAccountType = EcAccountType::SAVE; $paymentMethod-&gt;Note = 'New payment method using bank data'; $paymentMethod-&gt;IsDefault = TRUE; $paymentMethod_id = $webServ-&gt;insertNewPaymentMethod($paymentMethod); //echo "Payment method id: ".$paymentMethod_id; //echo "\n\n\n\n\n\nError array: "; //print_r($webServ-&gt;getError()); $agiTrxObj = new AGI_Transaction; $agiTrxObj-&gt;pg_client_id = $client_id; $agiTrxObj-&gt;pg_payment_method_id = $paymentMethod_id; $agiTrxObj-&gt;pg_transaction_type = EFT_TRXType::SALE; $agiTrxObj-&gt;pg_total_amount = 0.1; $agiTrxObj-&gt;ecom_billto_postal_name_first = 'Avinash'; $agiTrxObj-&gt;ecom_billto_postal_name_last = 'Kshirsagar'; $resp = $webServ-&gt;agiDoTransaction($agiTrxObj); //echo "Response: ".$resp; echo "&lt;pre&gt;"; print_r($webServ-&gt;getError()); print_r($webServ-&gt;getAgiTrxResponseArr()); echo "&lt;/pre&gt;"; </code></pre> <p>Following is a class file:</p> <pre><code>&lt;?php **// FILE NAME: pg_webservice.php** require_once('nusoap/lib/nusoap.php'); class PG_WebService { const CLIENTS_URL_LIVE = 'https://ws.paymentsgateway.net/Service/v1/Client.wsdl'; const CLIENTS_URL_TEST = 'https://sandbox.paymentsgateway.net/WS/Client.wsdl'; const MERCHANTS_URL_LIVE = 'https://ws.paymentsgateway.net/Service/v1/Merchant.wsdl'; const MERCHANTS_URL_TEST = 'https://sandbox.paymentsgateway.net/WS/Merchant.wsdl'; const TRANSACTIONS_URL_LIVE = 'https://ws.paymentsgateway.net/Service/v1/Transaction.wsdl'; const TRANSACTIONS_URL_TEST = 'https://sandbox.paymentsgateway.net/WS/Transaction.wsdl'; const AGI_DO_TRX_URL_LIVE = 'https://ws.paymentsgateway.net/pg/paymentsgateway.asmx?wsdl'; const AGI_DO_TRX_URL_TEST = 'https://ws.paymentsgateway.net/pgtest/paymentsgateway.asmx?wsdl'; private $clientEndPointURL = ''; private $merchantEndPointURL = ''; private $trxEndPointURL = ''; private $agiDoTrxURL = ''; private $agiTrxResponseArr = array(); private $allErrors = array(); private $errorArray = array('error'=&gt;FALSE, 'msg'=&gt;''); private $ticket; public function __construct(){ $this-&gt;ticket = new Authentication; $this-&gt;init(); } private function init(){ $mode = Const_AuthParam::ENV_MODE; switch($mode){ case 'test': $this-&gt;isTestMode = TRUE; $this-&gt;clientEndPointURL = self::CLIENTS_URL_TEST; $this-&gt;merchantEndPointURL = self::MERCHANTS_URL_TEST; $this-&gt;trxEndPointURL = self::TRANSACTIONS_URL_TEST; $this-&gt;agiDoTrxURL = self::AGI_DO_TRX_URL_TEST; break; case 'live': $this-&gt;isTestMode = FALSE; $this-&gt;clientEndPointURL = self::CLIENTS_URL_LIVE; $this-&gt;merchantEndPointURL = self::MERCHANTS_URL_LIVE; $this-&gt;trxEndPointURL = self::TRANSACTIONS_URL_LIVE; $this-&gt;agiDoTrxURL = self::AGI_DO_TRX_URL_LIVE; break; default: break; } } /** * @param client An instance of 'ClientRecord' class. * * @return client_id Return the id of created client. If client_id is -1 then an error has happen. */ public function insertNewClient(ClientRecord $client){ $createClientParams = array('ticket'=&gt;NULL, 'client'=&gt;NULL); $createClientParams['ticket'] = $this-&gt;ticket; $createClientParams['client'] = $client; $nuSoapClient = $this-&gt;getNuSoapClientInstance($this-&gt;clientEndPointURL); $err = $nuSoapClient-&gt;getError(); if ($err) { // Show error $this-&gt;setError(TRUE, 'Constructor error: ' . $err); $client_ID = -1; } else { $nuSoapClient-&gt;call("createClient", $createClientParams); if($nuSoapClient-&gt;fault){ $client_ID = -1; $faultString = $nuSoapClient-&gt;faultstring; if(is_array($faultString)) $faultString = end($faultString); $this-&gt;setError(TRUE, $faultString); } else{ $client_ID = $nuSoapClient-&gt;responseData; if(!is_numeric($client_ID)){ $client_ID = $this-&gt;parseXML($client_ID); } } } return $client_ID; } public function insertNewPaymentMethod(PaymentMethod $paymentMethod){ $paymentMethod_ID = -1; if(!isset($paymentMethod-&gt;ClientID)){ $this-&gt;setError(TRUE, 'You must assign a clientID to the new payment method !'); return $paymentMethod_ID; } if(!isset($paymentMethod-&gt;AcctHolderName) || trim($paymentMethod-&gt;AcctHolderName) == ''){ $this-&gt;setError(TRUE, 'Account holder name (AcctHolderName) is required'); return $paymentMethod_ID; } if(!isset($paymentMethod-&gt;EcAccountTRN) || trim($paymentMethod-&gt;EcAccountTRN) == ''){ $this-&gt;setError(TRUE, 'Transaction routing number(EcAccountTRN) is required'); return $paymentMethod_ID; } $createPaymentMethodParams = array('ticket'=&gt;$this-&gt;ticket, 'payment'=&gt;$paymentMethod); $nuSoapClient = $this-&gt;getNuSoapClientInstance($this-&gt;clientEndPointURL); $err = $nuSoapClient-&gt;getError(); if($err){ $this-&gt;setError(TRUE, 'Constructor error: ' . $err); $paymentMethod_ID = -1; } else { $nuSoapClient-&gt;call('createPaymentMethod', $createPaymentMethodParams); if($nuSoapClient-&gt;fault){ $faultString = $nuSoapClient-&gt;faultstring; if(is_array($faultString)) $faultString = end($faultString); $this-&gt;setError(TRUE, $faultString); $paymentMethod_ID = -1; } else{ $paymentMethod_ID = $nuSoapClient-&gt;responseData; if(!is_numeric($paymentMethod_ID)){ $paymentMethod_ID = $this-&gt;parseXML($paymentMethod_ID); } } } return $paymentMethod_ID; } public function agiDoTransaction(AGI_Transaction $agiTrxParams){ $trxResponse = -1; $nuSoapClient = $this-&gt;getNuSoapClientInstance($this-&gt;agiDoTrxURL); $err = $nuSoapClient-&gt;getError(); if($err){ $this-&gt;setError(TRUE, 'Constructor error: ' . $err); $trxResponse = -1; } else { $agiTrxParamsArr = get_object_vars($agiTrxParams); $nuSoapClient-&gt;call('ExecuteSocketQuery', $agiTrxParamsArr); if($nuSoapClient-&gt;fault){ $this-&gt;setError(TRUE, $nuSoapClient-&gt;faultstring); $trxResponse = -1; } else{ $trxResponse = $nuSoapClient-&gt;responseData; } } $trxResponseArr = array(); if($trxResponse != -1) $this-&gt;agiTrxResponseArr = $this-&gt;responseStr2Array($trxResponse); if(array_key_exists('pg_response_code', $this-&gt;agiTrxResponseArr)){ if($this-&gt;agiTrxResponseArr['pg_response_code'] == 'A01'){ $returnMsg = "Transactio completed successfully"; $this-&gt;setError(FALSE, $returnMsg); } else{ $this-&gt;setError(TRUE, $this-&gt;agiTrxResponseArr['pg_response_description']); } } return $this-&gt;agiTrxResponseArr; } public function getError(){ return $this-&gt;errorArray; } public function getAllErrors(){ return $this-&gt;allErrors; } public function getAgiTrxResponseArr(){ return $this-&gt;agiTrxResponseArr; } private function getNuSoapClientInstance($url){ $nuSoapClient = new nusoap_client($url, TRUE); //$nuSoapClient-&gt;setDebugLevel(9);echo $nuSoapClient-&gt;getDebug(); $nuSoapClient-&gt;soap_defencoding = 'UTF-8'; $nuSoapClient-&gt;decode_utf8 = FALSE; return $nuSoapClient; } private function responseStr2Array($responseStr){ $responseStr = $this-&gt;parseXML($responseStr); $tempArr = explode("\n", $responseStr); $responseArr = array(); if(!empty($tempArr)){ foreach($tempArr as $val){ $tempVal = explode("=", $val); if(count($tempVal) == 2) $responseArr[$tempVal[0]] = $tempVal[1]; } } return $responseArr; } private function parseXML($soapXmlStr){ $xmlObj = simplexml_load_string($soapXmlStr); $responseStr = $soapXmlStr; if($xmlObj instanceof SimpleXMLElement){ $xmlObj-&gt;registerXPathNamespace('soap', 'http://schemas.xmlsoap.org/soap/envelope/'); $xmlObj-&gt;registerXPathNamespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $xmlObj-&gt;registerXPathNamespace('xsd', 'http://www.w3.org/2001/XMLSchema'); $result = $xmlObj-&gt;xpath("//soap:Envelope/soap:Body"); foreach($result as $child){ foreach($child-&gt;children() as $child1) //print_r($child1-&gt;children()); foreach($child1 as $res) $responseStr = trim((string)$res); } } return $responseStr; } private function setError($isError, $msgError){ if(is_bool($isError)){ $this-&gt;errorArray['error'] = $isError; $this-&gt;errorArray['msg'] = $msgError; array_push($this-&gt;allErrors, $this-&gt;errorArray); } } } class Const_AuthParam { const APILoginID = 'xxx'; const SecureTransactionKey = "xxx"; const MERCHANT_ID = "xxx"; const PASSWORD = 'xxx'; const ENV_MODE = 'test';//'live' } /** * Electronic Funds Transfer (EFT) transaction types. Its used like enum type. */ class EFT_TRXType { const SALE = '20'; //Customer is charged const AUTH_ONLY = '21'; //Authorization only, CAPTURE transaction required const CAPTURE = '22'; //Completes AUTH ONLY transaction const CREDIT = '23'; //Customer is credited const VOID_TRXType = '24'; //Cancels non-settled transactions const FORCE = '25'; //Customer charged (no validation checks) const VERIFY_ONLY = '26'; //Verification only, no customer charge } class EcAccountType { const SAVE = 'SAVINGS'; const CHECK = 'CHECKING'; } /** * The Authentication object contains the ApiLoginID and SecureTransactionKey used to identify and authenticate the requestor. * Both fields may be maintained in the Virtual Terminal’s "Gateway Settings" section. */ class Authentication{ public $APILoginID ; public $UTCTime = ''; public $TSHash = ''; //HMACMD5 (APILoginID + "|" + UTCTime, SecureTransactionKey) public function __construct() { $this-&gt;APILoginID = Const_AuthParam::APILoginID; $time = time() + 62135596800; $addedtime = $time . '0000000'; $this-&gt;UTCTime = $addedtime; $this-&gt;setTsHash(); } /** * The hash generated by the transaction signing fields: APILoginID, UTCTime. */ private function setTsHash(){ $strToHash = $this-&gt;APILoginID."|".$this-&gt;UTCTime; $this-&gt;TSHash = hash_hmac("md5", $strToHash, Const_AuthParam::SecureTransactionKey, FALSE); } } class PaymentMethod{ public $MerchantID; public $ClientID; public $PaymentMethodID; public $AcctHolderName; public $CcCardNumber; public $CcExpirationDate; public $CcCardType; public $CcProcurementCard; public $EcAccountNumber; public $EcAccountTRN; public $EcAccountType; public $Note; public $IsDefault; public function __construct(){ $this-&gt;MerchantID = Const_AuthParam::MERCHANT_ID; if(!is_numeric($this-&gt;PaymentMethodID)) $this-&gt;PaymentMethodID = 0; } } class ClientRecord { public $MerchantID; public $ClientID; public $FirstName; public $LastName; public $CompanyName; public $Address1; public $Address2; public $City; public $State; public $PostalCode; public $PhoneNumber; public $CountryCode; public $EmailAddress; public $FaxNumber; public $ShiptoFirstName; public $ShiptoLastName; public $ShiptoCompanyName; public $ShiptoAddress1; public $ShiptoAddress2; public $ShiptoCity; public $ShiptoState; public $ShiptoPostalCode; public $ShiptoCountryCode; public $ShiptoPhoneNumber ; public $ShiptoFaxNumber ; public $ConsumerID ; public $Status ; public function __construct(){ $this-&gt;MerchantID = Const_AuthParam::MERCHANT_ID; if(!is_numeric($this-&gt;ClientID)) $this-&gt;ClientID = 0; } } class Transaction { public $MerchantID; public $Amount; public $SalesTaxAmount; public $ConvenienceFee ; public $ConvenienceFeePrincipal ; public $DebitCredit; public $EnteredBy; public $IPAddress; public $TransactionID; public $UpdatedDate; //Bill to public $BilltoFirstName; public $BilltoLastName; public $BilltoCompanyName; public $BilltoAddress ; public $BilltoAddress2 ; public $BilltoCity ; public $BilltoState ; public $BilltoPostalCode ; public $BilltoEmailAddress ; public $BilltoPhone ; //Ship to public $ShiptoName ; public $ShiptoCompanyName ; public $ShiptoAddresss ; public $ShiptoAddress2 ; public $ShiptoCity ; public $ShiptoState ; public $ShiptoPostalCode ; public $ShiptoFreightAmount ; //Defined Fields public $ConsumerOrderID ; public $ConsumerID ; public $WalletID ; public $MerchantData1 ; public $MerchantData2 ; public $MerchantData3 ; public $MerchantData4 ; public $MerchantData5 ; public $MerchantData6 ; public $MerchantData7 ; public $MerchantData8 ; public $MerchantData9 ; //eCheck Info public $OriginationDate ; public $AttemptNumber ; public $AcctTRN ; public $AccountType ; public $CheckNo ; public $EntryClassCode ; public $EntryDescription ; public $ItemDescription ; //Credit Card Info public $CardType ; public $CardExpDate ; public $CardHolderName ; function __construct() { $this-&gt;MerchantID = Const_AuthParam::MERCHANT_ID; if(!is_numeric($this-&gt;TransactionID)) $this-&gt;TransactionID = 0; } } class AGI_Transaction{ public $pg_merchant_id; public $pg_password; public $pg_transaction_type ; public $pg_merchant_data_1 ; public $pg_merchant_data_2 ; public $pg_merchant_data_3 ; public $pg_merchant_data_4 ; public $pg_merchant_data_5 ; public $pg_merchant_data_6 ; public $pg_merchant_data_7 ; public $pg_merchant_data_8 ; public $pg_merchant_data_9 ; public $pg_total_amount ; public $pg_sales_tax_amount ; public $pg_consumer_id ; public $ecom_consumerorderid ; public $ecom_walletid ; public $pg_billto_postal_name_company ; public $ecom_billto_postal_name_first ; public $ecom_billto_postal_name_last ; public $ecom_billto_postal_street_line1 ; public $ecom_billto_postal_street_line2 ; public $ecom_billto_postal_city ; public $ecom_billto_postal_stateprov ; public $ecom_billto_postal_postalcode ; public $ecom_billto_postal_countrycode ; public $ecom_billto_telecom_phone_number ; public $ecom_billto_online_email ; public $pg_billto_ssn ; public $pg_billto_dl_number ; public $pg_billto_dl_state ; public $pg_billto_date_of_birth ; public $pg_entered_by ; public $pg_schedule_quantity ; public $pg_schedule_frequency ; public $pg_schedule_recurring_amount ; public $pg_schedule_start_date ; public $pg_customer_ip_address ; public $pg_preauth_no_decline_on_fail ; public $pg_preauth_decline_on_noanswer ; /** * Address Verification System (AVS) is used to verify if the address data (street line, city, state, zip) provided are correct. * 'pg_avs_method' have the format: x1x2x3x4x5 where: * x1 = Credit Card Account/Zipcode Check * x2 = Credit Card Account/Street Number Check * x3 = State/Zipcode Check * x4 = State/Area Code Check * x5 = Anonymous Email Check * Values that can take each 'x' are: * 0 = Do not perform check * 1 = Check only, do not decline fail * 2 = Check and decline on fail */ public $pg_avs_method ; public $ecom_payment_card_type ; public $ecom_payment_card_name ; public $ecom_payment_card_number ; public $ecom_payment_card_expdate_month ; public $ecom_payment_card_expdate_year ; public $ecom_payment_card_verification ; public $pg_procurement_card ; public $pg_customer_acct_code ; public $pg_cc_swipe_data ; public $pg_mail_or_phone_order ; /** * Transit routing number (ABA) for customer’s account */ public $ecom_payment_check_trn ; public $ecom_payment_check_account ; public $ecom_payment_check_account_type ; public $ecom_payment_check_checkno ; public $pg_original_trace_number ; public $pg_original_authorization_code ; public $pg_client_id ; public $pg_payment_method_id ; function __construct() { $this-&gt;pg_merchant_id = Const_AuthParam::MERCHANT_ID; $this-&gt;pg_password = Const_AuthParam::PASSWORD; } } ?&gt; </code></pre> <p>When I run test_pg_webservice.php I get Following response.</p> <pre><code>Array ( [error] =&gt; 1 [msg] =&gt; INVALID MERCH OR PASSWD ) Array ( [pg_response_type] =&gt; E [pg_response_code] =&gt; E10 [pg_response_description] =&gt; INVALID MERCH OR PASSWD [pg_trace_number] =&gt; 07D5114F-7429-41B2-BD36-01A0152DC644 [pg_merchant_id] =&gt; 2000 [pg_transaction_type] =&gt; 20 [pg_total_amount] =&gt; 0.1 [pg_client_id] =&gt; 1008213 [pg_payment_method_id] =&gt; 1019484 ) </code></pre> <p>I don't think there is anything wrong with code. I think my just missing something or may be doing something in wrong way.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload