2017 © Pedro Peláez
 

library omnipay-paypal

Rest API paypal processor for Omnipay

image

clippings/omnipay-paypal

Rest API paypal processor for Omnipay

  • Wednesday, August 2, 2017
  • by hkdobrev
  • Repository
  • 11 Watchers
  • 5 Stars
  • 38,917 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 3 Versions
  • 14 % Grown

The README.md

Paypal REST driver for the Omnipay PHP payment processing library, (*1)

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version, (*2)

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

Installation

Omnipay is installed via Composer. To install, simply add it to your composer.json file:, (*4)

{
    "require": {
        "clippings/omnipay-paypal": "~0.1"
    }
}

And run composer to update your dependencies:, (*5)

$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update

Basic Usage

The following gateways are provided by this package:, (*6)

  • PaypalRest

For general usage instructions, please see the main Omnipay repository., (*7)

In order to use this gateway, you need to provide apiKey and clientId., (*8)

$gateway = Omnipay::create('PaypalRest');
$gateway->setClientId('abc123');
$gateway->setSecret('abc123');

For a successful purchase you need to provide amount,currency:, (*9)

$purchase = $gateway->purchase(array(
    'currency' => 'GBP',
    'amount' => '15.00',
    'description' => 'This is a purchase',
));

Funding methods

You can use 3 different methods for paying for purchases, (*10)

Paypal Redirect, (*11)

If you do not provide any payment methods, purchase() method will generate a redirect response., (*12)

$purchase = $gateway->purchase(array(
    'currency' => 'GBP',
    'amount' => '15.00',
    'description' => 'This is a purchase',
    'redirectUrl' => 'http://example.com/completed',
    'cancelUrl' => 'http://example.com/cancel',
));

$response = $purchase->send();

// redirect to $response->getRedirectUrl()
$response->redirect();
$key = $response->getTransactionReference();

// You'll need to pass $key as well as "payerid" query parameter that you'll get from paypal redirecting back to your site

$completePurchase = $gateway->completePurchase(array(
    'transactionReference' => $key,
    'payerId' => $_GET['PAYERID'],
));

$response2 = $completePurchase->send();

Credit card reference, (*13)

You can store user's credit cards within paypal's vault, and use a reference to that for purchases., (*14)

$createCard = $gateway->createCard(array(
    'card' => ...,
    'payerId' => 'payer id',
));

$response = $createCard->send();
$cardId = $response->getTransactionReference();

$purchase = $gateway->purchase(array(
    'currency' => 'GBP',
    'amount' => '15.00',
    'cardReference' => $cardId,
));

$response = $purchase->send();

Directly with a credit card, (*15)

$purchase = $gateway->purchase(array(
    'currency' => 'GBP',
    'amount' => '15.00',
    'card' => ...,
));

$response = $purchase->send();

Authorization

Authorisation, capture and void are supported too. It works the same way as purchase, but you'll need to "capture" or "void" afterwords, (*16)

$authorise = $gateway->authorise(array(
    'currency' => 'GBP',
    'amount' => '15.00',
    'card' => ...,
));

$response = $authorise->send();
$id = $response->getTransactionReference();

$capture = $gateway->capture(array(
    'transactionReference' => $id,
    'amount' => '15.00',
));

$capture->send();

// Or

$capture = $gateway->void(array(
    'transactionReference' => $id,
));

$capture->send();

Refund

$refund = $gateway->refund(array(
    'transactionReference' => $id,
));

$refund->send();

// If you are refunding a capture
$refund = $gateway->refund(array(
    'transactionReference' => $id,
    'type' => 'capture'
));

$refund->send();

// Partial refund
$refund = $gateway->refund(array(
    'transactionReference' => $id,
    'amount' => '10.00'
    'currency' => 'GBP'
));

$refund->send();

Credit Card Vault

createCard, updateCard and deleteCard are supported too., (*17)

$createCard = $gateway->createCard(array(
    'card' => ...,
    'payerId' => '123123' // Optional, if set, will be required when referencing for a purchase later
));

$response = $createCard->send();
$cardReference = $response->getTransactionReference();

$updateCard = $gateway->updateCard(array(
    'card' => ...,
));

$deleteCard = $gateway->deleteCard(array(
    'card' => ...,
));

Support

If you are having general issues with Omnipay, we suggest posting on Stack Overflow. Be sure to add the omnipay tag so it can be easily found., (*18)

If you want to keep up to date with release announcements, discuss ideas for the project, or ask more detailed questions, there is also a mailing list which you can subscribe to., (*19)

If you believe you have found a bug, please report it using the GitHub issue tracker, or better yet, fork the library and submit a pull request., (*20)

License

Copyright (c) 2014, Clippings Ltd. Developed by Ivan Kerin, (*21)

Under BSD-3-Clause license, read LICENSE file., (*22)

The Versions

02/08 2017

dev-master

9999999-dev

Rest API paypal processor for Omnipay

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

04/11 2014

0.2.0

0.2.0.0

Rest API paypal processor for Omnipay

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

17/10 2014

0.1.0

0.1.0.0

Rest API paypal processor for Omnipay

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires