Skip to content

payment_coupon_cash

thenbsp edited this page Mar 8, 2016 · 4 revisions

现金红包

use Thenbsp\Wechat\Payment\Coupon\Cash;

$cash = new Cash('appid', 'mch_id', 'key');

// 现金红包必需设置证书
$cahs->setSSLCert('your ssl cert file', 'your ssl key file');

// 设置红包信息
$cash->set('send_name',     '红包发送者名称');
$cash->set('act_name',      '活动名称');
$cash->set('remark',        '备注信息');
$cash->set('wishing',       '红包祝福语');
$cash->set('re_openid',     'openid');
$cash->set('total_amount',  100);
$cash->set('total_num',     1);
$cash->set('mch_billno',    date('YmdHis').mt_rand(10000, 99999));

try {
    $response = $cash->getResponse();
} catch (\Exception $e) {
    exit($e->getMessage());
}

// 发放结果
print_r($response->toArray());