#damonstrr

1 messages · Page 1 of 1 (latest)

astral magnetBOT
west carbon
#

maybe i should paste my full code??

#
$response = app('stripe')->checkout->sessions->create([
            'payment_method_types' => ['card'],
            'amount_subtotal' => 1000,
            'amount_total' => 1000,

            'mode' => 'subscription',
            'line_items' => [
                [
                    'price_data' => [
                        'currency' => 'usd',
                        'unit_amount' => $plan->price->getAmount(),
                        'product_data' => [
                            'name' => $productName,
                        ],
                        'recurring' => ['interval' => $plan->abbreviation],
                    ],
                    'quantity' => 1,
                ],
            ],
            'subscription_data' => [
                'application_fee_percent' => 10,
                'metadata' => [
                    'post_id' => $latestPost->id,
                    'user_id' => $blog->user->id,
                    'user_email' => $blog->user->email,
                    'name' => $plan->abbreviation,
                    'reader_id' => Auth::user()->id,
                    'price_id' => $plan->stripe_price_id,
                    'product_id' => $plan->stripe_product_id,
                ]
            ],

            'client_reference_id' => Auth::user()->id,
            'success_url' => route('blog.checkout.success', ['blog' => $blog->name, 'plan' => $plan->slug]),
            'cancel_url' => route('blog.post.show', [$blog->name, 'post' => $latestPost->slug]),
            'metadata' => [
                'post_id' => $latestPost->id,
                'user_id' => Auth::user()->id,
                'name' => $plan->abbreviation
            ],
            'customer_email' => Auth::user()->email,
        ], [
            'stripe_account' => $stripeAccount,
        ]);
eternal drift
west carbon
#

I did that too but i still get error

#

Received unknown parameters: amount_total, amount_subtotal

eternal drift
#

Apologies, wrong link and wrong info

west carbon
#

        $response = app('stripe')->checkout->sessions->create([
            'payment_method_types' => ['card'],


            'mode' => 'subscription',
            'line_items' => [
                [
                    'amount_subtotal' => 1000,
                    'amount_total' => 1000,
eternal drift
#

So those are results of what you pass in

#

So you don't directly say that the amount total is $10, you include items and then Stripe calculates that their total is $10 and outputs that in the Checkout Session object that is created

west carbon
#

yeah but how do i display it on the checkout??

eternal drift
#

It will automatically be displayed on the page

west carbon
#

it is not

#

Will it be displayed on the live mode??

#

Cause i do not see on test mode

eternal drift
#

Can you send me a screenshot of what you are seeing? The total shows up for me in test mode

west carbon
#

That’s what I’m seeing

#

Also I want to add google pay but couldn’t add google_pay to payment method

eternal drift
#

It shows $10 in the upper left of the page. What are you looking for it to say?

west carbon
#

It should say the subtotal and total due today

#

Like this

eternal drift
#

If you only have one subscription item, we won't show sub-items. It looks like you only have one $10 item so we are only showing the total

#

Try your code again but with two items in the line items array:

                [
                    'price_data' => [
                        'currency' => 'usd',
                        'unit_amount' => $plan->price->getAmount(),
                        'product_data' => [
                            'name' => $productName,
                        ],
                        'recurring' => ['interval' => $plan->abbreviation],
                    ],
                    'quantity' => 1,
                ],
                [
                    'price_data' => [
                        'currency' => 'usd',
                        'unit_amount' => $plan->price->getAmount(),
                        'product_data' => [
                            'name' => 'Another product',
                        ],
                        'recurring' => ['interval' => $plan->abbreviation],
                    ],
                    'quantity' => 1,
                ],
            ],```
west carbon
#

how about the google pay?? is that possible to add?

#

Also when i check my customer.subscription.created after checkout session has been completed the productId and Priceid seems to be different from the one inside the product in stripe dashboard

eternal drift
#

It should be possible to add Google Pay. Can you send me the ID of a Checkout Session so that I can look in to why Google Pay did not show up? (cs_test_1234)

#

You are using price_data and product_data which create new ad-hoc product objects. If you want to use the price and product from your dashboard, you should pass the price's ID (price_1234) into the price parameter instead of using price_data

west carbon
#

cs_test_a1yVKW52iy4g4I2MuptENgkzz4h7oprbqxQwXa1LNOcC5gy0MEzSWrOKOw

west carbon
astral magnetBOT
eternal drift
#

Correct

#

And thank you for the ID, we will check in to that

#

Ah, so google pay shows up for me when I go to that checkout link

#

So the issue is that you don't have Google Pay set up on your current device/browser

west carbon
#

but when i visit other platform i see it but anyways i did this

'line_items' => [
                [
                    'price' => [
                        'id' => $plan->stripe_price_id,
                        'currency' => "usd",
                        // 'unit_amount' => $plan->price->getAmount(),
                        'recurring' => [
                            'interval' => $latestMonthlyPlan->abbreviation
                        ],
                    ],
``` but i get this error ```Invalid string: {:recurring=>{:interval=>"month"}, :id=>"price_1NhzWYRPCk44sUIFp1otPaVA", :currency=>"usd"}```
eternal drift
#

Did you check the other platform on the same device in the same browser? I can see GPay on your same Checkout Session so it should be visible if you have the proper setup on this device

west carbon
#

how about the other question??

eternal drift
#

Unsure about the invalid string, that looks to be a local php error, not one that Stripe is throwing

#

Can you try changing or removing each of those parameters to see if one makes the error go away?

west carbon
#

i have done that but i still get that same error unsure why

#

??

obsidian grove
#

Hi 👋

I'm taking over as @eternal drift has to go.

#

Can you set your line_items to their own variable and log them before attempting to create the Checkout Session?

west carbon
#

i did that

                [
                    'price' => [
                        'id' => $plan->stripe_price_id,
                        'currency' => "usd",
                        // 'unit_amount' => $plan->price->getAmount(),
                        'recurring' => [
                            'interval' => $latestMonthlyPlan->abbreviation
                        ],
                    ],```
#

Invalid string: {:recurring=>{:interval=>"month"}, :id=>"price_1NhzWYRPCk44sUIFp1otPaVA", :currency=>"usd"}

obsidian grove
#

Is that separate from when you are creating a Checkout Session? What is the full code for creating the session?

west carbon
#

hold on let me send now

#
            'payment_method_types' => ['card'],


            'mode' => 'subscription',
            'line_items' => [
                [

                    'price' => [
                        'id' => $plan->stripe_price_id,
                        'currency' => 'usd',
                        'unit_amount' => $plan->price->getAmount(),
                        'recurring' => [
                            'interval' => $latestMonthlyPlan->abbreviation
                        ],
                    ],

                    'quantity' => 1,
                ],
            ],
            'subscription_data' => [
                'application_fee_percent' => 10,
                'metadata' => [
                    'post_id' => $latestPost->id,
                    'user_id' => $blog->user->id,
                    'user_email' => $blog->user->email,
                    'name' => $plan->abbreviation,
                    'reader_id' => Auth::user()->id,
                    'price_id' => $plan->stripe_price_id,
                    'product_id' => $plan->stripe_product_id,
                ]
            ],

            'client_reference_id' => Auth::user()->id,
            'success_url' => route('blog.checkout.success', ['blog' => $blog->name, 'plan' => $plan->slug]),
            'cancel_url' => route('blog.post.show', [$blog->name, 'post' => $latestPost->slug]),
            'metadata' => [
                'post_id' => $latestPost->id,
                'user_id' => Auth::user()->id,
                'name' => $plan->abbreviation
            ],
            'customer_email' => Auth::user()->email,
        ], [
            'stripe_account' => $stripeAccount,
        ]);```
obsidian grove
#

Okay so you are not doing what I said

#

I asked you to set the line items as their own variable and print them out before you attempt to create a Checkout Session

#

Like

$line_items = [....]
west carbon
#

oh my bad

 $line_items = [
            [

                'price' => [
                    'id' => $plan->stripe_price_id,
                    'currency' => 'usd',
                    'unit_amount' => 1000,
                    'recurring' => [
                        'interval' => $latestMonthlyPlan->abbreviation
                    ],
                ],

                'quantity' => 1,
            ],
        ];
        dd($line_items);
``` and

array:1 [▼ // app/Http/Controllers/Blog/Post/PostController.php:153
0 => array:2 [▼
"price" => array:4 [▼
"id" => "price_1NhzWYRPCk44sUIFp1otPaVA"
"currency" => "usd"
"unit_amount" => 1000
"recurring" => array:1 [▼
"interval" => "month"
]
]
"quantity" => 1
]
]

obsidian grove
#

If you have the price ID you don't need to rest of that information

west carbon
#

Oh mate that works, didn't know why i was confused really lol

#

Cheers