GetPaymentMethods.js 825 B

1234567891011121314151617181920212223242526272829
  1. const API = require("../../lib/API")
  2. const { BaseStdResponse } = require("../../BaseStdResponse")
  3. const { getPaymentMethods } = require("../../lib/OrderPayment")
  4. class GetPaymentMethods extends API {
  5. constructor() {
  6. super()
  7. this.setPath('/Order/PaymentMethods')
  8. this.setMethod('GET')
  9. }
  10. async onRequest(req, res) {
  11. try {
  12. const methods = await getPaymentMethods()
  13. return res.json({
  14. ...BaseStdResponse.OK,
  15. data: methods
  16. })
  17. } catch (error) {
  18. this.logger.error(`获取支付方式失败:${error.stack || error}`)
  19. return res.json({
  20. ...BaseStdResponse.OK,
  21. data: []
  22. })
  23. }
  24. }
  25. }
  26. module.exports.GetPaymentMethods = GetPaymentMethods