- payment for subscription frontend

This commit is contained in:
Peter Papp
2021-03-23 11:12:41 +01:00
parent 97f13c0b62
commit 7521c588fc
9 changed files with 230 additions and 183 deletions
+24 -12
View File
@@ -36,17 +36,6 @@ class OasisSubscriptionTest extends TestCase
],
],
];
// Define test billing to subscribe
$this->billing = [
'billing_address' => '2794 Alfreda Mount Suite 467 East Crystalberg',
'billing_city' => 'Christianfort',
'billing_country' => 'SK',
'billing_name' => 'Heidi Romaguera PhD',
'billing_phone_number' => '+421',
'billing_postal_code' => '59445',
'billing_state' => 'SK',
];
}
/**
@@ -72,6 +61,25 @@ class OasisSubscriptionTest extends TestCase
]);
}
/**
* @test
*/
public function it_get_setup_intent()
{
$user = User::factory(User::class)
->create(['role' => 'user']);
$user
->subscriptionRequest()
->create([
'requested_plan' => 'virtualni-sanon-basic',
'creator' => 'john@doe.com',
]);
$this->getJson("/api/oasis/subscribe/{$user->subscriptionRequest->id}/setup-intent")
->assertStatus(201);
}
/**
* @test
*/
@@ -105,9 +113,9 @@ class OasisSubscriptionTest extends TestCase
$user->createOrGetStripeCustomer();
$this->postJson("/api/oasis/subscribe/{$user->subscriptionRequest->id}", [
'billing' => $this->billing,
'plan' => $this->plan,
'payment' => [
'type' => 'stripe',
'meta' => [
'pm' => $paymentMethod['id']
],
@@ -118,6 +126,10 @@ class OasisSubscriptionTest extends TestCase
'stripe_status' => 'active'
]);
$this->assertDatabaseHas('subscription_requests', [
'status' => 'payed'
]);
$this->assertDatabaseHas('user_settings', [
'storage_capacity' => 50,
'payment_activation' => 1,