#michael-harvey_code

1 messages ¡ Page 1 of 1 (latest)

desert valleyBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1279116708551852041

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

undone kernel
#

API code:

//handleReadOAAuthorizationHeader();
_companyId = 179859;
createCustomerInformation = new CreateCustomerAndIntent
{
Name = "John Doe",
Email = "johndoe@test.com"
};

StripeConfiguration.ApiKey = _paymentProcessor.StripeApiKey;

string stripeAccountId = await _stripeAccountSessionBal.GetAccountId(_companyId);

// Todo: look up if there already is a customer for this company with this email address and name return that customer id if it exists
string customerId = "";//await _stripeAccountSessionBal.GetCustomerId(_companyId, createCustomerInformation.Name, createCustomerInformation.Email);

// if customer already exists, skip creating customer

if (string.IsNullOrEmpty(customerId))
{
// create customer
var options = new CustomerCreateOptions
{
Email = createCustomerInformation.Email,
Name = createCustomerInformation.Name,

};

var requestOptionsCustomer = new RequestOptions()
{
    StripeAccount = stripeAccountId
};

var service = new CustomerService();
Customer customer = await service.CreateAsync(options, requestOptionsCustomer);

customerId = customer.Id;


// Todo: save customer
//_stripeAccountSessionBal.SaveCustomer(_companyId, customerId, createCustomerInformation.Name, createCustomerInformation.Email);

}

var intentOptions = new PaymentIntentCreateOptions
{
Amount = 1099,
Currency = "usd",
// In the latest version of the API, specifying the automatic_payment_methods parameter
// is optional because Stripe enables its functionality by default.
AutomaticPaymentMethods = new PaymentIntentAutomaticPaymentMethodsOptions
{
Enabled = true
},

Customer = customerId,
SetupFutureUsage = "off_session"

};

#

RequestOptions requestOptionsPaymentIntent = new RequestOptions();
requestOptionsPaymentIntent.StripeAccount = stripeAccountId;

        var intentService = new PaymentIntentService();
        var intent = intentService.Create(intentOptions, requestOptionsPaymentIntent);

        var customerSessionOptions = new CustomerSessionCreateOptions
        {
            Customer = customerId,
            Components = new CustomerSessionComponentsOptions(),

        };

        customerSessionOptions.AddExtraParam("components[payment_element][enabled]", true);
        customerSessionOptions.AddExtraParam(
            "components[payment_element][features][payment_method_redisplay]",
            "enabled");
        customerSessionOptions.AddExtraParam(
            "components[payment_element][features][payment_method_save]",
            "enabled");
        customerSessionOptions.AddExtraParam(
            "components[payment_element][features][payment_method_save_usage]",
            "on_session");
        customerSessionOptions.AddExtraParam(
            "components[payment_element][features][payment_method_remove]",
            "enabled");
        var customerSessionService = new CustomerSessionService();

        RequestOptions requestOptionsCustomerSession = new RequestOptions();
        requestOptionsCustomerSession.StripeAccount = stripeAccountId;
        var customerSession = customerSessionService.Create(customerSessionOptions, requestOptionsCustomerSession);


        return Ok(new {
            client_secret = intent.ClientSecret,
            customerSessionClientSecret = customerSession.ClientSecret
        });
#

is this disabled because i'm in a dev environment?

astral trail
#

It's likely because you're not serving the form over HTTPS. I would guess that if you open the developer console, you'll see a warning about that as well

undone kernel
#

so would i see this if i was over https:

#

i am trying to show the right side menu with the saved credit cards

astral trail
#

Yup! That's what I would expect. Do you see the console warning I was telling you about in the developer tools?

undone kernel
#

no i don't see any errors in the console

astral trail
#

No warnings either?

#

Can you send a screenshot?

undone kernel
astral trail
#

Can you click on console tab?

undone kernel
astral trail
#

I think you might be filtering out the messages I would expect with a non-HTTPS connection. Can you try selecting the default levels in the dropdown from this screenshot?

undone kernel
#

You may test your Stripe.js integration over HTTP. However, live Stripe.js integrations must use HTTPS.

astral trail
#

Yup, okay so the solution remains. You have to serve over HTTPS for this functionality to work