Migrate billing from Paddle to Lemon Squeezy
This commit is contained in:
@@ -58,7 +58,7 @@ class CheckoutSessionStatusTest extends TestCase
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_session_status_recovers_completed_paddle_transaction(): void
|
||||
public function test_session_status_recovers_completed_lemonsqueezy_order(): void
|
||||
{
|
||||
$tenant = Tenant::factory()->create();
|
||||
$user = User::factory()->for($tenant)->create([
|
||||
@@ -74,34 +74,34 @@ class CheckoutSessionStatusTest extends TestCase
|
||||
$session = $sessions->createOrResume($user, $package, [
|
||||
'tenant' => $tenant,
|
||||
]);
|
||||
$sessions->selectProvider($session, CheckoutSession::PROVIDER_PADDLE);
|
||||
$sessions->selectProvider($session, CheckoutSession::PROVIDER_LEMONSQUEEZY);
|
||||
$session->forceFill([
|
||||
'provider_metadata' => [
|
||||
'paddle_checkout_id' => 'chk_123',
|
||||
'lemonsqueezy_checkout_id' => 'chk_123',
|
||||
],
|
||||
])->save();
|
||||
|
||||
config()->set([
|
||||
'paddle.api_key' => 'test-key',
|
||||
'paddle.base_url' => 'https://paddle.test',
|
||||
'paddle.environment' => 'sandbox',
|
||||
'lemonsqueezy.api_key' => 'test-key',
|
||||
'lemonsqueezy.base_url' => 'https://lemonsqueezy.test',
|
||||
]);
|
||||
|
||||
Http::fake([
|
||||
'https://paddle.test/*' => Http::response([
|
||||
'https://lemonsqueezy.test/checkouts/chk_123' => Http::response([
|
||||
'data' => [
|
||||
[
|
||||
'id' => 'txn_123',
|
||||
'status' => 'completed',
|
||||
'details' => [
|
||||
'totals' => [
|
||||
'currency_code' => 'EUR',
|
||||
'total' => ['amount' => 9900],
|
||||
],
|
||||
],
|
||||
'custom_data' => [
|
||||
'checkout_session_id' => $session->id,
|
||||
],
|
||||
'id' => 'chk_123',
|
||||
'attributes' => [
|
||||
'order_id' => 'ord_123',
|
||||
],
|
||||
],
|
||||
], 200),
|
||||
'https://lemonsqueezy.test/orders/ord_123' => Http::response([
|
||||
'data' => [
|
||||
'id' => 'ord_123',
|
||||
'attributes' => [
|
||||
'status' => 'paid',
|
||||
'currency' => 'EUR',
|
||||
'total' => 9900,
|
||||
],
|
||||
],
|
||||
], 200),
|
||||
@@ -128,7 +128,7 @@ class CheckoutSessionStatusTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_session_confirm_recovers_completed_paddle_transaction(): void
|
||||
public function test_session_confirm_recovers_completed_lemonsqueezy_order(): void
|
||||
{
|
||||
$tenant = Tenant::factory()->create();
|
||||
$user = User::factory()->for($tenant)->create([
|
||||
@@ -144,27 +144,21 @@ class CheckoutSessionStatusTest extends TestCase
|
||||
$session = $sessions->createOrResume($user, $package, [
|
||||
'tenant' => $tenant,
|
||||
]);
|
||||
$sessions->selectProvider($session, CheckoutSession::PROVIDER_PADDLE);
|
||||
$sessions->selectProvider($session, CheckoutSession::PROVIDER_LEMONSQUEEZY);
|
||||
|
||||
config()->set([
|
||||
'paddle.api_key' => 'test-key',
|
||||
'paddle.base_url' => 'https://paddle.test',
|
||||
'paddle.environment' => 'sandbox',
|
||||
'lemonsqueezy.api_key' => 'test-key',
|
||||
'lemonsqueezy.base_url' => 'https://lemonsqueezy.test',
|
||||
]);
|
||||
|
||||
Http::fake([
|
||||
'https://paddle.test/transactions/txn_987' => Http::response([
|
||||
'https://lemonsqueezy.test/orders/ord_987' => Http::response([
|
||||
'data' => [
|
||||
'id' => 'txn_987',
|
||||
'status' => 'completed',
|
||||
'details' => [
|
||||
'totals' => [
|
||||
'currency_code' => 'EUR',
|
||||
'total' => ['amount' => 7900],
|
||||
],
|
||||
],
|
||||
'custom_data' => [
|
||||
'checkout_session_id' => $session->id,
|
||||
'id' => 'ord_987',
|
||||
'attributes' => [
|
||||
'status' => 'paid',
|
||||
'currency' => 'EUR',
|
||||
'total' => 7900,
|
||||
],
|
||||
],
|
||||
], 200),
|
||||
@@ -176,8 +170,8 @@ class CheckoutSessionStatusTest extends TestCase
|
||||
$this->actingAs($user);
|
||||
|
||||
$response = $this->postJson(route('checkout.session.confirm', $session), [
|
||||
'transaction_id' => 'txn_987',
|
||||
'checkout_id' => 'che_987',
|
||||
'order_id' => 'ord_987',
|
||||
'checkout_id' => 'chk_987',
|
||||
]);
|
||||
|
||||
$response->assertOk()
|
||||
|
||||
Reference in New Issue
Block a user