Exemple #1
0
 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;
 }
Exemple #2
0
 /**
  * {@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();
}
Exemple #5
0
// 		'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'
 /**
  * Create a new gateway.
  *
  *
  * @api
  */
 public function setProvider($provider)
 {
     return Omnipay::create($provider);
 }