private void Authenticate(string AcctCode, string Token) { //EasyPay API Service Reference CardProc.CardProcessClient CardClient; //Response Object CardProc.api_AuthResponse AuthResp; // Using Statement recommended to release resources when appropriate using (CardClient = new CardProc.CardProcessClient()) { // Using the Try block will catch communication errors try { //NOTE!!!IMPORTANT!!!6 UNSUCCESSFUL ATEMPTS OF AUTHENTICATION CAUSES IP LOCK OUT . AuthResp = CardClient.Authenticate(AcctCode, Token); } catch (Exception ee) { MessageBox.Show("Problem communicating with service:" + ee.Message); /// important to insert your Logging function here return; } // Check for null Response for any critical error if (AuthResp == null) { MessageBox.Show("Critical communication Error:"); /// important to insert your Logging function here return; } //Check for unexpected Errors on cloud servers. If errors found Stop Processing and check ErrorCodes if (!AuthResp.FunctionOk) { MessageBox.Show(AuthResp.ErrMsg + "ErrorCode:" + AuthResp.ErrCode); /// important to insert your Logging function here return; } //Check for Expected problems such as Invalid or Expired Credentials or Inactive Account. if (!AuthResp.AuthSuccess) { MessageBox.Show(AuthResp.RespMsg); /// important to insert your Logging function here return; } /// Arriving here means that the Authentication was successful. You will retrieve a SessionKey and /// a list of Merchant Records associated with this account. The session key will be used for all /// subsequent API calls string SessKey = AuthResp.SessKey; CardProc.api_MerchantInfo[] MerchList = AuthResp.MerchantList; } }
private void ProcessConsentAnnual(string Sesskey, int ConsentID, decimal Amount, int MerchantID) { //Pass in the Session Key obtained from Authentication call, the ConsentID ( saved Card ) obtained from EasyPay, // the Amount that needs to be processed, and (optional) which MerchantID to process //Sample Session Key. 42 Characters long Sesskey = "AABAF6C95552447D8B303031353341303032303634 "; //EasyPay API Service Reference CardProc.CardProcessClient CardClient; //Using Statement is the best way to manage the Connection pool using (CardClient = new CardProc.CardProcessClient()) { //CCSaleResponse Object CardProc.api_CCSaleResponse Resp = new CardProc.api_CCSaleResponse(); // use the Try Catch block in ordewr to catch the communication error: try { // initate the charge Resp = CardClient.ConsentAnnual_ProcPayment_Alt(Sesskey, ConsentID, Amount, MerchantID); } catch (Exception ee) { MessageBox.Show("Problem communicating with service: " + ee.Message); /// important to insert your Logging function here return; } //Check for null Response for any critical error if (Resp == null) { MessageBox.Show("Critical Error:"); /// important to insert your Logging function here return; } //Check for unexpected Errors. If errors are detected Stop Processing and check ErrorCodes , errormessages , and log the condition if (!Resp.FunctionOk) { MessageBox.Show("Error : " + Resp.ErrMsg + " ErrorCode: " + Resp.ErrCode); /// important to insert your Logging function here return; } //Transaction Declined. Check the RespMsg for more details. if (!Resp.TxApproved) { MessageBox.Show("TRANSACTION DECLINED: " + Resp.RespMsg + " Decline Code : " + Resp.TxnCode ); /// important to insert your Logging function here return; } else { //Successful Transaction MessageBox.Show("TRANSACTION SUCCESS : " + Resp.RespMsg.ToUpper() + " : TxID : " + Resp.TxID); string ApprovalCode = Resp.TxnCode; /// important to insert your Logging function here return; } } }
private void Void(string SessKey, int TxID) { //Pass in the Session Key obtained from Authentication call and TransactionID being voided //EasyPay API Service Reference CardProc.CardProcessClient CardClient; //Using Statement is the best way to manage the Connection pool using (CardClient = new CardProc.CardProcessClient()) { //Build the Transaction Void response object CardProc.api_TransactionVoidResponse voidResp = new CardProc.api_TransactionVoidResponse(); //Important to use the Try Catch block in order to catch the communication error: try { voidResp = CardClient.Transaction_Void(SessKey, TxID); } catch (Exception ee) { MessageBox.Show("Problem communicating with service: " + ee.Message.ToString()); /// important to insert your Logging function here return; } //Check for null Response for any critical error if (voidResp == null) { MessageBox.Show("Critical Error"); /// important to insert your Logging function here return; } //Check for unexpected Errors. If errors found Stop Processing and check ErrorCodes if (!voidResp.FunctionOk) { MessageBox.Show(" Error:" + voidResp.ErrMsg + "; ErrorCode:" + voidResp.ErrCode); /// important to insert your Logging function here return; } // The return Authorization may not be approved , check the Response message for reason. if (!voidResp.TxApproved) { MessageBox.Show(voidResp.RespMsg.ToUpper()); /// important to insert your Logging function here return; } //Successfull Void Transaction gives the TXID. else { //Successfull Void Transaction gives the TXID. MessageBox.Show(voidResp.RespMsg.ToUpper() + " : TxID - " + voidResp.TxID.ToString()); /// important to insert your Logging function here return; } } }
private void Credit(string SessKey, int TxID, decimal CreditAmount) { //Pass in the Session Key obtained from Authentication call and TransactionID being credited, and the amount of the credit //EasyPay API Service Reference CardProc.CardProcessClient CardClient; using (CardClient = new CardProc.CardProcessClient()) { //Build the Transaction Credit response object CardProc.api_TransactionCreditResponse transResp = new CardProc.api_TransactionCreditResponse(); //Important to use the Try Catch block in order to catch the communication error: try { transResp = CardClient.Transaction_ApplyCredit(SessKey, TxID, CreditAmount); } catch (Exception ee) { MessageBox.Show("COMMUNICATION ERROR:" + ee.Message.ToString()); /// important to insert your Logging function here return; } //Check for null Response for any critical error if (transResp == null) { MessageBox.Show("CRITICAL ERROR"); /// important to insert your Logging function here return; } //Check for unexpected Errors. If errors found Stop Processing and check ErrorCodes if (!transResp.FunctionOk) { MessageBox.Show("Error:" + transResp.ErrMsg + "; ErrorCode:" + transResp.ErrCode); /// important to insert your Logging function here return; } //Refund not approved. Pleasse check the response message. if (!transResp.TxApproved) { MessageBox.Show(transResp.RespMsg.ToUpper()); /// important to insert your Logging function here return; } else { //Successful Refund shows the TransactionID. MessageBox.Show(transResp.RespMsg.ToUpper() + " : TX ID - " + transResp.TxID.ToString()); /// important to insert your Logging function here return; } } }
private void TransactionQuery(string SessKey, string Query) { //Pass in the Session Key obtained from Authentication call and Query used for filtering the list of transactions //EasyPay API Service Reference CardProc.CardProcessClient CardClient; //Sample Query. All query variables and more examples can be found on the Introduction to Querying page Query = "(A=1)&&(C>='6/1/2021')&&(C<'7/1/2021')&&(B=2)"; // this will return all records from merchant record 1 which were created in JUNE and are SETTLED. // Using Statement recommended to release resources when appropriate using (CardClient = new CardProc.CardProcessClient()) { //response object CardProc.api_TransactionQryResponse Resp = new CardProc.api_TransactionQryResponse(); //Try Catch block will catch any communication errors try { //Execute the query Resp = CardClient.Transaction_Query(SessKey, Query); } catch (Exception ee) { MessageBox.Show("Problem communicating with service:" + ee.Message); /// important to insert your Logging function here return; } //Check for null Response for any critical error if (Resp == null) { MessageBox.Show("Critical Error"); /// important to insert your Logging function here return; } //Check for unexpected Errors on cloud servers. If errors found Stop Processing and check ErrorCodes if (!Resp.FunctionOk) { MessageBox.Show(" Error:" + Resp.RespMsg + " ErrorCode : " + Resp.ErrCode); /// important to insert your Logging function here return; } //Query success. now you can display your transactions CardProc.api_Transaction[] MyTransactions = Resp.Transactions; } }
private void ConsentGeneralQuery(string SessKey, string Query) { //Pass in the Session Key obtained from Authentication call and Query used for filtering the list of transactions //EasyPay API Service Reference CardProc.CardProcessClient CardClient; //Sample Query. All query variables and more examples can be found on the Introduction to Querying page Query = "(D='SMITH')&&(E>'10/20/2020')"; // all Consent records from cardholder SMITH created after 10/20/2020 // Using Statement recommended to release resources when appropriate using (CardClient = new CardProc.CardProcessClient()) { //response object CardProc.api_ConsentGeneralQryResponse Resp; //Try Catch block will catch any communication errors try {// execute the API call Resp = CardClient.ConsentGeneral_Query(SessKey, Query); } catch (Exception ee) { MessageBox.Show("Problem communicating with service:" + ee.Message); /// important to insert your Logging function here return; } //Check for null Response for any critical error if (Resp == null) { MessageBox.Show("Critical Error"); /// important to insert your Logging function here return; } //Check for unexpected Errors on cloud servers. If errors found Stop Processing and check ErrorCodes if (!Resp.FunctionOk) { MessageBox.Show(" Error:" + Resp.RespMsg + " ErrorCode : " + Resp.ErrCode); /// important to insert your Logging function here return; } // success , here are the result Consent records ( Card on file ) CardProc.api_ConsentGeneral[] MyConsents = Resp.Consents; } }
private void ShowReceipt(string SessKey, int RefID, int ReceiptType, int Recipient) { //ReceiptType 1 TRANSACTION RECEIPT //ReceiptType 2 VOID RECEIPT //ReceiptType 3 REFUND RECEIPT //ReceiptType 4 ANNUAL RECEIPT //ReceiptType 5 RECURRING RECEIPT //ReceiptType 6 SUBSCRIPTION RECEIPT //Recipient 1 MERCHANT COPY //Recipient 2 CUSTOMER COPY //Recipient 3 DUAL COPY //EasyPay API Service Reference CardProc.CardProcessClient CardClient; // Using Statement recommended to release resources when appropriate using (CardClient = new CardProc.CardProcessClient()) { // create the Response Object CardProc.api_ReceiptQryResponse Resp = new CardProc.api_ReceiptQryResponse(); //Try Catch block will catch any communication errors try { // execute the API call Resp = CardClient.ReceiptGenerate(SessKey, RefID, ReceiptType, Recipient); } catch (Exception ex) { MessageBox.Show("Problem communicating with service:" + ex.Message.ToString()); /// important to insert your Logging function here return; } //Check for null Response for any critical error if (Resp == null) { MessageBox.Show("Critical Error"); /// important to insert your Logging function here return; } //Check for unexpected Errors on cloud servers. If errors found Stop Processing and check ErrorCodes if (!Resp.FunctionOk) { MessageBox.Show(" Error:" + Resp.RespMsg + " ErrorCode : " + Resp.ErrCode); /// important to insert your Logging function here return; } //Receipt Generation successful. you may now display the receipt html to your page. else { webBrowser1.DocumentText = Resp.ReceiptHtml; } } }