Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/PaymentsStripeTest.php
Show First 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | public function testMandates(): void | ||||
$this->assertSame('success', $json['status']); | $this->assertSame('success', $json['status']); | ||||
$this->assertRegExp('|^cs_test_|', $json['id']); | $this->assertRegExp('|^cs_test_|', $json['id']); | ||||
// Assert the proper payment amount has been used | // Assert the proper payment amount has been used | ||||
// Stripe in 'setup' mode does not allow to set the amount | // Stripe in 'setup' mode does not allow to set the amount | ||||
$payment = Payment::where('wallet_id', $wallet->id)->first(); | $payment = Payment::where('wallet_id', $wallet->id)->first(); | ||||
$this->assertSame(0, $payment->amount); | $this->assertSame(0, $payment->amount); | ||||
$this->assertSame("Kolab Now Auto-Payment Setup", $payment->description); | $this->assertSame(\config('app.name') . " Auto-Payment Setup", $payment->description); | ||||
$this->assertSame(PaymentProvider::TYPE_MANDATE, $payment->type); | $this->assertSame(PaymentProvider::TYPE_MANDATE, $payment->type); | ||||
// Test fetching the mandate information | // Test fetching the mandate information | ||||
$response = $this->actingAs($user)->get("api/v4/payments/mandate"); | $response = $this->actingAs($user)->get("api/v4/payments/mandate"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
▲ Show 20 Lines • Show All 154 Lines • ▼ Show 20 Lines | public function testStoreAndWebhook(): void | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertSame('error', $json['status']); | $this->assertSame('error', $json['status']); | ||||
$this->assertCount(1, $json['errors']); | $this->assertCount(1, $json['errors']); | ||||
$min = intval(PaymentProvider::MIN_AMOUNT / 100) . ' CHF'; | $min = intval(PaymentProvider::MIN_AMOUNT / 100) . ' CHF'; | ||||
$this->assertSame("Minimum amount for a single payment is {$min}.", $json['errors']['amount']); | $this->assertSame("Minimum amount for a single payment is {$min}.", $json['errors']['amount']); | ||||
$post = ['amount' => '12.34']; | |||||
// Invalid currency | |||||
$post = ['amount' => '12.34', 'currency' => 'FOO', 'methodId' => 'creditcard']; | |||||
$response = $this->actingAs($user)->post("api/v4/payments", $post); | |||||
$response->assertStatus(500); | |||||
// Successful payment | |||||
$post = ['amount' => '12.34', 'currency' => 'CHF', 'methodId' => 'creditcard']; | |||||
$response = $this->actingAs($user)->post("api/v4/payments", $post); | $response = $this->actingAs($user)->post("api/v4/payments", $post); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertSame('success', $json['status']); | $this->assertSame('success', $json['status']); | ||||
$this->assertRegExp('|^cs_test_|', $json['id']); | $this->assertRegExp('|^cs_test_|', $json['id']); | ||||
▲ Show 20 Lines • Show All 392 Lines • Show Last 20 Lines |