Service.php 1.14 KB
<?php

/**
 * Created by PhpStorm.
 * User: Ziy
 * Date: 14/9/2
 * Time: 下午2:19
 */
class YOHOPay_Package_Alipay_Service extends YOHOPay_Package_Abstract
{
    public function notify(array $notifyData)
    {
        $alipay_config = array();
        require_once(__DIR__ . "/Sdk/alipay.config.php");
        require_once(__DIR__ . "/Sdk/lib/alipay_notify.class.php");
        //计算得出通知验证结果
        $config = new YOHOPay_Package_Alipay_Config();
        $alipay_config['partner'] = $config->partnerID;

        $alipayNotify = new AlipayNotify($alipay_config);
        $verify_result = $alipayNotify->verifyNotify();

        if ($verify_result) {
            if ($_POST['trade_status'] == 'TRADE_FINISHED') {

            } else if ($_POST['trade_status'] == 'TRADE_SUCCESS') {
                if (empty($notifyData['out_trade_no']) || empty($notifyData['total_fee'])) {
                    return 'fail';
                }
                $response = $this->makeResponseParameters($notifyData);
                $this->orderNotify($response);
            }
            return "success";
        } else {
            return "fail";
        }
    }
}