2017 © Pedro Peláez
 

library omnipay-2checkout

2Checkout driver for the Omnipay payment processing library

image

collizo4sky/omnipay-2checkout

2Checkout driver for the Omnipay payment processing library

  • Tuesday, June 6, 2017
  • by collizo4sky
  • Repository
  • 1 Watchers
  • 9 Stars
  • 4,196 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 11 Forks
  • 2 Open issues
  • 11 Versions
  • 10 % Grown

The README.md

Omnipay: 2checkout

2checkout gateway for the Omnipay PHP payment processing library, (*1)

Latest Version on Packagist Software License Build Status Coverage Status Code Climate Dependency Status Total Downloads, (*2)

Omnipay is a framework agnostic, multi-gateway payment processing library for PHP 5.3+. This package implements 2checkout support for Omnipay., (*3)

Install

Via Composer, (*4)

``` bash $ composer require collizo4sky/omnipay-2checkout, (*5)


## Usage The following gateways are provided by this package: * TwoCheckoutPlus * TwoCheckoutPlus_Token ### TwoCheckoutPlus ``` php use Omnipay\Omnipay; $gateway = Omnipay::create('TwoCheckoutPlus'); $gateway->setAccountNumber($this->account_number); $gateway->setSecretWord($this->secret_word); $gateway->setTestMode($this->is_sandbox_test()); // activate test mode by passing demo parameter to checkout parameters. $gateway->setDemoMode($this->is_test_mode()); try { $formData = array( 'firstName' => $order->get_billing_first_name(), 'lastName' => $order->get_billing_last_name(), 'email' => $order->get_billing_email(), 'address1' => $order->get_billing_address_1(), 'address2' => $order->get_billing_address_2(), 'city' => $order->get_billing_city(), 'state' => $order->get_billing_state(), 'postcode' => $order->get_billing_postcode(), 'country' => $order->get_billing_country(), ); $order_cart = $order->get_items(); $cart = array(); $i = 0; foreach ($order_cart as $order_item_id => $product) { $product_id = $product['product_id']; $cart[$i]['name'] = $product['name']; $cart[$i]['quantity'] = $product['qty']; $cart[$i]['type'] = 'product'; $cart[$i]['price'] = round($product['line_subtotal'] / $product['qty'], 2); $cart[$i]['product_id'] = $product_id; $i++; } if (($shipping_total = $order->get_shipping_total()) > 0) { $cart[] = array( 'name' => 'Shipping Fee', 'quantity' => 1, 'type' => 'shipping', 'price' => round($shipping_total, 2), ); } if (($discount_total = $order->get_total_discount()) > 0) { $cart[] = array( 'name' => 'Discount', 'quantity' => 1, 'type' => 'coupon', 'price' => round($discount_total, 2), ); } if (($tax_total = $order->get_total_tax()) > 0) { $cart[] = array( 'name' => 'Tax Fee', 'type' => 'tax', 'quantity' => 1, 'price' => round($tax_total, 2), ); } $gateway->setCart($cart); $response = $gateway->purchase( array( 'card' => $formData, 'transactionId' => $order->get_order_number(), 'currency' => 'USD', // add a query parameter to the returnUrl to listen and complete payment 'returnUrl' => $this->returnUrl, ) )->send(); if ($response->isRedirect()) { $response->getRedirectUrl(); } else { $error = $response->getMessage(); } } catch (Exception $e) { $e->getMessage(); }

TwoCheckoutPlus_Token

``` php use Omnipay\Omnipay;, (*6)

try { $gateway = Omnipay::create('TwoCheckoutPlus_Token'); $gateway->setAccountNumber($this->account_number); $gateway->setTestMode($this->is_sandbox_test()); $gateway->setPrivateKey($this->private_key);, (*7)

$formData = array(
    'firstName' => $order->get_billing_first_name(),
    'lastName' => $order->get_billing_last_name(),
    'email' => $order->get_billing_email(),
    'billingAddress1' => $order->get_billing_address_1(),
    'billingAddress2' => $order->get_billing_address_2(),
    'billingCity' => $order->get_billing_city(),
    'billingPostcode' => $order->get_billing_postcode(),
    'billingState' => $order->get_billing_state(),
    'billingCountry' => $order->get_billing_country(),
);


$purchase_request_data = array(
    'card' => $formData,
    'token' => sanitize_text_field($_POST['twocheckout_token']),
    'transactionId' => $order->get_order_number(),
    'currency' => 'USD',
    'amount' => $order->order_total,
);

$response = $gateway->purchase($purchase_request_data)->send();

if ($response->isSuccessful()) {
    $transaction_ref = $response->getTransactionReference();
} else {
    $error = $response->getMessage();
}

} catch (Exception $e) { $e->getMessage(); }, (*8)


For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay) repository. ## Support If you are having general issues with Omnipay, we suggest posting on [Stack Overflow](http://stackoverflow.com/). Be sure to add the [omnipay tag](http://stackoverflow.com/questions/tagged/omnipay) so it can be easily found. If you want to keep up to date with release anouncements, discuss ideas for the project, or ask more detailed questions, there is also a [mailing list](https://groups.google.com/forum/#!forum/omnipay) which you can subscribe to. If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/collizo4sky/omnipay-2checkout/issues), or better yet, fork the library and submit a pull request. ## Testing ``` bash $ composer test

Security

If you discover any security related issues, please email me@w3guy.com instead of using the issue tracker., (*9)

Credits

License

The MIT License (MIT). Please see License File for more information., (*10)

The Versions

06/06 2017

dev-master

9999999-dev https://github.com/collizo4sky/omnipay-2checkout

2Checkout driver for the Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

omnipay 2checkout

11/05 2017

1.6

1.6.0.0 https://github.com/collizo4sky/omnipay-2checkout

2Checkout driver for the Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

omnipay 2checkout

19/02 2017

1.5

1.5.0.0 https://github.com/collizo4sky/omnipay-2checkout

2Checkout driver for the Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

omnipay 2checkout

12/03 2016

1.4.3

1.4.3.0 https://github.com/collizo4sky/omnipay-2checkout

2Checkout driver for the Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

omnipay 2checkout

06/03 2016

1.4.2

1.4.2.0 https://github.com/collizo4sky/omnipay-2checkout

2Checkout driver for the Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

omnipay 2checkout

04/03 2016

1.4.1

1.4.1.0 https://github.com/collizo4sky/omnipay-2checkout

2Checkout driver for the Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

omnipay 2checkout

17/02 2016

1.4

1.4.0.0 https://github.com/collizo4sky/omnipay-2checkout

2Checkout driver for the Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

omnipay 2checkout

06/01 2016

1.3

1.3.0.0 https://github.com/collizo4sky/omnipay-2checkout

2Checkout driver for the Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

omnipay 2checkout

27/12 2015

1.2

1.2.0.0 https://github.com/collizo4sky/omnipay-2checkout

2Checkout driver for the Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

omnipay 2checkout

26/12 2015

1.1

1.1.0.0 https://github.com/collizo4sky/omnipay-2checkout

2Checkout driver for the Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

omnipay 2checkout

22/12 2015

1.0

1.0.0.0 https://github.com/collizo4sky/omnipay-2checkout

2Checkout driver for the Omnipay payment processing library

  Sources   Download

MIT

The Requires

 

The Development Requires

omnipay 2checkout