public static stripe.TokenCreateOptions CreateTokenOptions(this ProcessPaymentRequest processPaymentRequest, ICustomerService customerService, IStateProvinceService stateProvinceService, ICountryService countryService, StripeCurrency stripeCurrency) { return(new stripe.TokenCreateOptions() { Card = processPaymentRequest.CreateCreditCardOptions(customerService, stateProvinceService, countryService, stripeCurrency) }); }
public static stripe.CreditCardOptions CreateCreditCardOptions(this ProcessPaymentRequest processPaymentRequest, ICustomerService customerService, IStateProvinceService stateProvinceService, ICountryService countryService, StripeCurrency stripeCurrency) { var creditCardOptions = new stripe.CreditCardOptions() { Cvc = processPaymentRequest.CreditCardCvv2, Currency = stripeCurrency.ToString(), ExpMonth = processPaymentRequest.CreditCardExpireMonth, ExpYear = processPaymentRequest.CreditCardExpireYear, Name = processPaymentRequest.CreditCardName, Number = processPaymentRequest.CreditCardNumber, }; var customer = customerService.GetCustomerById(processPaymentRequest.CustomerId); var customerBillingAddress = customerService.GetCustomerBillingAddress(customer); var billingStateProvince = customerBillingAddress.StateProvinceId.HasValue ? stateProvinceService.GetStateProvinceById(customerBillingAddress.StateProvinceId.Value) : null; var billingCountry = customerBillingAddress != null && customerBillingAddress.CountryId.HasValue ? countryService.GetCountryById(customerBillingAddress.CountryId.Value) : null; if (customer != null && customerBillingAddress != null) { creditCardOptions.AddressCity = customerBillingAddress.City; creditCardOptions.AddressCountry = billingCountry?.Name; creditCardOptions.AddressLine1 = customerBillingAddress.Address1; creditCardOptions.AddressLine2 = customerBillingAddress.Address2; creditCardOptions.AddressState = billingStateProvince?.Name; creditCardOptions.AddressZip = customerBillingAddress.ZipPostalCode; } return(creditCardOptions); }
public static stripe.ChargeCreateOptions CreateChargeOptions(this ProcessPaymentRequest processPaymentRequest, Store store, stripe.Token token, TransactionMode transactionMode, StripeCurrency stripeCurrency) { var chargeRequest = new stripe.ChargeCreateOptions() { Amount = (int)(processPaymentRequest.OrderTotal * 100), Capture = transactionMode == TransactionMode.Charge, Source = token.Id, StatementDescriptor = $"{store.Name.ToStripeDescriptor()}", Currency = stripeCurrency.ToString(), }; return(chargeRequest); }
public static stripe.CreditCardOptions CreateCreditCardOptions(this ProcessPaymentRequest processPaymentRequest, Core.Domain.Customers.Customer customer, StripeCurrency stripeCurrency) { var creditCardOptions = new stripe.CreditCardOptions() { Cvc = processPaymentRequest.CreditCardCvv2, Currency = stripeCurrency.ToString(), ExpMonth = processPaymentRequest.CreditCardExpireMonth, ExpYear = processPaymentRequest.CreditCardExpireYear, Name = processPaymentRequest.CreditCardName, Number = processPaymentRequest.CreditCardNumber, }; if (customer.BillingAddress != null) { creditCardOptions.AddressCity = customer.BillingAddress.City; creditCardOptions.AddressCountry = customer.BillingAddress.Country?.Name; creditCardOptions.AddressLine1 = customer.BillingAddress.Address1; creditCardOptions.AddressLine2 = customer.BillingAddress.Address2; creditCardOptions.AddressState = customer.BillingAddress.StateProvince?.Name; creditCardOptions.AddressZip = customer.BillingAddress.ZipPostalCode; } return(creditCardOptions); }
public static stripe.TokenCreateOptions CreateTokenOptions(this ProcessPaymentRequest processPaymentRequest, Core.Domain.Customers.Customer customer, StripeCurrency stripeCurrency) { return(new stripe.TokenCreateOptions() { Card = processPaymentRequest.CreateCreditCardOptions(customer, stripeCurrency) }); }