VoidClient.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License").
  6. * You may not use this file except in compliance with the License.
  7. * A copy of the License is located at
  8. *
  9. * http://aws.amazon.com/apache2.0
  10. *
  11. * or in the "license" file accompanying this file. This file is distributed
  12. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  13. * express or implied. See the License for the specific language governing
  14. * permissions and limitations under the License.
  15. */
  16. namespace Amazon\Payment\Gateway\Http\Client;
  17. /**
  18. * Class VoidClient
  19. * Amazon Pay client for gateway cancel and void
  20. */
  21. class VoidClient extends AbstractClient
  22. {
  23. /**
  24. * @inheritdoc
  25. */
  26. protected function process(array $data)
  27. {
  28. $store_id = $data['store_id'];
  29. unset($data['store_id']);
  30. $response = [
  31. 'status' => false
  32. ];
  33. $client = $this->clientFactory->create($store_id);
  34. $responseParser = $client->cancelOrderReference($data);
  35. if ($responseParser->response['Status'] == 200) {
  36. // Gateway expects response to be in form of array
  37. $response['status'] = true;
  38. } else {
  39. $log['error'] = __('VoidClient - Unable to Close/Cancel order - bad status response.');
  40. $this->logger->debug($log);
  41. }
  42. return $response;
  43. }
  44. }