<?php
namespace extend\wechatpay;

require_once APP_PATH . "extends/wechatpay/lib/WxPay.Api.php";
require_once APP_PATH . 'extends/wechatpay/example/WxPay.NativePay.php';
class Wxpay
{
    /**
     * @description: 
     * @param {*} $param username,money,order_no
     * @return {*}
     */    
    public function pay($param) {
        $notify = new \NativePay();
        $input = new \WxPayUnifiedOrder();
        $input->SetBody("购买软路由-".$param['username']);
        $input->SetOut_trade_no($param['order_no']);
        $input->SetTotal_fee($param['money']);
        $input->SetTime_start(date("YmdHis"));
        $input->SetTime_expire(date("YmdHis", time() + 600));
        $input->SetNotify_url("https://php-api.juip.com/common/wxpay/wxpayverify");
        $input->SetTrade_type("NATIVE");
        
        $result = $notify->GetPayUrl($input);
        
        $url2 = $result["code_url"];
        return $url2;
    }
    
    public function http_pay($param) {
        $notify = new \NativePay();
        $input = new \WxPayUnifiedOrder();
        $input->SetBody("HTTP充值");
        $input->SetOut_trade_no($param['order_no']);
        $input->SetTotal_fee($param['money']);
        $input->SetTime_start(date("YmdHis"));
        $input->SetTime_expire(date("YmdHis", time() + 600));
        $input->SetNotify_url("https://php-api.juip.com/common/wxpay/httpwxpayverify");
        $input->SetTrade_type("NATIVE");
        
        $result = $notify->GetPayUrl($input);
        
        $url2 = $result["code_url"];
        return $url2;
    }
    
    public function jinyou_pay($param) {
        $notify = new \NativePay();
        $input = new \WxPayUnifiedOrder();
        $input->SetBody("购买水滴");
        $input->SetOut_trade_no($param['order_no']);
        $input->SetTotal_fee($param['money']);
        $input->SetTime_start(date("YmdHis"));
        $input->SetTime_expire(date("YmdHis", time() + 600));
        $input->SetNotify_url("https://php-api.juip.com/common/wxpay/jinyouwxpayverify");
        $input->SetTrade_type("NATIVE");
        
        $result = $notify->GetPayUrl($input);
        
        $url2 = $result["code_url"];
        return $url2;
    }
    
    public function jinqiao_pay($param) {
        $notify = new \NativePay();
        $input = new \WxPayUnifiedOrder();
        $input->SetBody("购买金桥投屏");
        $input->SetOut_trade_no($param['order_no']);
        $input->SetTotal_fee($param['money']);
        $input->SetTime_start(date("YmdHis"));
        $input->SetTime_expire(date("YmdHis", time() + 600));
        $input->SetNotify_url("https://php-api.juip.com/common/wxpay/jinqiaowxpayverify");
        $input->SetTrade_type("NATIVE");
        
        $result = $notify->GetPayUrl($input);
        
        $url2 = $result["code_url"];
        return $url2;
    }
}
