'How to make a one-time payment in Stripe?

I am trying to make my site do a one time payment and verify, /payment/confirm will verify the payment went through and add the item to the current user, and /pricing is just the page they were before being redirected to the stripe checkout, this is my code for the payment so far:

    params := &stripe.CustomerParams{
        Name: stripe.String(usr.Username),
    }
    newCustomer, err := customer.New(params)
    if err != nil {
        return nil, err
    }
    checkout := &stripe.CheckoutSessionParams{
        Customer:   &newCustomer.ID,
        SuccessURL: stripe.String(host + "/payment/confirm"),
        CancelURL:  stripe.String(host + "/pricing"),
        PaymentMethodTypes: stripe.StringSlice([]string{
            "card",
        }),
        Mode: stripe.String(string(stripe.CheckoutSessionModePayment)),
        LineItems: []*stripe.CheckoutSessionLineItemParams{
            &stripe.CheckoutSessionLineItemParams{
                Price:    stripe.String(PriceID),
                Quantity: stripe.Int64(1),
            },
        },
    }
    return session.New(checkout)

This is my code, For some reason this doesn't work... it says: "cannot use checkout (variable of type *stripe.CheckoutSessionParams) as *stripe.BillingPortalSessionParams value in argument to session.New"



Solution 1:[1]

I found the error, I need to import github.com/stripe/stripe-go/v72/checkout/session and I was importing some other session.

import "github.com/stripe/stripe-go/v72/checkout/session"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 yaxeldragon