public async Task <SetupIntent> CreateSetupIntent() { // Here we create a customer, then create a SetupIntent. // The SetupIntent is the object that keeps track of the // Customer's intent to allow saving their card details // so they can be charged later when the customer is no longer // on your site. // Create a customer var options = new CustomerCreateOptions(); var service = new CustomerService(); var customer = await service.CreateAsync(options); // Create a setup intent, and return the setup intent. var setupIntentOptions = new SetupIntentCreateOptions { Customer = customer.Id, }; var setupIntentService = new SetupIntentService(); // We're returning the full SetupIntent object here, but you could // also just return the ClientSecret for the newly created // SetupIntent as that's the only required data to confirm the // SetupIntent on the front end with Stripe.js. return(await setupIntentService.CreateAsync(setupIntentOptions)); }
public JsonResult SetupCard() { var options = new SetupIntentCreateOptions { }; var service = new SetupIntentService(); var intent = service.Create(options); return(Json(intent.ClientSecret, JsonRequestBehavior.AllowGet)); }
public SetupIntent CreateNewCard(string customerId, string userId) { var setupIntentService = new SetupIntentService(); var intentOptions = new SetupIntentCreateOptions { Customer = customerId }; return(setupIntentService.Create(intentOptions)); }
public async Task <string> PostSetupPayment() { var options = new SetupIntentCreateOptions { Usage = "off_session" }; var service = new SetupIntentService(); var setupIntent = await service.CreateAsync(options); return(setupIntent.ClientSecret); }
public async Task <SetupIntent> CreateSetupIntent(string customerId) { var setupIntentOptions = new SetupIntentCreateOptions { Customer = customerId, }; var setupIntentService = new SetupIntentService(); var response = await setupIntentService.CreateAsync(setupIntentOptions); return(response); }
public async Task <string> CreateClientSecretAsync() { var options = new SetupIntentCreateOptions { PaymentMethodTypes = new List <string> { "card" } }; var service = new SetupIntentService(); SetupIntent intent = await service.CreateAsync(options); return(intent.ClientSecret); }
public ActionResult Index() { //TODO: need to save customer var options = new SetupIntentCreateOptions { Customer = createACustomer() }; var service = new SetupIntentService(); var intent = service.Create(options); ViewData["ClientSecret"] = intent.ClientSecret; return(View()); }
public async Task <IActionResult> RegisterCard(AppZeroAPI.Entities.Customer customer) { var customerId = customer.customer_id; var options = new SetupIntentCreateOptions { Customer = customerId.ToString(), }; var service = new SetupIntentService(); var intent = service.Create(options); var clientSecret = intent.ClientSecret; var response = await Task.FromResult(clientSecret); return(Ok(response)); }
public async Task <SetupIntentDao> CreateSetupIntent(string paymentCustomerId, CancellationToken cancellationToken) { Guard.Argument(paymentCustomerId, nameof(paymentCustomerId)).NotNull().NotEmpty().NotWhiteSpace(); var options = new SetupIntentCreateOptions { Customer = paymentCustomerId, PaymentMethodTypes = new List <string> { "card" } }; var newSetupIntent = await _setupIntentService.CreateAsync(options, cancellationToken : cancellationToken); if (newSetupIntent != null) { return(newSetupIntent.ToSetupIntentDao()); } throw new PaymentServiceException($"Unable to create customer with customer identifier '{paymentCustomerId}' in stripe payment system."); }
public SetupIntentServiceTest( StripeMockFixture stripeMockFixture, MockHttpClientFixture mockHttpClientFixture) : base(stripeMockFixture, mockHttpClientFixture) { this.service = new SetupIntentService(this.StripeClient); this.cancelOptions = new SetupIntentCancelOptions { }; this.confirmOptions = new SetupIntentConfirmOptions { }; this.createOptions = new SetupIntentCreateOptions { PaymentMethodTypes = new List <string> { "card", }, }; this.listOptions = new SetupIntentListOptions { Limit = 1, }; this.updateOptions = new SetupIntentUpdateOptions { Metadata = new Dictionary <string, string> { { "key", "value" }, }, }; }