微信卡券核销

1.引入JS文件

<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js "></script>


2.js配置

<script type="text/javascript">
wx.config({
     // debug: true,
        appId: '<?php echo $wxjs['appId']?>',
      timestamp: <?php echo $wxjs['timestamp']?>,
      nonceStr: '<?php echo $wxjs['nonceStr']?>',
      signature: '<?php echo $wxjs['signature']?>',
       jsApiList: [
        'pauseVoice',
        'chooseCard',
      ]
  });
  wx.error(function (res) {
  alert(res.errMsg);
});
  wx.ready(function(){
  });
</script>


3.拉起店铺可用卡券列表

<script type="text/javascript">
function doFind(){
  wx.chooseCard({
    shopId: '', // 门店Id
    cardType: '<?php echo $arr['card_type']?>', // 卡券类型
    cardId: '', // 卡券Id
    timestamp: '<?php echo $arr['time_stamp']?>', // 卡券签名时间戳
    nonceStr: '<?php echo $arr['nonceStr']?>', // 卡券签名随机串
    signType: 'SHA1', // 签名方式,默认'SHA1'
    cardSign: '<?php echo $arr['sign']?>', // 卡券签名
    success: function (res) {
        var cardList= res.cardList; // 用户选中的卡券列表信息
        $('#s').html(cardList);
    }
    
})
}

</script>

4.Code解码

http请求方式: POST
https://api.weixin.qq.com/card/code/decrypt?access_token=TOKEN

POST数据

{
  "encrypt_code":"XXIzTtMqCxwOaawoE91+VJdsFmv7b8g0VZIZkqf4GWA60Fzpc8ksZ/5ZZ0DVkXdE"
}

5.查询Code的有效应

http请求方式: POST
https://api.weixin.qq.com/card/code/consume?access_token=TOKEN

POST数据

非自定义Code卡券的请求
{
  "code": "12312313"
}
或自定义Code卡券的请求
{
  "code": "12312313",
  "card_id": "pFS7Fjg8kV1IdDz01r4SQwMkuCKc"
}

6.核销

接口调用请求说明

http请求方式: POST
https://api.weixin.qq.com/card/code/consume?access_token=TOKEN

POST数据

非自定义Code卡券的请求
{
  "code": "12312313"
}
或自定义Code卡券的请求
{
  "code": "12312313",
  "card_id": "pFS7Fjg8kV1IdDz01r4SQwMkuCKc"
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

淋过雨的街头

你的鼓励是我创作的做大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值