Skip to content

Commit

Permalink
Merge pull request #5 from rushi/XOL-3031
Browse files Browse the repository at this point in the history
XOL-3031 Merge from omnipay/stripe
  • Loading branch information
anush authored Aug 24, 2016
2 parents d33ce2c + d1295e0 commit def44a8
Show file tree
Hide file tree
Showing 146 changed files with 6,599 additions and 678 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
composer.lock
composer.phar
phpunit.xml
.directory
/dirlist.*
/documents/
/.idea/
51 changes: 45 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

**Stripe driver for the Omnipay PHP payment processing library**

[![Build Status](https://travis-ci.org/omnipay/stripe.png?branch=master)](https://travis-ci.org/omnipay/stripe)
[![Build Status](https://travis-ci.org/thephpleague/omnipay-stripe.png?branch=master)](https://travis-ci.org/thephpleague/omnipay-stripe)
[![Latest Stable Version](https://poser.pugx.org/omnipay/stripe/version.png)](https://packagist.org/packages/omnipay/stripe)
[![Total Downloads](https://poser.pugx.org/omnipay/stripe/d/total.png)](https://packagist.org/packages/omnipay/stripe)

[Omnipay](https://github.com/omnipay/omnipay) is a framework agnostic, multi-gateway payment
[Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment
processing library for PHP 5.3+. This package implements Stripe support for Omnipay.

## Installation
Expand All @@ -31,20 +31,59 @@ And run composer to update your dependencies:

The following gateways are provided by this package:

* Stripe
* [Stripe](https://stripe.com/)

For general usage instructions, please see the main [Omnipay](https://github.com/omnipay/omnipay)
For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay)
repository.

### Stripe.js

The Stripe integration is fairly straight forward. Essentially you just pass
a `token` field through to Stripe instead of the regular credit card data.

Start by following the standard Stripe JS guide here:
[https://stripe.com/docs/tutorials/forms](https://stripe.com/docs/tutorials/forms)

After that you will have a `stripeToken` field which will be submitted to your server.
Simply pass this through to the gateway as `token`, instead of the usual `card` array:

```php
$token = $_POST['stripeToken'];
$response = $gateway->purchase(['amount' => '10.00', 'currency' => 'USD', 'token' => $token])->send();
```

### Stripe Connect

Stripe connect applications can charge an additional fee on top of Stripe's fees for charges they make on behalf of
their users. To do this you need to specify an additional `transactionFee` parameter as part of an authorize or purchase
request.

When a charge is refunded the transaction fee is refunded with an amount proportional to the amount of the charge
refunded and by default this will come from your connected user's Stripe account effectively leaving them out of pocket.
To refund from your (the applications) Stripe account instead you can pass a ``refundApplicationFee`` parameter with a
boolean value of true as part of a refund request.

Note: making requests with Stripe Connect specific parameters can only be made using the OAuth access token you received
as part of the authorization process. Read more on Stripe Connect [here](https://stripe.com/docs/connect).

## Test Mode

Stripe accounts have test-mode API keys as well as live-mode API keys. These keys can be active
at the same time. Data created with test-mode credentials will never hit the credit card networks
and will never cost anyone money.

Unlike some gateways, there is no test mode endpoint separate to the live mode endpoint, the
Stripe API endpoint is the same for test and for live.

## 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,
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](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/omnipay/stripe/issues),
If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/thephpleague/omnipay-stripe/issues),
or better yet, fork the library and submit a pull request.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"payment",
"stripe"
],
"homepage": "https://github.com/omnipay/stripe",
"homepage": "https://github.com/thephpleague/omnipay-stripe",
"license": "MIT",
"authors": [
{
Expand All @@ -19,7 +19,7 @@
},
{
"name": "Omnipay Contributors",
"homepage": "https://github.com/omnipay/stripe/contributors"
"homepage": "https://github.com/thephpleague/omnipay-stripe/contributors"
}
],
"repositories": [
Expand All @@ -29,7 +29,7 @@
}
],
"autoload": {
"psr-0": { "Omnipay\\Stripe\\" : "src/" }
"psr-4": { "Omnipay\\Stripe\\" : "src/" }
},
"require": {
"omnipay/common": "~2.5"
Expand Down
146 changes: 146 additions & 0 deletions makedoc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
#!/bin/sh

#
# Smart little documentation generator.
# GPL/LGPL
# (c) Del 2015 http://www.babel.com.au/
#

APPNAME='Omnipay Stripe Gateway Module'
CMDFILE=apigen.cmd.$$
DESTDIR=./documents

#
# 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 src -name \*.php -print | \
(
while read file; do
grep -q 'class' $file && dirname $file
done
) | sort -u | \
grep -v -E 'config|docs|migrations|phpunit|test|Test|views|web' > dirlist.app

echo "Find vendor source directories"
find vendor -name \*.php -print | \
(
while read file; do
grep -q 'class' $file && dirname $file
done
) | sort -u | \
grep -v -E 'config|docs|migrations|phpunit|codesniffer|test|Test|views' > dirlist.vendor

#
# Filter out any vendor 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
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="tests/bootstrap.php"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
Expand Down
25 changes: 25 additions & 0 deletions runtests.sh
Original file line number Diff line number Diff line change
@@ -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

Loading

0 comments on commit def44a8

Please sign in to comment.