public function confirm(Request $request) { $cart = $this->cartRepository->getCart(['cartItems.product']); $order = Order::find($request->get('id')); $gateway = \Omnipay::gateway('paypal'); $settings = $gateway->getDefaultParameters(); //dd($settings); $desc = ''; foreach ($cart->cartItems as $item) { $desc .= "> " . $item->product->title . "\r\n"; } $card = \Omnipay::creditCard($order->toArray()); $response = \Omnipay::purchase(['currency' => 'GBP', 'amount' => $order->total, 'returnUrl' => 'http://google.co.uk', 'cancelUrl' => 'http://google.co.uk', 'description' => $desc, 'transactionId' => $order->id, 'card' => $card])->send(); //dd($response); // $purchaseRequest = $this->omnipay->purchase($data); // // // Grab the parameters // $purchaseParameters = $purchaseRequest->getData(); // // // Add our additional parameters // $purchaseParameters['MC_paymentType'] = 'payment'; // // // Send off the request // $response = $purchaseRequest->sendData($purchaseParameters); // Check we got a redirect response if ($response->isRedirect()) { // If so redirect the user $response->redirect(); } else { // Broken data dd($response); throw new Exception(); } }
function doPaymnet() { $amount = 0; $return_url = ''; $cardInput = array('number' => Input::get('cc_number'), 'firstName' => Input::get('firstName'), 'lastName' => Input::get('lastName'), 'expiryMonth' => Input::get('expiryMonth'), 'expiryYear' => Input::get('expiryYear'), 'cvv' => Input::get('cvv')); $card = Omnipay::creditCard($cardInput); $response = Omnipay::purchase(['amount' => $amount, 'returnUrl' => $return_url, 'cancelUrl' => $cancel_url, 'card' => $cardInput]); }
public function testCallStatic() { $factory = m::mock('Omnipay\\Common\\GatewayFactory'); $factory->shouldReceive('testMethod')->with('some-argument')->once()->andReturn('some-result'); Omnipay::setFactory($factory); $result = Omnipay::testMethod('some-argument'); $this->assertSame('some-result', $result); }
public function getFields() { $paymentLibrary = $this->paymentlibrary; if ($paymentLibrary->id == PAYMENT_LIBRARY_OMNIPAY) { $fields = Omnipay::create($this->provider)->getDefaultParameters(); } else { $fields = Payment_Utility::load('config', 'drivers/' . strtolower($this->provider)); } if ($fields == null) { $fields = array(); } return $fields; }
/** * -------------------------------------------------------------- * 服务器端get响应 * -------------------------------------------------------------- * 返回成功提示,5秒后跳转到指定页面 */ public function respondGet($code = '') { if (empty($code)) { return false; } \Omnipay::setGateway($code); $resquest = \Omnipay::completePurchase(['request_params' => \Input::all()]); $response = $resquest->send(); if ($response->isSuccessful()) { //TODO //验证成功 //更新账户余额 //更新订单状态 } else { } if ($code) { $payment = $this->get_by_code($_GET['code']); if (!$payment) { showmessage(L('payment_failed')); } $cfg = unserialize_config($payment['config']); $pay_name = ucwords($payment['pay_code']); pc_base::load_app_class('pay_factory', '', 0); $payment_handler = new pay_factory($pay_name, $cfg); $return_data = $payment_handler->receive(); if ($return_data) { if ($return_data['order_status'] == 0) { $this->update_member_amount_by_sn($return_data['order_id']); } $this->update_recode_status_by_sn($return_data['order_id'], $return_data['order_status']); //支付成功 //showmessage(L('pay_success'),APP_PATH.'index.php?m=pay&c=deposit'); } else { //支付失败 //showmessage(L('pay_failed'),APP_PATH.'index.php?m=pay&c=deposit'); } } else { //支付成功 } }
/** * {@inheritDoc} */ public function processPaymentForm($data, $host, $invoice) { $rules = ['first_name' => 'required', 'last_name' => 'required', 'expiry_date_month' => ['required', 'regex:/^[0-9]*$/'], 'expiry_date_year' => ['required', 'regex:/^[0-9]*$/'], 'card_number' => ['required', 'regex:/^[0-9]*$/'], 'CVV' => ['required', 'regex:/^[0-9]*$/']]; $validation = Validator::make($data, $rules); try { if ($validation->fails()) { throw new ValidationException($validation); } } catch (Exception $ex) { $invoice->logPaymentAttempt($ex->getMessage(), 0, [], [], null); throw $ex; } if (!($paymentMethod = $invoice->getPaymentMethod())) { throw new ApplicationException('Payment method not found'); } /* * Send payment request */ $gateway = Omnipay::create('PayPal_Pro'); $gateway->setSignature($host->api_signature); $gateway->setUsername($host->api_username); $gateway->setPassword($host->api_password); $gateway->setTestMode($host->test_mode); $formData = ['firstName' => array_get($data, 'first_name'), 'lastName' => array_get($data, 'last_name'), 'number' => array_get($data, 'card_number'), 'expiryMonth' => array_get($data, 'expiry_date_month'), 'expiryYear' => array_get($data, 'expiry_date_year'), 'cvv' => array_get($data, 'CVV')]; $cardAction = $host->card_action == 'purchase' ? 'purchase' : 'authorize'; $totals = (object) $invoice->getTotalDetails(); $response = $gateway->{$cardAction}(['amount' => $totals->total, 'currency' => $totals->currency, 'card' => $formData])->send(); // Clean the credit card number $formData['number'] = '...' . substr($formData['number'], -4); if ($response->isSuccessful()) { $invoice->logPaymentAttempt('Successful payment', 1, $formData, null, null); $invoice->markAsPaymentProcessed(); $invoice->updateInvoiceStatus($paymentMethod->invoice_status); } else { $errorMessage = $response->getMessage(); $invoice->logPaymentAttempt($errorMessage, 0, $formData, null, null); throw new ApplicationException($errorMessage); } }
private function createGateway($accountGateway) { $gateway = Omnipay::create($accountGateway->gateway->provider); $config = json_decode($accountGateway->config); /* $gateway->setSolutionType("Sole"); $gateway->setLandingPage("Billing"); */ foreach ($config as $key => $val) { if (!$val) { continue; } $function = "set" . ucfirst($key); $gateway->{$function}($val); } /* if (!Utils::isProd()) { $gateway->setTestMode(true); } */ return $gateway; }
<?php $gw = Omnipay::create('PayZen'); $gw->setCertificate('1234567890'); $gw->setTestMode(true); $card = new CreditCard(array('firstName' => 'John', 'lastName' => 'Doe', 'billingAddress1' => '1 rue de la gare', 'billingCity' => 'MACON', 'billingPostcode' => '71000', 'billingCountry' => 'FRANCE', 'billingPhone' => '0600000000', 'email' => '*****@*****.**')); $response = $gw->purchase(array('amount' => '10.00', 'currency' => 'EUR', 'card' => $card))->send(); // Process response if ($response->isSuccessful()) { // Payment was successful print_r($response); } elseif ($response->isRedirect()) { // Redirect to offsite payment gateway $response->redirect(); } else { // Payment failed echo $response->getMessage(); }
// 'callback' => 'http://localhost/access' // ]); // // echo '<pre>'; // // var_dump($service); // // echo '</pre>'; // $service->requestAuthorize(); // }); // Route::get('access', function() { // // dd('dd'); // require_once './vendor/autoload.php'; //加载Composer自动生成的autoload // $token = $service->getAccessToken(); // $httpClient = new Eva\EvaOAuth\AuthorizedHttpClient($token); // $response = $httpClient->get('https://graph.qq.com/user/get_user_info?oauth_consumer_key=100330589&access_token=C8DC5F803954B582B6AD215083B6EDE7&openid=133C2F3092CE16620BF629F756660C45&format=json'); // }); Route::get('gateway', function () { $gateway = Omnipay::create('Alipay_Express'); $gateway->setPartner('2088002026520434'); $gateway->setKey('4q1b99qcqp65o1b1v9yiapx0fwhejz58'); $gateway->setSellerEmail('*****@*****.**'); $gateway->setReturnUrl('http://www.campuswitkey.com/return'); $gateway->setNotifyUrl('http://www.campuswitkey.com/notify'); //For 'Alipay_MobileExpress', 'Alipay_WapExpress' //$gateway->setPrivateKey('/such-as/private_key.pem'); $options = ['out_trade_no' => date('YmdHis') . mt_rand(1000, 9999), 'subject' => 'test', 'total_fee' => '0.01']; $response = $gateway->purchase($options)->send(); $demo = $response->getRedirectUrl(); $demo1 = $response->getRedirectData(); echo '<pre>'; // var_dump($response->getOrderString()); echo '</pre>'; //For 'Alipay_MobileExpress'
|-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ Route::get('/', 'WelcomeController@index'); Route::get('home', 'HomeController@index'); Route::get('test', function () { //进行第三方支付网站跳转 \Omnipay::setGateway('Alipay_Bank'); $options = array('out_trade_no' => '2014010122390002', 'subject' => 'test', 'total_fee' => 0.03, 'price' => '0.01', 'quantity' => '2', 'defaultBank' => 'CCB'); $response = \Omnipay::purchase($options)->send(); //request->response $response->redirect(); //$redirectData = $response->getRedirectData(); //dd($redirectData); /** *正则匹配工具类测试 $regexTool = new \App\Repositories\RegexTool(); dump($regexTool->isEmail('*****@*****.**')); */ }); Route::get('/test2', function () { DB::listen(function ($sql, $bindings, $time) { dump($sql); }); $data = \App\Model\Tag::find(68262);
/** * Create a new gateway. * * * @api */ public function setProvider($provider) { return Omnipay::create($provider); }