本文整理汇总了PHP中Omnipay\Omnipay类的典型用法代码示例。如果您正苦于以下问题:PHP Omnipay类的具体用法?PHP Omnipay怎么用?PHP Omnipay使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Omnipay类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: 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
示例3: 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
示例4: __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
示例5: createConfig
/**
* {@inheritDoc}
*/
public function createConfig(array $config = array())
{
$config = ArrayObject::ensureArrayObject($config);
$config->defaults($this->defaultConfig);
$config->defaults($this->coreGatewayFactory->createConfig());
$config->defaults(array('payum.action.capture' => new CaptureAction(), 'payum.action.convert_payment' => new ConvertPaymentAction(), 'payum.action.status' => new StatusAction()));
if (false == $config['payum.api']) {
$config['payum.required_options'] = array('type');
$config->defaults(array('options' => array()));
$config['payum.api.gateway'] = function (ArrayObject $config) {
$config->validateNotEmpty($config['payum.required_options']);
$gatewayFactory = Omnipay::getFactory();
$gatewayFactory->find();
$supportedTypes = $gatewayFactory->all();
if (false == in_array($config['type'], $supportedTypes)) {
throw new LogicException(sprintf('Given type %s is not supported. Try one of supported types: %s.', $config['type'], implode(', ', $supportedTypes)));
}
$gateway = $gatewayFactory->create($config['type']);
foreach ($config['options'] as $name => $value) {
$gateway->{'set' . strtoupper($name)}($value);
}
return $gateway;
};
}
return (array) $config;
}
开发者ID:artkonekt,项目名称:OmnipayBridge,代码行数:29,代码来源:OmnipayDirectGatewayFactory.php
示例6: __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
示例7: 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
示例8: addConfiguration
/**
* {@inheritdoc}
*/
public function addConfiguration(ArrayNodeDefinition $builder)
{
parent::addConfiguration($builder);
$builder->children()
->scalarNode('type')->isRequired()->cannotBeEmpty()->end()
->arrayNode('options')->isRequired()
->useAttributeAsKey('key')
->prototype('scalar')->end()
->end()
->end();
$builder
->validate()
->ifTrue(function ($v) {
$gatewayFactory = Omnipay::getFactory();
$gatewayFactory->find();
$supportedTypes = $gatewayFactory->all();
if (false == in_array($v['type'], $supportedTypes) && !class_exists($v['type'])) {
throw new LogicException(sprintf(
'Given type %s is not supported. Try one of supported types: %s or use the gateway full class name.',
$v['type'],
implode(', ', $supportedTypes)
));
}
return false;
})
->thenInvalid('A message')
;
}
开发者ID:xxspartan16,项目名称:BMS-Market,代码行数:35,代码来源:OmnipayDirectPaymentFactory.php
示例9: 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
示例10: __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
示例11: 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
示例12: __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
示例13: 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
示例14: 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
示例15: 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
示例16: testCallStatic
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);
}
开发者ID:TheSoftwareFarm,项目名称:omnipay-common,代码行数:8,代码来源:OmnipayTest.php
示例17: 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
示例18: __construct
/**
* Assign middleware & initate the PayPal gateway
*/
public function __construct()
{
$this->middleware('auth', ['except' => ['getPaymentWall']]);
// Setup the PayPal gateway
$this->gateway = Omnipay::create('PayPal_Rest');
$this->gateway->initialize(['clientId' => settings('paypal_client_id'), 'secret' => settings('paypal_secret'), 'testMode' => false]);
// Setup the PaymentWall instance
Paymentwall_Config::getInstance()->set(['api_type' => Paymentwall_Config::API_VC, 'public_key' => settings('paymentwall_app_key'), 'private_key' => settings('paymentwall_key')]);
}
开发者ID:huludini,项目名称:aura-kingdom-web,代码行数:12,代码来源:DonateController.php
示例19: verify
/**
* Verify if a payment has happened at Buckaroo
*
* @param $service
* @param $amount
* @param $transactionId
* @return AbstractResponse
*/
public function verify($service, $amount, $transactionId)
{
$gateway = Omnipay::create($service);
$gateway->setWebsiteKey($this->credentials['websiteKey']);
$gateway->setSecretKey($this->credentials['secretKey']);
$gateway->setTestMode($this->testMode);
$paymentData = ["amount" => $this->formatAmount($amount), "currency" => "EUR", "culture" => "nl-NL", "transactionId" => $transactionId];
return $gateway->completePurchase($paymentData)->send();
}
开发者ID:rogierkn,项目名称:buckaroo-wrapper,代码行数:17,代码来源:API.php
示例20: setUp
public function setUp()
{
parent::setUp();
$this->gateway = Omnipay::create('GlobalAlipay_App');
$this->gateway->setPartner('123456');
$this->gateway->setSellerId('[email protected]');
$this->gateway->setPrivateKey(__DIR__ . '/Assets/private_key.pem');
$this->gateway->setNotifyUrl('http://example.com/notify');
}
开发者ID:lokielse,项目名称:omnipay-global-alipay,代码行数:9,代码来源:AppGatewayTest.php
注:本文中的Omnipay\Omnipay类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论