Annual Consent Process Payment Alternate Merchant
URL Endpoint: https://easypay5.com/APIcardProcREST/v1.0.0/ConsentAnnual/ProcPayment_Alt
Request Method: POST
Headers:
Session Key is passed to the API via the header:
Content-Type: application/json
Accept: application/json
SessKey: A1842D663E9A4A72XXXXXXXX303541303234373138
Use this call to process a payment using a stored card. You will need the ConsentID acquired from creating a consent., as well as the merchant ID for the alternate merchant. As usual you will monitor the FunctionOK flag (to ensure no exceptions were encountered), then take a look at the TxApproved Flag to determine your approval or declined status.
IMPORTANT: Duplicate Charges
One of the most common issues we encounter is the DUPLICATE CHARGE: It is up to you to make sure the user cannot cause a stored card to get charged twice in a short period of time. Make sure your Button or other means of requesting an authorization is Immediately disabled in order to prevent the DOUBLE TAP. Merchants and Cardholders need to be protected against this nuisance. For Web Forms simply disable your button during processing and close out your session after you receive a response. In addition, you can take note of the ConsentID and amount so that you no longer process a charge for this SAME ConsentID and amount for some reasonable time period.
{
"ConsentID": 542,
"ProcessAmount": 1.0,
"AlternateMerchID": 1
}
{
"ConsentAnnual_ProcPayment_AltResult": {
"AVSresult": "N",
"AcquirerResponseEMV": null,
"CVVresult": "",
"ErrCode": 0,
"ErrMsg": "",
"FunctionOk": true,
"IsPartialApproval": false,
"RequiresVoiceAuth": false,
"RespMsg": "APPROVAL",
"ResponseApprovedAmount": 0,
"ResponseAuthorizedAmount": 0,
"ResponseBalanceAmount": 0,
"TxApproved": true,
"TxID": 2875,
"TxnCode": "TAS018"
}
}
private void ProcessCardOnFile()
{
// create JSON object with credentials ( using Newtonsoft )
var MyCardOnFileCharge = JObject.FromObject(new
{ // your ConsentID represents a Card On File
ConsentID = 1,
// the amount you want to charge
ProcessAmount = 10.0,
// the merchant Record within this account
AlternateMerchID = 1
});
byte[] data = Encoding.UTF8.GetBytes(MyCardOnFileCharge.ToString());
// create Request
WebRequest request = WebRequest.Create("https://easypay5.com/APIcardProcREST/v1.0.0/ConsentAnnual/ProcPayment_Alt");
request.Method = "POST";
request.ContentType = "application/json";
request.ContentLength = data.Length;
// use your session key obtained when you authenticated
request.Headers.Add("SessKey: 8FBAEC35BFFE422E80303231333441303331343335");
string Myheaders = request.Headers.ToString();
string responseContent = null;
// Using the Try block will catch communication errors
try
{
using (Stream stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
using (WebResponse response = request.GetResponse())
{
using (Stream stream = response.GetResponseStream())
{
using (StreamReader sr99 = new StreamReader(stream))
{
responseContent = sr99.ReadToEnd();
}
}
}
}
catch (Exception ee)
{
MessageBox.Show("Problem communicating with EasyPay Service:" + ee.Message);
/// important to insert your Logging function here
return;
}
// Check for null Response as this would be a critical communication error as well
if (responseContent == null)
{
MessageBox.Show("Critical Error , Null Response");
/// important to insert your Logging function here
return;
}
/// develop Response Object
var SaleResp = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(responseContent);
bool FunctionOk = (bool)SaleResp.ConsentAnnual_ProcPayment_AltResult.FunctionOk;
bool TxApproved = (bool)SaleResp.ConsentAnnual_ProcPayment_AltResult.TxApproved;
int ErrCode = (int)SaleResp.ConsentAnnual_ProcPayment_AltResult.ErrCode;
string ErrMsg = (string)SaleResp.ConsentAnnual_ProcPayment_AltResult.ErrMsg;
string RespMsg = (string)SaleResp.ConsentAnnual_ProcPayment_AltResult.RespMsg;
string TxnCode = (string)SaleResp.ConsentAnnual_ProcPayment_AltResult.TxnCode;
//Check for unexpected Errors on cloud servers. If errors found Stop Processing and check ErrorCodes
if (!FunctionOk)
{
MessageBox.Show(ErrMsg + "ErrorCode: " + ErrCode.ToString());
/// important to insert your Logging function here
return;
}
//Transaction Declined. Check the RespMsg for more details. TXNCODE has the decline code
if (!TxApproved)
{
MessageBox.Show(RespMsg + " Decline Code: " + TxnCode);
/// important to insert your Logging function here
return;
}
//Successful Transaction ( get TransactionID TxID)
int TxID = (int)SaleResp.ConsentAnnual_ProcPayment_AltResult.TxID;
MessageBox.Show("TRANSACTION SUCCESS : " + RespMsg.ToUpper() + " : TxID : " + TxID.ToString());
// your approval code
string ApprovalCode = TxnCode;
/// important to insert your Logging function here
}