-
Notifications
You must be signed in to change notification settings - Fork 10
/
live.php
51 lines (34 loc) · 1.14 KB
/
live.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
require __DIR__.'/vendor/autoload.php';
use Sujip\PayPal\Notification\Events\Failure;
use Sujip\PayPal\Notification\Events\Invalid;
use Sujip\PayPal\Notification\Events\Verified;
use Sujip\PayPal\Notification\Handler\ArrayHandler;
use Sujip\PayPal\Notification\Handler\StreamHandler;
// Usage of this package in two different ways
$event = (new StreamHandler())->handle();
// or
$event = (new ArrayHandler([
'foo' => 'bar',
'bar' => 'baz',
]))
->sandbox()
->handle();
$event->onInvalid(function (Invalid $request) {
$error = $request->error();
$payload = $request->getPayload();
echo "Invalid \n";
// Log error, payload was invalid, or something.
});
$event->onVerified(function (Verified $request) {
$payload = $request->getPayload();
echo "Verified \n";
// Ok, payload was valid, go ahead with your app logic.
});
$event->onError(function (Failure $request) {
$error = $request->error();
echo "Error \n";
// Oh snap !. error occured while establishing connection !
});
$event->fire();
//http://www.inanzzz.com/index.php/post/7cwp/mocking-guzzle-and-testing-external-api-with-phpunit