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 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 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."); }