PHP code example of wycto / pay

1. Go to this page and download the library: Download wycto/pay library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wycto / pay example snippets


use wycto\pay\PayFactory;
protected $_payconfig = array(
		'app_id'=>"2018062060400732",
		'private_key'=>"",//生成平台公钥的时候对应的私钥
		'apjs_src' => '/static/js/ap.js',
		'jump_url' => "http://www.wycto.cn",
		'return_url'=> 'http://www.wycto.cn',
		'notify_url'=> 'http://www.wycto.cn'
);

//支付宝支付
$out_trade_no = $order->number;     //你自己的商品订单号
$total_amount = $order->price;//付款金额,单位:元
$subject = $order->subject;    //订单标题

$this->config['return_url'] = 'http://' . $_SERVER['HTTP_HOST'] . url('wap::payment/return');
$this->config['notify_url'] = 'http://' . $_SERVER['HTTP_HOST'] . url('wap::payment/notify');
$this->config['jump_url'] = 'http://' . $_SERVER['HTTP_HOST'] . url('wap::payment/weixin');

//使用工厂类
$aliPay = PayFactory::getApp('alipay', $this->config)->gateway('weixin')->meta();//微信传参weixin,手机网站wap,电脑网站web
$aliPay->setSubject($subject);
$body = "全栈小子-" . $order->subject?$order->subject:"本次支付" . $order->price . "元";
$aliPay->setBody($body);
$aliPay->setTotalAmount($total_amount);
$aliPay->setOutTradeNo($out_trade_no);
$aliPay->Pay();

var_dump($_POST);
array(24) {
    gmt_create=>2018-08-04 15:55:09
	charset=>utf8,
	seller_email=>[email protected],
	subject=>支付测试,
	sign=>ePutXvBuc2gsFaTPVFUJOmOUuCGwylDcwITYirNI+nH7bW2biA9hfIGtU8hYy2w4uHwxC0qi9pXqoCzv4gKeB69vrQmgwyO0ZGCyBQUXHwYUSAxfH5fpTO/s993bRFO3jEODW9xb0pW+Zg1ycTtDTtrhMvL657iXJekrDyUpshEN5K+dHlNbGYkFiGDjEcQaSVqzTnwcxFWIxlMwGq+p1hMIqCZcxom1iCnHH/I4h7nwtW/9FBZ8eTP4u/sRJKU0KdWOR1CnHwP1QzvFvm0KdstitWW+Iam1NrdbiHYdqRmwSrAR3x89UdfqGFl3q9G79La7w11hxSZZUKxrxYo7Vg==,
	buyer_id=>2088802533010673,
	invoice_amount=>0.01,
	notify_id=>1ef231b418c5bd03a972c491da3bf6cl69,
	fund_bill_list=>[{"amount":"0.01","fundChannel":"ALIPAYACCOUNT"}],
	notify_type=>trade_status_sync,
	trade_status=>TRADE_SUCCESS,
	receipt_amount=>0.01,
	buyer_pay_amount=>0.01,
	app_id=>2018062060400732,
	sign_type=>RSA2,
	seller_id=>2088721870519422,
	gmt_payment=>2018-08-04 15:55:11,
	notify_time=>2018-08-04 15:55:11,
	version=>1.0,
	out_trade_no=>5b655bd759e66,
	total_amount=>0.01,
	trade_no=>2018080421001004670510094404,
	auth_app_id=>2018062060400732,
	buyer_logon_id=>294***@qq.com,
	point_amount=>0.00
}