public CreditCardDataRequest MountCreditCardDataRequest(ResponseViewModel sale) { var credotCardDataRequest = new CreditCardDataRequest() { BraspagTransactionId = sale.PaymentId, MerchantId = new Guid(ConfigurationManager.AppSettings["merchantId"]), Version = "1.0", RequestId = Guid.NewGuid() }; return(credotCardDataRequest); }
public async Task <ResponseViewModel> AuthorizeTransaction(SaleViewModel sale, string merchantOrderId) { var soapSendRequestMessage = new AuthorizeTransactionRequest(); soapSendRequestMessage.Version = "v1.0"; soapSendRequestMessage.RequestId = Guid.NewGuid(); soapSendRequestMessage.OrderData = new OrderDataRequest { MerchantId = new Guid(ConfigurationManager.AppSettings["merchantId"]), OrderId = merchantOrderId }; soapSendRequestMessage.CustomerData = new CustomerDataRequest { CustomerName = sale.CustomerName }; soapSendRequestMessage.PaymentDataCollection = new PaymentDataRequest[1]; var payment = new CreditCardDataRequest { CardNumber = sale.CreditCardCardNumber, Amount = sale.PaymentAmount, CardExpirationDate = sale.CreditCardExpirationDate, CardHolder = sale.CreditCardHolder, CardSecurityCode = sale.CreditCardSecurityCode, PaymentMethod = 997, Currency = "BRL", Country = "BRA", NumberOfPayments = (short)(sale.PaymentInstallments), PaymentPlan = 0, TransactionType = 1 }; soapSendRequestMessage.PaymentDataCollection[0] = payment; var soapResponse = await PagadorTransactionWrapper.AuthorizeTransactionAsync(soapSendRequestMessage); var responseObject = new ResponseViewModel { PaymentId = soapResponse.PaymentDataCollection[0].BraspagTransactionId }; return(responseObject); }
//POST PARAMETERS public AuthorizeTransactionRequest AddingAuthorizeParameters(SoapViewModel soapCreditCard) { var serviceOrderData = new OrderDataRequest { MerchantId = new Guid(soapCreditCard.MerchanId), OrderId = "0000" }; var serviceCustomer = new CustomerDataRequest { CustomerIdentity = soapCreditCard.Identity, CustomerIdentityType = soapCreditCard.CustomerIdentityType, CustomerName = soapCreditCard.CustomerName, CustomerEmail = soapCreditCard.CustomerEmail }; var servicePayment = new CreditCardDataRequest { PaymentMethod = soapCreditCard.PaymentMethod, Amount = soapCreditCard.Amount, Currency = soapCreditCard.Currency, Country = soapCreditCard.Country, NumberOfPayments = (short)soapCreditCard.NumberPayments, PaymentPlan = 0, // cash TransactionType = 1, // preauth CardHolder = soapCreditCard.CustomerName, CardNumber = soapCreditCard.CardNumber, CardSecurityCode = soapCreditCard.SecurityCode, CardExpirationDate = soapCreditCard.Expiration }; var authorizationRequest = new AuthorizeTransactionRequest { RequestId = new Guid("00000000-0000-0000-0000-000000000000"), Version = "1.0", CustomerData = serviceCustomer, OrderData = serviceOrderData, PaymentDataCollection = new PaymentDataRequest[] { servicePayment } }; return(authorizationRequest); }
// FINANCIALS // add/updates credit card public UpdateCardResponse UpdateCard(CreditCardDataRequest request) { try { Logs.LogsInsertAction("User credit card attempted"); var validResponse = Users.updateCard.updateCardImplementation(request); if (validResponse.success == true) { Logs.LogsInsertAction("User credit card success: " + validResponse.message); } else { Logs.LogsInsertAction("User credit card failure: " + validResponse.message); } return(validResponse); } catch (Exception exception) { Logs.LogsInsertError(exception); return(new UpdateCardResponse { message = "An error occured. The Pedal team has been notified.", success = false }); } }
public static UpdateCardResponse UpdateCardInfo(CreditCardDataRequest request, StripeAction stripeAction) { //validate incoming data if (String.IsNullOrWhiteSpace(request.token)) { return(new UpdateCardResponse { message = "Missing token.", status = 601, success = false }); } if (request == null || String.IsNullOrWhiteSpace(request.authToken) || request.accountId == null) { return(new UpdateCardResponse { message = "User not found.", status = 404, success = false, }); } using (var db = new UniversalGymEntities()) { var user = db.Users.SingleOrDefault(a => a.CurrentToken == request.authToken && a.UserId == request.accountId); if (user == null) { return(new UpdateCardResponse { message = "User not found.", status = 404, success = false, }); } var message = ""; // temporarily add credits to frontend so user immediately sees money var shouldAddCredits = false; // empty stripe url means new customer if (String.IsNullOrWhiteSpace(user.StripeUrl)) { message = "Card added successfully."; shouldAddCredits = true; } // has active subscription already means updating card if (user.hasActiveSubscription) { message = "Card updated successfully."; shouldAddCredits = false; } // does not have active subscription means re-activating card else { message = "Card re-activated successfully."; shouldAddCredits = true; } user.StripeUrl = stripeAction(request.token, user); db.SaveChanges(); return(new UpdateCardResponse { message = message, status = 200, success = true, shouldAddCredits = shouldAddCredits }); } }
public static UpdateCardResponse updateCardImplementation(CreditCardDataRequest request) { return(UpdateCardInfo(request, StripeCustomer.HandleCustomer)); }