public virtual StripeCard Create(string customerId, StripeCardCreateOptions createOptions) { var url = string.Format(Urls.Cards, customerId); url = ParameterBuilder.ApplyAllParameters(createOptions, url); var response = Requestor.PostString(url, ApiKey); return Mapper<StripeCard>.MapFromJson(response); }
public virtual async Task<StripeCard> CreateAsync(string customerId, StripeCardCreateOptions createOptions, StripeRequestOptions requestOptions = null) { var url = SetupUrl(customerId, false); return Mapper<StripeCard>.MapFromJson( await Requestor.PostStringAsync(this.ApplyAllParameters(createOptions, url, false), SetupRequestOptions(requestOptions)) ); }
//Sync public virtual StripeCard Create(string customerId, StripeCardCreateOptions createOptions, StripeRequestOptions requestOptions = null) { var url = SetupUrl(customerId, false); return(Mapper <StripeCard> .MapFromJson( Requestor.PostString(this.ApplyAllParameters(createOptions, url, false), SetupRequestOptions(requestOptions)) )); }
public virtual StripeCard Create(string customerOrRecipientId, StripeCardCreateOptions createOptions, bool isRecipient = false) { var url = SetupUrl(customerOrRecipientId, isRecipient); url = this.ApplyAllParameters(createOptions, url, false); var response = Requestor.PostString(url, ApiKey); return Mapper<StripeCard>.MapFromJson(response); }
public virtual StripeCard Create(string customerId, StripeCardCreateOptions createOptions) { var url = string.Format(Urls.Cards, customerId); url = this.ApplyAllParameters(createOptions, url, false); var response = Requestor.PostString(url, ApiKey); return(Mapper <StripeCard> .MapFromJson(response)); }
//Async public virtual async Task <StripeCard> CreateAsync(string customerId, StripeCardCreateOptions createOptions, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) { var url = SetupUrl(customerId, false); return(Mapper <StripeCard> .MapFromJson( await Requestor.PostStringAsync(this.ApplyAllParameters(createOptions, url, false), SetupRequestOptions(requestOptions), cancellationToken) )); }
public virtual StripeCard Create(string customerOrRecipientId, StripeCardCreateOptions createOptions, bool isRecipient = false) { var url = SetupUrl(customerOrRecipientId, isRecipient); url = this.ApplyAllParameters(createOptions, url, false); var response = Requestor.PostString(url, ApiKey); return(Mapper <StripeCard> .MapFromJson(response)); }
public virtual StripeCard Create(string customerOrRecipientId, StripeCardCreateOptions createOptions, bool isRecipient = false, StripeRequestOptions requestOptions = null) { requestOptions = SetupRequestOptions(requestOptions); var url = SetupUrl(customerOrRecipientId, isRecipient); url = this.ApplyAllParameters(createOptions, url, false); var response = Requestor.Instance.PostString(url, requestOptions); return Mapper<StripeCard>.MapFromJson(response); }
/// <summary> /// Implements <see cref="IStripeService.CreateCreditCard"/> /// </summary> public MemberCreditCard CreateCreditCard(Member member, string stripeCardToken) { var newCard = new StripeCardCreateOptions { Source = new StripeSourceOptions { TokenId = stripeCardToken // Note: Adding Object = "card" will result in a generic stripe error } }; var cardService = new StripeCardService(); StripeCard card; try { card = cardService.Create(member.StripeCustomerId, newCard); } catch (StripeException ex) { throw HandleStripeException(ex); } int expiryMonth = int.Parse(card.ExpirationMonth); int expiryYear = int.Parse(card.ExpirationYear); MemberCreditCard newMemberCard = new MemberCreditCard { CardholderName = card.Name, ExpiryMonth = expiryMonth, ExpiryYear = expiryYear, Last4Digits = card.Last4, StripeCardId = card.Id, Member = member, MemberId = member.UserId }; return newMemberCard; }
private StripeCard AddCardToStripe(CreditCard card, string stripeCustomerId) { var options = new StripeCardCreateOptions { Source = new StripeSourceOptions { TokenId = card.StripeToken } }; return _cardService.Create(stripeCustomerId, options); }
private StripeCard AddCardToStripe(CreditCard card, string stripeCustomerId) { var options = new StripeCardCreateOptions { SourceCard = new SourceCard { Number = card.CardNumber, ExpirationMonth = card.ExpirationMonth, ExpirationYear = card.ExpirationYear, AddressCountry = card.AddressCountry, AddressLine1 = card.AddressLine1, AddressLine2 = card.AddressLine2, AddressCity = card.AddressCity, AddressState = card.AddressState, AddressZip = card.AddressZip, Name = card.Name, Cvc = card.Cvc, } }; return _cardService.Create(stripeCustomerId, options); }
public ActionResult AddNewCard(string stripeToken) { bool tokenUsed = false; User userObj = (User)Session["user"]; if (userObj.PrimaryUser == false) return RedirectToAction("Index", "Admin"); var stripeCustomerID = accountRepo.Accounts.FirstOrDefault(aid => aid.ID == userObj.AccountID).StripeCustomerID; if (stripeCustomerID == null) { // create subscription and get subscription id var customerService = new StripeCustomerService(); customerService.ApiKey = "sk_test_4Xusc3Meo8gniONh6dDRZvlp"; var currentAccountDetails = accountRepo.Accounts.FirstOrDefault(aid => aid.ID == userObj.AccountID); var customer = new StripeCustomerCreateOptions(); customer.PlanId = "Empty Plan"; customer.Quantity = 1; customer.TokenId = stripeToken; customer.Email = userObj.Email; // Create subscription var subscriptionDetails = customerService.Create(customer); stripeCustomerID = subscriptionDetails.Id; // save StripeCustomerID currentAccountDetails.StripeCustomerID = stripeCustomerID; accountRepo.SaveAccount(currentAccountDetails); tokenUsed = true; } else { var card = new StripeCardService(); card.ApiKey = "sk_test_4Xusc3Meo8gniONh6dDRZvlp"; var cardOpt = new StripeCardCreateOptions(); cardOpt.TokenId = stripeToken; var res = card.Create(stripeCustomerID, cardOpt); } return RedirectToAction("BillingOptions", "Admin", new { id = 1 }); }