Skip to content

Commit 8c0e615

Browse files
sergej-koscejevgreydnls
authored andcommitted
Document incoming notifications interface
1 parent d7c1f5c commit 8c0e615

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

README.md

100644100755
Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,17 @@ The main methods implemented by gateways are:
284284
* `completePurchase($options)` - handle return from off-site gateways after purchase
285285
* `refund($options)` - refund an already processed transaction
286286
* `void($options)` - generally can only be called up to 24 hours after submitting a transaction
287+
* `acceptNotification()` - convert an incoming request from an off-site gateway to a generic notification object
288+
for further processing
287289

288-
On-site gateways do not need to implement the `completeAuthorize` and `completePurchase` methods. If any gateway does not support
289-
certain features (such as refunds), it will throw `BadMethodCallException`.
290+
On-site gateways do not need to implement the `completeAuthorize` and `completePurchase` methods. Gateways that don't
291+
receive payment notifications don't need to implement `acceptNotification`. If any gateway does not support certain
292+
features (such as refunds), it will throw `BadMethodCallException`.
290293

291-
All gateway methods take an `$options` array as an argument. Each gateway differs in which
292-
parameters are required, and the gateway will throw `InvalidRequestException` if you
293-
omit any required parameters. All gateways will accept a subset of these options:
294+
All gateway methods except `acceptNotification` take an `$options` array as an argument. The `acceptNotification` method
295+
does not take any parameters and will access the HTTP URL variables or POST data implicitly. Each gateway differs in
296+
which parameters are required, and the gateway will throw `InvalidRequestException` if you omit any required parameters.
297+
All gateways will accept a subset of these options:
294298

295299
* card
296300
* token
@@ -425,6 +429,22 @@ recurring billing profiles. Also in most cases token billing will cover your nee
425429
store a credit card then charge it on whatever schedule you like. Feel free to get in touch if
426430
you really think this should be a core feature and worth the effort.
427431

432+
## Incoming Notifications
433+
434+
Some gateways (e.g. Cybersource, GoPay) offer HTTP notifications to inform the merchant about the completion (or, in
435+
general, status) of the payment. To assist with handling such notifications, the `acceptNotification()` method will
436+
extract the transaction reference and payment status from the HTTP request and return a generic `NotificationInterface`.
437+
438+
```php
439+
$notification = $gateway->acceptNotification();
440+
441+
$notification->getTransactionReference(); // A reference provided by the gateway to represent this transaction
442+
$notification->getTransactionStatus(); // Current status of the transaction, one of NotificationInterface::STATUS_*
443+
$notification->getMessage(); // Additional message, if any, provided by the gateway
444+
445+
// update the status of the corresponding transaction in your database
446+
```
447+
428448
## Example Application
429449

430450
An example application is provided in the [omnipay/example](https://github.com/thephpleague/omnipay-example) repo.

0 commit comments

Comments
 (0)