-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding samples for parsing errors (#11)
* adding samples for parsing errors * updating travis * removing version from hhvm * removing hhvm - no longer supports php
- Loading branch information
Showing
6 changed files
with
158 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,6 @@ php: | |
- 7.1 | ||
- 7.2 | ||
- 7.3 | ||
- hhvm-3.18 | ||
before_script: | ||
- composer self-update | ||
- composer install | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,52 @@ | ||
<?php | ||
|
||
namespace Sample; | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
use Sample\PayPalClient; | ||
use PaypalPayoutsSDK\Payouts\PayoutsGetRequest; | ||
use Sample\CreatePayoutSample; | ||
use PayPalHttp\HttpException; | ||
|
||
class GetPayoutSample | ||
{ | ||
|
||
/** | ||
* This function can be used to create payout. | ||
*/ | ||
public static function GetPayout($batchId,$debug=false) | ||
public static function GetPayout($batchId, $debug = false) | ||
{ | ||
$request = new PayoutsGetRequest($batchId); | ||
$client = PayPalClient::client(); | ||
$response = $client->execute($request); | ||
if ($debug) | ||
{ | ||
print "Status Code: {$response->statusCode}\n"; | ||
print "Status: {$response->result->batch_header->batch_status}\n"; | ||
print "Batch ID: {$response->result->batch_header->payout_batch_id}\n"; | ||
print "First Item ID: {$response->result->items[0]->payout_item_id}\n"; | ||
try { | ||
$request = new PayoutsGetRequest($batchId); | ||
$client = PayPalClient::client(); | ||
$response = $client->execute($request); | ||
if ($debug) { | ||
print "Status Code: {$response->statusCode}\n"; | ||
print "Status: {$response->result->batch_header->batch_status}\n"; | ||
print "Batch ID: {$response->result->batch_header->payout_batch_id}\n"; | ||
print "First Item ID: {$response->result->items[0]->payout_item_id}\n"; | ||
|
||
print "Links:\n"; | ||
foreach($response->result->links as $link) | ||
{ | ||
print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n"; | ||
print "Links:\n"; | ||
foreach ($response->result->links as $link) { | ||
print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n"; | ||
} | ||
// To toggle printing the whole response body comment/uncomment below line | ||
echo json_encode($response->result, JSON_PRETTY_PRINT), "\n"; | ||
} | ||
// To toggle printing the whole response body comment/uncomment below line | ||
echo json_encode($response->result, JSON_PRETTY_PRINT), "\n"; | ||
return $response; | ||
} catch (HttpException $e) { | ||
//Parse failure response | ||
echo $e->getMessage() . "\n"; | ||
$error = json_decode($e->getMessage()); | ||
echo $error->message . "\n"; | ||
echo $error->name . "\n"; | ||
echo $error->debug_id . "\n"; | ||
} | ||
return $response; | ||
} | ||
} | ||
|
||
if (!count(debug_backtrace())) | ||
{ | ||
$response = CreatePayoutSample::CreatePayout(true); | ||
GetPayoutSample::GetPayout($response->result->batch_header->payout_batch_id,true); | ||
|
||
} | ||
if (!count(debug_backtrace())) { | ||
$response = CreatePayoutSample::CreatePayout(true); | ||
GetPayoutSample::GetPayout($response->result->batch_header->payout_batch_id, true); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,52 @@ | ||
<?php | ||
|
||
namespace Sample; | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
use Sample\PayPalClient; | ||
use PaypalPayoutsSDK\Payouts\PayoutsItemCancelRequest; | ||
use Sample\CreatePayoutSample; | ||
use Sample\GetPayoutSample; | ||
use PayPalHttp\HttpException; | ||
|
||
class ItemCancelSample | ||
{ | ||
|
||
/** | ||
* This function can be used to create payout. | ||
*/ | ||
public static function CancelItem($itemId,$debug=false) | ||
public static function CancelItem($itemId, $debug = false) | ||
{ | ||
$request = new PayoutsItemCancelRequest($itemId); | ||
$client = PayPalClient::client(); | ||
$response = $client->execute($request); | ||
if ($debug) | ||
{ | ||
print "Status Code: {$response->statusCode}\n"; | ||
print "Item status: {$response->result->transaction_status}\n"; | ||
try { | ||
$request = new PayoutsItemCancelRequest($itemId); | ||
$client = PayPalClient::client(); | ||
$response = $client->execute($request); | ||
if ($debug) { | ||
print "Status Code: {$response->statusCode}\n"; | ||
print "Item status: {$response->result->transaction_status}\n"; | ||
|
||
print "Links:\n"; | ||
foreach($response->result->links as $link) | ||
{ | ||
print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n"; | ||
print "Links:\n"; | ||
foreach ($response->result->links as $link) { | ||
print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n"; | ||
} | ||
// To toggle printing the whole response body comment/uncomment below line | ||
echo json_encode($response->result, JSON_PRETTY_PRINT), "\n"; | ||
} | ||
// To toggle printing the whole response body comment/uncomment below line | ||
echo json_encode($response->result, JSON_PRETTY_PRINT), "\n"; | ||
return $response; | ||
} catch (HttpException $e) { | ||
//Parse failure response | ||
echo $e->getMessage() . "\n"; | ||
$error = json_decode($e->getMessage()); | ||
echo $error->message . "\n"; | ||
echo $error->name . "\n"; | ||
echo $error->debug_id . "\n"; | ||
} | ||
return $response; | ||
} | ||
} | ||
|
||
if (!count(debug_backtrace())) | ||
{ | ||
$payout = CreatePayoutSample::CreatePayout(true); | ||
$response= GetPayoutSample::getPayout($payout->result->batch_header->payout_batch_id,true); | ||
ItemCancelSample::CancelItem($response->result->items[0]->payout_item_id,true); | ||
|
||
} | ||
if (!count(debug_backtrace())) { | ||
$payout = CreatePayoutSample::CreatePayout(true); | ||
$response = GetPayoutSample::getPayout($payout->result->batch_header->payout_batch_id, true); | ||
ItemCancelSample::CancelItem($response->result->items[0]->payout_item_id, true); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,52 @@ | ||
<?php | ||
|
||
namespace Sample; | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
use Sample\PayPalClient; | ||
use PaypalPayoutsSDK\Payouts\PayoutsItemGetRequest; | ||
use Sample\CreatePayoutSample; | ||
use Sample\GetPayoutSample; | ||
use PayPalHttp\HttpException; | ||
|
||
class ItemGetSample | ||
{ | ||
|
||
/** | ||
* This function can be used to create payout. | ||
*/ | ||
public static function GetPayoutItem($itemId,$debug=false) | ||
public static function GetPayoutItem($itemId, $debug = false) | ||
{ | ||
$request = new PayoutsItemGetRequest($itemId); | ||
$client = PayPalClient::client(); | ||
$response = $client->execute($request); | ||
if ($debug) | ||
{ | ||
print "Status Code: {$response->statusCode}\n"; | ||
print "Item status: {$response->result->transaction_status}\n"; | ||
try { | ||
$request = new PayoutsItemGetRequest($itemId); | ||
$client = PayPalClient::client(); | ||
$response = $client->execute($request); | ||
if ($debug) { | ||
print "Status Code: {$response->statusCode}\n"; | ||
print "Item status: {$response->result->transaction_status}\n"; | ||
|
||
print "Links:\n"; | ||
foreach($response->result->links as $link) | ||
{ | ||
print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n"; | ||
print "Links:\n"; | ||
foreach ($response->result->links as $link) { | ||
print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n"; | ||
} | ||
// To toggle printing the whole response body comment/uncomment below line | ||
echo json_encode($response->result, JSON_PRETTY_PRINT), "\n"; | ||
} | ||
// To toggle printing the whole response body comment/uncomment below line | ||
echo json_encode($response->result, JSON_PRETTY_PRINT), "\n"; | ||
return $response; | ||
} catch (HttpException $e) { | ||
//Parse failure response | ||
echo $e->getMessage() . "\n"; | ||
$error = json_decode($e->getMessage()); | ||
echo $error->message . "\n"; | ||
echo $error->name . "\n"; | ||
echo $error->debug_id . "\n"; | ||
} | ||
return $response; | ||
} | ||
} | ||
|
||
if (!count(debug_backtrace())) | ||
{ | ||
$payout = CreatePayoutSample::CreatePayout(true); | ||
$response= GetPayoutSample::getPayout($payout->result->batch_header->payout_batch_id,true); | ||
ItemGetSample::GetPayoutItem($response->result->items[0]->payout_item_id,true); | ||
|
||
} | ||
if (!count(debug_backtrace())) { | ||
$payout = CreatePayoutSample::CreatePayout(true); | ||
$response = GetPayoutSample::getPayout($payout->result->batch_header->payout_batch_id, true); | ||
ItemGetSample::GetPayoutItem($response->result->items[0]->payout_item_id, true); | ||
} |