public static bool CreateCustomerProfileTransactionAuthCapture(Site site, Invoice invoice, Customer customer, CreditCard creditCard, out long transactionId, out string message, out bool cancel) { cancel = false; MerchantAuthenticationType merchantAT = new MerchantAuthenticationType(); merchantAT.name = site.AuthorizeLoginId; merchantAT.transactionKey = site.AuthorizeTransactionKey; ProfileTransactionType profileTT = new ProfileTransactionType(); ProfileTransAuthCaptureType profileTACT = new ProfileTransAuthCaptureType(); OrderExType orderET = new OrderExType(); orderET.invoiceNumber = invoice.Id.ToString(); profileTACT.amount = invoice.Amount; profileTACT.customerProfileId = customer.AuthorizeProfileId; profileTACT.customerPaymentProfileId = creditCard.AuthorizePaymentProfileId; profileTACT.order = orderET; profileTT.Item = profileTACT; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;// comparable to modern browsers ServiceSoapClient client = new ServiceSoapClient(); CreateCustomerProfileTransactionResponseType resp = client.CreateCustomerProfileTransaction(merchantAT, profileTT, String.Empty); if (resp.directResponse != null) { PaymentGatewayResponse paymentGatewayResponse = new PaymentGatewayResponse(resp.directResponse); transactionId = paymentGatewayResponse.TransactionId; message = paymentGatewayResponse.ResponseReasonText; if (!string.IsNullOrEmpty(paymentGatewayResponse.ResponseReasonText)) { cancel = paymentGatewayResponse.ResponseReasonText.ToLower().Contains("the credit card number is invalid") || paymentGatewayResponse.ResponseReasonText.ToLower().Contains("the credit card expiration date is invalid") || paymentGatewayResponse.ResponseReasonText.ToLower().Contains("the credit card has expired"); } } else { transactionId = 0; if (resp.messages.Length > 0) { message = resp.messages[0].text; } else { message = ""; } } return(resp.resultCode == MessageTypeEnum.Ok); }
public static bool CreateCustomerProfileTransactionAuthCapture(SiteDT site, InvoiceDT invoice, CustomerDT customer, CreditCardDT creditCard, out long transactionId, out string message, out string code) { MerchantAuthenticationType merchantAT = new MerchantAuthenticationType(); merchantAT.name = site.AuthorizeLoginId; merchantAT.transactionKey = site.AuthorizeTransactionKey; ProfileTransactionType profileTT = new ProfileTransactionType(); ProfileTransAuthCaptureType profileTACT = new ProfileTransAuthCaptureType(); OrderExType orderET = new OrderExType(); orderET.invoiceNumber = invoice.Id.ToString(); profileTACT.amount = invoice.Amount; profileTACT.customerProfileId = customer.AuthorizeProfileId; profileTACT.customerPaymentProfileId = creditCard.AuthorizePaymentProfileId; profileTACT.order = orderET; profileTT.Item = profileTACT; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; ServiceSoapClient client = new ServiceSoapClient(); CreateCustomerProfileTransactionResponseType resp = client.CreateCustomerProfileTransaction(merchantAT, profileTT, String.Empty); code = string.Empty; if (resp.directResponse != null) { PaymentGatewayResponse paymentGatewayResponse = new PaymentGatewayResponse(resp.directResponse); transactionId = paymentGatewayResponse.TransactionId; message = paymentGatewayResponse.ResponseReasonText; code = resp.messages != null && resp.messages.Count() > 0 ? resp.messages.Select(x => x.code + " - " + x.text).Aggregate((a, b) => a + "; " + b) : string.Empty; } else { transactionId = 0; if (resp.messages.Length > 0) { message = resp.messages[0].text; } else { message = ""; } } return(resp.resultCode == MessageTypeEnum.Ok); }
public static bool CreateCustomerProfileTransactionRefund(SiteDT site, InvoiceDT invoice, TransactionDT transaction, CustomerDT customer, CreditCardDT creditCard, out long transactionId, out string message) { //This datetime is when system change. int deployYear = CastleClub.BusinessLogic.Data.GlobalParameters.DeployYear; int deployMonth = CastleClub.BusinessLogic.Data.GlobalParameters.DeployMonth; int deployDay = CastleClub.BusinessLogic.Data.GlobalParameters.DeployDay; if (invoice.BilledDate >= new DateTime(deployYear, deployMonth, deployDay)) { MerchantAuthenticationType merchantAT = new MerchantAuthenticationType(); merchantAT.name = site.AuthorizeLoginId; merchantAT.transactionKey = site.AuthorizeTransactionKey; ProfileTransactionType profileTT = new ProfileTransactionType(); ProfileTransRefundType profileTRT = new ProfileTransRefundType(); OrderExType orderET = new OrderExType(); orderET.invoiceNumber = invoice.Id.ToString(); profileTRT.amount = invoice.Amount; profileTRT.transId = transaction.AuthorizeTransactionId.ToString(); profileTRT.customerProfileId = customer.AuthorizeProfileId; profileTRT.customerProfileIdSpecified = true; profileTRT.customerPaymentProfileId = creditCard.AuthorizePaymentProfileId; profileTRT.customerPaymentProfileIdSpecified = true; profileTRT.order = orderET; profileTT.Item = profileTRT; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; ServiceSoapClient client = new ServiceSoapClient(); CreateCustomerProfileTransactionResponseType resp = client.CreateCustomerProfileTransaction(merchantAT, profileTT, String.Empty); if (resp.directResponse != null) { PaymentGatewayResponse paymentGatewayResponse = new PaymentGatewayResponse(resp.directResponse); transactionId = paymentGatewayResponse.TransactionId; message = paymentGatewayResponse.ResponseReasonText; } else { transactionId = 0; if (resp.messages.Length > 0) { message = resp.messages[0].text; } else { message = ""; } } return(resp.resultCode == MessageTypeEnum.Ok); } else { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; using (ServiceSoapClient client = new ServiceSoapClient()) { MerchantAuthenticationType merchant = new MerchantAuthenticationType() { name = site.AuthorizeLoginId, transactionKey = site.AuthorizeTransactionKey }; ProfileTransactionType profileTT = new ProfileTransactionType(); ProfileTransRefundType profileTRT = new ProfileTransRefundType(); profileTRT.amount = invoice.Amount; profileTRT.transId = transaction.AuthorizeTransactionId.ToString(); profileTRT.creditCardNumberMasked = "XXXX" + creditCard.LastFourDigit; profileTT.Item = profileTRT; var resp = client.CreateCustomerProfileTransaction(merchant, profileTT, string.Empty); if (resp.resultCode == MessageTypeEnum.Ok) { PaymentGatewayResponse paymentGatewayResponse = new PaymentGatewayResponse(resp.directResponse); transactionId = paymentGatewayResponse.TransactionId; message = paymentGatewayResponse.ResponseReasonText; } else { transactionId = 0; message = string.Empty; message = resp.messages != null && resp.messages.Count() > 0 ? resp.messages.Select(a => a.text).Aggregate((a, b) => a + " - " + b) : string.Empty; } return(resp.resultCode == MessageTypeEnum.Ok); } } }
public static ProfileTransAuthCaptureType CreateProfileTransAuthCaptureType(Int64 profileId, Int64 paymentProfileId, OrderExType order, decimal amount) { return(new ProfileTransAuthCaptureType() { customerProfileId = profileId, customerPaymentProfileId = paymentProfileId, amount = amount, order = order, }); }