protected virtual XElement Cv2AvsElement(CardDetails card, BillingAddress billingAddress, Cv2AvsPolicy policy) { var cv2AvsElements = new List <XElement>(); if (billingAddress != null) { var numericAddress = numericPartsOfAddress(billingAddress); if (!string.IsNullOrWhiteSpace(numericAddress)) { cv2AvsElements.Add(new XElement("street_address1", numericAddress)); } var formattedPostcode = formatPostcode(billingAddress.Postcode); if (!string.IsNullOrWhiteSpace(formattedPostcode)) { cv2AvsElements.Add(new XElement("postcode", formattedPostcode)); } } // 0 is not a valid per-transaction policy code. var cvPolicy = (int)policy; if (cvPolicy > 0) { cv2AvsElements.Add(new XElement("policy", cvPolicy)); } cv2AvsElements.Add(new XElement("cv2", card.Cv2)); return(new XElement("Cv2Avs", cv2AvsElements.ToArray())); }
protected virtual XElement CardElement(CardDetails card, BillingAddress billingAddress, Cv2AvsPolicy policy) { return(new XElement("Card", new XElement("pan", card.Number), new XElement("expirydate", card.ExpiryDate), new XElement("startdate", card.StartDate), new XElement("issuenumber", card.IssueNumber), Cv2AvsElement(card, billingAddress, policy))); }
protected virtual XElement CardElement(CardDetails card, BillingAddress billingAddress) { return new XElement("Card", new XElement("pan", card.Number), new XElement("expirydate", card.ExpiryDate), new XElement("startdate", card.StartDate), new XElement("issuenumber", card.IssueNumber), Cv2AvsElement(card, billingAddress)); }
public I3DSecureResponse Payment(string merchantReference, decimal amount, CardDetails card, BillingAddress billingAddress = null, string currencyCode = null) { if (string.IsNullOrWhiteSpace(merchantReference)) throw new ArgumentNullException("merchantReference"); var requestDocument = _paymentPaymentRequestBuilder.Build(merchantReference, amount, currencyCode, card, billingAddress); var httpResponse = _httpClient.Post(_configuration.Host, requestDocument.ToString(SaveOptions.DisableFormatting)); var response = _responseParser.Parse(httpResponse); if (response.CanAuthorize()) response = Authorise(response.TransactionReference, null); return response; }
/// <summary> /// AVS checks strip out all non-numeric characters from addresses. /// The DataCash specification clearly states that we can do this ourselves /// before sending the address to them. /// </summary> static string numericPartsOfAddress(BillingAddress billingAddress) { var regex = new Regex("[^0-9]"); var address = string.Join("", new[] { billingAddress.StreetAddress1, billingAddress.StreetAddress2, billingAddress.StreetAddress3, billingAddress.StreetAddress4, billingAddress.City, billingAddress.State }.Where(x => x != null)); return(regex.Replace(address, string.Empty)); }
protected virtual XElement Cv2AvsElement(CardDetails card, BillingAddress billingAddress) { var cv2AvsElements = new List<XElement>(); if (billingAddress != null) { var numericAddress = numericPartsOfAddress(billingAddress); if (!string.IsNullOrWhiteSpace(numericAddress)) cv2AvsElements.Add(new XElement("street_address1", numericAddress)); var formattedPostcode = formatPostcode(billingAddress.Postcode); if (!string.IsNullOrWhiteSpace(formattedPostcode)) cv2AvsElements.Add(new XElement("postcode", formattedPostcode)); } cv2AvsElements.Add(new XElement("cv2", card.Cv2)); return new XElement("Cv2Avs", cv2AvsElements.ToArray()); }
protected virtual XElement Cv2AvsElement(CardDetails card, BillingAddress billingAddress) { var cv2AvsElements = new List <XElement>(); if (billingAddress != null) { var numericAddress = numericPartsOfAddress(billingAddress); if (!string.IsNullOrWhiteSpace(numericAddress)) { cv2AvsElements.Add(new XElement("street_address1", numericAddress)); } var formattedPostcode = formatPostcode(billingAddress.Postcode); if (!string.IsNullOrWhiteSpace(formattedPostcode)) { cv2AvsElements.Add(new XElement("postcode", formattedPostcode)); } } cv2AvsElements.Add(new XElement("cv2", card.Cv2)); return(new XElement("Cv2Avs", cv2AvsElements.ToArray())); }
public I3DSecureResponse Payment(string merchantReference, decimal amount, CardDetails card, BillingAddress billingAddress = null, string currencyCode = null) { if (string.IsNullOrWhiteSpace(merchantReference)) { throw new ArgumentNullException("merchantReference"); } var requestDocument = _paymentPaymentRequestBuilder.Build(merchantReference, amount, currencyCode, card, billingAddress); var httpResponse = _httpClient.Post(_configuration.Host, requestDocument.ToString(SaveOptions.DisableFormatting)); var response = _responseParser.Parse(httpResponse); if (response.CanAuthorize()) { response = Authorise(response.TransactionReference, null); } return(response); }
public ICardPaymentResponse Payment(string merchantReference, decimal amount, CardDetails card, BillingAddress billingAddress = null, string currencyCode = null) { var requestDocument = _paymentRequestBuilder.Build(merchantReference, amount, currencyCode, card, billingAddress); var response = _httpClient.Post(_configuration.Host, requestDocument.ToString(SaveOptions.DisableFormatting)); return(_responseParser.Parse(response)); }
public IRecurringPaymentResponse SetupPayment(string merchantReference, decimal amount, CardDetails card, BillingAddress billingAddress = null, Cv2AvsPolicy policy = Cv2AvsPolicy.UNSPECIFIED, string currencyCode = null, MCC6012 mcc6012 = null, string captureMethod = "ecomm") { var requestDocument = _paymentRequestBuilder.BuildSetupPaymentRequest(merchantReference, amount, currencyCode, card, policy, billingAddress, mcc6012, captureMethod); var response = _httpClient.Post(_configuration.Host, requestDocument.ToString(SaveOptions.DisableFormatting)); return(_responseParser.Parse(response)); }
protected virtual XElement CardTxnElement(CardDetails card, BillingAddress billingAddress, Cv2AvsPolicy policy) { return(new XElement("CardTxn", new XElement("method", "auth"), CardElement(card, billingAddress, policy))); }
public XDocument Build(string merchantReference, decimal amount, CardDetails card, BillingAddress billingAddress) { return GetDocument( TxnDetailsElement(merchantReference, amount), CardTxnElement(card, billingAddress)); }
public I3DSecureResponse Payment(string merchantReference, decimal amount, CardDetails card, BillingAddress billingAddress = null, Cv2AvsPolicy policy = Cv2AvsPolicy.UNSPECIFIED, string currencyCode = null, MCC6012 mcc6012 = null) { if (string.IsNullOrWhiteSpace(merchantReference)) { throw new ArgumentNullException("merchantReference"); } var requestDocument = _paymentPaymentRequestBuilder.Build(merchantReference, amount, currencyCode, card, policy, billingAddress, mcc6012); var requestData = requestDocument.ToString(SaveOptions.None); var httpResponse = _httpClient.Post(_configuration.Host, requestData); var response = _responseParser.Parse(httpResponse); if (response.CanAuthorize()) { response = Authorise(response.TransactionReference, null); } return(response); }
public XDocument Build(string merchantReference, decimal amount, string currencyCode, CardDetails card, BillingAddress billingAddress) { return(GetDocument( TxnDetailsElement(merchantReference, amount, currencyCode), CardTxnElement(card, billingAddress))); }
public ICardPaymentResponse Payment(string merchantReference, decimal amount, CardDetails card, BillingAddress billingAddress = null) { var requestDocument = _paymentRequestBuilder.Build(merchantReference, amount, card, billingAddress); var response = _httpClient.Post(_configuration.Host, requestDocument.ToString(SaveOptions.DisableFormatting)); return _responseParser.Parse(response); }
public XDocument BuildSetupPaymentRequest(string merchantReference, decimal amount, string currencyCode, CardDetails card, Cv2AvsPolicy policy, BillingAddress billingAddress, MCC6012 mcc6012, string captureMethod = "ecomm") { return(GetDocument( AddCaptureMethod(TxnDetailsElement(merchantReference, amount, currencyCode, mcc6012), captureMethod), CardTxnElement(card, billingAddress, policy), ContAuthTxnElement(false))); }
public XDocument Build(string merchantReference, decimal amount, string currencyCode, CardDetails card, Cv2AvsPolicy policy, BillingAddress billingAddress, MCC6012 mcc6012) { return(GetDocument( TxnDetailsElement(merchantReference, amount, currencyCode, mcc6012), CardTxnElement(card, billingAddress, policy))); }
protected virtual XElement CardTxnElement(CardDetails card, BillingAddress billingAddress) { return new XElement("CardTxn", new XElement("method", "auth"), CardElement(card, billingAddress)); }
/// <summary> /// AVS checks strip out all non-numeric characters from addresses. /// The DataCash specification clearly states that we can do this ourselves /// before sending the address to them. /// </summary> static string numericPartsOfAddress(BillingAddress billingAddress) { var regex = new Regex("[^0-9]"); var address = string.Join("", new[] { billingAddress.StreetAddress1, billingAddress.StreetAddress2, billingAddress.StreetAddress3, billingAddress.StreetAddress4, billingAddress.City, billingAddress.State }.Where(x => x != null)); return regex.Replace(address, string.Empty); }