AmazonConstraint.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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\Domain;
  17. class AmazonConstraint
  18. {
  19. const PAYMENT_METHOD_NOT_ALLOWED_ID = 'PaymentMethodNotAllowed';
  20. const PAYMENT_PLAN_NOT_SET_ID = 'PaymentPlanNotSet';
  21. /**
  22. * @var string
  23. */
  24. private $id;
  25. /**
  26. * @var string
  27. */
  28. private $description;
  29. /**
  30. * AmazonConstraint constructor.
  31. *
  32. * @param string $id
  33. * @param string $description
  34. */
  35. public function __construct($id, $description)
  36. {
  37. $this->id = $id;
  38. $this->description = $description;
  39. }
  40. /**
  41. * Get id
  42. *
  43. * @return string
  44. */
  45. public function getId()
  46. {
  47. return $this->id;
  48. }
  49. /**
  50. * Get description
  51. *
  52. * @return string
  53. */
  54. public function getDescription()
  55. {
  56. return $this->description;
  57. }
  58. public function getErrorMessage()
  59. {
  60. switch ($this->getId()) {
  61. case static::PAYMENT_METHOD_NOT_ALLOWED_ID:
  62. case static::PAYMENT_PLAN_NOT_SET_ID:
  63. return 'Please select a payment method.';
  64. default:
  65. return 'Amazon could not process your request.';
  66. }
  67. }
  68. }