Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/PaymentsMollieTest.php
Show First 20 Lines • Show All 485 Lines • ▼ Show 20 Lines | public function testStoreAndWebhookForeignCurrency(): void | ||||
$post = ['amount' => '12.34', 'currency' => 'EUR', 'methodId' => 'banktransfer']; | $post = ['amount' => '12.34', 'currency' => 'EUR', 'methodId' => 'banktransfer']; | ||||
$response = $this->actingAs($user)->post("api/v4/payments", $post); | $response = $this->actingAs($user)->post("api/v4/payments", $post); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$payment = $wallet->payments() | $payment = $wallet->payments() | ||||
->where('currency', 'EUR')->get()->last(); | ->where('currency', 'EUR')->get()->last(); | ||||
$this->assertSame(1234, $payment->amount); | $this->assertSame(1234, $payment->amount); | ||||
$this->assertSame(1117, $payment->currency_amount); | $this->assertSame(1127, $payment->currency_amount); | ||||
$this->assertSame('EUR', $payment->currency); | $this->assertSame('EUR', $payment->currency); | ||||
$this->assertEquals(0, $wallet->balance); | $this->assertEquals(0, $wallet->balance); | ||||
$mollie_response = [ | $mollie_response = [ | ||||
"resource" => "payment", | "resource" => "payment", | ||||
"id" => $payment->id, | "id" => $payment->id, | ||||
"status" => "paid", | "status" => "paid", | ||||
// Status is not enough, paidAt is used to distinguish the state | // Status is not enough, paidAt is used to distinguish the state | ||||
▲ Show 20 Lines • Show All 420 Lines • ▼ Show 20 Lines | public function testRefundAndChargebackForeignCurrency(): void | ||||
$responseStack->append(new Response(200, [], json_encode($mollie_response2))); | $responseStack->append(new Response(200, [], json_encode($mollie_response2))); | ||||
$post = ['id' => $payment->id]; | $post = ['id' => $payment->id]; | ||||
$response = $this->post("api/webhooks/payment/mollie", $post); | $response = $this->post("api/webhooks/payment/mollie", $post); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$wallet->refresh(); | $wallet->refresh(); | ||||
$this->assertEquals(-112, $wallet->balance); | $this->assertTrue($wallet->balance <= -108); | ||||
$this->assertTrue($wallet->balance >= -114); | |||||
$payments = $wallet->payments()->where('id', 're_123456')->get(); | $payments = $wallet->payments()->where('id', 're_123456')->get(); | ||||
$this->assertCount(1, $payments); | $this->assertCount(1, $payments); | ||||
$this->assertSame(-112, $payments[0]->amount); | $this->assertTrue($payments[0]->amount <= -108); | ||||
$this->assertTrue($payments[0]->amount >= -114); | |||||
$this->assertSame(-101, $payments[0]->currency_amount); | $this->assertSame(-101, $payments[0]->currency_amount); | ||||
$this->assertSame('EUR', $payments[0]->currency); | $this->assertSame('EUR', $payments[0]->currency); | ||||
$this->unmockMollie(); | $this->unmockMollie(); | ||||
} | } | ||||
/** | /** | ||||
* Create Mollie's auto-payment mandate using our API and Chrome browser | * Create Mollie's auto-payment mandate using our API and Chrome browser | ||||
▲ Show 20 Lines • Show All 116 Lines • Show Last 20 Lines |