Skip to content

Commit

Permalink
Merge pull request #132 from academe/master
Browse files Browse the repository at this point in the history
Issue #130 documentation changes
  • Loading branch information
judgej authored Mar 27, 2019
2 parents 9f24c0e + 24210c2 commit bba571a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ php:
- 7.0
- 7.1
- 7.2
- 7.3

before_script:
- composer install -n --dev --prefer-source
Expand Down
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ Table of Contents
* [Server Notification Handler](#server-notification-handler)
* [Sage Pay Form Methods](#sage-pay-form-methods)
* [Form Authorize](#form-authorize)
* [Form completeAuthorise](#form-completeauthorise)
* [Form Purchase](#form-purchase)
* [Sage Pay Shared Methods (Direct and Server)](#sage-pay-shared-methods-for-both-direct-and-server)
* [Sage Pay Shared Methods (Direct and Server)](#sage-pay-shared-methods-direct-and-server)
* [Repeat Authorize/Purchase](#repeat-authorizepurchase)
* [Capture](#capture)
* [Delete Card](#delete-card)
Expand Down Expand Up @@ -681,7 +682,10 @@ At the gateway, the user will authenticate or authorise their credit card,
perform any 3D Secure actions that may be requested, then will return to the
merchant site.

To get the result details, the transaction is "completed" on return:
### Form completeAuthorise

To get the result details, the transaction is "completed" on the
user's return. This wil be at your `returnUrl` endpoint:

```php
// The result will be read and decrypted from the return URL (or failure URL)
Expand All @@ -696,14 +700,30 @@ $result->getTransactionReference();

If you already have the encrypted response string, then it can be passed in.
However, you would normally leave it for the driver to read it for you from
the current server request:
the current server request, so the following would not normally be necessary:

$crypt = $_GET['crypt']; // or supplied by your framework
$result = $gateway->completeAuthorize(['crypt' => $crypt])->send();

This is handy for testing or if the current page query parameters are not
available in a particular architecture.

It is important to make sure this result is what was expected by your
merchant site.
Your transaction ID will be returned in the result and can be inspected:

$result->getTransactionId()

You *must* make sure this transaction ID matches the one you sent
the user off with in the first place (store it in your session).
If they do no match, then you cannot trust the result, as the user
could be running two checkout flows at the same time, possibly
for wildly different amounts.

In a future release, the `completeAuthorize()` method will expect the
`transactionId` to be supplied and it must match before it will
return a success status.

Like `Server` and `Direct`, you can use either the `DEFERRED` or the `AUTHENTICATE`
method to reserve the amount.

Expand Down
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"name": "Adrian Macneil",
"email": "[email protected]"
},
{
"name": "Jason Judge",
"email": "[email protected]"
},
{
"name": "Omnipay Contributors",
"homepage": "https://github.com/thephpleague/omnipay-sagepay/contributors"
Expand Down
7 changes: 5 additions & 2 deletions src/Message/Form/CompleteAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function getTxType()
public function getData()
{
// The application has the option of passing the query parameter
// in, perhaps using its own middleware, or allowing Omnipay t0
// in, perhaps using its own middleware, or allowing Omnipay to
// provide it.

$crypt = $this->getCrypt() ?: $this->httpRequest->query->get('crypt');
Expand All @@ -45,7 +45,7 @@ public function getData()
}

// Remove the leading '@' and decrypt the remainder into a query string.
// And E_WARNING error will be issued if the crypt parameter data is not
// An InvalidResponseException is thrown if the crypt parameter data is not
// a hexadecimal string.

$hexString = substr($crypt, 1);
Expand All @@ -64,6 +64,9 @@ public function getData()

parse_str($queryString, $data);

// The result will be ASCII data only, being a very restricted set of
// IDs and flags, so can be treated as UTF-8 without any conversion.

return($data);
}

Expand Down

0 comments on commit bba571a

Please sign in to comment.