OmgPaymentMethod.java 1001 B

1234567891011121314151617181920212223242526272829303132333435
  1. package com.ruoyi.app.omgpay;
  2. /** Maps the App payment-method allowlist to one OMG hosted payment channel. */
  3. public enum OmgPaymentMethod {
  4. CREDIT("Credit", true),
  5. APPLE_PAY("ApplePay", false);
  6. private final String choosePayment;
  7. private final boolean unionPayDisabled;
  8. OmgPaymentMethod(String choosePayment, boolean unionPayDisabled) {
  9. this.choosePayment = choosePayment;
  10. this.unionPayDisabled = unionPayDisabled;
  11. }
  12. public String getChoosePayment() {
  13. return choosePayment;
  14. }
  15. public boolean isUnionPayDisabled() {
  16. return unionPayDisabled;
  17. }
  18. public static OmgPaymentMethod require(String value) {
  19. try {
  20. return value == null ? invalid() : valueOf(value);
  21. } catch (IllegalArgumentException error) {
  22. return invalid();
  23. }
  24. }
  25. private static OmgPaymentMethod invalid() {
  26. throw new OmgPaymentBusinessException(OmgPaymentErrorCode.PAYMENT_METHOD_INVALID);
  27. }
  28. }