Полосная подписка возвращает 404 в Asp Core - PullRequest
0 голосов
/ 31 марта 2020

Я следую примеру на Stripe и Github и при отправке платежа выдает ошибку 404. Форма загружается, и она работает, как я вижу, она регистрируется на моей информационной панели, но форма зависает и продолжает загружаться.

Ошибка в return fetch ('create-customer') . Метод CreateCustomerAsyn c не получает

Index.cs html

    async function createCustomer(paymentMethod, cardholderEmail) {
    return fetch('create-customer', {
        method: 'post',
        headers: {
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({
            email: cardholderEmail,
            payment_method: paymentMethod
        })
    })
        .then(response => {
            return response.json();
        })
        .then(subscription => {
            handleSubscription(subscription);
        });
}

PaymentController

        [HttpPost("create-customer")]
    public async Task<ActionResult<Subscription>> CreateCustomerAsync([FromBody] CustomerCreateRequest request)
    {
        var customerService = new CustomerService(this.client);

        var customer = await customerService.CreateAsync(new CustomerCreateOptions
        {
            Email = request.Email,
            PaymentMethod = request.PaymentMethod,
            InvoiceSettings = new CustomerInvoiceSettingsOptions
            {
                DefaultPaymentMethod = request.PaymentMethod,
            }
        });

        var subscriptionService = new SubscriptionService(this.client);

        var subscription = await subscriptionService.CreateAsync(new SubscriptionCreateOptions
        {
            Items = new List<SubscriptionItemOptions>
        {
            new SubscriptionItemOptions
            {
                Plan = this.options.Value.SubscriptionPlanId,
            },
        },
            Customer = customer.Id,
            Expand = new List<string>
        {
            "latest_invoice.payment_intent",
        }
        });

        return View(subscription);
    }
...