阿里支付同时签约

//支付同时签约
public function Agreepay(Request $request){
    $config=config('pay.alipay');
    $privateKey = $config['private_key'];
    $alipayPublicKey = $config['ali_public_key'];
    [$order_no,$paytype] = $request->getMore([
        ['order_no', ''],
        ['paytype', 'alipay'],
    ],true);

    if (empty($order_no)) {
        return  app('json')->fail('订单号无效');
    }
    $services = app()->make(\mp\services\MealServices::class);
    $order=$services->getOrder($order_no);
    $payprice=$order['payprice'];

    $meal=MealModel::where(['id'=>$order['meal_id']])->find();
    $days=3650;
    if($meal['type']==10){
        $days=30;
    }else if($meal['type']==30){
        $days=365;
    }
    else if($meal['type']==20){
        $days=90;
    }
    $aop = new \AopClient();
    $aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
    $aop->appId = $config['app_id'];
    $aop->rsaPrivateKey = $privateKey;
    $aop->alipayrsaPublicKey=$alipayPublicKey;
    $aop->apiVersion = '1.0';
    $aop->signType = 'RSA2';
    $aop->postCharset='GBK';
    $aop->format='json';
    $object = new \stdClass();
    $object->out_trade_no = $order_no;
    $object->total_amount =$payprice ;
    $object->subject = $meal['name'];
    $object->product_code ='CYCLE_PAY_AUTH';
    $agreementParams = new \stdClass();
    $agreementParams->personal_product_code='CYCLE_PAY_AUTH_P';
    //$agreementParams->external_agreement_no='U91753-220330-7328';
    //$agreementParams->sign_scene='INDUSTRY|DIGITAL_MEDIA';

$agreementParams->external_logon_id=$order['uid'].'_'.$order['meal_id'];
$agreementParams->access_params=new \stdClass();
$agreementParams->access_params->channel='ALIPAYAPP';
$agreementParams->period_rule_params=new \stdClass();
$agreementParams->period_rule_params->period_type='DAY';
$agreementParams->period_rule_params->period=$days;
$agreementParams->period_rule_params->execute_time=date('Y-m-d',strtotime("$days day"));
$agreementParams->period_rule_params->single_amount=$payprice;
$agreementParams->sign_notify_url='https://zxqm.jubaovip.com/mp.php/xiaomi/Aliplanpay/alipayagrnotify';//签约回调
$object->agreement_sign_params=$agreementParams;


$json = json_encode($object);
$request = new \AlipayTradeAppPayRequest();
$request->setNotifyUrl('https://zxqm.jubaovip.com/mp.php/xiaomi/Meal/alipaynotify');
$request->setBizContent($json);

$result = $aop->sdkExecute($request);
$data['data']=$result;
$data['status']=200;
return json_encode($data);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值