admin管理员组

文章数量:1192764

I am trying to implement a subscription with Laravel Cashier and Stripe. I've created a product in my Stripe dashboard and cut and pasted the product id and price id into the newSubscription method. See code below. But every time I try and run it, it returns the error message "No such price: 'price_1Qkgr4Az8wYmHt8vp5njDBoF'" But that price exists. What's the problem and solution?

Route::get('/subscribe', function (Request $request) {
    return $request->user()
        ->newSubscription('prod_Rdyo9nUDWFaX3h', 'price_1Qkgr4Az8wYmHt8vp5njDBoF')
        ->checkout([
            'success_url' => route('subscribe-success'),
            'cancel_url' => route('subscribe-cancel'),
        ])->create($request->paymentMethodId);
})->name('subscribe');

I am trying to implement a subscription with Laravel Cashier and Stripe. I've created a product in my Stripe dashboard and cut and pasted the product id and price id into the newSubscription method. See code below. But every time I try and run it, it returns the error message "No such price: 'price_1Qkgr4Az8wYmHt8vp5njDBoF'" But that price exists. What's the problem and solution?

Route::get('/subscribe', function (Request $request) {
    return $request->user()
        ->newSubscription('prod_Rdyo9nUDWFaX3h', 'price_1Qkgr4Az8wYmHt8vp5njDBoF')
        ->checkout([
            'success_url' => route('subscribe-success'),
            'cancel_url' => route('subscribe-cancel'),
        ])->create($request->paymentMethodId);
})->name('subscribe');
Share Improve this question edited Jan 25 at 2:40 Andrew Koper asked Jan 24 at 7:39 Andrew KoperAndrew Koper 7,1998 gold badges44 silver badges53 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

In Stripe, you have three dashboards and environments: regular, sandbox and test mode. They each have their own API key and API secret_key. You've put one set of keys in your .ENV file but made your product in another other, so your application's request is going to an environment where the product and its price_id don't exist. Put the correct/matching API keys in your .ENV.

本文标签: phpNo such price 39price1Qkgr4Az8wYmHt8vp5njDBoF39Stack Overflow