联系官方销售客服
1835022288
028-61286886
我想增加一个自定义支付方式
用户可以用金币来支付下载查看,看到金币类似于账户余额,就把余额支付代码复制了一份,重新命名修改为积分支付方式,然后在后台开启积分支付
在支付页面测试的时候,用户积分为0,可以提示积分不足,给用户充值,积分够了,点击购买,可以购买成功,但是用户的积分和余额均不扣除,求大佬帮忙看看,怎么实现购买后减去积分?
<?php /** * 支付接口配置 */ return [ 'name' => '积分支付', 'icon' => '<i class="icon iconfont icon-caifua"></i>', ];
notify_js.php <?php switch ($data['status']) { case 1: $return = ['code' => 1, 'msg' => dr_lang('已付款')]; break; case 0: $return = ['code' => 0, 'msg' => dr_lang('未付款')]; break; case 2: $return = ['code' => 0, 'msg' => dr_lang('支付中')]; break; case 3: $return = ['code' => 0, 'msg' => dr_lang('支付失败')]; break; }
pay.php <?php /** * 积分付款发起接口 */ // 判断用户权限 if (!$this->uid) { $return = dr_return_data(0, dr_lang('你还没有登录'), ['url' => \Phpcmf\Service::L('router')->member_url('login/index')]); } elseif ($data['type'] == 'recharge') { $return = dr_return_data(0, dr_lang('充值不能使用余额支付')); } elseif ($data['uid'] != $this->uid) { $return = dr_return_data(0, dr_lang('无权限操作')); } elseif ((float)\Phpcmf\Service::C()->member['score'] <= 0 ) { $return = dr_return_data(0, dr_lang('账户积分不足')); } elseif ((float)\Phpcmf\Service::C()->member['score'] - $data['value'] < 0) { $return = dr_return_data(0, dr_lang('账户可用积分不足')); } else { $rt = $this->paysuccess('fc-'.$id, ''); if (!$rt['code']) { $return = $rt; } else { dr_redirect(dr_url('api/pay/call', ['id'=>$id]));exit; } // 付款界面模板 $htmlfile = is_file(WEBPATH.'config/pay/score_pay.html') ? WEBPATH.'config/pay/score_pay.html' : ROOTPATH.'config/pay/score_pay.html'; $member = \Phpcmf\Service::C()->member; $url = \Phpcmf\Service::L('router')->member_url('paylog/show', ['id'=>$id]); }
setting.php <div class="form-group"> <label class="col-md-2 control-label">描述模板</label> <div class="col-md-9"> <p class="form-control-static"> ./config/pay/score_pay.html </p> </div> </div> <div class="form-group"> <label class="col-md-2 control-label">付款流程</label> <div class="col-md-9"> <p class="form-control-static"> 使用积分支付</p> </div> </div>
score_pay.html <form action="/index.php?s=member&c=pay" class="form-horizontal" method="post" name="myform" id="payform"> {dr_form_hidden()} <input type="hidden" name="pay[url]" value="{$html.url}" /> <input type="hidden" name="pay[mark]" value="{$html.mark}" /> <input type="hidden" name="pay[title]" value="{$html.title}" /> <div class="form-body form"> <div class="form-group"> <label class="col-md-3 control-label">支付积分</label> <div class="col-md-2"> <input type="hidden" value="{$html.pay_value}" name="pay[money]"> <p class="form-control-static fc-price-color"> <i class="fa fa-rmb"></i> {number_format($html.pay_value, 2)} 元</p> </div> </div> <div class="form-group"> <label class="col-md-3 control-label">积分余额</label> <div class="col-md-2"> <p class="form-control-static fc-price-color"> <i class="fa fa-rmb"></i> {number_format($member.score, 2)} 元</p> </div> </div> <div class="form-group"> <label class="col-md-3 control-label" style="padding-top:10px">付款方式</label> <div class="col-md-5"> <div class="btn-group" data-toggle="buttons"> {loop $html.pay_type $name $t} <label style="border-radius:0" onclick="dr_select_paytype('{$name}')" class="btn btn-lg btn-default {if $name == $html.pay_default}active{/if}"> <input type="radio" class="toggle"> {$t['icon']} {$t['name']} </label> {/loop} <input type="hidden" name="pay[type]" value="{$html.pay_default}" id="dr_payselect"> </div> </div> </div> <div class="form-actions fc-form-actions"> <label class="col-md-3 control-label"> </label> <div class="col-md-9 fc-form-submit"> <button type="submit" class="btn btn-lg green"> 确认付款 </button> </div> </div> </div> </form>
大佬们帮忙瞅瞅怎么支付后减去用户积分,谢谢了