private string ProcessStoredValueTransactionResponse(ref ResponseDetails _Response) { StoredValueTransactionResponse _SVAResponse = new StoredValueTransactionResponse(); _SVAResponse = (StoredValueTransactionResponse)_Response.Response; //Set the amount reference _Response.TxnAmount = _SVAResponse.Amount; string strMessage = ""; //Note : IMPORTANT Always verify the approved amount was the same as the requested approval amount for "AuthorizeAndCapture" as well as "Authorize" if (_Response.TransactionType == "AuthorizeAndCapture" | _Response.TransactionType == "Authorize") if (!_Response.Verbose) {// In this case don't present to the user all of the data. if (_SVAResponse.Status == Status.Successful)//The transaction was approved { //NOTE : Please reference the developers guide for a more complete explination of the return fields strMessage = "Your '" + _Response.TransactionType + "' transaction was APPROVED" //Note Highly recommended to save + "\r\nTransactionId : " + _SVAResponse.TransactionId //The unique id of the transaction. TransactionId is required for all subsequent transactions such as Return, Undo, etc. + "\r\nWorkflowId : " + _Response.WorkflowId + "\r\nMerchantProfileId : " + _Response.MerchantProfileId //Must be stored with the TransactionId in order to identify which merchant sent which transaction. Required to support multi-merchant. //Note Optional but recommended to save + "\r\nStatus Code : " + _SVAResponse.StatusCode //Status code generated by the Service Provider. This code should be displayed to the user as verification of the transaction. + "\r\nStatus Message : " + _SVAResponse.StatusMessage //Explains the StatusCode which is generated by the Service Provider. This message should be displayed to the user as verification of the transaction. + "\r\nApprovalCode : " + _SVAResponse.ApprovalCode //A value returned when a transaction is approved. This value should be printed on the receipt, and also recorded for every off-line transaction, such as a voice authorization. This same data element and value must be provided during settlement. Required. + "\r\nAmount : " + _SVAResponse.Amount //Specifies the authorization amount of the transaction. This is the actual amount authorized. ; } if (_SVAResponse.Status == Status.Failure)//The transaction was declined { //NOTE : Please reference the developers guide for a more complete explination of the return fields strMessage = "Your '" + _Response.TransactionType + "' transaction was DECLINED" //Note Highly recommended to save + "\r\nTransactionId : " + _SVAResponse.TransactionId //The unique id of the transaction. TransactionId is required for all subsequent transactions such as Return, Undo, etc. + "\r\nWorkflowId : " + _Response.WorkflowId + "\r\nMerchantProfileId : " + _Response.MerchantProfileId //Must be stored with the TransactionId in order to identify which merchant sent which transaction. Required to support multi-merchant. //Note Optional but recommended to save + "\r\nStatus Code : " + _SVAResponse.StatusCode //Status code generated by the Service Provider. This code should be displayed to the user as verification of the transaction. + "\r\nStatus Message : " + _SVAResponse.StatusMessage //Explains the StatusCode which is generated by the Service Provider. This message should be displayed to the user as verification of the transaction. ; } return strMessage; } if (_SVAResponse.Status == Status.Successful)//The transaction was approved { //NOTE : Please reference the developers guide for a more complete explination of the return fields strMessage = "Your '" + _Response.TransactionType + "' transaction was APPROVED" //Note Highly recommended to save + "\r\nTransactionId : " + _SVAResponse.TransactionId //The unique id of the transaction. TransactionId is required for all subsequent transactions such as Return, Undo, etc. + "\r\nWorkflowId : " + _Response.WorkflowId + "\r\nMerchantProfileId : " + _Response.MerchantProfileId //Must be stored with the TransactionId in order to identify which merchant sent which transaction. Required to support multi-merchant. //Note Highly recommended to save if Tokenization will be used //+ "\r\nPaymentAccountDataToken : " + _BCResponse.PaymentAccountDataToken //If tokenization purchased this field represents the actual token returned in the transaction for future use. //Note Optional but recommended to save + "\r\nStatus Code : " + _SVAResponse.StatusCode //Status code generated by the Service Provider. This code should be displayed to the user as verification of the transaction. + "\r\nStatus Message : " + _SVAResponse.StatusMessage //Explains the StatusCode which is generated by the Service Provider. This message should be displayed to the user as verification of the transaction. + "\r\nApprovalCode : " + _SVAResponse.ApprovalCode //A value returned when a transaction is approved. This value should be printed on the receipt, and also recorded for every off-line transaction, such as a voice authorization. This same data element and value must be provided during settlement. Required. + "\r\nAmount : " + _SVAResponse.Amount //Specifies the authorization amount of the transaction. This is the actual amount authorized. //Note Optional but recommended if AVS is supported //+ "\r\nAVSResult ActualResult : " + _BCResponse.AVSResult.ActualResult //Specifies the actual result of AVS from the Service Provider. //+ "\r\nAVSResult AddressResult : " + _BCResponse.AVSResult.AddressResult //Specifies the result of AVS as it pertains to Address matching //+ "\r\nAVSResult PostalCodeResult : " + _BCResponse.AVSResult.PostalCodeResult //Specifies the result of AVS as it pertains to Postal Code matching //Note Optional but recommended if CV data is supported + "\r\nCVResult : " + _SVAResponse.CVResult //Response code returned by the card issuer indicating the result of Card Verification (CVV2/CVC2/CID). //Note Optional + "\r\nServiceTransactionId : " + _SVAResponse.ServiceTransactionId //+ "\r\nSettlementDate : " + _BCResponse.SettlementDate //Settlement date. Conditional, if present in the authorization response, this same data element and value must be provided during settlement ; } if (_SVAResponse.Status == Status.Failure)//The transaction was declined { //NOTE : Please reference the developers guide for a more complete explination of the return fields strMessage = "Your '" + _Response.TransactionType + "' transaction was DECLINED" //Note Highly recommended to save + "\r\nTransactionId : " + _SVAResponse.TransactionId //The unique id of the transaction. TransactionId is required for all subsequent transactions such as Return, Undo, etc. + "\r\nWorkflowId : " + _Response.WorkflowId + "\r\nMerchantProfileId : " + _Response.MerchantProfileId //Must be stored with the TransactionId in order to identify which merchant sent which transaction. Required to support multi-merchant. //Note Optional but recommended to save + "\r\nStatus Code : " + _SVAResponse.StatusCode //Status code generated by the Service Provider. This code should be displayed to the user as verification of the transaction. + "\r\nStatus Message : " + _SVAResponse.StatusMessage //Explains the StatusCode which is generated by the Service Provider. This message should be displayed to the user as verification of the transaction. //Note Optional but recommended if CV data is supported + "\r\nCVResult : " + _SVAResponse.CVResult //Response code returned by the card issuer indicating the result of Card Verification (CVV2/CVC2/CID). //Note Optional + "\r\nServiceTransactionId : " + _SVAResponse.ServiceTransactionId ; } return strMessage; }
public List<ResponseDetails> ProcessSVATransaction( TransactionType _TT //Required , StoredValueTransaction _SVAtransaction //Conditional : Only used for an AuthorizeAndCapture, Authorize and ReturnUnlinked. Otherwise null , StoredValueManage _SVManage // Conditional : Only used to manage. Otherwise null , StoredValueCapture _SVDifferenceData //Conditional : Only used for a Capture. Otherwise null , StoredValueReturn _SVRDifferenceData //Conditional : Only used for a ReturnById. Otherwise null , Undo _UDifferenceData //Conditional : Only used for an Undo. Otherwise null , bool _SendAcknowledge) { List<Response> _Response = new List<Response>(); try { CheckTokenExpire();//Make sure the current token is valid //if (_TT == TransactionType.AuthorizeAndCapture) if (_TT == TransactionType.Authorize) { _Response.Add(Cwsbc.Authorize(_sessionToken, _SVAtransaction, _applicationProfileId, _merchantProfileId, _serviceId)); //Always Verify that the requested amount and approved amount are the same. StoredValueTransactionResponse SVR = new StoredValueTransactionResponse(); SVR = (StoredValueTransactionResponse)_Response[0]; if (_SVAtransaction.TransactionData.Amount != SVR.Amount) _message += "The transaction was approved for " + SVR.Amount + " which is an amount not equal to than the requested amount of " + _SVAtransaction.TransactionData.Amount + ". Please provide alternate payment to complete transaction"; } if (_TT == TransactionType.ManageAccountById) _Response.Add(Cwsbc.ManageAccountById(_sessionToken, _SVManage, _applicationProfileId, _serviceId)); if (_TT == TransactionType.ManageAccount) _Response.Add(Cwsbc.ManageAccount(_sessionToken, _SVAtransaction, _applicationProfileId, _merchantProfileId, _serviceId)); if (_TT == TransactionType.Capture) _Response.Add(Cwsbc.Capture(_sessionToken, _SVDifferenceData, _applicationProfileId, _serviceId)); if (_TT == TransactionType.ReturnById) _Response.Add(Cwsbc.ReturnById(_sessionToken, _SVRDifferenceData, _applicationProfileId, _serviceId)); if (_TT == TransactionType.Return) _Response.Add(Cwsbc.ReturnUnlinked(_sessionToken, _SVAtransaction, _applicationProfileId, _merchantProfileId, _serviceId)); if (_TT == TransactionType.Undo) _Response.Add(Cwsbc.Undo(_sessionToken, _UDifferenceData, _applicationProfileId, _serviceId)); if (_TT == TransactionType.QueryAccount) _Response.Add(Cwsbc.QueryAccount(_sessionToken, _SVAtransaction, _applicationProfileId, _merchantProfileId, _serviceId)); List<ResponseDetails> RD = new List<ResponseDetails>();//Convert the response to response details so that we can report on the UI if (_Response != null) { foreach (Response r in _Response) { if (_SendAcknowledge && r.TransactionId.Length > 0) Cwsbc.Acknowledge(_sessionToken, r.TransactionId, _applicationProfileId, _serviceId); ResponseDetails RDN = new ResponseDetails(0.00M, r, _TT.ToString(), _serviceId, _merchantProfileId, true, TypeCardType.NotSet, ""); _message += ProcessResponse(ref RDN);//Pass as reference so we can extract more values from the response RD.Add(RDN); } } return RD; } catch (EndpointNotFoundException) { //In this case the SvcEndpoint was not available. Try the same logic again with the alternate Endpoint try { SetTxnEndpoint();//Change the endpoint to use the backup. //TODO : Add a copy of the code above once fully tested out. return null; } catch (EndpointNotFoundException) { _message += "Neither the primary or secondary endpoints are available. Unable to process."; } catch (Exception ex) { _message += "Unable to AuthorizeAndCapture\r\nError Message : " + ex.Message; } } catch (System.TimeoutException te) { //A timeout has occured. Prompt the user if they'd like to query for the last transaction submitted if (_SVAtransaction != null) { _message += "A timeout has occured. A call to 'RequestTransaction' was made to obtain the transactions that should have been returned. Your code will need to reconcile transactions."; RequestTransaction(_SVAtransaction.TenderData); } else { throw te; } } catch (Exception ex) { string strErrorId; string strErrorMessage; if (_FaultHandler.handleTxnFault(ex, out strErrorId, out strErrorMessage)) { _message += strErrorId + " : " + strErrorMessage; } else { _message += ex.Message; } } return null; }