composer update and payment shit
This commit is contained in:
parent
a3ab84e993
commit
f32a85c8bd
312 changed files with 5301 additions and 3071 deletions
|
@ -25,7 +25,8 @@
|
|||
"20150621",
|
||||
"20150627",
|
||||
"20150628",
|
||||
"20150629"
|
||||
"20150629",
|
||||
"20150630"
|
||||
|
||||
]
|
||||
|
||||
|
@ -1363,6 +1364,28 @@
|
|||
"change": "Changed SAKURA_VTYPE to a SAKURA_STABLE boolean that can be used for only showing things on stable or development builds."
|
||||
}
|
||||
|
||||
],
|
||||
|
||||
"20150630": [
|
||||
|
||||
{
|
||||
"type": "ADD",
|
||||
"change": "Added Payments class (and some transaction function with help from <a href=\"http://github.com/kamilrakowski\" target=\"_blank\">kamilrakowski</a>)."
|
||||
},
|
||||
{
|
||||
"type": "ADD",
|
||||
"change": "Added automatic premium after payment."
|
||||
}
|
||||
|
||||
],
|
||||
|
||||
"20150701": [
|
||||
|
||||
{
|
||||
"type": "FIX",
|
||||
"change": "Fixed a multitude of fuckups."
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ namespace Sakura;
|
|||
class Configuration {
|
||||
|
||||
// Configuration data
|
||||
public static $_LCNF;
|
||||
public static $_DCNF;
|
||||
private static $_LCNF;
|
||||
private static $_DCNF;
|
||||
|
||||
// Initialise configuration, does not contain database initialisation because explained below
|
||||
public static function init($local) {
|
||||
|
|
|
@ -1,14 +1,141 @@
|
|||
<?php
|
||||
/*
|
||||
* Payment components
|
||||
* Payment components (only slightly convoluted)
|
||||
*/
|
||||
|
||||
namespace Sakura;
|
||||
|
||||
use PayPal\Api;
|
||||
use \PayPal\Api\Payer;
|
||||
use \PayPal\Api\Item;
|
||||
use \PayPal\Api\ItemList;
|
||||
use \PayPal\Api\Details;
|
||||
use \PayPal\Api\Amount;
|
||||
use \PayPal\Api\Transaction;
|
||||
use \PayPal\Api\RedirectUrls;
|
||||
use \PayPal\Api\Payment;
|
||||
use \PayPal\Api\PaymentExecution;
|
||||
|
||||
class Payments {
|
||||
|
||||
// Container for PayPal API
|
||||
private static $paypal;
|
||||
|
||||
// Initialise PayPal API
|
||||
public static function init() {
|
||||
|
||||
// Set PayPal object
|
||||
try {
|
||||
self::$paypal = new \PayPal\Rest\ApiContext(
|
||||
new \PayPal\Auth\OAuthTokenCredential(
|
||||
Configuration::getConfig('paypal_client_id'),
|
||||
Configuration::getConfig('paypal_secret')
|
||||
)
|
||||
);
|
||||
} catch(Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
// Create transaction
|
||||
public static function createTransaction($total, $itemName, $transDescription, $returnUrl) {
|
||||
|
||||
// Create the payer object
|
||||
$payer = new Payer();
|
||||
|
||||
// Set the method
|
||||
$payer->setPaymentMethod('paypal');
|
||||
|
||||
// Create the item
|
||||
$item = new Item();
|
||||
|
||||
// Set the item details
|
||||
$item ->setName($itemName)
|
||||
->setCurrency('EUR')
|
||||
->setQuantity(1)
|
||||
->setPrice($total);
|
||||
|
||||
// Create itemlist
|
||||
$list = new ItemList();
|
||||
|
||||
// Add the items
|
||||
$list->setItems([$item]);
|
||||
|
||||
// Create details
|
||||
$details = new Details();
|
||||
|
||||
// Set details
|
||||
$details->setSubtotal($total);
|
||||
|
||||
// Create amount
|
||||
$amount = new Amount();
|
||||
|
||||
// Set amount data
|
||||
$amount ->setCurrency('EUR')
|
||||
->setTotal($total)
|
||||
->setDetails($details);
|
||||
|
||||
// Create transaction
|
||||
$trans = new Transaction();
|
||||
|
||||
// Set transaction data (aka shit we already set but whatever who cares we need to set it again 500 times over again anyway, YAY TECHNOLOGY!)
|
||||
$trans ->setAmount($amount)
|
||||
->setItemList($list)
|
||||
->setDescription($transDescription)
|
||||
->setInvoiceNumber(uniqid());
|
||||
|
||||
// Create redirect url object
|
||||
$redir = new RedirectUrls();
|
||||
|
||||
// Set redirect url data
|
||||
$redir ->setReturnUrl($returnUrl. '?mode=finish&success=true')
|
||||
->setCancelUrl($returnUrl. '?mode=finish&success=false');
|
||||
|
||||
// Create payment object
|
||||
$payment = new Payment();
|
||||
|
||||
// Set payment data (finally)
|
||||
$payment->setIntent('sale')
|
||||
->setPayer($payer)
|
||||
->setRedirectUrls($redir)
|
||||
->setTransactions([$trans]);
|
||||
|
||||
// Try to create payment
|
||||
try {
|
||||
$payment->create(self::$paypal);
|
||||
} catch(Exception $ex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return the approval link if everything is gucci
|
||||
return $payment->getApprovalLink();
|
||||
|
||||
}
|
||||
|
||||
// Complete the PayPal transaction
|
||||
public static function completeTransaction($paymentId, $payerId) {
|
||||
|
||||
// Attempt to get the payment
|
||||
$payment = Payment::get($paymentId, self::$paypal);
|
||||
|
||||
// Create payment execution object
|
||||
$execute = new PaymentExecution();
|
||||
|
||||
// Set the payer ID
|
||||
$execute->setPayerId($payerId);
|
||||
|
||||
// Attempt to charge the fucker
|
||||
try {
|
||||
$payment->execute($execute, self::$paypal);
|
||||
} catch(Exception $ex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If everything was cute return true
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class Permissions {
|
|||
'SITE' => [
|
||||
|
||||
'DEACTIVATED' => 1, // Is a user in this group deactivated
|
||||
'VIEW_ONLINE' => 2, // Can view the extended online list
|
||||
'STATIC_PREMIUM' => 2, // Is always premium
|
||||
'ALTER_PROFILE' => 4, // Can alter their profile data
|
||||
'CHANGE_AVATAR' => 8, // Can change their avatar
|
||||
'CREATE_BACKGROUND' => 16, // Can create a background (different from changing)
|
||||
|
|
|
@ -40,8 +40,7 @@ class Users {
|
|||
'rankname' => 'Sakura Rank',
|
||||
'multi' => 0,
|
||||
'colour' => '#444',
|
||||
'description' => 'A hardcoded dummy rank for fallback.',
|
||||
'is_premium' => 0
|
||||
'description' => 'A hardcoded dummy rank for fallback.'
|
||||
];
|
||||
|
||||
// Check if a user is logged in
|
||||
|
@ -852,22 +851,9 @@ class Users {
|
|||
|
||||
}
|
||||
|
||||
// Check if user has Tenshi
|
||||
// Check if user has Tenshi [ REWRITE THIS ]
|
||||
public static function checkUserTenshi($id) {
|
||||
|
||||
// Get user's ranks
|
||||
$ranks = json_decode(self::getUser($id)['ranks'], true);
|
||||
|
||||
// Check premium flag
|
||||
foreach($ranks as $rank) {
|
||||
|
||||
// If premium rank was found return true
|
||||
if(self::getRank($rank)['is_premium'])
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
// Else return false
|
||||
return false;
|
||||
|
||||
}
|
||||
|
|
38
_sakura/composer.lock
generated
38
_sakura/composer.lock
generated
|
@ -47,16 +47,16 @@
|
|||
},
|
||||
{
|
||||
"name": "paypal/rest-api-sdk-php",
|
||||
"version": "v1.3.2",
|
||||
"version": "v1.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/paypal/PayPal-PHP-SDK.git",
|
||||
"reference": "0a32a6323c829e0e424e9f4d15e7b346c8472c08"
|
||||
"reference": "18e4eaaf319b48de2457abb7b2b1807cfe704c0a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/paypal/PayPal-PHP-SDK/zipball/0a32a6323c829e0e424e9f4d15e7b346c8472c08",
|
||||
"reference": "0a32a6323c829e0e424e9f4d15e7b346c8472c08",
|
||||
"url": "https://api.github.com/repos/paypal/PayPal-PHP-SDK/zipball/18e4eaaf319b48de2457abb7b2b1807cfe704c0a",
|
||||
"reference": "18e4eaaf319b48de2457abb7b2b1807cfe704c0a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -84,27 +84,27 @@
|
|||
}
|
||||
],
|
||||
"description": "PayPal's PHP SDK for REST APIs",
|
||||
"homepage": "https://github.com/paypal/rest-api-sdk-php",
|
||||
"homepage": "http://paypal.github.io/PayPal-PHP-SDK/",
|
||||
"keywords": [
|
||||
"payments",
|
||||
"paypal",
|
||||
"rest",
|
||||
"sdk"
|
||||
],
|
||||
"time": "2015-03-18 20:40:42"
|
||||
"time": "2015-06-25 17:12:03"
|
||||
},
|
||||
{
|
||||
"name": "phpmailer/phpmailer",
|
||||
"version": "v5.2.9",
|
||||
"version": "v5.2.10",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHPMailer/PHPMailer.git",
|
||||
"reference": "73b61679809615850706f1dbf88e6df2ddc05745"
|
||||
"reference": "07005ecbb80d11ec8c0f067bb37e8909cc7fcbb7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/73b61679809615850706f1dbf88e6df2ddc05745",
|
||||
"reference": "73b61679809615850706f1dbf88e6df2ddc05745",
|
||||
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/07005ecbb80d11ec8c0f067bb37e8909cc7fcbb7",
|
||||
"reference": "07005ecbb80d11ec8c0f067bb37e8909cc7fcbb7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -112,14 +112,16 @@
|
|||
},
|
||||
"require-dev": {
|
||||
"phpdocumentor/phpdocumentor": "*",
|
||||
"phpunit/phpunit": "4.1.*"
|
||||
"phpunit/phpunit": "4.3.*"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"class.phpmailer.php",
|
||||
"class.smtp.php",
|
||||
"class.pop3.php",
|
||||
"class.smtp.php"
|
||||
"extras/EasyPeasyICS.php",
|
||||
"extras/ntlm_sasl_client.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
|
@ -144,20 +146,20 @@
|
|||
}
|
||||
],
|
||||
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
|
||||
"time": "2014-09-26 18:33:30"
|
||||
"time": "2015-05-04 12:37:21"
|
||||
},
|
||||
{
|
||||
"name": "twig/twig",
|
||||
"version": "v1.18.1",
|
||||
"version": "v1.18.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/twigphp/Twig.git",
|
||||
"reference": "9f70492f44398e276d1b81c1b43adfe6751c7b7f"
|
||||
"reference": "e8e6575abf6102af53ec283f7f14b89e304fa602"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/9f70492f44398e276d1b81c1b43adfe6751c7b7f",
|
||||
"reference": "9f70492f44398e276d1b81c1b43adfe6751c7b7f",
|
||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/e8e6575abf6102af53ec283f7f14b89e304fa602",
|
||||
"reference": "e8e6575abf6102af53ec283f7f14b89e304fa602",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -201,7 +203,7 @@
|
|||
"keywords": [
|
||||
"templating"
|
||||
],
|
||||
"time": "2015-04-19 08:30:27"
|
||||
"time": "2015-06-06 23:31:24"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace Sakura;
|
||||
|
||||
// Define Sakura version
|
||||
define('SAKURA_VERSION', '20150629');
|
||||
define('SAKURA_VERSION', '20150701');
|
||||
define('SAKURA_VLABEL', 'Eminence');
|
||||
define('SAKURA_STABLE', false);
|
||||
define('SAKURA_COLOUR', '#6C3082');
|
||||
|
@ -83,7 +83,7 @@ $renderData = [
|
|||
|
||||
'perms' => [
|
||||
|
||||
'canViewOnline' => Permissions::check('SITE', 'USE_CHAT', Session::$userId, 1),
|
||||
'canGetPremium' => Permissions::check('SITE', 'OBTAIN_PREMIUM', Session::$userId, 1),
|
||||
'canUseForums' => Permissions::check('FORUM', 'USE_FORUM', Session::$userId, 1)
|
||||
|
||||
],
|
||||
|
@ -103,6 +103,7 @@ $renderData = [
|
|||
'data' => ($_init_udata = Users::getUser(Session::$userId)),
|
||||
'rank' => ($_init_rdata = Users::getRank($_init_udata['rank_main'])),
|
||||
'colour' => ($_init_udata['name_colour'] == null ? $_init_rdata['colour'] : $_init_udata['name_colour'])
|
||||
|
||||
]
|
||||
|
||||
];
|
||||
|
|
6
_sakura/templates/yuuno/errors/premiumComplete.tpl
Normal file
6
_sakura/templates/yuuno/errors/premiumComplete.tpl
Normal file
|
@ -0,0 +1,6 @@
|
|||
{% include 'global/header.tpl' %}
|
||||
<div class="content standalone" style="text-align: center;">
|
||||
<h1 class="stylised" style="margin: 1em auto;">Thank you for your contribution!</h1>
|
||||
<h1 class="fa fa-heart stylised" style="font-size: 20em;"></h1>
|
||||
</div>
|
||||
{% include 'global/footer.tpl' %}
|
|
@ -1,7 +1,12 @@
|
|||
{% include 'global/header.tpl' %}
|
||||
{% if page.fail %}
|
||||
<div class="headerNotify">
|
||||
<h1>The payment failed or was cancelled!</h1>
|
||||
<p>Something went wrong while processing the transaction, your PayPal account wasn't charged.</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="content donate">
|
||||
{#<h1 style="font-size: 5em; line-height: 1.5em;">Note to Flashwave: Don't forget to update this with the proper shit.</h1>#}
|
||||
<div class="head">Support Flashii (Get Tenshi)</div>
|
||||
<div class="head">Support Flashii</div>
|
||||
<div style="font-size: .9em; margin-bottom: 10px;">
|
||||
<p>In order to keep the site, its services and improvements on it going I need money but I'm not that big of a fan of asking for money without really giving anything special in return.</p>
|
||||
<p>Thus Tenshi exists. Tenshi is the "premium" user group on Flashii which gives you access to an extra set of features (which are listed further down on this page).</p>
|
||||
|
@ -44,16 +49,18 @@
|
|||
{% endfor %}
|
||||
</div>
|
||||
<div class="sectionHeader">Payment Options</div>
|
||||
{% if user.checklogin %}
|
||||
<span style="font-size: 8pt;">We do not (and probably will never) accept cryptocurrencies, sorry. Right now the only option is PayPal but we'll try to add more options in the future.</span>
|
||||
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top" class="paypal-donate-form">
|
||||
<input type="hidden" name="cmd" value="_s-xclick" />
|
||||
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHVwYJKoZIhvcNAQcEoIIHSDCCB0QCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYBm5EzqnU7RR0mOKVJuqnC0K4dE8T60AwKukd7vpB90F82FsiLx0eUxfaaKb2cWNSwxJelFFWir7XER7KQv2W4nNXK2o9uG851JzIAmoH/mg9TNKe5FAfGOOmw5mxTGIKWFFwjf4SO0lYojfszi63HfUqWe6I4KDC/4wsyKdonFQjELMAkGBSsOAwIaBQAwgdQGCSqGSIb3DQEHATAUBggqhkiG9w0DBwQI8sZbWMoOcWuAgbAGPHHEPx2CM0rUT6oGxC7XZMMQUWbh31PuBlGkZvNpDbiKMK9MaPySM4evmJnaDKzseY1dKqMDLAErDp2LRra1nejL8JDqdbIwzNZwUOeNtWcdCMV5X2USk58pBttMhC/Iuo8nOyWfvs/5kMWKx0YpTOA/kXbkiqWJEVaPnDyPC4GN/UhsnFpUEG1HDSM21xG5I+OOpPWfiHbGB77g7jpYp9OZEZYOCHLpc/rQjElEeqCCA4cwggODMIIC7KADAgECAgEAMA0GCSqGSIb3DQEBBQUAMIGOMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxFDASBgNVBAoTC1BheVBhbCBJbmMuMRMwEQYDVQQLFApsaXZlX2NlcnRzMREwDwYDVQQDFAhsaXZlX2FwaTEcMBoGCSqGSIb3DQEJARYNcmVAcGF5cGFsLmNvbTAeFw0wNDAyMTMxMDEzMTVaFw0zNTAyMTMxMDEzMTVaMIGOMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxFDASBgNVBAoTC1BheVBhbCBJbmMuMRMwEQYDVQQLFApsaXZlX2NlcnRzMREwDwYDVQQDFAhsaXZlX2FwaTEcMBoGCSqGSIb3DQEJARYNcmVAcGF5cGFsLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwUdO3fxEzEtcnI7ZKZL412XvZPugoni7i7D7prCe0AtaHTc97CYgm7NsAtJyxNLixmhLV8pyIEaiHXWAh8fPKW+R017+EmXrr9EaquPmsVvTywAAE1PMNOKqo2kl4Gxiz9zZqIajOm1fZGWcGS0f5JQ2kBqNbvbg2/Za+GJ/qwUCAwEAAaOB7jCB6zAdBgNVHQ4EFgQUlp98u8ZvF71ZP1LXChvsENZklGswgbsGA1UdIwSBszCBsIAUlp98u8ZvF71ZP1LXChvsENZklGuhgZSkgZEwgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAgV86VpqAWuXvX6Oro4qJ1tYVIT5DgWpE692Ag422H7yRIr/9j/iKG4Thia/Oflx4TdL+IFJBAyPK9v6zZNZtBgPBynXb048hsP16l2vi0k5Q2JKiPDsEfBhGI+HnxLXEaUWAcVfCsQFvd2A1sxRr67ip5y2wwBelUecP3AjJ+YcxggGaMIIBlgIBATCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTE0MDYwOTA5Mzc0NVowIwYJKoZIhvcNAQkEMRYEFIWyN+ucs3zVasPJB4BMeytk8sBEMA0GCSqGSIb3DQEBAQUABIGAeKZgq6m22LZ+516NUYp4FnGPuA88+qJHjwZmt3TV2R6Jg4/H8R4dQ3958pcxDOpVjeg6o/vn+PhYbik6wBC6n1q9+oOsx9MNhmJPWBFeA2tiJ3aSFQ/QkfrI7fB6de54ywl58sAqC+opGA/ld3zUMzUJJ7nGopSeqX1dawpj2sc=-----END PKCS7-----" />
|
||||
<input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif" name="submit" alt="PayPal – The safer, easier way to pay online." style="border: 0;" />
|
||||
<img alt="" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" style="border: 0; width: 1px; height: 1px;" />
|
||||
</form>{#<h1 style="text-align: center;"><PayPal donate button here></h1>#}
|
||||
{% if user.checklogin and perms.canGetPremium %}
|
||||
<span style="font-size: 8pt;">Our transactions are handled through PayPal.</span>
|
||||
<form action="/support" method="post" style="text-align: center;">
|
||||
<input type="hidden" name="mode" value="purchase" />
|
||||
<input type="hidden" name="time" value="{{ php.time }}" />
|
||||
<input type="hidden" name="session" value="{{ php.sessionid }}" />
|
||||
<input type="number" name="months" /> <input type="submit" value="throw money at flashwave" />
|
||||
</form>
|
||||
{% elseif user.checklogin %}
|
||||
<h1 style="text-align: center; margin: 1em auto;" class="stylised">You can't get Tenshi at the current moment!</h1>
|
||||
{% else %}
|
||||
<h1 style="text-align: center;">You need to be logged in to donate!</h1>
|
||||
<h1 style="text-align: center; margin: 1em auto;" class="stylised">You need to be logged in to get Tenshi!</h1>
|
||||
{% endif %}
|
||||
</div>
|
||||
<script type="text/javascript">window.onload = function() {donatePage();}</script>
|
||||
|
|
|
@ -6,8 +6,10 @@ $vendorDir = dirname(dirname(__FILE__));
|
|||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'EasyPeasyICS' => $vendorDir . '/phpmailer/phpmailer/extras/EasyPeasyICS.php',
|
||||
'PHPMailer' => $vendorDir . '/phpmailer/phpmailer/class.phpmailer.php',
|
||||
'POP3' => $vendorDir . '/phpmailer/phpmailer/class.pop3.php',
|
||||
'SMTP' => $vendorDir . '/phpmailer/phpmailer/class.smtp.php',
|
||||
'ntlm_sasl_client_class' => $vendorDir . '/phpmailer/phpmailer/extras/ntlm_sasl_client.php',
|
||||
'phpmailerException' => $vendorDir . '/phpmailer/phpmailer/class.phpmailer.php',
|
||||
);
|
||||
|
|
142
_sakura/vendor/composer/installed.json
vendored
142
_sakura/vendor/composer/installed.json
vendored
|
@ -1,59 +1,4 @@
|
|||
[
|
||||
{
|
||||
"name": "phpmailer/phpmailer",
|
||||
"version": "v5.2.9",
|
||||
"version_normalized": "5.2.9.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHPMailer/PHPMailer.git",
|
||||
"reference": "73b61679809615850706f1dbf88e6df2ddc05745"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/73b61679809615850706f1dbf88e6df2ddc05745",
|
||||
"reference": "73b61679809615850706f1dbf88e6df2ddc05745",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpdocumentor/phpdocumentor": "*",
|
||||
"phpunit/phpunit": "4.1.*"
|
||||
},
|
||||
"time": "2014-09-26 18:33:30",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"class.phpmailer.php",
|
||||
"class.pop3.php",
|
||||
"class.smtp.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"LGPL-2.1"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jim Jagielski",
|
||||
"email": "jimjag@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Marcus Bointon",
|
||||
"email": "phpmailer@synchromedia.co.uk"
|
||||
},
|
||||
{
|
||||
"name": "Andy Prevost",
|
||||
"email": "codeworxtech@users.sourceforge.net"
|
||||
},
|
||||
{
|
||||
"name": "Brent R. Matzelle"
|
||||
}
|
||||
],
|
||||
"description": "PHPMailer is a full-featured email creation and transfer class for PHP"
|
||||
},
|
||||
{
|
||||
"name": "flashwave/parsedown",
|
||||
"version": "1.5.1",
|
||||
|
@ -97,23 +42,23 @@
|
|||
},
|
||||
{
|
||||
"name": "twig/twig",
|
||||
"version": "v1.18.1",
|
||||
"version_normalized": "1.18.1.0",
|
||||
"version": "v1.18.2",
|
||||
"version_normalized": "1.18.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/twigphp/Twig.git",
|
||||
"reference": "9f70492f44398e276d1b81c1b43adfe6751c7b7f"
|
||||
"reference": "e8e6575abf6102af53ec283f7f14b89e304fa602"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/9f70492f44398e276d1b81c1b43adfe6751c7b7f",
|
||||
"reference": "9f70492f44398e276d1b81c1b43adfe6751c7b7f",
|
||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/e8e6575abf6102af53ec283f7f14b89e304fa602",
|
||||
"reference": "e8e6575abf6102af53ec283f7f14b89e304fa602",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.2.7"
|
||||
},
|
||||
"time": "2015-04-19 08:30:27",
|
||||
"time": "2015-06-06 23:31:24",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
|
@ -155,18 +100,75 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "paypal/rest-api-sdk-php",
|
||||
"version": "v1.3.2",
|
||||
"version_normalized": "1.3.2.0",
|
||||
"name": "phpmailer/phpmailer",
|
||||
"version": "v5.2.10",
|
||||
"version_normalized": "5.2.10.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/paypal/PayPal-PHP-SDK.git",
|
||||
"reference": "0a32a6323c829e0e424e9f4d15e7b346c8472c08"
|
||||
"url": "https://github.com/PHPMailer/PHPMailer.git",
|
||||
"reference": "07005ecbb80d11ec8c0f067bb37e8909cc7fcbb7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/paypal/PayPal-PHP-SDK/zipball/0a32a6323c829e0e424e9f4d15e7b346c8472c08",
|
||||
"reference": "0a32a6323c829e0e424e9f4d15e7b346c8472c08",
|
||||
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/07005ecbb80d11ec8c0f067bb37e8909cc7fcbb7",
|
||||
"reference": "07005ecbb80d11ec8c0f067bb37e8909cc7fcbb7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpdocumentor/phpdocumentor": "*",
|
||||
"phpunit/phpunit": "4.3.*"
|
||||
},
|
||||
"time": "2015-05-04 12:37:21",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"class.phpmailer.php",
|
||||
"class.smtp.php",
|
||||
"class.pop3.php",
|
||||
"extras/EasyPeasyICS.php",
|
||||
"extras/ntlm_sasl_client.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"LGPL-2.1"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jim Jagielski",
|
||||
"email": "jimjag@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Marcus Bointon",
|
||||
"email": "phpmailer@synchromedia.co.uk"
|
||||
},
|
||||
{
|
||||
"name": "Andy Prevost",
|
||||
"email": "codeworxtech@users.sourceforge.net"
|
||||
},
|
||||
{
|
||||
"name": "Brent R. Matzelle"
|
||||
}
|
||||
],
|
||||
"description": "PHPMailer is a full-featured email creation and transfer class for PHP"
|
||||
},
|
||||
{
|
||||
"name": "paypal/rest-api-sdk-php",
|
||||
"version": "v1.5.0",
|
||||
"version_normalized": "1.5.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/paypal/PayPal-PHP-SDK.git",
|
||||
"reference": "18e4eaaf319b48de2457abb7b2b1807cfe704c0a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/paypal/PayPal-PHP-SDK/zipball/18e4eaaf319b48de2457abb7b2b1807cfe704c0a",
|
||||
"reference": "18e4eaaf319b48de2457abb7b2b1807cfe704c0a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -177,7 +179,7 @@
|
|||
"require-dev": {
|
||||
"phpunit/phpunit": "3.7.*"
|
||||
},
|
||||
"time": "2015-03-18 20:40:42",
|
||||
"time": "2015-06-25 17:12:03",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
|
@ -196,7 +198,7 @@
|
|||
}
|
||||
],
|
||||
"description": "PayPal's PHP SDK for REST APIs",
|
||||
"homepage": "https://github.com/paypal/rest-api-sdk-php",
|
||||
"homepage": "http://paypal.github.io/PayPal-PHP-SDK/",
|
||||
"keywords": [
|
||||
"payments",
|
||||
"paypal",
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
![Home Image](https://raw.githubusercontent.com/wiki/paypal/PayPal-PHP-SDK/images/homepage.jpg)
|
||||
|
||||
[![Build Status](https://travis-ci.org/paypal/PayPal-PHP-SDK.png?branch=master)](https://travis-ci.org/paypal/PayPal-PHP-SDK) [![Coverage Status](https://img.shields.io/coveralls/paypal/PayPal-PHP-SDK.svg)](https://coveralls.io/r/paypal/PayPal-PHP-SDK?branch=master)
|
||||
[![Build Status](https://travis-ci.org/paypal/PayPal-PHP-SDK.png?branch=master)](https://travis-ci.org/paypal/PayPal-PHP-SDK)
|
||||
[![Coverage Status](https://coveralls.io/repos/paypal/PayPal-PHP-SDK/badge.svg?branch=master)](https://coveralls.io/r/paypal/PayPal-PHP-SDK?branch=master)
|
||||
|
||||
__Welcome to PayPal PHP SDK__. This repository contains PayPal's PHP SDK and samples for REST API.
|
||||
|
||||
|
@ -21,8 +22,7 @@ __Welcome to PayPal PHP SDK__. This repository contains PayPal's PHP SDK and sam
|
|||
|
||||
## Latest Updates
|
||||
|
||||
> **Seeing this error: `'Method PayPal\Api\Sale::getTransactionFee() does not exist' in paypal/vendor/paypal/rest-api-sdk-php/lib/PayPal/Common/PPReflectionUtil.php:73`, Please upgrade the SDK to latest version [v1.3.0](https://github.com/paypal/PayPal-PHP-SDK/releases/tag/v1.3.0).**
|
||||
|
||||
- Vault APIs now have List Credit Card with Filters, new Fields to help you find the object easily. Checkout the latest release.
|
||||
- Checkout the latest 1.0.0 release. Here are all the [ breaking Changes in v1.0.0 ](https://github.com/paypal/PayPal-PHP-SDK/wiki/Breaking-Changes---1.0.0) if you are migrating from older versions.
|
||||
- Now we have a [Github Page](http://paypal.github.io/PayPal-PHP-SDK/), that helps you find all helpful resources building applications using PayPal-PHP-SDK.
|
||||
- Introduced `DEBUG` level to logging. Deprecated `FINE`. Ability to restrict `DEBUG` level on `live` mode. [Read More](https://github.com/paypal/PayPal-PHP-SDK/wiki/Logging).
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"keywords": ["paypal", "payments", "rest", "sdk"],
|
||||
"type": "library",
|
||||
"license": "Apache2",
|
||||
"homepage": "https://github.com/paypal/rest-api-sdk-php",
|
||||
"homepage": "http://paypal.github.io/PayPal-PHP-SDK/",
|
||||
"authors": [
|
||||
{
|
||||
"name": "PayPal",
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
namespace PayPal\Api;
|
||||
|
||||
use PayPal\Common\PayPalResourceModel;
|
||||
use PayPal\Transport\PayPalRestCall;
|
||||
use PayPal\Validation\ArgumentValidator;
|
||||
use PayPal\Rest\ApiContext;
|
||||
use PayPal\Transport\PayPalRestCall;
|
||||
|
||||
/**
|
||||
* Class CreditCard
|
||||
|
@ -24,10 +24,14 @@ use PayPal\Transport\PayPalRestCall;
|
|||
* @property string last_name
|
||||
* @property \PayPal\Api\Address billing_address
|
||||
* @property string external_customer_id
|
||||
* @property string merchant_id
|
||||
* @property string payer_id
|
||||
* @property string external_card_id
|
||||
* @property string state
|
||||
* @property string valid_until
|
||||
* @property string create_time
|
||||
* @property string update_time
|
||||
* @property string valid_until
|
||||
* @property \PayPal\Api\Links[] links
|
||||
*/
|
||||
class CreditCard extends PayPalResourceModel
|
||||
{
|
||||
|
@ -78,7 +82,8 @@ class CreditCard extends PayPalResourceModel
|
|||
}
|
||||
|
||||
/**
|
||||
* Type of the Card (eg. Visa, Mastercard, etc.).
|
||||
* Type of the Card. Currently supporting Visa, Mastercard, Amex, Discover and Maestro
|
||||
* Valid Values: ["visa", "mastercard", "amex", "discover", "maestro"]
|
||||
*
|
||||
* @param string $type
|
||||
*
|
||||
|
@ -91,7 +96,7 @@ class CreditCard extends PayPalResourceModel
|
|||
}
|
||||
|
||||
/**
|
||||
* Type of the Card (eg. Visa, Mastercard, etc.).
|
||||
* Type of the Card. Currently supporting Visa, Mastercard, Amex, Discover and Maestro
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
@ -261,6 +266,75 @@ class CreditCard extends PayPalResourceModel
|
|||
return $this->external_customer_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* A user provided, optional convenvience field that functions as a unique identifier for the merchant on behalf of whom this credit card is being stored for. Note that this has no relation to PayPal merchant id
|
||||
*
|
||||
* @param string $merchant_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMerchantId($merchant_id)
|
||||
{
|
||||
$this->merchant_id = $merchant_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A user provided, optional convenvience field that functions as a unique identifier for the merchant on behalf of whom this credit card is being stored for. Note that this has no relation to PayPal merchant id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMerchantId()
|
||||
{
|
||||
return $this->merchant_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* A unique identifier that you can assign and track when storing a credit card or using a stored credit card. This ID can help to avoid unintentional use or misuse of credit cards. This ID can be any value you would like to associate with the saved card, such as a UUID, username, or email address. Required when using a stored credit card if a payer_id was originally provided when storing the credit card in vault.
|
||||
* @deprecated This is being deprecated in favor of the `external_customer_id` property.
|
||||
* @param string $payer_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPayerId($payer_id)
|
||||
{
|
||||
$this->payer_id = $payer_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A unique identifier that you can assign and track when storing a credit card or using a stored credit card. This ID can help to avoid unintentional use or misuse of credit cards. This ID can be any value you would like to associate with the saved card, such as a UUID, username, or email address. Required when using a stored credit card if a payer_id was originally provided when storing the credit card in vault.
|
||||
* @deprecated This is being deprecated in favor of the `external_customer_id` property.
|
||||
* @return string
|
||||
*/
|
||||
public function getPayerId()
|
||||
{
|
||||
return $this->payer_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* A unique identifier of the bank account resource. Generated and provided by the facilitator so it can be used to restrict the usage of the bank account to the specific merchant.
|
||||
*
|
||||
* @param string $external_card_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setExternalCardId($external_card_id)
|
||||
{
|
||||
$this->external_card_id = $external_card_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A unique identifier of the bank account resource. Generated and provided by the facilitator so it can be used to restrict the usage of the bank account to the specific merchant.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExternalCardId()
|
||||
{
|
||||
return $this->external_card_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* State of the funding instrument.
|
||||
* Valid Values: ["expired", "ok"]
|
||||
|
@ -285,6 +359,52 @@ class CreditCard extends PayPalResourceModel
|
|||
return $this->state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resource creation time as ISO8601 date-time format (ex: 1994-11-05T13:15:30Z) that indicates creation time.
|
||||
*
|
||||
* @param string $create_time
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCreateTime($create_time)
|
||||
{
|
||||
$this->create_time = $create_time;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resource creation time as ISO8601 date-time format (ex: 1994-11-05T13:15:30Z) that indicates creation time.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCreateTime()
|
||||
{
|
||||
return $this->create_time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resource creation time as ISO8601 date-time format (ex: 1994-11-05T13:15:30Z) that indicates the updation time.
|
||||
*
|
||||
* @param string $update_time
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUpdateTime($update_time)
|
||||
{
|
||||
$this->update_time = $update_time;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resource creation time as ISO8601 date-time format (ex: 1994-11-05T13:15:30Z) that indicates the updation time.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUpdateTime()
|
||||
{
|
||||
return $this->update_time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Date/Time until this resource can be used fund a payment.
|
||||
*
|
||||
|
@ -308,52 +428,6 @@ class CreditCard extends PayPalResourceModel
|
|||
return $this->valid_until;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time the resource was created in UTC ISO8601 format.
|
||||
*
|
||||
* @param string $create_time
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCreateTime($create_time)
|
||||
{
|
||||
$this->create_time = $create_time;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time the resource was created in UTC ISO8601 format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCreateTime()
|
||||
{
|
||||
return $this->create_time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time the resource was created in UTC ISO8601 format.
|
||||
*
|
||||
* @param string $update_time
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUpdateTime($update_time)
|
||||
{
|
||||
$this->update_time = $update_time;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time the resource was created in UTC ISO8601 format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUpdateTime()
|
||||
{
|
||||
return $this->update_time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Credit Card Resource (aka Tokenize).
|
||||
*
|
||||
|
@ -448,4 +522,43 @@ class CreditCard extends PayPalResourceModel
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of Credit Card resources.
|
||||
*
|
||||
* @param array $params
|
||||
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
|
||||
* @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
|
||||
* @return CreditCardList
|
||||
*/
|
||||
public static function all($params, $apiContext = null, $restCall = null)
|
||||
{
|
||||
if (is_null($params)) {
|
||||
$params = array();
|
||||
}
|
||||
ArgumentValidator::validate($params, 'params');
|
||||
$payLoad = "";
|
||||
$allowedParams = array(
|
||||
'page_size' => 1,
|
||||
'page' => 1,
|
||||
'start_time' => 1,
|
||||
'end_time' => 1,
|
||||
'sort_order' => 1,
|
||||
'sort_by' => 1,
|
||||
'merchant_id' => 1,
|
||||
'external_card_id' => 1,
|
||||
'external_customer_id' => 1,
|
||||
);
|
||||
$json = self::executeCall(
|
||||
"/v1/vault/credit-cards" . "?" . http_build_query(array_intersect_key($params, $allowedParams)),
|
||||
"GET",
|
||||
$payLoad,
|
||||
null,
|
||||
$apiContext,
|
||||
$restCall
|
||||
);
|
||||
$ret = new CreditCardList();
|
||||
$ret->fromJson($json);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace PayPal\Api;
|
||||
|
||||
use PayPal\Common\PayPalModel;
|
||||
use PayPal\Common\PayPalResourceModel;
|
||||
|
||||
/**
|
||||
* Class CreditCardList
|
||||
|
@ -11,22 +11,23 @@ use PayPal\Common\PayPalModel;
|
|||
*
|
||||
* @package PayPal\Api
|
||||
*
|
||||
* @property \PayPal\Api\CreditCard[] credit_cards
|
||||
* @property int count
|
||||
* @property string next_id
|
||||
* @property \PayPal\Api\CreditCard[] items
|
||||
* @property \PayPal\Api\Links[] links
|
||||
* @property int total_items
|
||||
* @property int total_pages
|
||||
*/
|
||||
class CreditCardList extends PayPalModel
|
||||
class CreditCardList extends PayPalResourceModel
|
||||
{
|
||||
/**
|
||||
* A list of credit card resources
|
||||
*
|
||||
* @param \PayPal\Api\CreditCard[] $credit_cards
|
||||
* @param \PayPal\Api\CreditCard[] $items
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCreditCards($credit_cards)
|
||||
public function setItems($items)
|
||||
{
|
||||
$this->{"credit-cards"} = $credit_cards;
|
||||
$this->items = $items;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -35,85 +36,85 @@ class CreditCardList extends PayPalModel
|
|||
*
|
||||
* @return \PayPal\Api\CreditCard[]
|
||||
*/
|
||||
public function getCreditCards()
|
||||
public function getItems()
|
||||
{
|
||||
return $this->{"credit-cards"};
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append CreditCards to the list.
|
||||
* Append Items to the list.
|
||||
*
|
||||
* @param \PayPal\Api\CreditCard $creditCard
|
||||
* @return $this
|
||||
*/
|
||||
public function addCreditCard($creditCard)
|
||||
public function addItem($creditCard)
|
||||
{
|
||||
if (!$this->getCreditCards()) {
|
||||
return $this->setCreditCards(array($creditCard));
|
||||
if (!$this->getItems()) {
|
||||
return $this->setItems(array($creditCard));
|
||||
} else {
|
||||
return $this->setCreditCards(
|
||||
array_merge($this->getCreditCards(), array($creditCard))
|
||||
return $this->setItems(
|
||||
array_merge($this->getItems(), array($creditCard))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove CreditCards from the list.
|
||||
* Remove Items from the list.
|
||||
*
|
||||
* @param \PayPal\Api\CreditCard $creditCard
|
||||
* @return $this
|
||||
*/
|
||||
public function removeCreditCard($creditCard)
|
||||
public function removeItem($creditCard)
|
||||
{
|
||||
return $this->setCreditCards(
|
||||
array_diff($this->getCreditCards(), array($creditCard))
|
||||
return $this->setItems(
|
||||
array_diff($this->getItems(), array($creditCard))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items.
|
||||
* Total number of items present in the given list. Note that the number of items might be larger than the records in the current page.
|
||||
*
|
||||
* @param int $count
|
||||
* @param int $total_items
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCount($count)
|
||||
public function setTotalItems($total_items)
|
||||
{
|
||||
$this->count = $count;
|
||||
$this->total_items = $total_items;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items.
|
||||
* Total number of items present in the given list. Note that the number of items might be larger than the records in the current page.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCount()
|
||||
public function getTotalItems()
|
||||
{
|
||||
return $this->count;
|
||||
return $this->total_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifier of the next element to get the next range of results.
|
||||
* Total number of pages that exist, for the total number of items, with the given page size.
|
||||
*
|
||||
* @param string $next_id
|
||||
* @param int $total_pages
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setNextId($next_id)
|
||||
public function setTotalPages($total_pages)
|
||||
{
|
||||
$this->next_id = $next_id;
|
||||
$this->total_pages = $total_pages;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifier of the next element to get the next range of results.
|
||||
* Total number of pages that exist, for the total number of items, with the given page size.
|
||||
*
|
||||
* @return string
|
||||
* @return int
|
||||
*/
|
||||
public function getNextId()
|
||||
public function getTotalPages()
|
||||
{
|
||||
return $this->next_id;
|
||||
return $this->total_pages;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
namespace PayPal\Api;
|
||||
|
||||
use PayPal\Common\PayPalModel;
|
||||
use PayPal\Converter\FormatConverter;
|
||||
use PayPal\Validation\NumericValidator;
|
||||
|
||||
/**
|
||||
* Class InvoiceItem
|
||||
|
@ -70,12 +72,14 @@ class InvoiceItem extends PayPalModel
|
|||
/**
|
||||
* Quantity of the item. Range of 0 to 9999.999.
|
||||
*
|
||||
* @param \PayPal\Api\number $quantity
|
||||
* @param string|double $quantity
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setQuantity($quantity)
|
||||
{
|
||||
NumericValidator::validate($quantity, "Percent");
|
||||
$quantity = FormatConverter::formatToPrice($quantity);
|
||||
$this->quantity = $quantity;
|
||||
return $this;
|
||||
}
|
||||
|
@ -83,7 +87,7 @@ class InvoiceItem extends PayPalModel
|
|||
/**
|
||||
* Quantity of the item. Range of 0 to 9999.999.
|
||||
*
|
||||
* @return \PayPal\Api\number
|
||||
* @return string
|
||||
*/
|
||||
public function getQuantity()
|
||||
{
|
||||
|
|
|
@ -19,8 +19,8 @@ use PayPal\Common\PayPalModel;
|
|||
class Patch extends PayPalModel
|
||||
{
|
||||
/**
|
||||
* Patch operation to perform.Value required for add & remove operation can be any JSON value.
|
||||
* Valid Values: ["add", "remove", "replace"]
|
||||
* The operation to perform.
|
||||
* Valid Values: ["add", "remove", "replace", "move", "copy", "test"]
|
||||
*
|
||||
* @param string $op
|
||||
*
|
||||
|
@ -33,7 +33,7 @@ class Patch extends PayPalModel
|
|||
}
|
||||
|
||||
/**
|
||||
* Patch operation to perform.Value required for add & remove operation can be any JSON value.
|
||||
* The operation to perform.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
@ -43,7 +43,7 @@ class Patch extends PayPalModel
|
|||
}
|
||||
|
||||
/**
|
||||
* string containing a JSON-Pointer value that references a location within the target document (the target location) where the operation is performed.
|
||||
* String containing a JSON-Pointer value that references a location within the target document where the operation is performed.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
|
@ -56,7 +56,7 @@ class Patch extends PayPalModel
|
|||
}
|
||||
|
||||
/**
|
||||
* string containing a JSON-Pointer value that references a location within the target document (the target location) where the operation is performed.
|
||||
* String containing a JSON-Pointer value that references a location within the target document where the operation is performed.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
@ -89,7 +89,7 @@ class Patch extends PayPalModel
|
|||
}
|
||||
|
||||
/**
|
||||
* A string containing a JSON Pointer value that references the location in the target document to move the value from.
|
||||
* A string containing a JSON Pointer value that references the location in the target document from which to move the value. Required for use where op=move.
|
||||
*
|
||||
* @param string $from
|
||||
*
|
||||
|
@ -102,7 +102,7 @@ class Patch extends PayPalModel
|
|||
}
|
||||
|
||||
/**
|
||||
* A string containing a JSON Pointer value that references the location in the target document to move the value from.
|
||||
* A string containing a JSON Pointer value that references the location in the target document from which to move the value. Required for use where op=move.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
namespace PayPal\Api;
|
||||
|
||||
use PayPal\Common\PayPalModel;
|
||||
use PayPal\Converter\FormatConverter;
|
||||
use PayPal\Validation\NumericValidator;
|
||||
|
||||
/**
|
||||
* Class Tax
|
||||
|
@ -67,12 +69,14 @@ class Tax extends PayPalModel
|
|||
/**
|
||||
* Rate of the specified tax. Range of 0.001 to 99.999.
|
||||
*
|
||||
* @param \PayPal\Api\number $percent
|
||||
* @param string|double $percent
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPercent($percent)
|
||||
{
|
||||
NumericValidator::validate($percent, "Percent");
|
||||
$percent = FormatConverter::formatToPrice($percent);
|
||||
$this->percent = $percent;
|
||||
return $this;
|
||||
}
|
||||
|
@ -80,7 +84,7 @@ class Tax extends PayPalModel
|
|||
/**
|
||||
* Rate of the specified tax. Range of 0.001 to 99.999.
|
||||
*
|
||||
* @return \PayPal\Api\number
|
||||
* @return string
|
||||
*/
|
||||
public function getPercent()
|
||||
{
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
namespace PayPal\Api;
|
||||
|
||||
use PayPal\Common\PayPalModel;
|
||||
use PayPal\Common\PayPalResourceModel;
|
||||
use PayPal\Exception\PayPalConnectionException;
|
||||
use PayPal\Validation\ArgumentValidator;
|
||||
use PayPal\Api\WebhookEventList;
|
||||
use PayPal\Rest\ApiContext;
|
||||
use PayPal\Transport\PayPalRestCall;
|
||||
use PayPal\Validation\JsonValidator;
|
||||
|
||||
/**
|
||||
* Class WebhookEvent
|
||||
|
@ -163,6 +163,44 @@ class WebhookEvent extends PayPalResourceModel
|
|||
return $this->resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates Received Event from Webhook, and returns the webhook event object. Because security verifications by verifying certificate chain is not enabled in PHP yet,
|
||||
* we need to fallback to default behavior of retrieving the ID attribute of the data, and make a separate GET call to PayPal APIs, to retrieve the data.
|
||||
* This is important to do again, as hacker could have faked the data, and the retrieved data cannot be trusted without either doing client side security validation, or making a separate call
|
||||
* to PayPal APIs to retrieve the actual data. This limits the hacker to mimick a fake data, as hacker wont be able to predict the Id correctly.
|
||||
*
|
||||
* NOTE: PLEASE DO NOT USE THE DATA PROVIDED IN WEBHOOK DIRECTLY, AS HACKER COULD PASS IN FAKE DATA. IT IS VERY IMPORTANT THAT YOU RETRIEVE THE ID AND MAKE A SEPARATE CALL TO PAYPAL API.
|
||||
*
|
||||
* @param string $body
|
||||
* @param ApiContext $apiContext
|
||||
* @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
|
||||
* @return WebhookEvent
|
||||
* @throws \InvalidArgumentException if input arguments are incorrect, or Id is not found.
|
||||
* @throws PayPalConnectionException if any exception from PayPal APIs other than not found is sent.
|
||||
*/
|
||||
public static function validateAndGetReceivedEvent($body, $apiContext = null, $restCall = null)
|
||||
{
|
||||
if ($body == null | empty($body)){
|
||||
throw new \InvalidArgumentException("Body cannot be null or empty");
|
||||
}
|
||||
if (!JsonValidator::validate($body, true)) {
|
||||
throw new \InvalidArgumentException("Request Body is not a valid JSON.");
|
||||
}
|
||||
$object = new WebhookEvent($body);
|
||||
if ($object->getId() == null) {
|
||||
throw new \InvalidArgumentException("Id attribute not found in JSON. Possible reason could be invalid JSON Object");
|
||||
}
|
||||
try {
|
||||
return self::get($object->getId(), $apiContext, $restCall);
|
||||
} catch(PayPalConnectionException $ex) {
|
||||
if ($ex->getCode() == 404) {
|
||||
// It means that the given webhook event Id is not found for this merchant.
|
||||
throw new \InvalidArgumentException("Webhook Event Id provided in the data is incorrect. This could happen if anyone other than PayPal is faking the incoming webhook data.");
|
||||
}
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the Webhooks event resource identified by event_id. Can be used to retrieve the payload for an event.
|
||||
*
|
||||
|
|
|
@ -58,7 +58,7 @@ class PayPalModel
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a list of Object from Array or Json String. It is generally used when you json
|
||||
* Returns a list of Object from Array or Json String. It is generally used when your json
|
||||
* contains an array of this object
|
||||
*
|
||||
* @param mixed $data Array object or json string representation
|
||||
|
@ -66,21 +66,38 @@ class PayPalModel
|
|||
*/
|
||||
public static function getList($data)
|
||||
{
|
||||
if (!is_array($data) && JsonValidator::validate($data)) {
|
||||
//Convert to Array if Json Data Sent
|
||||
$data = json_decode($data, true);
|
||||
// Return Null if Null
|
||||
if ($data === null) { return null; }
|
||||
|
||||
if (is_a($data, get_class(new \stdClass()))) {
|
||||
//This means, root element is object
|
||||
return new static(json_encode($data));
|
||||
}
|
||||
if (!ArrayUtil::isAssocArray($data)) {
|
||||
|
||||
$list = array();
|
||||
//This means, root element is array
|
||||
foreach ($data as $k => $v) {
|
||||
$obj = new static;
|
||||
$obj->fromArray($v);
|
||||
$list[] = $obj;
|
||||
|
||||
if (is_array($data)) {
|
||||
$data = json_encode($data);
|
||||
}
|
||||
|
||||
if (JsonValidator::validate($data)) {
|
||||
// It is valid JSON
|
||||
$decoded = json_decode($data);
|
||||
if ($decoded === null) {
|
||||
return $list;
|
||||
}
|
||||
return array();
|
||||
if (is_array($decoded)) {
|
||||
foreach ($decoded as $k => $v) {
|
||||
$list[] = self::getList($v);
|
||||
}
|
||||
}
|
||||
if (is_a($decoded, get_class(new \stdClass()))) {
|
||||
//This means, root element is object
|
||||
$list[] = new static(json_encode($decoded));
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,7 +123,7 @@ class PayPalModel
|
|||
public function __set($key, $value)
|
||||
{
|
||||
ModelAccessorValidator::validate($this, $this->convertToCamelCase($key));
|
||||
if (!is_array($value) && $value == null) {
|
||||
if (!is_array($value) && $value === null) {
|
||||
$this->__unset($key);
|
||||
} else {
|
||||
$this->_propMap[$key] = $value;
|
||||
|
|
|
@ -12,7 +12,7 @@ class PayPalConstants
|
|||
{
|
||||
|
||||
const SDK_NAME = 'PayPal-PHP-SDK';
|
||||
const SDK_VERSION = '1.3.2';
|
||||
const SDK_VERSION = '1.5.0';
|
||||
|
||||
/**
|
||||
* Approval URL for Payment
|
||||
|
|
|
@ -95,6 +95,7 @@ class PayPalHttpConnection
|
|||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
case 'PUT':
|
||||
case 'PATCH':
|
||||
case 'DELETE':
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ class PayPalLoggingManager
|
|||
if ($this->isLoggingEnabled) {
|
||||
$config = PayPalConfigManager::getInstance()->getConfigHashmap();
|
||||
// Check if logging in live
|
||||
if ($config['mode'] == 'live') {
|
||||
if (array_key_exists('mode', $config) && $config['mode'] == 'live') {
|
||||
// Live should not have logging level above INFO.
|
||||
if ($this->loggingLevel >= PayPalLoggingLevel::INFO) {
|
||||
// If it is at Debug Level, throw an warning in the log.
|
||||
|
|
|
@ -83,7 +83,7 @@ class ApiContext
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getrequestId()
|
||||
public function getRequestId()
|
||||
{
|
||||
if ($this->requestId == null) {
|
||||
$this->requestId = $this->generateRequestId();
|
||||
|
@ -102,7 +102,7 @@ class ApiContext
|
|||
public function resetRequestId()
|
||||
{
|
||||
$this->requestId = $this->generateRequestId();
|
||||
return $this->getrequestId();
|
||||
return $this->getRequestId();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,17 @@
|
|||
PayPal PHP SDK release notes
|
||||
============================
|
||||
v1.5.0
|
||||
----
|
||||
* Enabled Vault List API
|
||||
* Added More Fields to Vault Credit Card Object
|
||||
* Minor Fixes
|
||||
|
||||
v1.4.0
|
||||
----
|
||||
* Ability to validate Webhook
|
||||
* Fixes to Logging Manager to skip if mode is not set
|
||||
* SDK updates and fixes
|
||||
|
||||
v1.3.2
|
||||
----
|
||||
* Minor Fix for Agreement Details
|
||||
|
|
|
@ -1,57 +1,71 @@
|
|||
Rest API Samples
|
||||
===================
|
||||
# Rest API Samples
|
||||
|
||||
This sample project is a simple web app that you can explore to understand what the payment APIs can do for you.
|
||||
![Home Image](https://raw.githubusercontent.com/wiki/paypal/PayPal-PHP-SDK/images/homepage.jpg)
|
||||
|
||||
To try out the sample, run `composer update --no-dev` from the PayPal-PHP-SDK folder and you are all set.
|
||||
These examples are created to experiment with the PayPal-PHP-SDK capabilities. Each examples are designed to demonstrate the default use-cases in each segment.
|
||||
|
||||
#### Running Samples
|
||||
This sample project is a simple web app that you can explore to understand what each PayPal APIs can do for you. Irrespective of how you [installed your SDK](https://github.com/paypal/PayPal-PHP-SDK/wiki/Installation), you should be able to get the samples running by following the instructions below:
|
||||
|
||||
##### PHP 5.4 or higher
|
||||
* If you are running PHP 5.4 or greater, PHP provides a built-in support for hosting PHP sites.
|
||||
* The fastest way to get it running is
|
||||
```bash
|
||||
php -f sample/index.php
|
||||
```
|
||||
* This would get the [built-in web server](http://php.net/manual/en/features.commandline.webserver.php) started, and hosted on `http://localhost:5000'
|
||||
## Viewing Sample Code
|
||||
You can [view sample source codes here](http://paypal.github.io/PayPal-PHP-SDK/sample/). However, we recommend you run samples locally to get a better idea.
|
||||
|
||||
```bash
|
||||
LM-AUN-00876403:PayPal-PHP-SDK japatel$ php -f sample/index.php
|
||||
PHP 5.5.14 Development Server started at Wed Nov 19 21:07:52 2014
|
||||
Listening on http://localhost:5000
|
||||
Document root is /Users/japatel/Documents/workspace/Server-SDK/PayPal-PHP-SDK/sample
|
||||
Press Ctrl-C to quit.
|
||||
[Wed Nov 19 21:07:56 2014] ::1:60826 [200]: /index.php
|
||||
...
|
||||
```
|
||||
## Instructions
|
||||
|
||||
##### PHP 5.3 or less
|
||||
If you are running PHP 5.4 or greater, PHP provides a [ built-in support ]( http://php.net/manual/en/features.commandline.webserver.php) for hosting PHP sites.
|
||||
|
||||
* You could host the entire project in your local web server, by using tools like [MAMP](http://www.mamp.info/en/) or [XAMPP](https://www.apachefriends.org/index.html).
|
||||
* Once done, you could easily open the samples by opening the matching URL. For e.g.:
|
||||
`http://localhost/PayPal-PHP-SDK/sample/index.html`
|
||||
Note: The root directory for composer based download would be `vendor` and for direct download it would be `PayPal-PHP-SDK`. Please update the commands accordingly.
|
||||
|
||||
You should see a sample dashboard page as shown below:
|
||||
![Web Output!](/sample/images/sample_web.png)
|
||||
1. Run `php -f PayPal-PHP-SDK/paypal/rest-api-sdk-php/sample/index.php` from your project root directory.
|
||||
2. This would host a PHP server at `localhost:5000`. The output should look something like this:
|
||||
|
||||
#### Running on console
|
||||
> Please note that there are few samples that requires you to have a working local server, to receive redirects when user accepts/denies PayPal Web flow
|
||||
```
|
||||
<!-- Welcome to PayPal REST SDK -- >
|
||||
PHP 5.5.14 Development Server started at Sat Jan 10 14:04:35 2015
|
||||
Listening on http://localhost:5000
|
||||
Document root is /Users/japatel/Desktop/project/PayPal-PHP-SDK/paypal/rest-api-sdk-php/sample
|
||||
Press Ctrl-C to quit.
|
||||
```
|
||||
3. Open [http://localhost:5000/](http://localhost:5000/) in your web browser, and you should be able to see the sample dashboard.
|
||||
4. You should see a sample dashboard page as shown below:
|
||||
![Sample Web](https://raw.githubusercontent.com/wiki/paypal/PayPal-PHP-SDK/images/sample_web.gif)
|
||||
|
||||
* To run samples itself on console, you need to open command prompt, and direct to samples directory.
|
||||
* Execute the sample php script by using `php -f` command as shown below:
|
||||
```bat
|
||||
php -f payments/CreatePaymentUsingSavedCard.php
|
||||
```
|
||||
|
||||
The result would be as shown below:
|
||||
![Console Output!](/sample/images/sample_console.png)
|
||||
#### Configuration
|
||||
#### Configuration (Optional)
|
||||
|
||||
The sample comes pre-configured with a test account but in case you need to try them against your account, you must
|
||||
|
||||
* Obtain your client id and client secret from the [developer portal](https://developer.paypal.com/webapps/developer/applications/myapps)
|
||||
* Update the [bootstrap.php](https://github.com/paypal/PayPal-PHP-SDK/blob/master/sample/bootstrap.php#L29) file with your new client id and secret.
|
||||
|
||||
#### More Help
|
||||
## Alternative Options
|
||||
|
||||
There are two other ways you could run your samples, as shown below:
|
||||
|
||||
* #### Alternatives: LAMP Stack (All supported PHP Versions)
|
||||
|
||||
* You could host the entire project in your local web server, by using tools like [MAMP](http://www.mamp.info/en/) or [XAMPP](https://www.apachefriends.org/index.html).
|
||||
* Once done, you could easily open the samples by opening the matching URL. For e.g.:
|
||||
`http://localhost/PayPal-PHP-SDK/paypal/rest-api-sdk-php/sample/index.html`
|
||||
|
||||
* #### Alternatives: Running on console
|
||||
> Please note that there are few samples that requires you to have a working local server, to receive redirects when user accepts/denies PayPal Web flow
|
||||
|
||||
* To run samples itself on console, you need to open command prompt, and direct to samples directory.
|
||||
* Execute the sample php script by using `php -f` command as shown below:
|
||||
```bat
|
||||
php -f payments/CreatePaymentUsingSavedCard.php
|
||||
```
|
||||
|
||||
* The result would be as shown below:
|
||||
![Sample Console](https://raw.githubusercontent.com/wiki/paypal/PayPal-PHP-SDK/images/sample_console.png)
|
||||
|
||||
#### Sample App
|
||||
|
||||
If you are looking for a full fledged application that uses the new RESTful APIs, check out the Pizza store sample app at https://github.com/paypal/rest-api-sample-app-php
|
||||
|
||||
## More help
|
||||
* [Going Live](https://github.com/paypal/PayPal-PHP-SDK/wiki/Going-Live)
|
||||
* [PayPal-PHP-SDK Home Page](http://paypal.github.io/PayPal-PHP-SDK/)
|
||||
* [SDK Documentation](https://github.com/paypal/PayPal-PHP-SDK/wiki)
|
||||
* [Sample Source Code](http://paypal.github.io/PayPal-PHP-SDK/sample/)
|
||||
* [API Reference](https://developer.paypal.com/webapps/developer/docs/api/)
|
||||
* [Reporting Issues / Feature Requests] (https://github.com/paypal/PayPal-PHP-SDK/issues)
|
||||
* [Pizza App Using Paypal REST API] (https://github.com/paypal/rest-api-sample-app-php)
|
||||
|
|
|
@ -56,7 +56,7 @@ $agreement = new Agreement();
|
|||
|
||||
$agreement->setName('DPRP')
|
||||
->setDescription('Payment with credit Card')
|
||||
->setStartDate('2015-06-17T9:45:04Z');
|
||||
->setStartDate('2019-06-17T9:45:04Z');
|
||||
|
||||
// Add Plan ID
|
||||
// Please note that the plan Id should be only set in this case.
|
||||
|
@ -101,10 +101,12 @@ try {
|
|||
$agreement = $agreement->create($apiContext);
|
||||
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Created Billing Agreement.", "Agreement", $agreement->getId(), $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult("Created Billing Agreement.", "Agreement", $agreement->getId(), $request, $agreement);
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("Created Billing Agreement.", "Agreement", $agreement->getId(), $request, $agreement);
|
||||
|
||||
return $agreement;
|
||||
|
|
|
@ -39,7 +39,7 @@ $agreement = new Agreement();
|
|||
|
||||
$agreement->setName('Base Agreement')
|
||||
->setDescription('Basic Agreement')
|
||||
->setStartDate('2015-06-17T9:45:04Z');
|
||||
->setStartDate('2019-06-17T9:45:04Z');
|
||||
|
||||
// Add Plan ID
|
||||
// Please note that the plan Id should be only set in this case.
|
||||
|
@ -76,10 +76,12 @@ try {
|
|||
$approvalUrl = $agreement->getApprovalLink();
|
||||
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Created Billing Agreement.", "Agreement", null, $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult("Created Billing Agreement. Please visit the URL to Approve.", "Agreement", "<a href='$approvalUrl' >$approvalUrl</a>", $request, $agreement);
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("Created Billing Agreement. Please visit the URL to Approve.", "Agreement", "<a href='$approvalUrl' >$approvalUrl</a>", $request, $agreement);
|
||||
|
||||
return $agreement;
|
||||
|
|
|
@ -65,10 +65,12 @@ $request = clone $plan;
|
|||
try {
|
||||
$output = $plan->create($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Created Plan", "Plan", null, $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult("Created Plan", "Plan", $output->getId(), $request, $output);
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("Created Plan", "Plan", $output->getId(), $request, $output);
|
||||
|
||||
return $output;
|
||||
|
|
|
@ -15,10 +15,12 @@ use PayPal\Api\Plan;
|
|||
try {
|
||||
$result = $createdPlan->delete($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Deleted a Plan", "Plan", $createdPlan->getId(), null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult("Deleted a Plan", "Plan", $createdPlan->getId(), null, null);
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("Deleted a Plan", "Plan", $createdPlan->getId(), null, null);
|
||||
|
||||
return $createdPlan;
|
||||
|
|
|
@ -16,10 +16,12 @@ if (isset($_GET['success']) && $_GET['success'] == 'true') {
|
|||
// Execute the agreement by passing in the token
|
||||
$agreement->execute($token, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Executed an Agreement", "Agreement", $agreement->getId(), $_GET['token'], $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("Executed an Agreement", "Agreement", $agreement->getId(), $_GET['token'], $agreement);
|
||||
|
||||
// ## Get Agreement
|
||||
|
@ -27,12 +29,15 @@ if (isset($_GET['success']) && $_GET['success'] == 'true') {
|
|||
try {
|
||||
$agreement = \PayPal\Api\Agreement::get($agreement->getId(), $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Get Agreement", "Agreement", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("Get Agreement", "Agreement", $agreement->getId(), null, $agreement);
|
||||
|
||||
} else {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("User Cancelled the Approval", null);
|
||||
}
|
||||
|
|
|
@ -15,10 +15,12 @@ use PayPal\Api\Agreement;
|
|||
try {
|
||||
$agreement = Agreement::get($createdAgreement->getId(), $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Retrieved an Agreement", "Agreement", $agreement->getId(), $createdAgreement->getId(), $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("Retrieved an Agreement", "Agreement", $agreement->getId(), $createdAgreement->getId(), $agreement);
|
||||
|
||||
return $agreement;
|
||||
|
|
|
@ -15,10 +15,12 @@ use PayPal\Api\Plan;
|
|||
try {
|
||||
$plan = Plan::get($createdPlan->getId(), $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Retrieved a Plan", "Plan", $plan->getId(), null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult("Retrieved a Plan", "Plan", $plan->getId(), null, $plan);
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("Retrieved a Plan", "Plan", $plan->getId(), null, $plan);
|
||||
|
||||
return $plan;
|
||||
|
|
|
@ -20,10 +20,12 @@ try {
|
|||
$params = array('page_size' => '2');
|
||||
$planList = Plan::all($params, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("List of Plans", "Plan", null, $params, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult("List of Plans", "Plan", null, $params, $planList);
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("List of Plans", "Plan", null, $params, $planList);
|
||||
|
||||
return $planList;
|
||||
|
|
|
@ -25,10 +25,12 @@ try {
|
|||
$agreement = Agreement::get($suspendedAgreement->getId(), $apiContext);
|
||||
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("Reactivate the Agreement", "Agreement", $agreement->getId(), $suspendedAgreement, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("Reactivate the Agreement", "Agreement", $agreement->getId(), $suspendedAgreement, $agreement);
|
||||
|
||||
return $agreement;
|
||||
|
|
|
@ -21,10 +21,12 @@ $params = array('start_date' => date('Y-m-d', strtotime('-15 years')), 'end_date
|
|||
try {
|
||||
$result = Agreement::searchTransactions($agreementId, $params, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Search for Transactions", "AgreementTransaction", $agreementId, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult("Search for Transactions", "AgreementTransaction", $agreementId, $params, $result);
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("Search for Transactions", "AgreementTransaction", $agreementId, $params, $result);
|
||||
|
||||
return $agreement;
|
||||
|
|
|
@ -25,10 +25,12 @@ try {
|
|||
$agreement = Agreement::get($createdAgreement->getId(), $apiContext);
|
||||
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Suspended the Agreement", "Agreement", null, $agreementStateDescriptor, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult("Suspended the Agreement", "Agreement", $agreement->getId(), $agreementStateDescriptor, $agreement);
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("Suspended the Agreement", "Agreement", $agreement->getId(), $agreementStateDescriptor, $agreement);
|
||||
|
||||
return $agreement;
|
||||
|
|
|
@ -37,10 +37,12 @@ try {
|
|||
$agreement = Agreement::get($createdAgreement->getId(), $apiContext);
|
||||
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Updated the Agreement with new Description and Updated Shipping Address", "Agreement", null, $patchRequest, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult("Updated the Agreement with new Description and Updated Shipping Address", "Agreement", $agreement->getId(), $patchRequest, $agreement);
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("Updated the Agreement with new Description and Updated Shipping Address", "Agreement", $agreement->getId(), $patchRequest, $agreement);
|
||||
|
||||
return $agreement;
|
||||
|
|
|
@ -35,10 +35,12 @@ try {
|
|||
$plan = Plan::get($createdPlan->getId(), $apiContext);
|
||||
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Updated the Plan to Active State", "Plan", null, $patchRequest, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult("Updated the Plan to Active State", "Plan", $plan->getId(), $patchRequest, $plan);
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("Updated the Plan to Active State", "Plan", $plan->getId(), $patchRequest, $plan);
|
||||
|
||||
return $plan;
|
||||
|
|
|
@ -42,10 +42,12 @@ try {
|
|||
$plan = Plan::get($createdPlan->getId(), $apiContext);
|
||||
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Updated the Plan Payment Definition", "Plan", null, $patchRequest, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult("Updated the Plan Payment Definition", "Plan", $plan->getId(), $patchRequest, $plan);
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("Updated the Plan Payment Definition", "Plan", $plan->getId(), $patchRequest, $plan);
|
||||
|
||||
return $plan;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -50,7 +50,7 @@ define Plan information to create an agreement. Make sure the plan you are using
|
|||
|
||||
<span class="hljs-variable">$agreement</span>->setName(<span class="hljs-string">'DPRP'</span>)
|
||||
->setDescription(<span class="hljs-string">'Payment with credit Card'</span>)
|
||||
->setStartDate(<span class="hljs-string">'2015-06-17T9:45:04Z'</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Add Plan ID
|
||||
->setStartDate(<span class="hljs-string">'2019-06-17T9:45:04Z'</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Add Plan ID
|
||||
Please note that the plan Id should be only set in this case.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$plan</span> = <span class="hljs-keyword">new</span> Plan();
|
||||
<span class="hljs-variable">$plan</span>->setId(<span class="hljs-variable">$createdPlan</span>->getId());
|
||||
<span class="hljs-variable">$agreement</span>->setPlan(<span class="hljs-variable">$plan</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Add Payer</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$payer</span> = <span class="hljs-keyword">new</span> Payer();
|
||||
|
@ -74,11 +74,8 @@ Please note that the plan Id should be only set in this case.</p></div></div><di
|
|||
->setCountryCode(<span class="hljs-string">'US'</span>);
|
||||
<span class="hljs-variable">$agreement</span>->setShippingAddress(<span class="hljs-variable">$shippingAddress</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>For Sample Purposes Only.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$request</span> = <span class="hljs-keyword">clone</span> <span class="hljs-variable">$agreement</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-agreement">Create Agreement</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Please note that as the agreement has not yet activated, we wont be receiving the ID just yet.</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$agreement</span> = <span class="hljs-variable">$agreement</span>->create(<span class="hljs-variable">$apiContext</span>);
|
||||
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Created Billing Agreement."</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Created Billing Agreement."</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Created Billing Agreement."</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$agreement</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Created Billing Agreement."</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$agreement</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$agreement</span>;</div></div></div></div></body></html>
|
|
@ -33,7 +33,7 @@ define Plan information to create an agreement. Make sure the plan you are using
|
|||
|
||||
<span class="hljs-variable">$agreement</span>->setName(<span class="hljs-string">'Base Agreement'</span>)
|
||||
->setDescription(<span class="hljs-string">'Basic Agreement'</span>)
|
||||
->setStartDate(<span class="hljs-string">'2015-06-17T9:45:04Z'</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Add Plan ID
|
||||
->setStartDate(<span class="hljs-string">'2019-06-17T9:45:04Z'</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Add Plan ID
|
||||
Please note that the plan Id should be only set in this case.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$plan</span> = <span class="hljs-keyword">new</span> Plan();
|
||||
<span class="hljs-variable">$plan</span>->setId(<span class="hljs-variable">$createdPlan</span>->getId());
|
||||
<span class="hljs-variable">$agreement</span>->setPlan(<span class="hljs-variable">$plan</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Add Payer</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$payer</span> = <span class="hljs-keyword">new</span> Payer();
|
||||
|
@ -49,11 +49,8 @@ Please note that the plan Id should be only set in this case.</p></div></div><di
|
|||
the buyer to. Retrieve the url from the $agreement->getApprovalLink()
|
||||
method</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$agreement</span>->getApprovalLink();
|
||||
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Created Billing Agreement."</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Created Billing Agreement."</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Created Billing Agreement. Please visit the URL to Approve."</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-string">"<a href='$approvalUrl' >$approvalUrl</a>"</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$agreement</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Created Billing Agreement. Please visit the URL to Approve."</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-string">"<a href='$approvalUrl' >$approvalUrl</a>"</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$agreement</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$agreement</span>;</div></div></div></div></body></html>
|
|
@ -36,11 +36,8 @@ This will keep your plan compatible with both the possible scenarios on how it i
|
|||
<span class="hljs-variable">$plan</span>->setPaymentDefinitions(<span class="hljs-keyword">array</span>(<span class="hljs-variable">$paymentDefinition</span>));
|
||||
<span class="hljs-variable">$plan</span>->setMerchantPreferences(<span class="hljs-variable">$merchantPreferences</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>For Sample Purposes Only.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$request</span> = <span class="hljs-keyword">clone</span> <span class="hljs-variable">$plan</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-plan">Create Plan</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$output</span> = <span class="hljs-variable">$plan</span>->create(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Created Plan"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Created Plan"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Created Plan"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-variable">$output</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$output</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Created Plan"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-variable">$output</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$output</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$output</span>;</div></div></div></div></body></html>
|
|
@ -9,10 +9,12 @@ API used: /v1/payments/billing-plans</p></div></div></div><div class="segment"><
|
|||
<span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$result</span> = <span class="hljs-variable">$createdPlan</span>->delete(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError(<span class="hljs-string">"Deleted a Plan"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-variable">$createdPlan</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Deleted a Plan"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-variable">$createdPlan</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>);
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Deleted a Plan"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-variable">$createdPlan</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$createdPlan</span>;</div></div></div></div></body></html>
|
|
@ -7,21 +7,14 @@ Use this call to execute an agreement after the buyer approves it</p></div></div
|
|||
<span class="hljs-variable">$agreement</span> = <span class="hljs-keyword">new</span> \PayPal\Api\Agreement();
|
||||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h2 id="execute-agreement">Execute Agreement</h2>
|
||||
<p>Execute the agreement by passing in the token</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$agreement</span>->execute(<span class="hljs-variable">$token</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Executed an Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'token'</span>], <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Executed an Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'token'</span>], <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Executed an Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'token'</span>], <span class="hljs-variable">$agreement</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h2 id="get-agreement">Get Agreement</h2>
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Executed an Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'token'</span>], <span class="hljs-variable">$agreement</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h2 id="get-agreement">Get Agreement</h2>
|
||||
<p>Make a get call to retrieve the executed agreement details</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$agreement</span> = \PayPal\Api\Agreement::get(<span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Get Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Get Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Get Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$agreement</span>);
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$agreement</span>);
|
||||
|
||||
} <span class="hljs-keyword">else</span> {
|
||||
ResultPrinter::printResult(<span class="hljs-string">"User Cancelled the Approval"</span>, <span class="hljs-keyword">null</span>);
|
||||
} <span class="hljs-keyword">else</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"User Cancelled the Approval"</span>, <span class="hljs-keyword">null</span>);
|
||||
}</div></div></div></div></body></html>
|
|
@ -8,11 +8,8 @@ API used: /v1/payments/billing-agreements/<Agreement-Id></p></div></div></div><d
|
|||
|
||||
<span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$agreement</span> = Agreement::get(<span class="hljs-variable">$createdAgreement</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Retrieved an Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$createdAgreement</span>->getId(), <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Retrieved an Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$createdAgreement</span>->getId(), <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Retrieved an Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$createdAgreement</span>->getId(), <span class="hljs-variable">$agreement</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper">ResultPrinter::printResult(<span class="hljs-string">"Retrieved an Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$createdAgreement</span>->getId(), <span class="hljs-variable">$agreement</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$agreement</span>;</div></div></div></div></body></html>
|
|
@ -9,10 +9,12 @@ API used: /v1/payments/billing-plans</p></div></div></div><div class="segment"><
|
|||
<span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$plan</span> = Plan::get(<span class="hljs-variable">$createdPlan</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError(<span class="hljs-string">"Retrieved a Plan"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-variable">$plan</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Retrieved a Plan"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-variable">$plan</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$plan</span>);
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Retrieved a Plan"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-variable">$plan</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$plan</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$plan</span>;</div></div></div></div></body></html>
|
|
@ -11,11 +11,8 @@ You can modify different params to change the return list.
|
|||
The explanation about each pagination information could be found here
|
||||
at <a href="https://developer.paypal.com/webapps/developer/docs/api/#list-plans">https://developer.paypal.com/webapps/developer/docs/api/#list-plans</a></p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$params</span> = <span class="hljs-keyword">array</span>(<span class="hljs-string">'page_size'</span> => <span class="hljs-string">'2'</span>);
|
||||
<span class="hljs-variable">$planList</span> = Plan::all(<span class="hljs-variable">$params</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"List of Plans"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$params</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"List of Plans"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$params</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"List of Plans"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$params</span>, <span class="hljs-variable">$planList</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"List of Plans"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$params</span>, <span class="hljs-variable">$planList</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$planList</span>;</div></div></div></div></body></html>
|
|
@ -15,11 +15,8 @@ API used: /v1/payments/billing-agreements/<Agreement-Id>/suspend</p></div></div>
|
|||
|
||||
<span class="hljs-variable">$suspendedAgreement</span>->reActivate(<span class="hljs-variable">$agreementStateDescriptor</span>, <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Lets get the updated Agreement Object</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$agreement</span> = Agreement::get(<span class="hljs-variable">$suspendedAgreement</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Reactivate the Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$suspendedAgreement</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Reactivate the Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$suspendedAgreement</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Reactivate the Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$suspendedAgreement</span>, <span class="hljs-variable">$agreement</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper">ResultPrinter::printResult(<span class="hljs-string">"Reactivate the Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$suspendedAgreement</span>, <span class="hljs-variable">$agreement</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$agreement</span>;</div></div></div></div></body></html>
|
|
@ -8,11 +8,8 @@ API used: GET /v1/payments/billing-agreements/<Agreement-Id>/transactions? start
|
|||
|
||||
<span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$result</span> = Agreement::searchTransactions(<span class="hljs-variable">$agreementId</span>, <span class="hljs-variable">$params</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Search for Transactions"</span>, <span class="hljs-string">"AgreementTransaction"</span>, <span class="hljs-variable">$agreementId</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Search for Transactions"</span>, <span class="hljs-string">"AgreementTransaction"</span>, <span class="hljs-variable">$agreementId</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Search for Transactions"</span>, <span class="hljs-string">"AgreementTransaction"</span>, <span class="hljs-variable">$agreementId</span>, <span class="hljs-variable">$params</span>, <span class="hljs-variable">$result</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Search for Transactions"</span>, <span class="hljs-string">"AgreementTransaction"</span>, <span class="hljs-variable">$agreementId</span>, <span class="hljs-variable">$params</span>, <span class="hljs-variable">$result</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$agreement</span>;</div></div></div></div></body></html>
|
|
@ -15,11 +15,8 @@ API used: /v1/payments/billing-agreements/<Agreement-Id>/suspend</p></div></div>
|
|||
|
||||
<span class="hljs-variable">$createdAgreement</span>->suspend(<span class="hljs-variable">$agreementStateDescriptor</span>, <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Lets get the updated Agreement Object</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$agreement</span> = Agreement::get(<span class="hljs-variable">$createdAgreement</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Suspended the Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$agreementStateDescriptor</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Suspended the Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$agreementStateDescriptor</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Suspended the Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$agreementStateDescriptor</span>, <span class="hljs-variable">$agreement</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Suspended the Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$agreementStateDescriptor</span>, <span class="hljs-variable">$agreement</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$agreement</span>;</div></div></div></div></body></html>
|
|
@ -27,11 +27,8 @@ API used: /v1/payments/billing-agreements/<Agreement-Id></p></div></div></div><d
|
|||
<span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$createdAgreement</span>->update(<span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Lets get the updated Agreement Object</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$agreement</span> = Agreement::get(<span class="hljs-variable">$createdAgreement</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Updated the Agreement with new Description and Updated Shipping Address"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Updated the Agreement with new Description and Updated Shipping Address"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Updated the Agreement with new Description and Updated Shipping Address"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$agreement</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Updated the Agreement with new Description and Updated Shipping Address"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$agreement</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$agreement</span>;</div></div></div></div></body></html>
|
|
@ -26,11 +26,8 @@ API used: /v1/payments/billing-plans/<Plan-Id></p></div></div></div><div class=
|
|||
|
||||
<span class="hljs-variable">$plan</span> = Plan::get(<span class="hljs-variable">$createdPlan</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Updated the Plan to Active State"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Updated the Plan to Active State"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Updated the Plan to Active State"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-variable">$plan</span>->getId(), <span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$plan</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Updated the Plan to Active State"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-variable">$plan</span>->getId(), <span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$plan</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$plan</span>;</div></div></div></div></body></html>
|
|
@ -33,11 +33,8 @@ API used: /v1/payments/billing-plans/<Plan-Id></p></div></div></div><div class=
|
|||
|
||||
<span class="hljs-variable">$plan</span> = Plan::get(<span class="hljs-variable">$createdPlan</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Updated the Plan Payment Definition"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Updated the Plan Payment Definition"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Updated the Plan Payment Definition"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-variable">$plan</span>->getId(), <span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$plan</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Updated the Plan Payment Definition"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-variable">$plan</span>->getId(), <span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$plan</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$plan</span>;</div></div></div></div></body></html>
|
|
@ -20,9 +20,6 @@ static <code>cancel</code> method
|
|||
on the Invoice class by passing a valid
|
||||
notification object
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$cancelStatus</span> = <span class="hljs-variable">$invoice</span>->cancel(<span class="hljs-variable">$notify</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Cancel Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$notify</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Cancel Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$notify</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Cancel Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$notify</span>, <span class="hljs-keyword">null</span>);</div></div></div></div></body></html>
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Cancel Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$notify</span>, <span class="hljs-keyword">null</span>);</div></div></div></div></body></html>
|
|
@ -103,11 +103,8 @@ detailed breakdown of invoice</p></div></div><div class="code"><div class="wrapp
|
|||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-invoice">Create Invoice</h3>
|
||||
<p>Create an invoice by calling the invoice->create() method
|
||||
with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$invoice</span>->create(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Create Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Create Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Create Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$invoice</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Create Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$invoice</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$invoice</span>;</div></div></div></div></body></html>
|
|
@ -12,9 +12,6 @@ an invoice.</p></div></div><div class="code"><div class="wrapper"><span class="h
|
|||
on the Invoice class by passing a valid
|
||||
notification object
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$deleteStatus</span> = <span class="hljs-variable">$invoice</span>->delete(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Delete Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$deleteStatus</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Delete Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$deleteStatus</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Delete Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>);</div></div></div></div></body></html>
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Delete Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>);</div></div></div></div></body></html>
|
|
@ -11,11 +11,8 @@ on the Invoice class by passing a valid
|
|||
Invoice ID
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$invoice</span> = Invoice::get(<span class="hljs-variable">$invoiceId</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Get Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoiceId</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Get Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoiceId</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoiceId</span>, <span class="hljs-variable">$invoice</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Get Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoiceId</span>, <span class="hljs-variable">$invoice</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$invoice</span>;</div></div></div></div></body></html>
|
|
@ -10,7 +10,9 @@ static <code>get_all</code> method on the Invoice class.
|
|||
Refer the method doc for valid values for keys
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$invoices</span> = Invoice::getAll(<span class="hljs-keyword">array</span>(<span class="hljs-string">'page'</span> => <span class="hljs-number">0</span>, <span class="hljs-string">'page_size'</span> => <span class="hljs-number">4</span>, <span class="hljs-string">'total_count_required'</span> => <span class="hljs-string">"true"</span>), <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError(<span class="hljs-string">"Lookup Invoice History"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Lookup Invoice History"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$invoices</span>);</div></div></div></div></body></html>
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Lookup Invoice History"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$invoices</span>);</div></div></div></div></body></html>
|
||||
|
|
|
@ -20,23 +20,17 @@ You can use the new way of injecting json directly to the object.</p></div></div
|
|||
on the Invoice class by passing a valid
|
||||
notification object
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$recordStatus</span> = <span class="hljs-variable">$invoice</span>->recordPayment(<span class="hljs-variable">$record</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Payment for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Payment for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Payment for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$record</span>, <span class="hljs-keyword">null</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Payment for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$record</span>, <span class="hljs-keyword">null</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
|
||||
<p>Retrieve the invoice object by calling the
|
||||
static <code>get</code> method
|
||||
on the Invoice class by passing a valid
|
||||
Invoice ID
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$invoice</span> = Invoice::get(<span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$invoice</span>;</div></div></div></div></body></html>
|
|
@ -19,23 +19,17 @@ You can use the new way of injecting json directly to the object.</p></div></div
|
|||
on the Invoice class by passing a valid
|
||||
notification object
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$refundStatus</span> = <span class="hljs-variable">$invoice</span>->recordRefund(<span class="hljs-variable">$refund</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Refund for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Refund for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Refund for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$refund</span>, <span class="hljs-keyword">null</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Refund for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$refund</span>, <span class="hljs-keyword">null</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
|
||||
<p>Retrieve the invoice object by calling the
|
||||
static <code>get</code> method
|
||||
on the Invoice class by passing a valid
|
||||
Invoice ID
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$invoice</span> = Invoice::get(<span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$invoice</span>;</div></div></div></div></body></html>
|
|
@ -19,23 +19,17 @@ and payer is retrieved from the invoice details</p></div></div><div class="code"
|
|||
on the Invoice class by passing a valid
|
||||
notification object
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$remindStatus</span> = <span class="hljs-variable">$invoice</span>->remind(<span class="hljs-variable">$notify</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Remind Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$notify</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Remind Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$notify</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Remind Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$notify</span>, <span class="hljs-keyword">null</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Remind Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$notify</span>, <span class="hljs-keyword">null</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
|
||||
<p>Retrieve the invoice object by calling the
|
||||
static <code>get</code> method
|
||||
on the Invoice class by passing a valid
|
||||
Invoice ID
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$invoice</span> = Invoice::get(<span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$invoice</span>;</div></div></div></div></body></html>
|
|
@ -16,12 +16,9 @@ notification object
|
|||
This will save the image as /samples/invoice/images/sample.png</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$path</span> = <span class="hljs-variable">$image</span>->saveToFile(<span class="hljs-string">"images/sample.png"</span>);
|
||||
|
||||
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Retrieved QR Code for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Retrieved QR Code for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Retrieved QR Code for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$image</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="show-the-image">Show the Image</h3>
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Retrieved QR Code for Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$image</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="show-the-image">Show the Image</h3>
|
||||
<p>In PHP, there are many ways to present an images.
|
||||
One of the ways, you could directly inject the base64-encoded string
|
||||
with proper image information in front of it.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">echo</span> <span class="hljs-string">'<img src="data:image/png;base64,'</span>. <span class="hljs-variable">$image</span>->getImage() . <span class="hljs-string">'" alt="Invoice QR Code" />'</span>;</div></div></div></div></body></html>
|
|
@ -21,7 +21,9 @@ static <code>search</code> method on the Invoice class.
|
|||
Refer the method doc for valid values for keys
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$invoices</span> = Invoice::search(<span class="hljs-variable">$search</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError(<span class="hljs-string">"Search Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Search Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$search</span>, <span class="hljs-variable">$invoices</span>);</div></div></div></div></body></html>
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Search Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$search</span>, <span class="hljs-variable">$invoices</span>);</div></div></div></div></body></html>
|
||||
|
|
|
@ -8,23 +8,17 @@ a legitimate invoice to the payer</p></div></div><div class="code"><div class="w
|
|||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="send-invoice">Send Invoice</h3>
|
||||
<p>Send a legitimate invoice to the payer
|
||||
with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$sendStatus</span> = <span class="hljs-variable">$invoice</span>->send(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Send Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Send Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Send Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Send Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
|
||||
<p>Retrieve the invoice object by calling the
|
||||
static <code>get</code> method
|
||||
on the Invoice class by passing a valid
|
||||
Invoice ID
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$invoice</span> = Invoice::get(<span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$invoice</span>;</div></div></div></div></body></html>
|
|
@ -13,23 +13,17 @@ There is already an internal ticket #PPTIPS-1932 created for it.</p></div></div>
|
|||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="update-invoice">Update Invoice</h3>
|
||||
<p>Update an invoice by calling the invoice->update() method
|
||||
with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$invoice</span>->update(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Invoice Updated"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Invoice Updated"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Invoice Updated"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$invoice</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Invoice Updated"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$invoice</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
|
||||
<p>Retrieve the invoice object by calling the
|
||||
static <code>get</code> method
|
||||
on the Invoice class by passing a valid
|
||||
Invoice ID
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$invoice</span> = Invoice::get(<span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Get Invoice (Not Required - For Sample Only)"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>->getId(), <span class="hljs-variable">$invoice</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$invoice</span>;</div></div></div></div></body></html>
|
|
@ -7,8 +7,10 @@
|
|||
<span class="hljs-variable">$tokenInfo</span> = <span class="hljs-variable">$tokenInfo</span>->createFromRefreshToken(<span class="hljs-keyword">array</span>(<span class="hljs-string">'refresh_token'</span> => <span class="hljs-variable">$refreshToken</span>), <span class="hljs-variable">$apiContext</span>);
|
||||
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError(<span class="hljs-string">"Obtained Access Token From Refresh Token"</span>, <span class="hljs-string">"Access Token"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Obtained Access Token From Refresh Token"</span>, <span class="hljs-string">"Access Token"</span>, <span class="hljs-variable">$tokenInfo</span>->getAccessToken(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$tokenInfo</span>);</div></div></div></div></body></html>
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Obtained Access Token From Refresh Token"</span>, <span class="hljs-string">"Access Token"</span>, <span class="hljs-variable">$tokenInfo</span>->getAccessToken(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$tokenInfo</span>);</div></div></div></div></body></html>
|
||||
|
|
|
@ -17,8 +17,10 @@ to retreive the information. The short lived access token can be retrieved using
|
|||
<span class="hljs-variable">$userInfo</span> = OpenIdUserinfo::getUserinfo(<span class="hljs-variable">$params</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError(<span class="hljs-string">"User Information"</span>, <span class="hljs-string">"User Info"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$params</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"User Information"</span>, <span class="hljs-string">"User Info"</span>, <span class="hljs-variable">$userInfo</span>->getUserId(), <span class="hljs-variable">$params</span>, <span class="hljs-variable">$userInfo</span>);</div></div></div></div></body></html>
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult(<span class="hljs-string">"User Information"</span>, <span class="hljs-string">"User Info"</span>, <span class="hljs-variable">$userInfo</span>->getUserId(), <span class="hljs-variable">$params</span>, <span class="hljs-variable">$userInfo</span>);</div></div></div></div></body></html>
|
||||
|
|
|
@ -14,6 +14,4 @@
|
|||
<span class="hljs-keyword">null</span>,
|
||||
<span class="hljs-keyword">null</span>,
|
||||
<span class="hljs-variable">$apiContext</span>
|
||||
);
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Generated the User Consent URL"</span>, <span class="hljs-string">"URL"</span>, <span class="hljs-string">'<a href="'</span>. <span class="hljs-variable">$redirectUrl</span> . <span class="hljs-string">'" >Click Here to Obtain User Consent</a>'</span>, <span class="hljs-variable">$baseUrl</span>, <span class="hljs-variable">$redirectUrl</span>);</div></div></div></div></body></html>
|
||||
);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Generated the User Consent URL"</span>, <span class="hljs-string">"URL"</span>, <span class="hljs-string">'<a href="'</span>. <span class="hljs-variable">$redirectUrl</span> . <span class="hljs-string">'" >Click Here to Obtain User Consent</a>'</span>, <span class="hljs-variable">$baseUrl</span>, <span class="hljs-variable">$redirectUrl</span>);</div></div></div></div></body></html>
|
|
@ -12,11 +12,8 @@ The user would then able to retrieve the access token by getting the code, which
|
|||
<span class="hljs-variable">$code</span> = <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'code'</span>];
|
||||
|
||||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Obtain Authorization Code from Code, Client ID and Client Secret</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$accessToken</span> = OpenIdTokeninfo::createFromAuthorizationCode(<span class="hljs-keyword">array</span>(<span class="hljs-string">'code'</span> => <span class="hljs-variable">$code</span>), <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (PayPalConnectionException <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Obtained Access Token"</span>, <span class="hljs-string">"Access Token"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'code'</span>], <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (PayPalConnectionException <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Obtained Access Token"</span>, <span class="hljs-string">"Access Token"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'code'</span>], <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Obtained Access Token"</span>, <span class="hljs-string">"Access Token"</span>, <span class="hljs-variable">$accessToken</span>->getAccessToken(), <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'code'</span>], <span class="hljs-variable">$accessToken</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Obtained Access Token"</span>, <span class="hljs-string">"Access Token"</span>, <span class="hljs-variable">$accessToken</span>->getAccessToken(), <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'code'</span>], <span class="hljs-variable">$accessToken</span>);
|
||||
|
||||
}</div></div></div></div></body></html>
|
|
@ -34,25 +34,19 @@ be using this in production</p></div></div><div class="code"><div class="wrapper
|
|||
<span class="hljs-variable">$output</span> = <span class="hljs-variable">$webhook</span>->create(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="code folded"><div class="wrapper marker"><span class="c1"> // Ignore workflow code segment</span></div><div class="wrapper"> <span class="hljs-comment">// Ignore workflow code segment</span>
|
||||
<span class="hljs-keyword">if</span> (<span class="hljs-variable">$ex</span> <span class="hljs-keyword">instanceof</span> \PayPal\<span class="hljs-keyword">Exception</span>\PayPalConnectionException) {
|
||||
<span class="hljs-variable">$data</span> = <span class="hljs-variable">$ex</span>->getData();
|
||||
ResultPrinter::printError(<span class="hljs-string">"Created Webhook Failed. Checking if it is Webhook Number Limit Exceeded. Trying to delete all existing webhooks"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-string">"Please Use <a style='color: red;' href='DeleteAllWebhooks.php' >Delete All Webhooks</a> Sample to delete all existing webhooks in sample"</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-variable">$data</span> = <span class="hljs-variable">$ex</span>->getData();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Created Webhook Failed. Checking if it is Webhook Number Limit Exceeded. Trying to delete all existing webhooks"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-string">"Please Use <a style='color: red;' href='DeleteAllWebhooks.php' >Delete All Webhooks</a> Sample to delete all existing webhooks in sample"</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">if</span> (strpos(<span class="hljs-variable">$data</span>,<span class="hljs-string">'WEBHOOK_NUMBER_LIMIT_EXCEEDED'</span>) !== <span class="hljs-keyword">false</span>) {
|
||||
<span class="hljs-keyword">require</span> <span class="hljs-string">'DeleteAllWebhooks.php'</span>;
|
||||
<span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$output</span> = <span class="hljs-variable">$webhook</span>->create(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Created Webhook"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Created Webhook"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
} <span class="hljs-keyword">else</span> {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Created Webhook"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">else</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Created Webhook"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
} <span class="hljs-keyword">else</span> {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Created Webhook"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">else</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Created Webhook"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Print Success Result</p></div></div><div class="code"><div class="wrapper">}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Created Webhook"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-variable">$output</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$output</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Print Success Result</p></div></div><div class="code"><div class="wrapper">}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Created Webhook"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-variable">$output</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$output</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$output</span>;</div></div></div></div></body></html>
|
|
@ -5,11 +5,8 @@ To properly use the sample, change the clientId and Secret from bootstrap.php fi
|
|||
<span class="hljs-keyword">foreach</span> (<span class="hljs-variable">$webhookList</span>->getWebhooks() <span class="hljs-keyword">as</span> <span class="hljs-variable">$webhook</span>) {
|
||||
<span class="hljs-variable">$webhook</span>->delete(<span class="hljs-variable">$apiContext</span>);
|
||||
}
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Deleted all Webhooks"</span>, <span class="hljs-string">"WebhookList"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Deleted all Webhooks"</span>, <span class="hljs-string">"WebhookList"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Delete all Webhook, as it may have exceed the maximum count."</span>, <span class="hljs-string">"WebhookList"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Delete all Webhook, as it may have exceed the maximum count."</span>, <span class="hljs-string">"WebhookList"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$output</span>;</div></div></div></div></body></html>
|
|
@ -4,11 +4,8 @@
|
|||
API used: DELETE v1/notifications/webhooks/<Webhook-Id></p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h2 id="get-webhook-instance">Get Webhook Instance</h2></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> \PayPal\Api\Webhook $webhook */</span>
|
||||
<span class="hljs-variable">$webhook</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateWebhook.php'</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="delete-webhook">Delete Webhook</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$output</span> = <span class="hljs-variable">$webhook</span>->delete(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Delete a Webhook"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$webhookId</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Delete a Webhook"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$webhookId</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Delete a Webhook"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-variable">$webhook</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Delete a Webhook"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-variable">$webhook</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$output</span>;</div></div></div></div></body></html>
|
|
@ -7,11 +7,8 @@ However, in real case scenario, we could use just the ID from database or retrie
|
|||
<span class="hljs-variable">$webhook</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateWebhook.php'</span>;
|
||||
<span class="hljs-variable">$webhookId</span> = <span class="hljs-variable">$webhook</span>->getId();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="get-webhook">Get Webhook</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$output</span> = \PayPal\Api\Webhook::get(<span class="hljs-variable">$webhookId</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Get a Webhook"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$webhookId</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Get a Webhook"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$webhookId</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get a Webhook"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-variable">$output</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$output</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Get a Webhook"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-variable">$output</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$output</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$output</span>;</div></div></div></div></body></html>
|
|
@ -6,11 +6,8 @@ API used: GET /v1/notifications/webhooks/<Webhook-Id></p></div></div></div><div
|
|||
<span class="hljs-variable">$webhook</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateWebhook.php'</span>;
|
||||
<span class="hljs-variable">$webhookId</span> = <span class="hljs-variable">$webhook</span>->getId();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="get-list-of-subscribed-event-types">Get List of Subscribed Event Types</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$output</span> = \PayPal\Api\WebhookEventType::subscribedEventTypes(<span class="hljs-variable">$webhookId</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"List subscribed webhook event types"</span>, <span class="hljs-string">"WebhookEventTypeList"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$webhookId</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"List subscribed webhook event types"</span>, <span class="hljs-string">"WebhookEventTypeList"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$webhookId</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"List subscribed webhook event types"</span>, <span class="hljs-string">"WebhookEventTypeList"</span>,<span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$output</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"List subscribed webhook event types"</span>, <span class="hljs-string">"WebhookEventTypeList"</span>,<span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$output</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$output</span>;</div></div></div></div></body></html>
|
|
@ -6,11 +6,8 @@ get an empty list at any point.
|
|||
In real case, you dont need to create any webhook to make this API call.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> \PayPal\Api\Webhook $webhook */</span>
|
||||
<span class="hljs-variable">$webhook</span> = <span class="hljs-keyword">require_once</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="get-list-of-all-webhooks">Get List of All Webhooks</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$output</span> = \PayPal\Api\Webhook::getAll(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"List all webhooks"</span>, <span class="hljs-string">"WebhookList"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$webhookId</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"List all webhooks"</span>, <span class="hljs-string">"WebhookList"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$webhookId</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"List all webhooks"</span>, <span class="hljs-string">"WebhookList"</span>,<span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$output</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"List all webhooks"</span>, <span class="hljs-string">"WebhookList"</span>,<span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$output</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$output</span>;</div></div></div></div></body></html>
|
|
@ -11,12 +11,9 @@ for a webhook events. This is made in a sample just to make sure there is minimu
|
|||
<span class="hljs-variable">$params</span> = <span class="hljs-keyword">array</span>(</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>'start_time'=>'2014-12-06T11:00:00Z',
|
||||
'end_time'=>'2014-12-12T11:00:00Z'</p></div></div><div class="code"><div class="wrapper">);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="search-webhook-events">Search Webhook events</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$output</span> = \PayPal\Api\WebhookEvent::all(<span class="hljs-variable">$params</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Search Webhook events"</span>, <span class="hljs-string">"WebhookEventList"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Search Webhook events"</span>, <span class="hljs-string">"WebhookEventList"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Search Webhook events"</span>, <span class="hljs-string">"WebhookEventList"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$params</span>, <span class="hljs-variable">$output</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Search Webhook events"</span>, <span class="hljs-string">"WebhookEventList"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$params</span>, <span class="hljs-variable">$output</span>);
|
||||
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$output</span>;</div></div></div></div></body></html>
|
|
@ -33,11 +33,8 @@ However, in real case scenario, we could use just the ID from database or use an
|
|||
<span class="hljs-variable">$patchRequest</span> = <span class="hljs-keyword">new</span> \PayPal\Api\PatchRequest();
|
||||
<span class="hljs-variable">$patchRequest</span>->addPatch(<span class="hljs-variable">$patch</span>)->addPatch(<span class="hljs-variable">$patch2</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="get-webhook">Get Webhook</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$output</span> = <span class="hljs-variable">$webhook</span>->update(<span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Updated a Webhook"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Updated a Webhook"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Updated a Webhook"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-variable">$output</span>->getId(), <span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$output</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Updated a Webhook"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-variable">$output</span>->getId(), <span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$output</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$output</span>;</div></div></div></div></body></html>
|
19
_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/notifications/ValidateWebhookEvent.html
vendored
Normal file
19
_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/notifications/ValidateWebhookEvent.html
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html><html lang="en"><head><title>notifications/ValidateWebhookEvent</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="notifications/ValidateWebhookEvent"><meta name="groc-project-path" content="notifications/ValidateWebhookEvent.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">notifications/ValidateWebhookEvent.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span>
|
||||
|
||||
<span class="hljs-variable">$apiContext</span> = <span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="validate-webhook">Validate Webhook</h1>
|
||||
<p>PHP Currently does not support certificate chain validation, that is necessary to validate webhook directly, from received data
|
||||
To resolve that, we need to use alternative, which includes making a GET call to obtain the data directly from PayPal.</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h2 id="received-body-from-webhook">Received Body from Webhook</h2>
|
||||
<p>Body received from webhook. This would be the data that you receive in the post request that comes from PayPal, to your webhook set URL.
|
||||
This is a sample data, that represents the webhook event data.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$bodyReceived</span> = <span class="hljs-string">'{"id":"WH-36G56432PK518391U-9HW18392D95289106","create_time":"2015-06-01T20:21:13Z","resource_type":"sale","event_type":"PAYMENT.SALE.COMPLETED","summary":"Payment completed for $ 20.0 USD","resource":{"id":"2FY57107YS3937627","create_time":"2015-06-01T20:20:28Z","update_time":"2015-06-01T20:20:46Z","amount":{"total":"20.00","currency":"USD"},"payment_mode":"INSTANT_TRANSFER","state":"completed","protection_eligibility":"ELIGIBLE","protection_eligibility_type":"ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE","parent_payment":"PAY-2SV945219E505370PKVWL5DA","transaction_fee":{"value":"0.88","currency":"USD"},"links":[{"href":"https://api.sandbox.paypal.com/v1/payments/sale/2FY57107YS3937627","rel":"self","method":"GET"},{"href":"https://api.sandbox.paypal.com/v1/payments/sale/2FY57107YS3937627/refund","rel":"refund","method":"POST"},{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-2SV945219E505370PKVWL5DA","rel":"parent_payment","method":"GET"}]},"links":[{"href":"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-36G56432PK518391U-9HW18392D95289106","rel":"self","method":"GET"},{"href":"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-36G56432PK518391U-9HW18392D95289106/resend","rel":"resend","method":"POST"}]}'</span>;
|
||||
|
||||
<span class="hljs-comment">/**
|
||||
* This is one way to receive the entire body that you received from PayPal webhook. This is one of the way to retrieve that information.
|
||||
* Just uncomment the below line to read the data from actual request.
|
||||
*/</span>
|
||||
<span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> String $bodyReceived */</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>$bodyReceived = file_get_contents('php://input');</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="validate-received-event-method">Validate Received Event Method</h3>
|
||||
<p>Call the validateReceivedEvent() method with provided body, and apiContext object to validate</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> \PayPal\Api\WebhookEvent $output */</span>
|
||||
<span class="hljs-variable">$output</span> = \PayPal\Api\WebhookEvent::validateAndGetReceivedEvent(<span class="hljs-variable">$bodyReceived</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Validate Received Webhook Event"</span>, <span class="hljs-string">"WebhookEvent"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$bodyReceived</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper">ResultPrinter::printResult(<span class="hljs-string">"Validate Received Webhook Event"</span>, <span class="hljs-string">"WebhookEvent"</span>, <span class="hljs-variable">$output</span>->getId(), <span class="hljs-variable">$bodyReceived</span>, <span class="hljs-variable">$output</span>);</div></div></div></div></body></html>
|
|
@ -3,11 +3,8 @@
|
|||
<a href="https://developer.paypal.com/webapps/developer/docs/api/#get-a-reference-list-of-webhook-event-types">https://developer.paypal.com/webapps/developer/docs/api/#get-a-reference-list-of-webhook-event-types</a>
|
||||
API used: GET /v1/notifications/webhooks-event-types</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$apiContext</span> = <span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="get-list-of-all-webhook-event-types">Get List of all Webhook event types</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$output</span> = \PayPal\Api\WebhookEventType::availableEventTypes(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Get List of All Webhook Event Types"</span>, <span class="hljs-string">"WebhookEventTypeList"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Get List of All Webhook Event Types"</span>, <span class="hljs-string">"WebhookEventTypeList"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get List of All Webhook Event Types"</span>, <span class="hljs-string">"WebhookEventTypeList"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$output</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Get List of All Webhook Event Types"</span>, <span class="hljs-string">"WebhookEventTypeList"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$output</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$output</span>;</div></div></div></div></body></html>
|
File diff suppressed because one or more lines are too long
|
@ -8,9 +8,6 @@ that contains the web profile ID.</p></div></div><div class="code"><div class="w
|
|||
<span class="hljs-variable">$webProfile</span>->setId(<span class="hljs-variable">$createProfileResponse</span>->getId());
|
||||
|
||||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Execute the delete method</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$webProfile</span>->delete(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (\PayPal\<span class="hljs-keyword">Exception</span>\PayPalConnectionException <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Deleted Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$createProfileResponse</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (\PayPal\<span class="hljs-keyword">Exception</span>\PayPalConnectionException <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Deleted Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$createProfileResponse</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Deleted Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$createProfileResponse</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>);</div></div></div></div></body></html>
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Deleted Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$createProfileResponse</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>);</div></div></div></div></body></html>
|
|
@ -8,10 +8,12 @@ that contains the web profile ID.</p></div></div><div class="code"><div class="w
|
|||
|
||||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>If your request is successful, the API returns a web_profile object response that contains the profile details.</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$webProfile</span> = \PayPal\Api\WebProfile::get(<span class="hljs-variable">$createProfileResponse</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (\PayPal\<span class="hljs-keyword">Exception</span>\PayPalConnectionException <span class="hljs-variable">$ex</span>) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError(<span class="hljs-string">"Get Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$webProfile</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$webProfile</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$webProfile</span>);
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$webProfile</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$webProfile</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$webProfile</span>;</div></div></div></div></body></html>
|
|
@ -5,15 +5,12 @@
|
|||
static <code>get_list</code> method on the WebProfile class.
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$list</span> = \PayPal\Api\WebProfile::get_list(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (\PayPal\<span class="hljs-keyword">Exception</span>\PayPalConnectionException <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Get List of All Web Profiles"</span>, <span class="hljs-string">"Web Profiles"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (\PayPal\<span class="hljs-keyword">Exception</span>\PayPalConnectionException <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Get List of All Web Profiles"</span>, <span class="hljs-string">"Web Profiles"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
<span class="hljs-variable">$result</span> = <span class="hljs-string">''</span>;
|
||||
<span class="hljs-keyword">foreach</span> (<span class="hljs-variable">$list</span> <span class="hljs-keyword">as</span> <span class="hljs-variable">$object</span>) {
|
||||
<span class="hljs-variable">$result</span> .= <span class="hljs-variable">$object</span>->toJSON(<span class="hljs-number">128</span>) . PHP_EOL;
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get List of All Web Profiles"</span>, <span class="hljs-string">"Web Profiles"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$result</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Get List of All Web Profiles"</span>, <span class="hljs-string">"Web Profiles"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$result</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$list</span>;</div></div></div></div></body></html>
|
|
@ -17,9 +17,6 @@ as shown below</p></div></div><div class="code"><div class="wrapper"><span class
|
|||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Execute the partial update, to carry out these two operations on a given web profile object</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-keyword">if</span> (<span class="hljs-variable">$webProfile</span>->partial_update(<span class="hljs-variable">$patches</span>, <span class="hljs-variable">$apiContext</span>)) {
|
||||
<span class="hljs-variable">$webProfile</span> = \PayPal\Api\WebProfile::get(<span class="hljs-variable">$webProfile</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
}
|
||||
} <span class="hljs-keyword">catch</span> (\<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Partially Updated Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$webProfile</span>->getId(), <span class="hljs-variable">$patches</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (\<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Partially Updated Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$webProfile</span>->getId(), <span class="hljs-variable">$patches</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Partially Updated Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$webProfile</span>->getId(), <span class="hljs-variable">$patches</span>, <span class="hljs-variable">$webProfile</span>);</div></div></div></div></body></html>
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Partially Updated Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$webProfile</span>->getId(), <span class="hljs-variable">$patches</span>, <span class="hljs-variable">$webProfile</span>);</div></div></div></div></body></html>
|
|
@ -7,9 +7,6 @@ create a new web profileId for sample, and return the web profile object.</p></d
|
|||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Update the web profile to change the logo image.</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-keyword">if</span> (<span class="hljs-variable">$webProfile</span>->update(<span class="hljs-variable">$apiContext</span>)) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>If the update is successfull, we can now get the object, and verify the web profile
|
||||
object</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$updatedWebProfile</span> = \PayPal\Api\WebProfile::get(<span class="hljs-variable">$webProfile</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
}
|
||||
} <span class="hljs-keyword">catch</span> (\<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Updated Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$webProfile</span>->getId(), <span class="hljs-variable">$webProfile</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (\<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Updated Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$webProfile</span>->getId(), <span class="hljs-variable">$webProfile</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Updated Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$updatedWebProfile</span>->getId(), <span class="hljs-variable">$webProfile</span>, <span class="hljs-variable">$updatedWebProfile</span>);</div></div></div></div></body></html>
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Updated Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$updatedWebProfile</span>->getId(), <span class="hljs-variable">$webProfile</span>, <span class="hljs-variable">$updatedWebProfile</span>);</div></div></div></div></body></html>
|
|
@ -19,11 +19,8 @@ with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)<
|
|||
<span class="hljs-comment">### Capture</span>
|
||||
<span class="hljs-variable">$capture</span> = <span class="hljs-keyword">new</span> Capture();
|
||||
<span class="hljs-variable">$capture</span>->setAmount(<span class="hljs-variable">$amt</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Perform a capture</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$getCapture</span> = <span class="hljs-variable">$authorization</span>->capture(<span class="hljs-variable">$capture</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Capture Payment"</span>, <span class="hljs-string">"Authorization"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$capture</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Capture Payment"</span>, <span class="hljs-string">"Authorization"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$capture</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Capture Payment"</span>, <span class="hljs-string">"Authorization"</span>, <span class="hljs-variable">$getCapture</span>->getId(), <span class="hljs-variable">$capture</span>, <span class="hljs-variable">$getCapture</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Capture Payment"</span>, <span class="hljs-string">"Authorization"</span>, <span class="hljs-variable">$getCapture</span>->getId(), <span class="hljs-variable">$capture</span>, <span class="hljs-variable">$getCapture</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$getCapture</span>;</div></div></div></div></body></html>
|
|
@ -52,12 +52,9 @@ authorization. Setting it to sale creates actual payment</p></div></div><div cla
|
|||
with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)
|
||||
The return object contains the state.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$payment</span>->create(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">'Authorize a Payment'</span>, <span class="hljs-string">'Authorized Payment'</span>, <span class="hljs-variable">$payment</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">'Authorize a Payment'</span>, <span class="hljs-string">'Authorized Payment'</span>, <span class="hljs-variable">$payment</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">'Authorize a Payment'</span>, <span class="hljs-string">'Authorized Payment'</span>, <span class="hljs-variable">$payment</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$payment</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">'Authorize a Payment'</span>, <span class="hljs-string">'Authorized Payment'</span>, <span class="hljs-variable">$payment</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$payment</span>);
|
||||
|
||||
<span class="hljs-variable">$transactions</span> = <span class="hljs-variable">$payment</span>->getTransactions();
|
||||
<span class="hljs-variable">$relatedResources</span> = <span class="hljs-variable">$transactions</span>[<span class="hljs-number">0</span>]->getRelatedResources();
|
||||
|
|
|
@ -68,6 +68,7 @@ url to which the buyer must be redirected to
|
|||
for payment approval</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$payment</span>->create(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError(<span class="hljs-string">"Created Payment Authorization Using PayPal. Please visit the URL to Authorize."</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="get-redirect-url">Get redirect url</h3>
|
||||
|
@ -75,6 +76,7 @@ for payment approval</p></div></div><div class="code"><div class="wrapper"><span
|
|||
the buyer to. Retrieve the url from the $payment->getLinks()
|
||||
method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$payment</span>->getApprovalLink();
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Created Payment Authorization Using PayPal. Please visit the URL to Authorize."</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-string">"<a href='$approvalUrl' >$approvalUrl</a>"</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$payment</span>);
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Created Payment Authorization Using PayPal. Please visit the URL to Authorize."</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-string">"<a href='$approvalUrl' >$approvalUrl</a>"</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$payment</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$payment</span>;</div></div></div></div></body></html>
|
|
@ -46,11 +46,8 @@ url to which the buyer must be redirected to
|
|||
for payment approval
|
||||
Please note that currently future payments works only with PayPal as a funding instrument.</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$payment</span>->create(<span class="hljs-variable">$apiContext</span>, <span class="hljs-variable">$clientMetadataId</span>);
|
||||
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Future Payment"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Future Payment"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Future Payment"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-variable">$payment</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$payment</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Future Payment"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-variable">$payment</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$payment</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$payment</span>;</div></div></div></div></body></html>
|
|
@ -77,11 +77,8 @@ the above types and intent set to sale 'sale'</p></div></div><div class=
|
|||
with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)
|
||||
The return object contains the state.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$payment</span>->create(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">'Create Payment Using Credit Card. If 500 Exception, try creating a new Credit Card using <a href="https://ppmts.custhelp.com/app/answers/detail/a_id/750">Step 4, on this link</a>, and using it.'</span>, <span class="hljs-string">'Payment'</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">'Create Payment Using Credit Card. If 500 Exception, try creating a new Credit Card using <a href="https://ppmts.custhelp.com/app/answers/detail/a_id/750">Step 4, on this link</a>, and using it.'</span>, <span class="hljs-string">'Payment'</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">'Create Payment Using Credit Card'</span>, <span class="hljs-string">'Payment'</span>, <span class="hljs-variable">$payment</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$payment</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">'Create Payment Using Credit Card'</span>, <span class="hljs-string">'Payment'</span>, <span class="hljs-variable">$payment</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$payment</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$payment</span>;</div></div></div></div></body></html>
|
|
@ -19,11 +19,13 @@ information</p></div></div><div class="code"><div class="wrapper"><span class="h
|
|||
<span class="hljs-variable">$item1</span>->setName(<span class="hljs-string">'Ground Coffee 40 oz'</span>)
|
||||
->setCurrency(<span class="hljs-string">'USD'</span>)
|
||||
->setQuantity(<span class="hljs-number">1</span>)
|
||||
->setSku(<span class="hljs-string">"123123"</span>) <span class="hljs-comment">// Similar to `item_number` in Classic API</span>
|
||||
->setPrice(<span class="hljs-number">7.5</span>);
|
||||
<span class="hljs-variable">$item2</span> = <span class="hljs-keyword">new</span> Item();
|
||||
<span class="hljs-variable">$item2</span>->setName(<span class="hljs-string">'Granola bars'</span>)
|
||||
->setCurrency(<span class="hljs-string">'USD'</span>)
|
||||
->setQuantity(<span class="hljs-number">5</span>)
|
||||
->setSku(<span class="hljs-string">"321321"</span>) <span class="hljs-comment">// Similar to `item_number` in Classic API</span>
|
||||
->setPrice(<span class="hljs-number">2</span>);
|
||||
|
||||
<span class="hljs-variable">$itemList</span> = <span class="hljs-keyword">new</span> ItemList();
|
||||
|
@ -65,14 +67,11 @@ The return object contains the state and the
|
|||
url to which the buyer must be redirected to
|
||||
for payment approval</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$payment</span>->create(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Created Payment Using PayPal. Please visit the URL to Approve."</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Created Payment Using PayPal. Please visit the URL to Approve."</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="get-redirect-url">Get redirect url</h3>
|
||||
<p>The API response provides the url that you must redirect
|
||||
the buyer to. Retrieve the url from the $payment->getApprovalLink()
|
||||
method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$payment</span>->getApprovalLink();
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Created Payment Using PayPal. Please visit the URL to Approve."</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-string">"<a href='$approvalUrl' >$approvalUrl</a>"</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$payment</span>);
|
||||
method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$payment</span>->getApprovalLink();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Created Payment Using PayPal. Please visit the URL to Approve."</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-string">"<a href='$approvalUrl' >$approvalUrl</a>"</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$payment</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$payment</span>;</div></div></div></div></body></html>
|
|
@ -68,11 +68,8 @@ passing it a valid apiContext.
|
|||
(See bootstrap.php for more on <code>ApiContext</code>)
|
||||
The return object contains the state.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$payment</span>->create(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Create Payment using Saved Card"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Create Payment using Saved Card"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Create Payment using Saved Card"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-variable">$payment</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$payment</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Create Payment using Saved Card"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-variable">$payment</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$payment</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$card</span>;</div></div></div></div></body></html>
|
|
@ -22,27 +22,20 @@ when the user is redirected from paypal back to your site</p></div></div><div cl
|
|||
<span class="hljs-variable">$execution</span>->setPayerId(<span class="hljs-variable">$_GET</span>[<span class="hljs-string">'PayerID'</span>]);
|
||||
|
||||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Execute the payment
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$result</span> = <span class="hljs-variable">$payment</span>->execute(<span class="hljs-variable">$execution</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Executed Payment"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-variable">$payment</span>->getId(), <span class="hljs-variable">$execution</span>, <span class="hljs-variable">$result</span>);
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$result</span> = <span class="hljs-variable">$payment</span>->execute(<span class="hljs-variable">$execution</span>, <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Executed Payment"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-variable">$payment</span>->getId(), <span class="hljs-variable">$execution</span>, <span class="hljs-variable">$result</span>);
|
||||
|
||||
<span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$payment</span> = Payment::get(<span class="hljs-variable">$paymentId</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Get Payment"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Get Payment"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Executed Payment"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Executed Payment"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get Payment"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-variable">$payment</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$payment</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Get Payment"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-variable">$payment</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$payment</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$payment</span>;
|
||||
|
||||
|
||||
} <span class="hljs-keyword">else</span> {
|
||||
ResultPrinter::printResult(<span class="hljs-string">"User Cancelled the Approval"</span>, <span class="hljs-keyword">null</span>);
|
||||
} <span class="hljs-keyword">else</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"User Cancelled the Approval"</span>, <span class="hljs-keyword">null</span>);
|
||||
<span class="hljs-keyword">exit</span>;
|
||||
}</div></div></div></div></body></html>
|
|
@ -10,11 +10,8 @@ API used: /v1/payments/authorization/<$authorizationId></p></div></div><di
|
|||
by invoking the Authorization::get method
|
||||
with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)
|
||||
The return object contains the authorization state.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieve the authorization</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$result</span> = Authorization::get(<span class="hljs-variable">$authorizationId</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Get Authorization"</span>, <span class="hljs-string">"Authorization"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Get Authorization"</span>, <span class="hljs-string">"Authorization"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get Authorization"</span>, <span class="hljs-string">"Authorization"</span>, <span class="hljs-variable">$authorizationId</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$result</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Get Authorization"</span>, <span class="hljs-string">"Authorization"</span>, <span class="hljs-variable">$authorizationId</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$result</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$result</span>;</div></div></div></div></body></html>
|
|
@ -10,9 +10,6 @@ API used: /v1/payments/capture/<$captureId></p></div></div><div class="cod
|
|||
<p>You can look up a capture by invoking the Capture::get method
|
||||
with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$capture</span> = Capture::get(<span class="hljs-variable">$request</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Get Captured Payment"</span>, <span class="hljs-string">"Capture"</span>, <span class="hljs-variable">$request</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Get Captured Payment"</span>, <span class="hljs-string">"Capture"</span>, <span class="hljs-variable">$request</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get Captured Payment"</span>, <span class="hljs-string">"Capture"</span>, <span class="hljs-variable">$capture</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$capture</span>);</div></div></div></div></body></html>
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Get Captured Payment"</span>, <span class="hljs-string">"Capture"</span>, <span class="hljs-variable">$capture</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$capture</span>);</div></div></div></div></body></html>
|
|
@ -16,11 +16,8 @@ on the Payment class by passing a valid
|
|||
Payment ID
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$payment</span> = Payment::get(<span class="hljs-variable">$paymentId</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Get Payment"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Get Payment"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get Payment"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-variable">$payment</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$payment</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Get Payment"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-variable">$payment</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$payment</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$payment</span>;</div></div></div></div></body></html>
|
|
@ -17,9 +17,6 @@ Refer the method doc for valid values for keys
|
|||
<span class="hljs-variable">$params</span> = <span class="hljs-keyword">array</span>(<span class="hljs-string">'count'</span> => <span class="hljs-number">10</span>, <span class="hljs-string">'start_index'</span> => <span class="hljs-number">5</span>);
|
||||
|
||||
<span class="hljs-variable">$payments</span> = Payment::all(<span class="hljs-variable">$params</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"List Payments"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$params</span>, <span class="hljs-variable">$ex</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"List Payments"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$params</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"List Payments"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$params</span>, <span class="hljs-variable">$payments</span>);</div></div></div></div></body></html>
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"List Payments"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$params</span>, <span class="hljs-variable">$payments</span>);</div></div></div></div></body></html>
|
|
@ -22,16 +22,13 @@ API used: POST /v1/payments/orders/<Order-Id>/authorize</p></div></div><div clas
|
|||
|
||||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="authorize-order">Authorize Order</h3>
|
||||
<p>Authorize the order by passing authorization object we created.
|
||||
We will get a new authorization object back.</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$result</span> = <span class="hljs-variable">$order</span>->authorize(<span class="hljs-variable">$authorization</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Authorized Order"</span>, <span class="hljs-string">"Authorization"</span>, <span class="hljs-variable">$result</span>->getId(), <span class="hljs-variable">$authorization</span>, <span class="hljs-variable">$result</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Authorized Order"</span>, <span class="hljs-string">"Authorization"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$authorization</span>, <span class="hljs-variable">$ex</span>);
|
||||
We will get a new authorization object back.</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$result</span> = <span class="hljs-variable">$order</span>->authorize(<span class="hljs-variable">$authorization</span>, <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Authorized Order"</span>, <span class="hljs-string">"Authorization"</span>, <span class="hljs-variable">$result</span>->getId(), <span class="hljs-variable">$authorization</span>, <span class="hljs-variable">$result</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Authorized Order"</span>, <span class="hljs-string">"Authorization"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$authorization</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$result</span>;
|
||||
|
||||
} <span class="hljs-keyword">else</span> {
|
||||
ResultPrinter::printResult(<span class="hljs-string">"User Cancelled the Approval"</span>, <span class="hljs-keyword">null</span>);
|
||||
} <span class="hljs-keyword">else</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"User Cancelled the Approval"</span>, <span class="hljs-keyword">null</span>);
|
||||
<span class="hljs-keyword">exit</span>;
|
||||
}</div></div></div></div></body></html>
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue