Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/PaymentsStripeTest.php
Show First 20 Lines • Show All 483 Lines • ▼ Show 20 Lines | class PaymentsStripeTest extends TestCase | ||||
/** | /** | ||||
* Test automatic payment charges | * Test automatic payment charges | ||||
* | * | ||||
* @group stripe | * @group stripe | ||||
*/ | */ | ||||
public function testTopUpAndWebhook(): void | public function testTopUpAndWebhook(): void | ||||
{ | { | ||||
$this->markTestIncomplete(); | |||||
Bus::fake(); | Bus::fake(); | ||||
$user = $this->getTestUser('john@kolab.org'); | $user = $this->getTestUser('john@kolab.org'); | ||||
$wallet = $user->wallets()->first(); | $wallet = $user->wallets()->first(); | ||||
// Stripe API does not allow us to create a mandate easily | // Stripe API does not allow us to create a mandate easily | ||||
// That's why we we'll mock API responses | // That's why we we'll mock API responses | ||||
// Create a fake mandate | // Create a fake mandate | ||||
Show All 34 Lines | public function testTopUpAndWebhook(): void | ||||
"description" => "Kolab Recurring Payment" | "description" => "Kolab Recurring Payment" | ||||
]); | ]); | ||||
$client = $this->mockStripe(); | $client = $this->mockStripe(); | ||||
$client->addResponse($setupIntent); | $client->addResponse($setupIntent); | ||||
$client->addResponse($paymentMethod); | $client->addResponse($paymentMethod); | ||||
$client->addResponse($setupIntent); | $client->addResponse($setupIntent); | ||||
$client->addResponse($paymentIntent); | $client->addResponse($paymentIntent); | ||||
$client->addResponse($setupIntent); | |||||
$client->addResponse($paymentMethod); | |||||
// Expect a recurring payment as we have a valid mandate at this point | // Expect a recurring payment as we have a valid mandate at this point | ||||
$result = PaymentsController::topUpWallet($wallet); | $result = PaymentsController::topUpWallet($wallet); | ||||
$this->assertTrue($result); | $this->assertTrue($result); | ||||
// Check that the payments table contains a new record with proper amount | // Check that the payments table contains a new record with proper amount | ||||
// There should be two records, one for the first payment and another for | // There should be two records, one for the first payment and another for | ||||
// the recurring payment | // the recurring payment | ||||
▲ Show 20 Lines • Show All 158 Lines • Show Last 20 Lines |