skip to Main Content

I am using the Stripe PHP SDK to create a Session. I have a product with a price that has a Payment Link created which includes a trial period. I want the Session to use the Payment Link as the Checkout page.

I keep getting error Stripe PHP error saying Received unknown parameter: payment_link. But when I check Stripe API docs the payment_link is a valid parameter for Session object. How else can I apply a trial to the product or price? Or do I need to add some additional parameters or library?

PHP CODE

    $session = StripeCheckoutSession::create([
        'line_items'  => [
            [
                'price' => 'price_1111',
                'quantity'   => 1,
            ],
        ],
        'mode'        => 'subscription', // tested with 'payment' as well
        'allow_promotion_codes' => true,
        'success_url' => env('APP_URL').'/x4/success/st?success={CHECKOUT_SESSION_ID}',
        'cancel_url'  => route('billing'),
        'payment_link' => 'plink_1111
    ]);
    return redirect()->away($session->url);

2

Answers


  1. You can’t do that.

    The Payment Link is itself like a streamlined Checkout Session.
    If you want to redirect your customer to a payment page that relate to your Payment Link, use your Payment Link url.
    https://docs.stripe.com/api/payment_links/payment_links/object#payment_link_object-url

    Login or Signup to reply.
  2. PaymentLink isn’t a valid parameter for Create a Checkout Session endpoint: https://docs.stripe.com/api/checkout/sessions/create

    It is only valid for List all Checkout Sessions API: https://docs.stripe.com/api/checkout/sessions/list

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search