Пример #1
0
 /**
  * Exception constructor
  *
  * @param string $code
  *            SLS error code.
  * @param string $message
  *            detailed information for the exception.
  * @param string $requestId
  *            the request id of the response, '' is set if client error.
  */
 public function __construct($code, $message, $requestId = '')
 {
     parent::__construct($message);
     $this->code = $code;
     $this->message = $message;
     $this->requestId = $requestId;
 }
Пример #2
0
 /**
  * @param \Exception $e
  */
 public static function report(\Exception $e)
 {
     $bugsnag = app('bugsnag');
     if (!$bugsnag instanceof \Bugsnag_Client) {
         return;
     }
     $metadata = null;
     if ($e instanceof BugSnagException && $e->willBeReported()) {
         $e = $e->getWillReport();
     }
     if ($e instanceof DontReportExceptionContract) {
         return;
     }
     if ($e instanceof BugSnagException) {
         if (!$e->willBeReported()) {
             return;
         }
         $metadata = $e->getExceptionMetaData();
         $metadata['app_version'] = DebugInfoServiceProvider::appVersion();
     }
     $bugsnag->notifyException($e, $metadata, "error");
 }
Пример #3
0
 /**
  * @param $out_trade_no string 交易号
  * @param $total_fee float 总金额
  * @param $subject string
  * @param null|string $trade_type
  * @param bool $redirect 是否重定向
  * @return Response|\Symfony\Component\HttpFoundation\StreamedResponse
  * @throws Exception
  */
 public function wechat_pay_url($out_trade_no, $total_fee, $subject, $trade_type = null, $redirect = false)
 {
     $config = Config::get('payments.wechat', array());
     if (is_null($trade_type) || WechatExpressGateway::Trade_Type_JSAPI === $trade_type) {
         //JS API方式支付
         //初始化wechat js api
         $jsApi = new \Omnipay\Wechat\Sdk\JsApi();
         $jsApi->init(array('app_id' => $config['app_id'], 'mch_id' => $config['mch_id'], 'app_secret' => $config['app_secret'], 'pay_sign_key' => $config['pay_sign_key'], 'cert_path' => $config['cert_path'], 'cert_key_path' => $config['cert_key_path']));
         //回调parameters,GET方式传给回调url
         $parameters = array('out_trade_no' => $out_trade_no, 'total_fee' => $total_fee, 'subject' => $subject);
         $r_link = url('pay/wechat/jsapi?' . http_build_query($parameters));
         $url = $jsApi->createOauthUrlForCode(urlencode($r_link));
         if (false == $redirect) {
             //造二维码
             $qrFactory = new QRFactory();
             return $qrFactory->make($url)->response();
         } else {
             return \Response::make('', 302, array('Location' => $url));
         }
     }
     if (WechatExpressGateway::Trade_Type_NATIVE === $trade_type) {
         //native方式
         $gateway = $this->wechat();
         $parameters = array('out_trade_no' => $out_trade_no, 'total_fee' => $total_fee, 'subject' => $subject, 'mch_id' => array_get($config, 'mch_id'), 'notify_url' => array_get($config, 'notify_url'));
         $result = $gateway->prePurchase($parameters, WechatExpressGateway::Trade_Type_NATIVE)->send();
         $result = $result->getTransactionReference();
         if (is_array($result) && array_get($result, 'return_code') === 'SUCCESS') {
             $url = array_get($result, 'code_url');
             if (false == $redirect) {
                 $qrFactory = new QRFactory();
                 return $qrFactory->make($url)->response();
             } else {
                 return \Response::make('', 302, array('Location' => $url));
             }
         } else {
             $e = new Exception();
             $e->setExceptionMetaData('wechat-qrcode-native-api-fail', $result);
             throw $e;
         }
     }
 }