-
Notifications
You must be signed in to change notification settings - Fork 682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying to get property 'payment_intent' of non-object #958
Comments
I can't seem to replicate this with the following test (which passes for me): public function test_no_prorate_on_subscription_create()
{
$user = $this->createCustomer('no_prorate_on_subscription_create');
$subscription = $user->newSubscription('main', static::$planId)->noProrate()->create('pm_card_visa');
$this->assertEquals(static::$planId, $subscription->stripe_plan);
} We'll need some more info here why the error is triggered. Afaik there's always a latest invoice. Please share the exact code needed to recreate this as well as how you've set up your subscription and prices. |
I'm using the following code to create the subscription:
Afterwards i'm trying to swap the subscription like so:
Both plans are a standard yearly pricing configuration. Edit: If im correct, your test is not about swapping but creating the initial subscription. There is no invoice in Stripe after creating the newSubscription for a newly created client/user. |
Ah okay, you said:
So I tested that and that wasn't the case (there was one). I'll try again with the info from above. |
I get:
So we'll need even more info on how exactly you set up the plans. Please share all the data you used to set them up. |
Think I cracked it: #959 Thanks for reporting! |
I've tried the code in my situation and it indeed works! Thanks for the quick response and i'll wait for it to be merged! :) |
I've just continued my developing and saw another issue with the solution. There is still an error when using:
Edit: The app/StripeSubscription.php is a temporary overwrite for testing. It uses your solution from Laravel\Cashier\Subscription |
I'm guessing the old check isn't wrong and should be combined with the new check. As there is a last invoice when using the always_invoice method. But this one does not have a payment_intent yet.
|
I think a lot of the problems that are surfacing here is because of Stripe's new "collection_method: send_invoice" method which we don't officially support yet. But it's good that we're tackling these now. I've sent a support question to Stripe to ask about this particular case because it's weird to me that the invoice after this scenario is in "draft" and that the subscription is "past due". |
Gonna re-open this until Stripe has gotten back to me. |
Just pasting in here the failing test for this for future reference: /** @group NoProrate */
public function test_always_invoice_after_no_prorate()
{
$user = $this->createCustomer('always_invoice_after_no_prorate');
$subscription = $user->newSubscription('main', static::$planId)->noProrate()->create('pm_card_visa', [], [
'collection_method' => 'send_invoice',
'days_until_due' => 30,
'backdate_start_date' => Carbon::now()->addDays(5)->subYear()->startOfDay()->unix(),
'billing_cycle_anchor' => Carbon::now()->addDays(5)->startOfDay()->unix(),
]);
$this->assertEquals(static::$planId, $subscription->stripe_plan);
$this->assertTrue($subscription->active());
$subscription = $subscription->swapAndInvoice(self::$otherPlanId);
$this->assertEquals(static::$otherPlanId, $subscription->stripe_plan);
$this->assertTrue($subscription->active());
} |
Stripe confirmed the behavior is a bug. Moved this to "needs more info" until Stripe has gotten back to me with a fix. |
Stripe has fixed the above behavior now. I've added a new test to cover this scenario: 3347f93 Basically it boils down that any invoicing is delayed because of the draft invoice from the beginning of the subscription. |
Description:
When swapping a subscription without a latest_invoice the swap errors. When creating a subscription with proration_behavior => none there is no first invoice.
Steps To Reproduce:
Looks like the solution would be to alter the if statement to:
The text was updated successfully, but these errors were encountered: