@@ -284,13 +284,17 @@ The main methods implemented by gateways are:
284
284
* ` completePurchase($options) ` - handle return from off-site gateways after purchase
285
285
* ` refund($options) ` - refund an already processed transaction
286
286
* ` 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
287
289
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 ` .
290
293
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:
294
298
295
299
* card
296
300
* token
@@ -425,6 +429,22 @@ recurring billing profiles. Also in most cases token billing will cover your nee
425
429
store a credit card then charge it on whatever schedule you like. Feel free to get in touch if
426
430
you really think this should be a core feature and worth the effort.
427
431
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
+
428
448
## Example Application
429
449
430
450
An example application is provided in the [ omnipay/example] ( https://github.com/thephpleague/omnipay-example ) repo.
0 commit comments