Skip to content

Commit

Permalink
use post instead of get as webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Jul 16, 2023
1 parent 5f6073b commit c740a33
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/Installation/NewInstallation.php
Expand Up @@ -1690,7 +1690,7 @@ private static function getOperations(): array
),
'payment.webhook' => new Operation(
action: System\Action\Payment\Webhook::class,
httpMethod: 'GET',
httpMethod: 'POST',
httpPath: '/payment/:provider/webhook',
httpCode: 200,
outgoing: Model\Common\Message::class,
Expand Down
37 changes: 15 additions & 22 deletions tests/System/Api/Payment/WebhookTest.php
Expand Up @@ -39,29 +39,22 @@ public function getDataSet(): array

public function testGet()
{
$response = $this->sendRequest('/system/payment/paypal/webhook', 'GET', array(
'User-Agent' => 'Fusio TestCase',
));
$response = $this->sendRequest('/system/payment/paypal/webhook', 'GET', [
'User-Agent' => 'Fusio TestCase',
]);

$body = (string) $response->getBody();
$expect = <<<'JSON'
{
"success": true,
"message": "Execution successful"
}
JSON;
$body = (string) $response->getBody();

$this->assertEquals(200, $response->getStatusCode(), $body);
$this->assertJsonStringEqualsJsonString($expect, $body, $body);
$this->assertEquals(404, $response->getStatusCode(), $body);
}

public function testPost()
{
$response = $this->sendRequest('/system/payment/paypal/webhook', 'GET', array(
'User-Agent' => 'Fusio TestCase',
));
$response = $this->sendRequest('/system/payment/paypal/webhook', 'POST', [
'User-Agent' => 'Fusio TestCase',
]);

$body = (string) $response->getBody();
$body = (string) $response->getBody();
$expect = <<<'JSON'
{
"success": true,
Expand All @@ -75,9 +68,9 @@ public function testPost()

public function testPut()
{
$response = $this->sendRequest('/system/payment/paypal/webhook', 'PUT', array(
'User-Agent' => 'Fusio TestCase',
), json_encode([
$response = $this->sendRequest('/system/payment/paypal/webhook', 'PUT', [
'User-Agent' => 'Fusio TestCase',
], json_encode([
'foo' => 'bar',
]));

Expand All @@ -88,9 +81,9 @@ public function testPut()

public function testDelete()
{
$response = $this->sendRequest('/system/payment/paypal/webhook', 'DELETE', array(
'User-Agent' => 'Fusio TestCase',
));
$response = $this->sendRequest('/system/payment/paypal/webhook', 'DELETE', [
'User-Agent' => 'Fusio TestCase',
]);

$body = (string) $response->getBody();

Expand Down

0 comments on commit c740a33

Please sign in to comment.