Skip to content

Commit

Permalink
Always return response as raw data
Browse files Browse the repository at this point in the history
  • Loading branch information
boboldehampsink committed Oct 17, 2023
1 parent 450f34a commit 03cb9b6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
'yoda_style' => false,
'no_superfluous_phpdoc_tags' => false,
'multiline_whitespace_before_semicolons' => false,
'global_namespace_import' => false,
'single_line_empty_body' => false,
])
->setCacheFile(__DIR__.'/.php_cs.cache')
->setFinder($finder);
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.1.3 - 2023-10-17

### Fixed
- Always return response as raw data

## 1.1.2 - 2022-09-22

### Changed
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "robuust/craft-commerce-pay",
"description": "PAY integration for Craft Commerce 4.0+",
"version": "1.1.2",
"version": "1.1.3",
"type": "craft-plugin",
"keywords": [
"pay",
Expand Down
7 changes: 4 additions & 3 deletions src/gateways/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,13 @@ public function supportsWebhooks(): bool
public function processWebHook(): Response
{
$response = Craft::$app->getResponse();
$response->format = Response::FORMAT_RAW;

$transactionHash = $this->getTransactionHashFromWebhook();
$transaction = Commerce::getInstance()->getTransactions()->getTransactionByHash($transactionHash);

if (!$transaction) {
Craft::warning('Transaction with the hash “' . $transactionHash . '“ not found.', 'commerce');
Craft::warning('Transaction with the hash “'.$transactionHash.'“ not found.', 'commerce');
$response->data = 'FALSE|Transaction not found';

return $response;
Expand All @@ -202,7 +203,7 @@ public function processWebHook(): Response
])->count();

if ($successfulPurchaseChildTransaction) {
Craft::warning('Successful child transaction for “' . $transactionHash . '“ already exists.', 'commerce');
Craft::warning('Successful child transaction for “'.$transactionHash.'“ already exists.', 'commerce');
$response->data = 'TRUE';

return $response;
Expand Down Expand Up @@ -402,6 +403,6 @@ protected function createGateway(): AbstractGateway
*/
protected function getGatewayClassName(): ?string
{
return '\\' . OmnipayGateway::class;
return '\\'.OmnipayGateway::class;
}
}

0 comments on commit 03cb9b6

Please sign in to comment.