Hang on whilst I channel my programming superpowers.......
Getting invalid_request_error
Hello, When creating a new subscription I'm getting this error with message "Received unknown parameters: object, card, client_ip, created, livemode, type, used". When looking at the Stripe dashboard, I see that the customer is created but without credit card or subscription.
@Snapey taking a while to find a phone booth.
@mikoo In other words, show your code. We don't know what you're actually doing by your basic explanation. Are you using the strip sdk directly or using Cashier or ???? Show some code and explain things better so we can focus on where to actually help.
I think a customer has to be created prior to the subscription. https://stripe.com/docs/billing/quickstart#create-customer
If you are new to stripe here is a guide, not laravel but can adjust as needed: https://daveismyname.blog/getting-stripe-api-setup-with-nova-framework
And here are more stripe tutorials: https://daveismyname.blog/categories/nova-framework
And https://daveismyname.blog/stripe-api-subscribing-new-and-existing-stripe-customers
These may or may not help, but hope they help.
i am using cashier and also contacted support at stripe. i don't really know what to show you it's pretty straightforward and like on laravel website normally works but in this case i used a different model for billing maybe that is why but i changed configs to take the new model instead.
customer gets created in the stripe website but no credit card added or subscriptionn
Problem lies in following function from laravel
public function updateCard($token)
{
$customer = $this->asStripeCustomer();
// the below error breaks app
$token = StripeToken::retrieve($token, ['api_key' => $this->getStripeKey()]);
// If the given token already has the card as their default source, we can just
// bail out of the method now. We don't need to keep adding the same card to
// a model's account every time we go through this particular method call.
if ($token[$token->type]->id === $customer->default_source) {
return;
}
//
$card = $customer->sources->create(['source' => $token]);
$customer->default_source = $card->id;
$customer->save();
// Next we will get the default source for this model so we can update the last
// four digits and the card brand on the record in the database. This allows
// us to display the information on the front-end when updating the cards.
$source = $customer->default_source
? $customer->sources->retrieve($customer->default_source)
: null;
$this->fillCardDetails($source);
$this->save();
}
I was getting this same error and believe that I've solved it.
Laravel's documentation is a bit lacking regarding how to obtain a Stripe Token. If you follow the Stripe Elements Quickstart, then you probably get a token via the stripe.createToken(card) function.
I made the mistake of submitting this result to the server as the 'token' field. It even made it past basic Laravel validation ( ex required|max:255).
I then got an error message similar to the OP's
The problem is that the stripe.createToken function returns an object, not a string. This object includes all sorts of extra data. As far as Cashier is concerned, you just need the token id.
So again, make sure that your javascript is getting the token.id (not the whole token object) and using this when Cashier calls for the $stripeToken
Please or to participate in this conversation.