Skip to content

Commit

Permalink
Limit used methods by status = activated
Browse files Browse the repository at this point in the history
  • Loading branch information
michielgerritsen committed Jul 11, 2024
1 parent 68d1f34 commit 281605f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions GraphQL/Resolver/General/MolliePaymentMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,17 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
];
}

public function getMethods(float $amount, ?string $currency, int $storeId): ?MethodCollection
private function getMethods(float $amount, ?string $currency, int $storeId): ?array
{
$mollieApiClient = $this->mollieApiClient->loadByStore($storeId);

if ($currency === null) {
return $mollieApiClient->methods->allAvailable();
$available = $mollieApiClient->methods->allAvailable();
$available = array_filter((array)$available, function (Method $method) use ($storeId) {
return $method->status == 'activated';
});

return $available;
}

$parameters = [
Expand All @@ -105,7 +110,7 @@ public function getMethods(float $amount, ?string $currency, int $storeId): ?Met
'includeWallets' => 'applepay',
];

return $mollieApiClient->methods->allActive(
return (array)$mollieApiClient->methods->allActive(
$this->methodParameters->enhance($parameters, $this->cartFactory->create())
);
}
Expand Down

0 comments on commit 281605f

Please sign in to comment.