当前位置: 首页>>代码示例>>PHP>>正文


PHP Omnipay::create方法代码示例

本文整理汇总了PHP中Omnipay\Omnipay::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Omnipay::create方法的具体用法?PHP Omnipay::create怎么用?PHP Omnipay::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Omnipay\Omnipay的用法示例。


在下文中一共展示了Omnipay::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct()
 {
     $this->platform = 'wechat';
     $this->gatewayName = 'WechatPay';
     $this->keys = ['body', 'detail', 'out_trade_no', 'total_fee', 'spbill_create_ip', 'notify_url'];
     $this->gateway = Omnipay::create($this->gatewayName);
 }
开发者ID:hjiash,项目名称:easypay,代码行数:7,代码来源:AbstractWechatPay.php

示例2: getSuccessPayment

 public function getSuccessPayment(Request $request)
 {
     $admin = User::where(['type' => 'admin'])->first();
     $gateway = Omnipay::create('PayPal_Express');
     $gateway->setUsername('fai1999.fa_api1.gmail.com');
     $gateway->setPassword('N8MALTPJ39RD3MG7');
     $gateway->setSignature('AVieiSDlpAV8gE.TnT6kpOEjJbTKAJJakY.PKQSfbkf.rc2Gy1N7vumm');
     $gateway->setTestMode(true);
     $params = Session::get('params');
     $response = $gateway->completePurchase($params)->send();
     $paypalResponse = $response->getData();
     // this is the raw response object
     if (isset($paypalResponse['PAYMENTINFO_0_ACK']) && $paypalResponse['PAYMENTINFO_0_ACK'] === 'Success') {
         // Response
         // print_r($paypalResponse);
     } else {
         //Failed transaction
     }
     $count = Transaction::where(['transactionid' => $paypalResponse['PAYMENTINFO_0_TRANSACTIONID']])->count();
     if ($count < 1) {
         Transaction::create(['senderid' => Auth::user()->id, 'transactionid' => $paypalResponse['PAYMENTINFO_0_TRANSACTIONID'], 'amount' => $paypalResponse['PAYMENTINFO_0_AMT'], 'recipientid' => $admin->id]);
         $balance = Balance::where(['userid' => Auth::user()->id])->first();
         $balance = $balance->balance + $paypalResponse['PAYMENTINFO_0_AMT'];
         Balance::where(['userid' => Auth::user()->id])->update(['balance' => $balance]);
     }
     if (Auth::user()->type != 'admin') {
         return redirect()->route('transactions');
     }
 }
开发者ID:fai1996,项目名称:tutortut,代码行数:29,代码来源:PaymentController.php

示例3: getWorker

 /**
  * @return \Omnipay\Common\GatewayInterface
  */
 public function getWorker()
 {
     if ($this->_worker === null) {
         $this->_worker = Omnipay::create($this->getGateway())->initialize($this->prepareData($this->data));
     }
     return $this->_worker;
 }
开发者ID:hiqdev,项目名称:php-merchant,代码行数:10,代码来源:OmnipayMerchant.php

示例4: create

 /**
  * Configure the Stripe payment gateway
  *
  * @param array $config The gateway configuration
  * @return void
  */
 public function create(array $config)
 {
     // Create payment gateway
     $this->_name = 'Stripe';
     $this->_gateway = Omnipay::create('Stripe');
     $this->_gateway->setApiKey($config['apiKey']);
 }
开发者ID:gintonicweb,项目名称:payments,代码行数:13,代码来源:StripeCharge.php

示例5: onShoppingCartPay

 /**
  * Handle paying via this gateway
  *
  * @param Event $event
  *
  * @return mixed|void
  */
 public function onShoppingCartPay(Event $event)
 {
     if (!$this->isCurrentGateway($event['gateway'])) {
         return false;
     }
     $order = $this->getOrderFromEvent($event);
     $amount = $order->amount;
     $currency = $this->grav['config']->get('plugins.shoppingcart.general.currency');
     $description = $this->grav['config']->get('plugins.shoppingcart.payment.methods.stripe.description');
     $token = $order->extra['stripeToken'];
     $secretKey = $this->grav['config']->get('plugins.shoppingcart.payment.methods.stripe.secretKey');
     $gateway = Omnipay::create('Stripe');
     $gateway->setApiKey($secretKey);
     try {
         $response = $gateway->purchase(['amount' => $amount, 'currency' => $currency, 'description' => $description, 'token' => $token])->send();
         if ($response->isSuccessful()) {
             // mark order as complete
             $this->grav->fireEvent('onShoppingCartSaveOrder', new Event(['gateway' => $this->name, 'order' => $order]));
             $this->grav->fireEvent('onShoppingCartReturnOrderPageUrlForAjax', new Event(['gateway' => $this->name, 'order' => $order]));
         } elseif ($response->isRedirect()) {
             $response->redirect();
         } else {
             // display error to customer
             throw new \RuntimeException("Payment not successful: " . $response->getMessage());
         }
     } catch (\Exception $e) {
         // internal error, log exception and display a generic message to the customer
         throw new \RuntimeException('Sorry, there was an error processing your payment: ' . $e->getMessage());
     }
 }
开发者ID:flaviocopes,项目名称:grav-plugin-shoppingcart-stripe,代码行数:37,代码来源:gateway.php

示例6: getSuccessPayment

 public function getSuccessPayment()
 {
     $gateway = Omnipay::create('PayPal_Express');
     $gateway->setUsername(ENV('PAYPAL_USERNAME'));
     $gateway->setPassword(ENV('PAYPAL_PASSWORD'));
     $gateway->setSignature(ENV('PAYPAL_SIGNATURE'));
     $gateway->setTestMode(ENV('PAYPAL_TEST'));
     $params = Session::get('params');
     $response = $gateway->completePurchase($params)->send();
     $paypalResponse = $response->getData();
     if (isset($paypalResponse['PAYMENTINFO_0_ACK']) && $paypalResponse['PAYMENTINFO_0_ACK'] === 'Success') {
         $user = Auth::user();
         // Assign Product to User
         $product = Product::find($params['product_id']);
         $user->products()->save($product, ['payment_type' => $params['payment_type'], 'amount' => $params['amount']]);
         foreach ($product->courses as $course) {
             $user->courses()->save($course);
         }
         // Assign Student Role to User
         if (!$user->hasRole('starter')) {
             $user->assignRole('starter');
         }
         $this->dispatch(new SendPurchaseConfirmationEmail($user, $product));
         return redirect()->route('thanks', $product->slug)->withSuccess('Your purchase of ' . $product->name . ' was successful.');
     } else {
         return redirect('purchase')->withErrors('Purchase failed.');
     }
 }
开发者ID:40DayStartup,项目名称:Core,代码行数:28,代码来源:PaymentController.php

示例7: postMakePaymentAction

 /**
  * Put Payment
  * @Rest\Post("/payment" )
  */
 public function postMakePaymentAction(Request $request)
 {
     $objEntityManager = $this->getDoctrine()->getManager();
     $objGateway = Omnipay::create('Stripe');
     $strJson = $request->getContent();
     $arrmixPaymentDetails = json_decode($strJson, true);
     $order = $objEntityManager->getRepository('BundlesOrderBundle:Orders')->find($arrmixPaymentDetails['order_id']);
     $objCustomer = $objEntityManager->getRepository('BundlesUserBundle:Customer')->find((int) $this->objSession->get('user/customer_id'));
     // Set secret key
     $objGateway->setApiKey('************');
     // Make Form data
     $formData = ['number' => $arrmixPaymentDetails['card_number'] . '', 'expiryMonth' => $arrmixPaymentDetails['expiry_month'] . '', 'expiryYear' => $arrmixPaymentDetails['expiry_year'] . '', 'cvv' => $arrmixPaymentDetails['cvv'] . ''];
     // Send purchase request
     $objResponse = $objGateway->purchase(['amount' => $order->getAmount() . '.00', 'currency' => 'USD', 'card' => $formData])->send();
     // Process response
     if ($objResponse->isSuccessful() || $objResponse->isRedirect()) {
         //         if( true ) {
         $objPayment = new Payment();
         $objPayment->setOrders($order);
         $objPayment->setCustomer($objCustomer);
         $objPayment->setTransactionId('transaction_' . (int) $this->objSession->get('user/customer_id'));
         $objPayment->setIsSuccess(true);
         $objPayment->setPaymentStatus('Completed');
         $objEntityManager->persist($objPayment);
         $objEntityManager->flush();
         return array('Payment' => array('id' => $objPayment->getId(), 'order_id' => $order->getId(), 'status' => 'success'));
     } else {
         return array('Payment' => array('status' => 'failed', 'order_id' => $order->getId()));
     }
 }
开发者ID:bose987,项目名称:symfony-angular,代码行数:34,代码来源:PaymentController.php

示例8: __construct

 public function __construct($body = null)
 {
     parent::__construct($body);
     $this->platform = 'alipay_wap_express';
     $this->gatewayName = 'Alipay_WapExpress';
     $this->gateway = Omnipay::create($this->gatewayName);
 }
开发者ID:hjiash,项目名称:easypay,代码行数:7,代码来源:AlipayWapExpress.php

示例9: __construct

 public function __construct()
 {
     parent::__construct();
     $this->platform = 'alipay_express';
     $this->gatewayName = 'Alipay_MobileExpress';
     $this->gateway = Omnipay::create($this->gatewayName);
 }
开发者ID:hjiash,项目名称:easypay,代码行数:7,代码来源:AlipayMobileExpress.php

示例10: processPaymentForm

 /**
  * {@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('Stripe');
     $gateway->initialize(array('apiKey' => $host->secret_key));
     $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')];
     $totals = (object) $invoice->getTotalDetails();
     $response = $gateway->purchase(['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);
     }
 }
开发者ID:dogiedog,项目名称:pay-plugin,代码行数:38,代码来源:Stripe.php

示例11: __construct

 public function __construct()
 {
     $this->platform = 'wechat';
     $this->gatewayName = 'WechatPay';
     $this->keys = ['send_name', 're_openid', 'total_amount', 'total_num', 'wishing', 'client_ip', 'act_name', 'remark'];
     $this->gateway = Omnipay::create($this->gatewayName);
 }
开发者ID:hjiash,项目名称:easypay,代码行数:7,代码来源:WechatRedPack.php

示例12: init

 public function init()
 {
     $this->gateway = Omnipay::create('Alipay_Express');
     $this->gateway->setPartner($this->settings->get('pid'));
     $this->gateway->setKey($this->settings->get('key'));
     $this->gateway->setSellerEmail($this->settings->get('seller_email'));
     $this->logo = dirname(__FILE__) . '/logo.png';
 }
开发者ID:kshar1989,项目名称:dianpou,代码行数:8,代码来源:Main.php

示例13: getOmniPayGateway

 public function getOmniPayGateway()
 {
     $gateway = Omnipay::create($this->name);
     $gateway->setPartner($this->partner_id);
     $gateway->setKey($this->partner_key);
     $gateway->setSellerEmail($this->seller_email);
     return $gateway;
 }
开发者ID:xjtuwangke,项目名称:laravel-payments,代码行数:8,代码来源:PaymentModel.php

示例14: createGateway

function createGateway($goId, $secureKey)
{
    $gateway = Omnipay::create('Gopay');
    $gateway->setTestMode(true);
    $gateway->setGoId($goId);
    $gateway->setSecureKey($secureKey);
    return $gateway;
}
开发者ID:magnolia61,项目名称:nz.co.fuzion.omnipaymultiprocessor,代码行数:8,代码来源:manual_test.php

示例15: create

 /**
  * Configure the PayPalRest payment gateway
  *
  * @param array $config The gateway configuration
  * @return void
  */
 public function create(array $config)
 {
     // Create payment gateway
     $this->_name = 'PayPal_Rest';
     $this->_gateway = Omnipay::create($this->_name);
     $this->_gateway->setClientId($config['clientId']);
     $this->_gateway->setSecret($config['secret']);
     $this->_gateway->setTestMode($config['testMode']);
 }
开发者ID:gintonicweb,项目名称:payments,代码行数:15,代码来源:PaypalRestCharge.php


注:本文中的Omnipay\Omnipay::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。