index.js 959 B

1234567891011121314151617181920212223242526272829
  1. /**
  2. * 微信支付 - 申请退款
  3. */
  4. const cloud = require('wx-server-sdk');
  5. cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV });
  6. // 云函数入口函数
  7. exports.main = async (event, context) => {
  8. const res = await cloud.callFunction({
  9. name: 'cloudbase_module',
  10. data: {
  11. name: 'wxpay_refund',
  12. data: {
  13. // transaction_id: '1217752501201407033233368018', // 微信订单号
  14. // out_refund_no: '2024040118006666', // 商户内部退款单号
  15. // amount: {
  16. // refund: 1, // 退款金额
  17. // total: 1, // 原订单金额,
  18. // currency: 'CNY',
  19. // },
  20. transaction_id: event.transaction_id,
  21. out_trade_no: event.out_trade_no,
  22. out_refund_no: event.out_refund_no,
  23. amount: event.amount,
  24. },
  25. },
  26. });
  27. return res.result;
  28. };