From e1689f5e87e51f9ce637acd73b8bea7393d48080 Mon Sep 17 00:00:00 2001 From: Del Date: Sat, 30 Jul 2016 15:29:24 +0700 Subject: [PATCH] Add docblocks, deprecate inquiry for fetchTransaction --- .gitignore | 6 + README.md | 4 +- makedoc.sh | 157 ++++++++++++++++++ runtests.sh | 25 +++ src/Message/AuthorizeRequest.php | 113 ++++++++++++- src/Message/CaptureRequest.php | 53 ++++++ src/Message/CreateCardRequest.php | 45 +++++- src/Message/FetchTransactionRequest.php | 74 +++++++++ src/Message/InquiryRequest.php | 4 +- src/Message/PurchaseRequest.php | 41 +++++ src/Message/RefundRequest.php | 53 ++++++ src/Message/VoidRequest.php | 50 ++++++ src/ProGateway.php | 206 +++++++++++++++++++++++- 13 files changed, 817 insertions(+), 14 deletions(-) create mode 100755 makedoc.sh create mode 100755 runtests.sh create mode 100644 src/Message/FetchTransactionRequest.php diff --git a/.gitignore b/.gitignore index 8a282a5..adc1f94 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,9 @@ composer.lock composer.phar phpunit.xml +.directory +.idea/ +dirlist.app +dirlist.vendor +dirlist.cache +/documents/ diff --git a/README.md b/README.md index 30725b8..44818aa 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![Total Downloads](https://poser.pugx.org/omnipay/payflow/d/total.png)](https://packagist.org/packages/omnipay/payflow) [Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment -processing library for PHP 5.3+. This package implements Payflow support for Omnipay. +processing library for PHP 5.3+. This package implements [Payflow](https://developer.paypal.com/docs/classic/products/payflow-gateway/) support for Omnipay. ## Installation @@ -31,7 +31,7 @@ And run composer to update your dependencies: The following gateways are provided by this package: -* Payflow_Pro +* [Payflow_Pro](https://developer.paypal.com/docs/classic/products/payflow-gateway/) For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay) repository. diff --git a/makedoc.sh b/makedoc.sh new file mode 100755 index 0000000..dc9b391 --- /dev/null +++ b/makedoc.sh @@ -0,0 +1,157 @@ +#!/bin/sh + +# +# Smart little documentation generator. +# GPL/LGPL +# (c) Del 2015 http://www.babel.com.au/ +# + +APPNAME='Omnipay Payflow Gateway Documentation' +CMDFILE=apigen.cmd.$$ +DESTDIR=./documents +SRCDIRS="src" +VENDORDIRS="vendor/guzzle vendor/omnipay" + +# +# Ensure that dependencies are installed (including codeception and phpunit) +# +if [ -f composer.lock ]; then + /usr/local/bin/composer install +else + /usr/local/bin/composer update +fi + +# +# Find apigen, either in the path or as a local phar file +# +if [ -f apigen.phar ]; then + APIGEN="php apigen.phar" + +else + APIGEN=`which apigen` + if [ ! -f "$APIGEN" ]; then + + # Search for phpdoc if apigen is not found. + if [ -f phpDocumentor.phar ]; then + PHPDOC="php phpDocumentor.phar" + + else + PHPDOC=`which phpdoc` + if [ ! -f "$PHPDOC" ]; then + echo "Neither apigen nor phpdoc is installed in the path or locally, please install one of them" + echo "see http://www.apigen.org/ or http://www.phpdoc.org/" + exit 1 + fi + fi + fi +fi + +# +# As of version 4 of apigen need to use the generate subcommand +# +if [ ! -z "$APIGEN" ]; then + APIGEN="$APIGEN generate" +fi + +# +# Without any arguments this builds the entire system documentation, +# making the cache file first if required. +# +if [ -z "$1" ]; then + # + # Check to see that the cache has been made. + # + if [ ! -f dirlist.cache ]; then + echo "Making dirlist.cache file" + $0 makecache + fi + + # + # Build the apigen/phpdoc command in a file. + # + if [ ! -z "$APIGEN" ]; then + echo "$APIGEN --php --tree --title '$APPNAME API Documentation' --destination $DESTDIR/main \\" > $CMDFILE + cat dirlist.cache | while read dir; do + echo "--source $dir \\" >> $CMDFILE + done + echo "" >> $CMDFILE + + elif [ ! -z "$PHPDOC" ]; then + echo "$PHPDOC --sourcecode --title '$APPNAME API Documentation' --target $DESTDIR/main --directory \\" > $CMDFILE + cat dirlist.cache | while read dir; do + echo "${dir},\\" >> $CMDFILE + done + echo "" >> $CMDFILE + + else + "Neither apigen nor phpdoc are found, how did I get here?" + exit 1 + fi + + # + # Run the apigen command + # + rm -rf $DESTDIR/main + mkdir -p $DESTDIR/main + . ./$CMDFILE + + /bin/rm -f ./$CMDFILE + +# +# The "makecache" argument causes the script to just make the cache file +# +elif [ "$1" = "makecache" ]; then + echo "Find application source directories" + find $SRCDIRS -name \*.php -print | \ + ( + while read file; do + grep -q 'class' $file && dirname $file + done + ) | sort -u | \ + grep -v -E 'config|docs|migrations|test|Test|views|web' > dirlist.app + + echo "Find vendor source directories" + find $VENDORDIRS -name \*.php -print | \ + ( + while read file; do + grep -q 'class' $file && dirname $file + done + ) | sort -u | \ + grep -v -E 'config|docs|migrations|test|Test|views|codesniffer|phpmd|pdepend|php-parser|codeception|phpunit' > dirlist.vendor + + # + # Filter out any directories for which apigen fails + # + echo "Filter source directories" + mkdir -p $DESTDIR/tmp + cat dirlist.app dirlist.vendor | while read dir; do + if [ ! -z "$APIGEN" ]; then + $APIGEN --quiet --title "Test please ignore" \ + --source $dir \ + --destination $DESTDIR/tmp && ( + echo "Including $dir" + echo $dir >> dirlist.cache + ) || ( + echo "Excluding $dir" + ) + + elif [ ! -z "$PHPDOC" ]; then + $PHPDOC --quiet --title "Test please ignore" \ + --directory $dir \ + --target $DESTDIR/tmp && ( + echo "Including $dir" + echo $dir >> dirlist.cache + ) || ( + echo "Excluding $dir" + ) + + fi + done + echo "Documentation cache dirlist.cache built OK" + + # + # Clean up + # + /bin/rm -rf $DESTDIR/tmp + +fi diff --git a/runtests.sh b/runtests.sh new file mode 100755 index 0000000..75a898f --- /dev/null +++ b/runtests.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# +# Command line runner for unit tests for composer projects +# (c) Del 2015 http://www.babel.com.au/ +# No Rights Reserved +# + +# +# Clean up after any previous test runs +# +mkdir -p documents +rm -rf documents/coverage-html-new +rm -f documents/coverage.xml + +# +# Run phpunit +# +vendor/bin/phpunit --coverage-html documents/coverage-html-new --coverage-clover documents/coverage.xml + +if [ -d documents/coverage-html-new ]; then + rm -rf documents/coverage-html + mv documents/coverage-html-new documents/coverage-html +fi + diff --git a/src/Message/AuthorizeRequest.php b/src/Message/AuthorizeRequest.php index e70f70a..e17150c 100644 --- a/src/Message/AuthorizeRequest.php +++ b/src/Message/AuthorizeRequest.php @@ -6,6 +6,47 @@ /** * Payflow Authorize Request + * + * ### Example + * + * + * // Create a gateway for the Payflow pro Gateway + * // (routes to GatewayFactory::create) + * $gateway = Omnipay::create('Payflow_Pro'); + * + * // Initialise the gateway + * $gateway->initialize(array( + * 'username' => $myusername, + * 'password' => $mypassword, + * 'vendor' => $mymerchantid, + * 'partner' => $PayPalPartner, + * 'testMode' => true, // Or false for live transactions. + * )); + * + * // Create a credit card object + * // This card can be used for testing. + * $card = new CreditCard(array( + * 'firstName' => 'Example', + * 'lastName' => 'Customer', + * 'number' => '4242424242424242', + * 'expiryMonth' => '01', + * 'expiryYear' => '2020', + * 'cvv' => '123', + * )); + * + * // Do an authorize transaction on the gateway + * $transaction = $gateway->authorize(array( + * 'amount' => '10.00', + * 'currency' => 'AUD', + * 'card' => $card, + * )); + * $response = $transaction->send(); + * if ($response->isSuccessful()) { + * echo "Authorize transaction was successful!\n"; + * $sale_id = $response->getTransactionReference(); + * echo "Transaction reference = " . $sale_id . "\n"; + * } + * */ class AuthorizeRequest extends AbstractRequest { @@ -13,41 +54,105 @@ class AuthorizeRequest extends AbstractRequest protected $testEndpoint = 'https://pilot-payflowpro.paypal.com'; protected $action = 'A'; + /** + * Get the username. + * + * This is the ID that you specified when you got the Payflow account. + * + * @return string + */ public function getUsername() { return $this->getParameter('username'); } + /** + * Set the username. + * + * This is the ID that you specified when you got the Payflow account. + * + * @param string $value + * @return AuthorizeRequest provides a fluent interface. + */ public function setUsername($value) { return $this->setParameter('username', $value); } + /** + * Get the password. + * + * This is the password that you specified when you got the Payflow account. + * + * @return string + */ public function getPassword() { return $this->getParameter('password'); } + /** + * Set the password. + * + * This is the password that you specified when you got the Payflow account. + * + * @param string $value + * @return AuthorizeRequest provides a fluent interface. + */ public function setPassword($value) { return $this->setParameter('password', $value); } + /** + * Get the vendor. + * + * The ID that you specified when you got the Payflow account, the same as the username unless you + * have created additional users on the account. That is, the merchant login ID for the account. + * + * @return string + */ public function getVendor() { return $this->getParameter('vendor'); } + /** + * Set the vendor. + * + * The ID that you specified when you got the Payflow account, the same as the username unless you + * have created additional users on the account. That is, the merchant login ID for the account. + * + * @param string $value + * @return AuthorizeRequest provides a fluent interface. + */ public function setVendor($value) { return $this->setParameter('vendor', $value); } + /** + * Get the partner. + * + * The Payflow partner. This may be PayPal, or if an account was provided by an authorized PayPal + * reseller, who registered a Payflow user, then the ID provided by the reseller is used. + * + * @return string + */ public function getPartner() { return $this->getParameter('partner'); } + /** + * Set the partner. + * + * The Payflow partner. This may be PayPal, or if an account was provided by an authorized PayPal + * reseller, who registered a Payflow user, then the ID provided by the reseller is used. + * + * @param string $value + * @return AuthorizeRequest provides a fluent interface. + */ public function setPartner($value) { return $this->setParameter('partner', $value); @@ -73,11 +178,17 @@ public function setComment2($value) return $this->setParameter('comment2', $value); } + /** + * @deprecated + */ public function getOrigid() { return $this->getParameter('origid'); } + /** + * @deprecated + */ public function setOrigid($value) { return $this->setParameter('origid', $value); @@ -117,7 +228,7 @@ public function getData() $data['BILLTOZIP'] = $this->getCard()->getPostcode(); $data['BILLTOCOUNTRY'] = $this->getCard()->getCountry(); } - + $data['TENDER'] = 'C'; $data['AMT'] = $this->getAmount(); $data['COMMENT1'] = $this->getDescription(); diff --git a/src/Message/CaptureRequest.php b/src/Message/CaptureRequest.php index 79939c3..a63b983 100644 --- a/src/Message/CaptureRequest.php +++ b/src/Message/CaptureRequest.php @@ -4,6 +4,59 @@ /** * Payflow Capture Request + * + * ### Example + * + * + * // Create a gateway for the Payflow pro Gateway + * // (routes to GatewayFactory::create) + * $gateway = Omnipay::create('Payflow_Pro'); + * + * // Initialise the gateway + * $gateway->initialize(array( + * 'username' => $myusername, + * 'password' => $mypassword, + * 'vendor' => $mymerchantid, + * 'partner' => $PayPalPartner, + * 'testMode' => true, // Or false for live transactions. + * )); + * + * // Create a credit card object + * // This card can be used for testing. + * $card = new CreditCard(array( + * 'firstName' => 'Example', + * 'lastName' => 'Customer', + * 'number' => '4242424242424242', + * 'expiryMonth' => '01', + * 'expiryYear' => '2020', + * 'cvv' => '123', + * )); + * + * // Do an authorize transaction on the gateway + * $transaction = $gateway->authorize(array( + * 'amount' => '10.00', + * 'currency' => 'AUD', + * 'card' => $card, + * )); + * $response = $transaction->send(); + * if ($response->isSuccessful()) { + * echo "Authorize transaction was successful!\n"; + * $sale_id = $response->getTransactionReference(); + * echo "Transaction reference = " . $sale_id . "\n"; + * } + * + * // Capture the authorization + * $transaction = $gateway->capture(array( + * 'amount' => '10.00', + * 'transactionReference' => $sale_id, + * )); + * $response = $transaction->send(); + * if ($response->isSuccessful()) { + * echo "Capture transaction was successful!\n"; + * $sale_id = $response->getTransactionReference(); + * echo "Transaction reference = " . $sale_id . "\n"; + * } + * */ class CaptureRequest extends AuthorizeRequest { diff --git a/src/Message/CreateCardRequest.php b/src/Message/CreateCardRequest.php index 2c15817..f8dcf0e 100644 --- a/src/Message/CreateCardRequest.php +++ b/src/Message/CreateCardRequest.php @@ -4,6 +4,45 @@ /** * Payflow Create Credit Card Request + * + * ### Example + * + * + * // Create a gateway for the Payflow pro Gateway + * // (routes to GatewayFactory::create) + * $gateway = Omnipay::create('Payflow_Pro'); + * + * // Initialise the gateway + * $gateway->initialize(array( + * 'username' => $myusername, + * 'password' => $mypassword, + * 'vendor' => $mymerchantid, + * 'partner' => $PayPalPartner, + * 'testMode' => true, // Or false for live transactions. + * )); + * + * // Create a credit card object + * // This card can be used for testing. + * $card = new CreditCard(array( + * 'firstName' => 'Example', + * 'lastName' => 'Customer', + * 'number' => '4242424242424242', + * 'expiryMonth' => '01', + * 'expiryYear' => '2020', + * 'cvv' => '123', + * )); + * + * // Do a create card transaction on the gateway + * $transaction = $gateway->createCard(array( + * 'card' => $card, + * )); + * $response = $transaction->send(); + * if ($response->isSuccessful()) { + * echo "Create Card transaction was successful!\n"; + * $card_id = $response->getCardReference(); + * echo "Card reference = " . $card_id . "\n"; + * } + * */ class CreateCardRequest extends AuthorizeRequest { @@ -11,12 +50,12 @@ class CreateCardRequest extends AuthorizeRequest public function getData() { - + $this->getCard()->validate(); $data = $this->getBaseData(); - + $data['TENDER'] = 'C'; - + $data['ACCT'] = $this->getCard()->getNumber(); $data['EXPDATE'] = $this->getCard()->getExpiryDate('my'); $data['CVV2'] = $this->getCard()->getCvv(); diff --git a/src/Message/FetchTransactionRequest.php b/src/Message/FetchTransactionRequest.php new file mode 100644 index 0000000..c1de739 --- /dev/null +++ b/src/Message/FetchTransactionRequest.php @@ -0,0 +1,74 @@ + + * // Create a gateway for the Payflow pro Gateway + * // (routes to GatewayFactory::create) + * $gateway = Omnipay::create('Payflow_Pro'); + * + * // Initialise the gateway + * $gateway->initialize(array( + * 'username' => $myusername, + * 'password' => $mypassword, + * 'vendor' => $mymerchantid, + * 'partner' => $PayPalPartner, + * 'testMode' => true, // Or false for live transactions. + * )); + * + * // Create a credit card object + * // This card can be used for testing. + * $card = new CreditCard(array( + * 'firstName' => 'Example', + * 'lastName' => 'Customer', + * 'number' => '4242424242424242', + * 'expiryMonth' => '01', + * 'expiryYear' => '2020', + * 'cvv' => '123', + * )); + * + * // Do a purchase transaction on the gateway + * $transaction = $gateway->purchase(array( + * 'amount' => '10.00', + * 'currency' => 'AUD', + * 'card' => $card, + * )); + * $response = $transaction->send(); + * if ($response->isSuccessful()) { + * echo "Purchase transaction was successful!\n"; + * $sale_id = $response->getTransactionReference(); + * echo "Transaction reference = " . $sale_id . "\n"; + * } + * + * // Fetch the purchase + * $transaction = $gateway->fetchTransaction(array( + * 'transactionReference' => $sale_id, + * )); + * $response = $transaction->send(); + * if ($response->isSuccessful()) { + * echo "Fetch transaction was successful!\n"; + * $data = $response->getData(); + * echo "Transaction Data =\n" . print_r($data, true) . "\n"; + * } + * + */ +class FetchTransactionRequest extends AuthorizeRequest +{ + protected $action = 'I'; + + public function getData() + { + $data = $this->getBaseData(); + + $data['TENDER'] = 'C'; + $data['VERBOSITY'] = 'HIGH'; + $data['ORIGID'] = $this->getTransactionReference(); + + return $data; + } +} diff --git a/src/Message/InquiryRequest.php b/src/Message/InquiryRequest.php index 0452099..98e77c9 100644 --- a/src/Message/InquiryRequest.php +++ b/src/Message/InquiryRequest.php @@ -4,6 +4,8 @@ /** * Payflow Inquiry Request + * + * @deprecated */ class InquiryRequest extends AuthorizeRequest { @@ -12,7 +14,7 @@ class InquiryRequest extends AuthorizeRequest public function getData() { $data = $this->getBaseData(); - + $data['TENDER'] = 'C'; $data['VERBOSITY'] = 'HIGH'; $data['ORIGID'] = $this->getOrigid(); diff --git a/src/Message/PurchaseRequest.php b/src/Message/PurchaseRequest.php index 70c3057..38f0c1a 100644 --- a/src/Message/PurchaseRequest.php +++ b/src/Message/PurchaseRequest.php @@ -4,6 +4,47 @@ /** * Payflow Purchase Request + * + * ### Example + * + * + * // Create a gateway for the Payflow pro Gateway + * // (routes to GatewayFactory::create) + * $gateway = Omnipay::create('Payflow_Pro'); + * + * // Initialise the gateway + * $gateway->initialize(array( + * 'username' => $myusername, + * 'password' => $mypassword, + * 'vendor' => $mymerchantid, + * 'partner' => $PayPalPartner, + * 'testMode' => true, // Or false for live transactions. + * )); + * + * // Create a credit card object + * // This card can be used for testing. + * $card = new CreditCard(array( + * 'firstName' => 'Example', + * 'lastName' => 'Customer', + * 'number' => '4242424242424242', + * 'expiryMonth' => '01', + * 'expiryYear' => '2020', + * 'cvv' => '123', + * )); + * + * // Do a purchase transaction on the gateway + * $transaction = $gateway->purchase(array( + * 'amount' => '10.00', + * 'currency' => 'AUD', + * 'card' => $card, + * )); + * $response = $transaction->send(); + * if ($response->isSuccessful()) { + * echo "Purchase transaction was successful!\n"; + * $sale_id = $response->getTransactionReference(); + * echo "Transaction reference = " . $sale_id . "\n"; + * } + * */ class PurchaseRequest extends AuthorizeRequest { diff --git a/src/Message/RefundRequest.php b/src/Message/RefundRequest.php index 8f72157..5b94b8c 100644 --- a/src/Message/RefundRequest.php +++ b/src/Message/RefundRequest.php @@ -4,6 +4,59 @@ /** * Payflow Refund Request + * + * ### Example + * + * + * // Create a gateway for the Payflow pro Gateway + * // (routes to GatewayFactory::create) + * $gateway = Omnipay::create('Payflow_Pro'); + * + * // Initialise the gateway + * $gateway->initialize(array( + * 'username' => $myusername, + * 'password' => $mypassword, + * 'vendor' => $mymerchantid, + * 'partner' => $PayPalPartner, + * 'testMode' => true, // Or false for live transactions. + * )); + * + * // Create a credit card object + * // This card can be used for testing. + * $card = new CreditCard(array( + * 'firstName' => 'Example', + * 'lastName' => 'Customer', + * 'number' => '4242424242424242', + * 'expiryMonth' => '01', + * 'expiryYear' => '2020', + * 'cvv' => '123', + * )); + * + * // Do a purchase transaction on the gateway + * $transaction = $gateway->purchase(array( + * 'amount' => '10.00', + * 'currency' => 'AUD', + * 'card' => $card, + * )); + * $response = $transaction->send(); + * if ($response->isSuccessful()) { + * echo "Purchase transaction was successful!\n"; + * $sale_id = $response->getTransactionReference(); + * echo "Transaction reference = " . $sale_id . "\n"; + * } + * + * // Refund the purchase + * $transaction = $gateway->refund(array( + * 'amount' => '10.00', + * 'transactionReference' => $sale_id, + * )); + * $response = $transaction->send(); + * if ($response->isSuccessful()) { + * echo "Refund transaction was successful!\n"; + * $refund_id = $response->getTransactionReference(); + * echo "Refund reference = " . $refund_id . "\n"; + * } + * */ class RefundRequest extends CaptureRequest { diff --git a/src/Message/VoidRequest.php b/src/Message/VoidRequest.php index 58ac671..74c8923 100644 --- a/src/Message/VoidRequest.php +++ b/src/Message/VoidRequest.php @@ -4,6 +4,56 @@ /** * Payflow Void Request + * + * ### Example + * + * + * // Create a gateway for the Payflow pro Gateway + * // (routes to GatewayFactory::create) + * $gateway = Omnipay::create('Payflow_Pro'); + * + * // Initialise the gateway + * $gateway->initialize(array( + * 'username' => $myusername, + * 'password' => $mypassword, + * 'vendor' => $mymerchantid, + * 'partner' => $PayPalPartner, + * 'testMode' => true, // Or false for live transactions. + * )); + * + * // Create a credit card object + * // This card can be used for testing. + * $card = new CreditCard(array( + * 'firstName' => 'Example', + * 'lastName' => 'Customer', + * 'number' => '4242424242424242', + * 'expiryMonth' => '01', + * 'expiryYear' => '2020', + * 'cvv' => '123', + * )); + * + * // Do a purchase transaction on the gateway + * $transaction = $gateway->purchase(array( + * 'amount' => '10.00', + * 'currency' => 'AUD', + * 'card' => $card, + * )); + * $response = $transaction->send(); + * if ($response->isSuccessful()) { + * echo "Purchase transaction was successful!\n"; + * $sale_id = $response->getTransactionReference(); + * echo "Transaction reference = " . $sale_id . "\n"; + * } + * + * // Void the purchase + * $transaction = $gateway->void(array( + * 'transactionReference' => $sale_id, + * )); + * $response = $transaction->send(); + * if ($response->isSuccessful()) { + * echo "Void transaction was successful!\n"; + * } + * */ class VoidRequest extends AuthorizeRequest { diff --git a/src/ProGateway.php b/src/ProGateway.php index 6980cbd..0b36458 100644 --- a/src/ProGateway.php +++ b/src/ProGateway.php @@ -3,17 +3,93 @@ namespace Omnipay\Payflow; use Omnipay\Common\AbstractGateway; -use Omnipay\Payflow\Message\AuthorizeRequest; -use Omnipay\Payflow\Message\CaptureRequest; -use Omnipay\Payflow\Message\PurchaseRequest; -use Omnipay\Payflow\Message\RefundRequest; -use Omnipay\Payflow\Message\CreateCardRequest; -use Omnipay\Payflow\Message\InquiryRequest; /** * Payflow Pro Class * - * @link https://www.x.com/sites/default/files/payflowgateway_guide.pdf + * Payflow refers to a suite of products. This gateway implements an interface to the PayFlow + * Pro gateway as described here: + * + * https://developer.paypal.com/docs/classic/products/payflow-gateway/ + * + * Note that there are 3 other gateways mentioned in the above documentation, these are: + * + * * PayPal Payments Pro, implemented by the omnipay-paypal gateway plugin. + * * PayPal Payments Advanced, deprecated. + * * PayFlow Link, deprecated. + * + * Although PayPal Payments Advanced and PayFlow Link are supported for existing clients, + * there is no omnipay implementation of either. + * + * Note that the PayPal Payments Pro gateway internally uses the Payflow gateway and + * provides much the same functionality. + * + * ### Availability + * + * * USA + * * Canada + * * UK + * * Australia + * + * For registration instructions for each country see here: + * + * https://developer.paypal.com/docs/classic/products/payflow-gateway/ + * + * ### Authentication + * + * Authentication requires the following parameters which are supplied at the time of gateway + * initialisation: + * + * * username + * * password + * * partner. This is the Payflow partner. The example below uses PayPal, since in this document, + * the account was purchased directly from PayPal. If an account was provided by an authorized + * PayPal reseller, who registered a Payflow user,then the ID provided by the reseller is used. + * * vendor. This is the merchant login ID for the account. This will often be the same as the + * username. + * + * ### Example + * + * + * // Create a gateway for the Payflow pro Gateway + * // (routes to GatewayFactory::create) + * $gateway = Omnipay::create('Payflow_Pro'); + * + * // Initialise the gateway + * $gateway->initialize(array( + * 'username' => $myusername, + * 'password' => $mypassword, + * 'vendor' => $mymerchantid, + * 'partner' => $PayPalPartner, + * 'testMode' => true, // Or false for live transactions. + * )); + * + * // Create a credit card object + * // This card can be used for testing. + * $card = new CreditCard(array( + * 'firstName' => 'Example', + * 'lastName' => 'Customer', + * 'number' => '4242424242424242', + * 'expiryMonth' => '01', + * 'expiryYear' => '2020', + * 'cvv' => '123', + * )); + * + * // Do a purchase transaction on the gateway + * $transaction = $gateway->purchase(array( + * 'amount' => '10.00', + * 'currency' => 'AUD', + * 'card' => $card, + * )); + * $response = $transaction->send(); + * if ($response->isSuccessful()) { + * echo "Purchase transaction was successful!\n"; + * $sale_id = $response->getTransactionReference(); + * echo "Transaction reference = " . $sale_id . "\n"; + * } + * + * + * @link https://developer.paypal.com/docs/classic/products/payflow-gateway/ */ class ProGateway extends AbstractGateway { @@ -33,78 +109,194 @@ public function getDefaultParameters() ); } + /** + * Get the username. + * + * This is the ID that you specified when you got the Payflow account. + * + * @return string + */ public function getUsername() { return $this->getParameter('username'); } + /** + * Set the username. + * + * This is the ID that you specified when you got the Payflow account. + * + * @param string $value + * @return ProGateway provides a fluent interface. + */ public function setUsername($value) { return $this->setParameter('username', $value); } + /** + * Get the password. + * + * This is the password that you specified when you got the Payflow account. + * + * @return string + */ public function getPassword() { return $this->getParameter('password'); } + /** + * Set the password. + * + * This is the password that you specified when you got the Payflow account. + * + * @param string $value + * @return ProGateway provides a fluent interface. + */ public function setPassword($value) { return $this->setParameter('password', $value); } + /** + * Get the vendor. + * + * The ID that you specified when you got the Payflow account, the same as the username unless you + * have created additional users on the account. That is, the merchant login ID for the account. + * + * @return string + */ public function getVendor() { return $this->getParameter('vendor'); } + /** + * Set the vendor. + * + * The ID that you specified when you got the Payflow account, the same as the username unless you + * have created additional users on the account. That is, the merchant login ID for the account. + * + * @param string $value + * @return ProGateway provides a fluent interface. + */ public function setVendor($value) { return $this->setParameter('vendor', $value); } + /** + * Get the partner. + * + * The Payflow partner. This may be PayPal, or if an account was provided by an authorized PayPal + * reseller, who registered a Payflow user, then the ID provided by the reseller is used. + * + * @return string + */ public function getPartner() { return $this->getParameter('partner'); } + /** + * Set the partner. + * + * The Payflow partner. This may be PayPal, or if an account was provided by an authorized PayPal + * reseller, who registered a Payflow user, then the ID provided by the reseller is used. + * + * @param string $value + * @return ProGateway provides a fluent interface. + */ public function setPartner($value) { return $this->setParameter('partner', $value); } + /** + * Create an authorize request. + * + * @param array $parameters + * @return \Omnipay\Payflow\Message\AuthorizeRequest + */ public function authorize(array $parameters = array()) { return $this->createRequest('\Omnipay\Payflow\Message\AuthorizeRequest', $parameters); } + /** + * Create a capture request. + * + * @param array $parameters + * @return \Omnipay\Payflow\Message\CaptureRequest + */ public function capture(array $parameters = array()) { return $this->createRequest('\Omnipay\Payflow\Message\CaptureRequest', $parameters); } + /** + * Create a purchase request. + * + * @param array $parameters + * @return \Omnipay\Payflow\Message\PurchaseRequest + */ public function purchase(array $parameters = array()) { return $this->createRequest('\Omnipay\Payflow\Message\PurchaseRequest', $parameters); } + /** + * Create a refund request. + * + * @param array $parameters + * @return \Omnipay\Payflow\Message\RefundRequest + */ public function refund(array $parameters = array()) { return $this->createRequest('\Omnipay\Payflow\Message\RefundRequest', $parameters); } + /** + * Create a void request. + * + * @param array $parameters + * @return \Omnipay\Payflow\Message\VoidRequest + */ public function void(array $parameters = array()) { return $this->createRequest('\Omnipay\Payflow\Message\VoidRequest', $parameters); } + /** + * Create a create card request. + * + * @param array $parameters + * @return \Omnipay\Payflow\Message\CreateCardRequest + */ public function createCard(array $parameters = array()) { return $this->createRequest('\Omnipay\Payflow\Message\CreateCardRequest', $parameters); } + /** + * Create an inquiry request. + * + * @deprecated use fetchTransaction instead + */ public function inquiry(array $parameters = array()) { return $this->createRequest('\Omnipay\Payflow\Message\InquiryRequest', $parameters); } + + /** + * Create a fetch transaction request. + * + * @param array $parameters + * @return \Omnipay\Payflow\Message\FetchTransactionRequest + */ + public function fetchTransaction(array $parameters = array()) + { + return $this->createRequest('\Omnipay\Payflow\Message\FetchTransactionRequest', $parameters); + } }