Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/PaymentsStripeTest.php
Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | public function testMandates(): void | ||||
// Test creating a mandate (valid input) | // Test creating a mandate (valid input) | ||||
$post = ['amount' => 20.10, 'balance' => 0]; | $post = ['amount' => 20.10, 'balance' => 0]; | ||||
$response = $this->actingAs($user)->post("api/v4/payments/mandate", $post); | $response = $this->actingAs($user)->post("api/v4/payments/mandate", $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->assertMatchesRegularExpression('|^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(\config('app.name') . " 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); | ||||
▲ Show 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | public function testStoreAndWebhook(): void | ||||
// Successful payment | // Successful payment | ||||
$post = ['amount' => '12.34', 'currency' => 'CHF', 'methodId' => 'creditcard']; | $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->assertMatchesRegularExpression('|^cs_test_|', $json['id']); | ||||
$wallet = $user->wallets()->first(); | $wallet = $user->wallets()->first(); | ||||
$payments = Payment::where('wallet_id', $wallet->id)->get(); | $payments = Payment::where('wallet_id', $wallet->id)->get(); | ||||
$this->assertCount(1, $payments); | $this->assertCount(1, $payments); | ||||
$payment = $payments[0]; | $payment = $payments[0]; | ||||
$this->assertSame(1234, $payment->amount); | $this->assertSame(1234, $payment->amount); | ||||
$this->assertSame(\config('app.name') . ' Payment', $payment->description); | $this->assertSame(\config('app.name') . ' Payment', $payment->description); | ||||
▲ Show 20 Lines • Show All 412 Lines • Show Last 20 Lines |