Skip to content
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

Add support for inline price data #1235

Merged
merged 4 commits into from
Aug 13, 2021

Conversation

josiasmontag
Copy link
Contributor

Stripe allows to create subscriptions and invoices without creating a price object via the dashboard beforehand. This is useful in cases where you want to create very individual subscriptions or invoices.

This PR adds the possibility to subscribe, swap and invoice with custom price_data:

// Create Subscription

$user->newSubscription('main')->price([
    'price_data' => [
        'product'      => $productId,
        'tax_behavior' => 'exclusive',
        'currency'     => 'USD',
        'recurring'    => [
            'interval' => 'month',
        ],
        'unit_amount'  => 1100
    ]
])
    ->create('pm_card_visa');
// Create Invoice

$user->invoiceFor('Laravel T-shirt', 599, [
    'price_data' => [
        'product'      => $productId,
        'tax_behavior' => 'exclusive'
    ]
]);
// Swap Subscription

$subscription->swap([
    [
        'price_data' => [
            'product'      => $productId,
            'tax_behavior' => 'exclusive',
            'currency'     => 'USD',
            'recurring'    => [
                'interval' => 'month',
            ],
            'unit_amount'  => 1100
        ]
    ]
]);

This also fixes one-off charges when automatic tax is enabled (#1204)

@josiasmontag josiasmontag marked this pull request as ready for review August 12, 2021 15:09
Copy link
Member

@driesvints driesvints left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the great PR @josiasmontag 👍

@taylorotwell taylorotwell merged commit 884ccd9 into laravel:13.x Aug 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants