forked from LiveCarta/PayPal-PHP-SDK
Enabled Billing Plans and Agreements APIs
- Added API Classes, Samples, and Tests - Updated Functional Tests - Updated Documentation with new SDK Name - Updated Few Samples to use newer nicer result page
This commit is contained in:
@@ -6,6 +6,393 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3
|
||||
|
||||
tableOfContents = [
|
||||
{
|
||||
"type": "folder",
|
||||
"data": {
|
||||
"path": "billing",
|
||||
"title": "billing"
|
||||
},
|
||||
"depth": 1,
|
||||
"children": [
|
||||
{
|
||||
"type": "file",
|
||||
"data": {
|
||||
"language": {
|
||||
"nameMatchers": [{}, ".fbp"],
|
||||
"pygmentsLexer": "php",
|
||||
"singleLineComment": ["//"],
|
||||
"ignorePrefix": "}",
|
||||
"foldPrefix": "^",
|
||||
"name": "PHP"
|
||||
},
|
||||
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/CreateBillingAgreementWithCreditCard.php",
|
||||
"projectPath": "billing/CreateBillingAgreementWithCreditCard.php",
|
||||
"targetPath": "billing/CreateBillingAgreementWithCreditCard",
|
||||
"pageTitle": "billing/CreateBillingAgreementWithCreditCard",
|
||||
"title": "CreateBillingAgreementWithCreditCard"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Create Billing Agreement with Credit Card as Payment Source",
|
||||
"slug": "create-billing-agreement-with-credit-card-as-payment-source"
|
||||
},
|
||||
"depth": 1,
|
||||
"children": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Create Agreement",
|
||||
"slug": "create-agreement"
|
||||
},
|
||||
"depth": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
"language": {
|
||||
"nameMatchers": [{}, ".fbp"],
|
||||
"pygmentsLexer": "php",
|
||||
"singleLineComment": ["//"],
|
||||
"ignorePrefix": "}",
|
||||
"foldPrefix": "^",
|
||||
"name": "PHP"
|
||||
},
|
||||
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/CreateBillingAgreementWithPayPal.php",
|
||||
"projectPath": "billing/CreateBillingAgreementWithPayPal.php",
|
||||
"targetPath": "billing/CreateBillingAgreementWithPayPal",
|
||||
"pageTitle": "billing/CreateBillingAgreementWithPayPal",
|
||||
"title": "CreateBillingAgreementWithPayPal"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Create Billing Agreement with PayPal as Payment Source",
|
||||
"slug": "create-billing-agreement-with-paypal-as-payment-source"
|
||||
},
|
||||
"depth": 1,
|
||||
"children": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Create Agreement",
|
||||
"slug": "create-agreement"
|
||||
},
|
||||
"depth": 3
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Get redirect url",
|
||||
"slug": "get-redirect-url"
|
||||
},
|
||||
"depth": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
"language": {
|
||||
"nameMatchers": [{}, ".fbp"],
|
||||
"pygmentsLexer": "php",
|
||||
"singleLineComment": ["//"],
|
||||
"ignorePrefix": "}",
|
||||
"foldPrefix": "^",
|
||||
"name": "PHP"
|
||||
},
|
||||
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/CreatePlan.php",
|
||||
"projectPath": "billing/CreatePlan.php",
|
||||
"targetPath": "billing/CreatePlan",
|
||||
"pageTitle": "billing/CreatePlan",
|
||||
"title": "CreatePlan"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Create Plan Sample",
|
||||
"slug": "create-plan-sample"
|
||||
},
|
||||
"depth": 1
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Basic Information",
|
||||
"slug": "basic-information"
|
||||
},
|
||||
"depth": 1
|
||||
}, {
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Payment definitions for this billing plan.",
|
||||
"slug": "payment-definitions-for-this-billing-plan"
|
||||
},
|
||||
"depth": 1,
|
||||
"children": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Create Plan",
|
||||
"slug": "create-plan"
|
||||
},
|
||||
"depth": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
"language": {
|
||||
"nameMatchers": [{}, ".fbp"],
|
||||
"pygmentsLexer": "php",
|
||||
"singleLineComment": ["//"],
|
||||
"ignorePrefix": "}",
|
||||
"foldPrefix": "^",
|
||||
"name": "PHP"
|
||||
},
|
||||
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/ExecuteAgreement.php",
|
||||
"projectPath": "billing/ExecuteAgreement.php",
|
||||
"targetPath": "billing/ExecuteAgreement",
|
||||
"pageTitle": "billing/ExecuteAgreement",
|
||||
"title": "ExecuteAgreement"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": []
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
"language": {
|
||||
"nameMatchers": [{}, ".fbp"],
|
||||
"pygmentsLexer": "php",
|
||||
"singleLineComment": ["//"],
|
||||
"ignorePrefix": "}",
|
||||
"foldPrefix": "^",
|
||||
"name": "PHP"
|
||||
},
|
||||
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/GetBillingAgreement.php",
|
||||
"projectPath": "billing/GetBillingAgreement.php",
|
||||
"targetPath": "billing/GetBillingAgreement",
|
||||
"pageTitle": "billing/GetBillingAgreement",
|
||||
"title": "GetBillingAgreement"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Get Billing Agreement Sample",
|
||||
"slug": "get-billing-agreement-sample"
|
||||
},
|
||||
"depth": 1
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
"language": {
|
||||
"nameMatchers": [{}, ".fbp"],
|
||||
"pygmentsLexer": "php",
|
||||
"singleLineComment": ["//"],
|
||||
"ignorePrefix": "}",
|
||||
"foldPrefix": "^",
|
||||
"name": "PHP"
|
||||
},
|
||||
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/GetPlan.php",
|
||||
"projectPath": "billing/GetPlan.php",
|
||||
"targetPath": "billing/GetPlan",
|
||||
"pageTitle": "billing/GetPlan",
|
||||
"title": "GetPlan"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Get Plan Sample",
|
||||
"slug": "get-plan-sample"
|
||||
},
|
||||
"depth": 1
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
"language": {
|
||||
"nameMatchers": [{}, ".fbp"],
|
||||
"pygmentsLexer": "php",
|
||||
"singleLineComment": ["//"],
|
||||
"ignorePrefix": "}",
|
||||
"foldPrefix": "^",
|
||||
"name": "PHP"
|
||||
},
|
||||
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/ListPlans.php",
|
||||
"projectPath": "billing/ListPlans.php",
|
||||
"targetPath": "billing/ListPlans",
|
||||
"pageTitle": "billing/ListPlans",
|
||||
"title": "ListPlans"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Get List of Plan Sample",
|
||||
"slug": "get-list-of-plan-sample"
|
||||
},
|
||||
"depth": 1
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
"language": {
|
||||
"nameMatchers": [{}, ".fbp"],
|
||||
"pygmentsLexer": "php",
|
||||
"singleLineComment": ["//"],
|
||||
"ignorePrefix": "}",
|
||||
"foldPrefix": "^",
|
||||
"name": "PHP"
|
||||
},
|
||||
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/ReactivateBillingAgreement.php",
|
||||
"projectPath": "billing/ReactivateBillingAgreement.php",
|
||||
"targetPath": "billing/ReactivateBillingAgreement",
|
||||
"pageTitle": "billing/ReactivateBillingAgreement",
|
||||
"title": "ReactivateBillingAgreement"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Reactivate an agreement",
|
||||
"slug": "reactivate-an-agreement"
|
||||
},
|
||||
"depth": 1
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
"language": {
|
||||
"nameMatchers": [{}, ".fbp"],
|
||||
"pygmentsLexer": "php",
|
||||
"singleLineComment": ["//"],
|
||||
"ignorePrefix": "}",
|
||||
"foldPrefix": "^",
|
||||
"name": "PHP"
|
||||
},
|
||||
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/SuspendBillingAgreement.php",
|
||||
"projectPath": "billing/SuspendBillingAgreement.php",
|
||||
"targetPath": "billing/SuspendBillingAgreement",
|
||||
"pageTitle": "billing/SuspendBillingAgreement",
|
||||
"title": "SuspendBillingAgreement"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Suspend an agreement",
|
||||
"slug": "suspend-an-agreement"
|
||||
},
|
||||
"depth": 1
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
"language": {
|
||||
"nameMatchers": [{}, ".fbp"],
|
||||
"pygmentsLexer": "php",
|
||||
"singleLineComment": ["//"],
|
||||
"ignorePrefix": "}",
|
||||
"foldPrefix": "^",
|
||||
"name": "PHP"
|
||||
},
|
||||
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/UpdateBillingAgreement.php",
|
||||
"projectPath": "billing/UpdateBillingAgreement.php",
|
||||
"targetPath": "billing/UpdateBillingAgreement",
|
||||
"pageTitle": "billing/UpdateBillingAgreement",
|
||||
"title": "UpdateBillingAgreement"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Update an agreement",
|
||||
"slug": "update-an-agreement"
|
||||
},
|
||||
"depth": 1
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "file",
|
||||
"data": {
|
||||
"language": {
|
||||
"nameMatchers": [{}, ".fbp"],
|
||||
"pygmentsLexer": "php",
|
||||
"singleLineComment": ["//"],
|
||||
"ignorePrefix": "}",
|
||||
"foldPrefix": "^",
|
||||
"name": "PHP"
|
||||
},
|
||||
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/billing/UpdatePlan.php",
|
||||
"projectPath": "billing/UpdatePlan.php",
|
||||
"targetPath": "billing/UpdatePlan",
|
||||
"pageTitle": "billing/UpdatePlan",
|
||||
"title": "UpdatePlan"
|
||||
},
|
||||
"depth": 2,
|
||||
"outline": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 1,
|
||||
"title": "Update a plan",
|
||||
"slug": "update-a-plan"
|
||||
},
|
||||
"depth": 1,
|
||||
"children": [
|
||||
{
|
||||
"type": "heading",
|
||||
"data": {
|
||||
"level": 3,
|
||||
"title": "Making Plan Active",
|
||||
"slug": "making-plan-active"
|
||||
},
|
||||
"depth": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"type": "folder",
|
||||
"data": {
|
||||
"path": "invoice",
|
||||
|
||||
85
sample/doc/billing/CreateBillingAgreementWithCreditCard.html
Normal file
85
sample/doc/billing/CreateBillingAgreementWithCreditCard.html
Normal file
@@ -0,0 +1,85 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>billing/CreateBillingAgreementWithCreditCard</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="billing/CreateBillingAgreementWithCreditCard"><meta name="groc-project-path" content="billing/CreateBillingAgreementWithCreditCard.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">billing/CreateBillingAgreementWithCreditCard.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="create-billing-agreement-with-credit-card-as-payment-source">Create Billing Agreement with Credit Card as Payment Source</h1>
|
||||
<p>This sample code demonstrate how you can create a billing agreement, as documented here at:
|
||||
<a href="https://developer.paypal.com/webapps/developer/docs/api/#create-an-agreement">https://developer.paypal.com/webapps/developer/docs/api/#create-an-agreement</a>
|
||||
API used: /v1/payments/billing-agreements</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieving the Plan from the Create Update Sample. This would be used to
|
||||
define Plan information to create an agreement. Make sure the plan you are using is in active state.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Plan $createdPlan */</span>
|
||||
<span class="hljs-variable">$createdPlan</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'UpdatePlan.php'</span>;
|
||||
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Agreement</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Plan</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Payer</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">ShippingAddress</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">PayerInfo</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">CreditCard</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">FundingInstrument</span>;
|
||||
|
||||
<span class="hljs-comment">/* Create a new instance of Agreement object
|
||||
{
|
||||
"name": "DPRP",
|
||||
"description": "Payment with credit Card ",
|
||||
"start_date": "2015-06-17T9:45:04Z",
|
||||
"plan": {
|
||||
"id": "P-1WJ68935LL406420PUTENA2I"
|
||||
},
|
||||
"shipping_address": {
|
||||
"line1": "111 First Street",
|
||||
"city": "Saratoga",
|
||||
"state": "CA",
|
||||
"postal_code": "95070",
|
||||
"country_code": "US"
|
||||
},
|
||||
"payer": {
|
||||
"payment_method": "credit_card",
|
||||
"payer_info": {
|
||||
"email": "jaypatel512-facilitator@hotmail.com"
|
||||
},
|
||||
"funding_instruments": [
|
||||
{
|
||||
"credit_card": {
|
||||
"type": "visa",
|
||||
"number": "4417119669820331",
|
||||
"expire_month": "12",
|
||||
"expire_year": "2017",
|
||||
"cvv2": "128"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}*/</span>
|
||||
<span class="hljs-variable">$agreement</span> = <span class="hljs-keyword">new</span> Agreement();
|
||||
|
||||
<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
|
||||
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();
|
||||
<span class="hljs-variable">$payer</span>->setPaymentMethod(<span class="hljs-string">'credit_card'</span>)
|
||||
->setPayerInfo(<span class="hljs-keyword">new</span> PayerInfo([<span class="hljs-string">'email'</span> => <span class="hljs-string">'jaypatel512-facilitator@hotmail.com'</span>]));</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Add Credit Card to Funding Instruments</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$creditCard</span> = <span class="hljs-keyword">new</span> CreditCard();
|
||||
<span class="hljs-variable">$creditCard</span>->setType(<span class="hljs-string">'visa'</span>)
|
||||
->setNumber(<span class="hljs-string">'4417119669820331'</span>)
|
||||
->setExpireMonth(<span class="hljs-string">'12'</span>)
|
||||
->setExpireYear(<span class="hljs-string">'2017'</span>)
|
||||
->setCvv2(<span class="hljs-string">'128'</span>);
|
||||
|
||||
<span class="hljs-variable">$fundingInstrument</span> = <span class="hljs-keyword">new</span> FundingInstrument();
|
||||
<span class="hljs-variable">$fundingInstrument</span>->setCreditCard(<span class="hljs-variable">$creditCard</span>);
|
||||
<span class="hljs-variable">$payer</span>->setFundingInstruments(<span class="hljs-keyword">array</span>(<span class="hljs-variable">$fundingInstrument</span>));
|
||||
<span class="hljs-comment">//Add Payer to Agreement</span>
|
||||
<span class="hljs-variable">$agreement</span>->setPayer(<span class="hljs-variable">$payer</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Add Shipping Address</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$shippingAddress</span> = <span class="hljs-keyword">new</span> ShippingAddress();
|
||||
<span class="hljs-variable">$shippingAddress</span>->setLine1(<span class="hljs-string">'111 First Street'</span>)
|
||||
->setCity(<span class="hljs-string">'Saratoga'</span>)
|
||||
->setState(<span class="hljs-string">'CA'</span>)
|
||||
->setPostalCode(<span class="hljs-string">'95070'</span>)
|
||||
->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> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
<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>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$agreement</span>;</div></div></div></div></body></html>
|
||||
65
sample/doc/billing/CreateBillingAgreementWithPayPal.html
Normal file
65
sample/doc/billing/CreateBillingAgreementWithPayPal.html
Normal file
@@ -0,0 +1,65 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>billing/CreateBillingAgreementWithPayPal</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="billing/CreateBillingAgreementWithPayPal"><meta name="groc-project-path" content="billing/CreateBillingAgreementWithPayPal.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">billing/CreateBillingAgreementWithPayPal.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="create-billing-agreement-with-paypal-as-payment-source">Create Billing Agreement with PayPal as Payment Source</h1>
|
||||
<p>This sample code demonstrate how you can create a billing agreement, as documented here at:
|
||||
<a href="https://developer.paypal.com/webapps/developer/docs/api/#create-an-agreement">https://developer.paypal.com/webapps/developer/docs/api/#create-an-agreement</a>
|
||||
API used: /v1/payments/billing-agreements</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieving the Plan from the Create Update Sample. This would be used to
|
||||
define Plan information to create an agreement. Make sure the plan you are using is in active state.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Plan $createdPlan */</span>
|
||||
<span class="hljs-variable">$createdPlan</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'UpdatePlan.php'</span>;
|
||||
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Agreement</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Plan</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Payer</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">ShippingAddress</span>;
|
||||
|
||||
<span class="hljs-comment">/* Create a new instance of Agreement object
|
||||
{
|
||||
"name": "Base Agreement",
|
||||
"description": "Basic agreement",
|
||||
"start_date": "2015-06-17T9:45:04Z",
|
||||
"plan": {
|
||||
"id": "P-1WJ68935LL406420PUTENA2I"
|
||||
},
|
||||
"payer": {
|
||||
"payment_method": "paypal"
|
||||
},
|
||||
"shipping_address": {
|
||||
"line1": "111 First Street",
|
||||
"city": "Saratoga",
|
||||
"state": "CA",
|
||||
"postal_code": "95070",
|
||||
"country_code": "US"
|
||||
}
|
||||
}*/</span>
|
||||
<span class="hljs-variable">$agreement</span> = <span class="hljs-keyword">new</span> Agreement();
|
||||
|
||||
<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
|
||||
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();
|
||||
<span class="hljs-variable">$payer</span>->setPaymentMethod(<span class="hljs-string">'paypal'</span>);
|
||||
<span class="hljs-variable">$agreement</span>->setPayer(<span class="hljs-variable">$payer</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Add Shipping Address</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$shippingAddress</span> = <span class="hljs-keyword">new</span> ShippingAddress();
|
||||
<span class="hljs-variable">$shippingAddress</span>->setLine1(<span class="hljs-string">'111 First Street'</span>)
|
||||
->setCity(<span class="hljs-string">'Saratoga'</span>)
|
||||
->setState(<span class="hljs-string">'CA'</span>)
|
||||
->setPostalCode(<span class="hljs-string">'95070'</span>)
|
||||
->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>);</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 $agreement->getLinks()
|
||||
method</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-keyword">foreach</span> (<span class="hljs-variable">$agreement</span>->getLinks() <span class="hljs-keyword">as</span> <span class="hljs-variable">$link</span>) {
|
||||
<span class="hljs-keyword">if</span> (<span class="hljs-variable">$link</span>->getRel() == <span class="hljs-string">'approval_url'</span>) {
|
||||
<span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$link</span>->getHref();
|
||||
<span class="hljs-keyword">break</span>;
|
||||
}
|
||||
}
|
||||
|
||||
} <span class="hljs-keyword">catch</span> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
<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>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$agreement</span>;</div></div></div></div></body></html>
|
||||
46
sample/doc/billing/CreatePlan.html
Normal file
46
sample/doc/billing/CreatePlan.html
Normal file
@@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>billing/CreatePlan</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="billing/CreatePlan"><meta name="groc-project-path" content="billing/CreatePlan.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">billing/CreatePlan.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="create-plan-sample">Create Plan Sample</h1>
|
||||
<p>This sample code demonstrate how you can create a billing plan, as documented here at:
|
||||
<a href="https://developer.paypal.com/webapps/developer/docs/api/#create-a-plan">https://developer.paypal.com/webapps/developer/docs/api/#create-a-plan</a>
|
||||
API used: /v1/payments/billing-plans</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Plan</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">PaymentDefinition</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">MerchantPreferences</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Currency</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">ChargeModel</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Create a new instance of Plan object</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$plan</span> = <span class="hljs-keyword">new</span> Plan();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="basic-information">Basic Information</h1>
|
||||
<p>Fill up the basic information that is required for the plan</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$plan</span>->setName(<span class="hljs-string">'T-Shirt of the Month Club Plan'</span>)
|
||||
->setDescription(<span class="hljs-string">'Template creation.'</span>)
|
||||
->setType(<span class="hljs-string">'fixed'</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="payment-definitions-for-this-billing-plan">Payment definitions for this billing plan.</h1></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-variable">$paymentDefinition</span> = <span class="hljs-keyword">new</span> PaymentDefinition();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>The possible values for such setters are mentioned in the setter method documentation.
|
||||
Just open the class file. e.g. lib/PayPal/Api/PaymentDefinition.php and look for setFrequency method.
|
||||
You should be able to see the acceptable values in the comments.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$paymentDefinition</span>->setName(<span class="hljs-string">'Regular Payments'</span>)
|
||||
->setType(<span class="hljs-string">'REGULAR'</span>)
|
||||
->setFrequency(<span class="hljs-string">'Month'</span>)
|
||||
->setFrequencyInterval(<span class="hljs-string">"2"</span>)
|
||||
->setCycles(<span class="hljs-string">"12"</span>)
|
||||
->setAmount(<span class="hljs-keyword">new</span> Currency([<span class="hljs-string">'value'</span> => <span class="hljs-string">'100'</span>, <span class="hljs-string">'currency'</span> => <span class="hljs-string">'USD'</span>]));</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Charge Models</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$chargeModel</span> = <span class="hljs-keyword">new</span> ChargeModel();
|
||||
<span class="hljs-variable">$chargeModel</span>->setType(<span class="hljs-string">'SHIPPING'</span>)
|
||||
->setAmount(<span class="hljs-keyword">new</span> Currency([<span class="hljs-string">'value'</span> => <span class="hljs-string">'10'</span>, <span class="hljs-string">'currency'</span> => <span class="hljs-string">'USD'</span>]));
|
||||
|
||||
<span class="hljs-variable">$paymentDefinition</span>->setChargeModels(<span class="hljs-keyword">array</span>(<span class="hljs-variable">$chargeModel</span>));
|
||||
|
||||
<span class="hljs-variable">$merchantPreferences</span> = <span class="hljs-keyword">new</span> MerchantPreferences();
|
||||
<span class="hljs-variable">$baseUrl</span> = getBaseUrl();
|
||||
<span class="hljs-variable">$merchantPreferences</span>->setReturnUrl(<span class="hljs-string">"$baseUrl/ExecuteAgreement.php?success=true"</span>)
|
||||
->setCancelUrl(<span class="hljs-string">"$baseUrl/ExecuteAgreement.php?success=false"</span>)
|
||||
->setAutoBillAmount(<span class="hljs-string">"YES"</span>)
|
||||
->setInitialFailAmountAction(<span class="hljs-string">"CONTINUE"</span>)
|
||||
->setMaxFailAttempts(<span class="hljs-string">"0"</span>)
|
||||
->setSetupFee(<span class="hljs-keyword">new</span> Currency([<span class="hljs-string">'value'</span> => <span class="hljs-string">'1'</span>, <span class="hljs-string">'currency'</span> => <span class="hljs-string">'USD'</span>]));
|
||||
|
||||
|
||||
<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> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
<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>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$output</span>;</div></div></div></div></body></html>
|
||||
22
sample/doc/billing/ExecuteAgreement.html
Normal file
22
sample/doc/billing/ExecuteAgreement.html
Normal file
@@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>billing/ExecuteAgreement</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="billing/ExecuteAgreement"><meta name="groc-project-path" content="billing/ExecuteAgreement.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">billing/ExecuteAgreement.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span>
|
||||
|
||||
<span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;
|
||||
session_start();
|
||||
<span class="hljs-keyword">if</span> (<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$_GET</span>[<span class="hljs-string">'success'</span>]) && <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'success'</span>] == <span class="hljs-string">'true'</span>) {
|
||||
|
||||
<span class="hljs-variable">$token</span> = <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'token'</span>];
|
||||
|
||||
<span class="hljs-variable">$agreement</span> = <span class="hljs-keyword">new</span> \PayPal\Api\Agreement();
|
||||
|
||||
<span class="hljs-keyword">try</span> {
|
||||
<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> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
<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>);
|
||||
|
||||
} <span class="hljs-keyword">else</span> {
|
||||
ResultPrinter::printResult(<span class="hljs-string">"User Cancelled the Approval"</span>, <span class="hljs-keyword">null</span>);
|
||||
}</div></div></div></div></body></html>
|
||||
19
sample/doc/billing/GetBillingAgreement.html
Normal file
19
sample/doc/billing/GetBillingAgreement.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>billing/GetBillingAgreement</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="billing/GetBillingAgreement"><meta name="groc-project-path" content="billing/GetBillingAgreement.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">billing/GetBillingAgreement.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="get-billing-agreement-sample">Get Billing Agreement Sample</h1>
|
||||
<p>This sample code demonstrate how you can get a billing agreement, as documented here at:
|
||||
<a href="https://developer.paypal.com/webapps/developer/docs/api/#retrieve-an-agreement">https://developer.paypal.com/webapps/developer/docs/api/#retrieve-an-agreement</a>
|
||||
API used: /v1/payments/billing-agreements/<Agreement-Id></p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieving the Agreement object from Create Agreement From Credit Card Sample</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Agreement $createdAgreement */</span>
|
||||
<span class="hljs-variable">$createdAgreement</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateBillingAgreementWithCreditCard.php'</span>;
|
||||
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Agreement</span>;
|
||||
|
||||
<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> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
<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>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$agreement</span>;</div></div></div></div></body></html>
|
||||
19
sample/doc/billing/GetPlan.html
Normal file
19
sample/doc/billing/GetPlan.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>billing/GetPlan</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="billing/GetPlan"><meta name="groc-project-path" content="billing/GetPlan.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">billing/GetPlan.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="get-plan-sample">Get Plan Sample</h1>
|
||||
<p>This sample code demonstrate how you can get a billing plan, as documented here at:
|
||||
<a href="https://developer.paypal.com/webapps/developer/docs/api/#retrieve-a-plan">https://developer.paypal.com/webapps/developer/docs/api/#retrieve-a-plan</a>
|
||||
API used: /v1/payments/billing-plans</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieving the Plan object from Create Plan Sample</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Plan $createdPlan */</span>
|
||||
<span class="hljs-variable">$createdPlan</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreatePlan.php'</span>;
|
||||
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Plan</span>;
|
||||
|
||||
<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> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
<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>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$plan</span>;</div></div></div></div></body></html>
|
||||
22
sample/doc/billing/ListPlans.html
Normal file
22
sample/doc/billing/ListPlans.html
Normal file
@@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>billing/ListPlans</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="billing/ListPlans"><meta name="groc-project-path" content="billing/ListPlans.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">billing/ListPlans.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="get-list-of-plan-sample">Get List of Plan Sample</h1>
|
||||
<p>This sample code demonstrate how you can get a list of billing plan, as documented 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>
|
||||
API used: /v1/payments/billing-plans</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieving the Plan object from Create Plan Sample to demonstrate the List</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Plan $createdPlan */</span>
|
||||
<span class="hljs-variable">$createdPlan</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreatePlan.php'</span>;
|
||||
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Plan</span>;
|
||||
|
||||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Get the list of all plans
|
||||
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> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
<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>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$planList</span>;</div></div></div></div></body></html>
|
||||
26
sample/doc/billing/ReactivateBillingAgreement.html
Normal file
26
sample/doc/billing/ReactivateBillingAgreement.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>billing/ReactivateBillingAgreement</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="billing/ReactivateBillingAgreement"><meta name="groc-project-path" content="billing/ReactivateBillingAgreement.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">billing/ReactivateBillingAgreement.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="reactivate-an-agreement">Reactivate an agreement</h1>
|
||||
<p>This sample code demonstrate how you can reactivate a billing agreement, as documented here at:
|
||||
<a href="https://developer.paypal.com/webapps/developer/docs/api/#suspend-an-agreement">https://developer.paypal.com/webapps/developer/docs/api/#suspend-an-agreement</a>
|
||||
API used: /v1/payments/billing-agreements/<Agreement-Id>/suspend</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieving the Agreement object from Suspend Agreement Sample to demonstrate the List</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Agreement $suspendedAgreement */</span>
|
||||
<span class="hljs-variable">$suspendedAgreement</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'SuspendBillingAgreement.php'</span>;
|
||||
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Agreement</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">AgreementStateDescriptor</span>;
|
||||
|
||||
<span class="hljs-comment">//Create an Agreement State Descriptor, explaining the reason to suspend.</span>
|
||||
<span class="hljs-variable">$agreementStateDescriptor</span> = <span class="hljs-keyword">new</span> AgreementStateDescriptor();
|
||||
<span class="hljs-variable">$agreementStateDescriptor</span>->setNote(<span class="hljs-string">"Reactivating the agreement"</span>);
|
||||
|
||||
<span class="hljs-keyword">try</span> {
|
||||
|
||||
<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> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
<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>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$agreement</span>;</div></div></div></div></body></html>
|
||||
26
sample/doc/billing/SuspendBillingAgreement.html
Normal file
26
sample/doc/billing/SuspendBillingAgreement.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>billing/SuspendBillingAgreement</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="billing/SuspendBillingAgreement"><meta name="groc-project-path" content="billing/SuspendBillingAgreement.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">billing/SuspendBillingAgreement.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="suspend-an-agreement">Suspend an agreement</h1>
|
||||
<p>This sample code demonstrate how you can suspend a billing agreement, as documented here at:
|
||||
<a href="https://developer.paypal.com/webapps/developer/docs/api/#suspend-an-agreement">https://developer.paypal.com/webapps/developer/docs/api/#suspend-an-agreement</a>
|
||||
API used: /v1/payments/billing-agreements/<Agreement-Id>/suspend</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieving the Agreement object from Create Agreement Sample to demonstrate the List</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Agreement $createdAgreement */</span>
|
||||
<span class="hljs-variable">$createdAgreement</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateBillingAgreementWithCreditCard.php'</span>;
|
||||
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Agreement</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">AgreementStateDescriptor</span>;
|
||||
|
||||
<span class="hljs-comment">//Create an Agreement State Descriptor, explaining the reason to suspend.</span>
|
||||
<span class="hljs-variable">$agreementStateDescriptor</span> = <span class="hljs-keyword">new</span> AgreementStateDescriptor();
|
||||
<span class="hljs-variable">$agreementStateDescriptor</span>->setNote(<span class="hljs-string">"Suspending the agreement"</span>);
|
||||
|
||||
<span class="hljs-keyword">try</span> {
|
||||
|
||||
<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> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
<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>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$agreement</span>;</div></div></div></div></body></html>
|
||||
38
sample/doc/billing/UpdateBillingAgreement.html
Normal file
38
sample/doc/billing/UpdateBillingAgreement.html
Normal file
@@ -0,0 +1,38 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>billing/UpdateBillingAgreement</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="billing/UpdateBillingAgreement"><meta name="groc-project-path" content="billing/UpdateBillingAgreement.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">billing/UpdateBillingAgreement.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="update-an-agreement">Update an agreement</h1>
|
||||
<p>This sample code demonstrate how you can update a billing agreement, as documented here at:
|
||||
<a href="https://developer.paypal.com/webapps/developer/docs/api/#update-an-agreement">https://developer.paypal.com/webapps/developer/docs/api/#update-an-agreement</a>
|
||||
API used: /v1/payments/billing-agreements/<Agreement-Id></p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieving the Agreement object from Create Agreement Sample to demonstrate the List</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Agreement $createdAgreement */</span>
|
||||
<span class="hljs-variable">$createdAgreement</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateBillingAgreementWithCreditCard.php'</span>;
|
||||
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Agreement</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">PatchRequest</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Patch</span>;
|
||||
|
||||
<span class="hljs-variable">$patch</span> = <span class="hljs-keyword">new</span> Patch();
|
||||
|
||||
<span class="hljs-variable">$patch</span>->setOp(<span class="hljs-string">'replace'</span>)
|
||||
->setPath(<span class="hljs-string">'/'</span>)
|
||||
->setValue(json_decode(<span class="hljs-string">'{
|
||||
"description": "New Description",
|
||||
"shipping_address": {
|
||||
"line1": "2065 Hamilton Ave",
|
||||
"city": "San Jose",
|
||||
"state": "CA",
|
||||
"postal_code": "95125",
|
||||
"country_code": "US"
|
||||
}
|
||||
}'</span>));
|
||||
<span class="hljs-variable">$patchRequest</span> = <span class="hljs-keyword">new</span> PatchRequest();
|
||||
<span class="hljs-variable">$patchRequest</span>->addPatch(<span class="hljs-variable">$patch</span>);
|
||||
<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> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
<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>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$agreement</span>;</div></div></div></div></body></html>
|
||||
37
sample/doc/billing/UpdatePlan.html
Normal file
37
sample/doc/billing/UpdatePlan.html
Normal file
@@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>billing/UpdatePlan</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="billing/UpdatePlan"><meta name="groc-project-path" content="billing/UpdatePlan.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">billing/UpdatePlan.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="update-a-plan">Update a plan</h1>
|
||||
<p>This sample code demonstrate how you can update a billing plan, as documented here at:
|
||||
<a href="https://developer.paypal.com/webapps/developer/docs/api/#update-a-plan">https://developer.paypal.com/webapps/developer/docs/api/#update-a-plan</a>
|
||||
API used: /v1/payments/billing-plans/<Plan-Id></p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="making-plan-active">Making Plan Active</h3>
|
||||
<p>This example demonstrate how you could activate the Plan.</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieving the Plan object from Create Plan Sample to demonstrate the List</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Plan $createdPlan */</span>
|
||||
<span class="hljs-variable">$createdPlan</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreatePlan.php'</span>;
|
||||
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Plan</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">PatchRequest</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Patch</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Common</span>\<span class="hljs-title">PPModel</span>;
|
||||
<span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$patch</span> = <span class="hljs-keyword">new</span> Patch();
|
||||
|
||||
<span class="hljs-variable">$value</span> = <span class="hljs-keyword">new</span> PPModel(<span class="hljs-string">'{
|
||||
"state":"ACTIVE"
|
||||
}'</span>);
|
||||
|
||||
<span class="hljs-variable">$patch</span>->setOp(<span class="hljs-string">'replace'</span>)
|
||||
->setPath(<span class="hljs-string">'/'</span>)
|
||||
->setValue(<span class="hljs-variable">$value</span>);
|
||||
<span class="hljs-variable">$patchRequest</span> = <span class="hljs-keyword">new</span> PatchRequest();
|
||||
<span class="hljs-variable">$patchRequest</span>->addPatch(<span class="hljs-variable">$patch</span>);
|
||||
|
||||
<span class="hljs-variable">$createdPlan</span>->update(<span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$apiContext</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> (PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
<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>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$plan</span>;</div></div></div></div></body></html>
|
||||
@@ -30,15 +30,4 @@ notification object
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
<span class="hljs-preprocessor">?></span>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Cancel Invoice</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>Cancel Invoice:</div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoice</span>->toJSON(128); <span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
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>
|
||||
@@ -69,7 +69,7 @@ detailed breakdown of invoice</p></div></div><div class="code"><div class="wrapp
|
||||
->setCity(<span class="hljs-string">"Portland"</span>)
|
||||
->setState(<span class="hljs-string">"OR"</span>)
|
||||
->setPostalCode(<span class="hljs-string">"97217"</span>)
|
||||
->setCountryCode(<span class="hljs-string">"US"</span>);
|
||||
->setCountryCode(<span class="hljs-string">"US"</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">$invoice</span>;
|
||||
|
||||
<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
|
||||
@@ -79,17 +79,5 @@ with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)<
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
<span class="hljs-preprocessor">?></span>
|
||||
<html>
|
||||
<head>
|
||||
<title>Invoice Creation</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
Created Invoice:
|
||||
<span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoice</span>->getId(); <span class="hljs-preprocessor">?></span>
|
||||
</div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoice</span>->toJSON(128); <span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Invoice Creation"</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></body></html>
|
||||
@@ -15,14 +15,5 @@ Invoice ID
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
<span class="hljs-preprocessor">?></span>
|
||||
<html>
|
||||
<head>
|
||||
<title>Lookup invoice details</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>Retrieving Invoice: <span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoiceId</span>;<span class="hljs-preprocessor">?></span></div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoice</span>->toJSON(128); <span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
|
||||
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></body></html>
|
||||
@@ -13,14 +13,4 @@ Refer the method doc for valid values for keys
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
<span class="hljs-preprocessor">?></span>
|
||||
<html>
|
||||
<head>
|
||||
<title>Lookup invoice history</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>Got invoices </div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoices</span>->toJSON(128); <span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
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>
|
||||
@@ -29,15 +29,4 @@ notification object
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
<span class="hljs-preprocessor">?></span>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Remind Invoice</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>Remind Invoice:</div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoice</span>->toJSON(128); <span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
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></body></html>
|
||||
@@ -18,14 +18,4 @@ with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)<
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
<span class="hljs-preprocessor">?></span>
|
||||
<html>
|
||||
<head>
|
||||
<title>Send Invoice</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>Send Invoice:</div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$invoice</span>->toJSON(128); <span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
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></body></html>
|
||||
@@ -12,4 +12,4 @@
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
print_result(<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-variable">$tokenInfo</span>);</div></div></div></div></body></html>
|
||||
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>
|
||||
@@ -22,4 +22,4 @@ to retreive the information. The short lived access token can be retrieved using
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
print_result(<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">$userInfo</span>->toJSON(128));</div></div></div></div></body></html>
|
||||
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>
|
||||
@@ -15,4 +15,4 @@
|
||||
<span class="hljs-variable">$apiContext</span>
|
||||
);
|
||||
|
||||
print_result(<span class="hljs-string">"Generated the User Consent URL"</span>, <span class="hljs-string">"URL"</span>, <span class="hljs-keyword">null</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>);</div></div></div></div></body></html>
|
||||
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>
|
||||
@@ -18,6 +18,6 @@ The user would then able to retrieve the access token by getting the code, which
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
print_result(<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">$accessToken</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></body></html>
|
||||
File diff suppressed because one or more lines are too long
@@ -17,4 +17,4 @@ that contains the web profile ID.</p></div></div><div class="code"><div class="w
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
print_result(<span class="hljs-string">"Deleted Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$createProfileResponse</span>->getId());</div></div></div></div></body></html>
|
||||
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>
|
||||
@@ -16,6 +16,6 @@ that contains the web profile ID.</p></div></div><div class="code"><div class="w
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
print_result(<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-variable">$webProfile</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>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$webProfile</span>;</div></div></div></div></body></html>
|
||||
@@ -15,9 +15,9 @@ static <code>get_list</code> method on the WebProfile class.
|
||||
}
|
||||
<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(128) . PHP_EOL;
|
||||
<span class="hljs-variable">$result</span> .= <span class="hljs-variable">$object</span>->toJSON(<span class="hljs-number">128</span>) . PHP_EOL;
|
||||
}
|
||||
|
||||
print_result(<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-variable">$result</span>);
|
||||
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>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$list</span>;</div></div></div></div></body></html>
|
||||
@@ -26,4 +26,4 @@ as shown below</p></div></div><div class="code"><div class="wrapper"><span class
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
print_result(<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">$webProfile</span>);</div></div></div></div></body></html>
|
||||
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>
|
||||
@@ -16,4 +16,4 @@ object</p></div></div><div class="code"><div class="wrapper"> <span class
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
print_result(<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">$updatedWebProfile</span>);</div></div></div></div></body></html>
|
||||
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>
|
||||
@@ -33,7 +33,7 @@ createAuthorization defined in common.php</p></div></div><div class="code"><div
|
||||
Captured payment <span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$getCapture</span>->getParentPayment(); <span class="hljs-preprocessor">?></span>. Capture Id:
|
||||
<span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$getCapture</span>->getId();<span class="hljs-preprocessor">?></span>
|
||||
</div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$getCapture</span>->toJSON(128);<span class="hljs-preprocessor">?></span></pre>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$getCapture</span>->toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
</html></div></div></div></div></body></html>
|
||||
@@ -61,7 +61,7 @@ Please note that currently future payments works only with PayPal as a funding i
|
||||
Created payment:
|
||||
<span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payment</span>->getId();<span class="hljs-preprocessor">?></span>
|
||||
</div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payment</span>->toJSON(128);<span class="hljs-preprocessor">?></span></pre>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payment</span>->toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
</html></div></div></div></div></body></html>
|
||||
@@ -91,7 +91,7 @@ The return object contains the state.</p></div></div><div class="code"><div clas
|
||||
Created payment:
|
||||
<span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payment</span>->getId();<span class="hljs-preprocessor">?></span>
|
||||
</div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payment</span>->toJSON(128);<span class="hljs-preprocessor">?></span></pre>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payment</span>->toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
</html></div></div></div></div></body></html>
|
||||
@@ -9,8 +9,7 @@ API used: /v1/payments/payment</p></div></div><div class="code"><div class="wrap
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Payer</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Payment</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">RedirectUrls</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Transaction</span>;
|
||||
session_start();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="payer">Payer</h3>
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Transaction</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="payer">Payer</h3>
|
||||
<p>A resource representing a Payer that funds a payment
|
||||
For paypal account payments, set payment method
|
||||
to 'paypal'.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$payer</span> = <span class="hljs-keyword">new</span> Payer();
|
||||
@@ -77,14 +76,7 @@ method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-k
|
||||
<span class="hljs-variable">$redirectUrl</span> = <span class="hljs-variable">$link</span>->getHref();
|
||||
<span class="hljs-keyword">break</span>;
|
||||
}
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="redirect-buyer-to-paypal-website">Redirect buyer to PayPal website</h3>
|
||||
<p>Save the payment id so that you can 'complete' the payment
|
||||
once the buyer approves the payment and is redirected
|
||||
back to your website.
|
||||
It is not a great idea to store the payment id
|
||||
in the session. In a real world app, you may want to
|
||||
store the payment id in a database.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$_SESSION</span>[<span class="hljs-string">'paymentId'</span>] = <span class="hljs-variable">$payment</span>->getId();
|
||||
<span class="hljs-keyword">if</span>(<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$redirectUrl</span>)) {
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="redirect-buyer-to-paypal-website">Redirect buyer to PayPal website</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">if</span>(<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$redirectUrl</span>)) {
|
||||
header(<span class="hljs-string">"Location: $redirectUrl"</span>);
|
||||
<span class="hljs-keyword">exit</span>;
|
||||
}</div></div></div></div></body></html>
|
||||
@@ -80,7 +80,7 @@ The return object contains the state.</p></div></div><div class="code"><div clas
|
||||
Created payment:
|
||||
<span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payment</span>->getId();<span class="hljs-preprocessor">?></span>
|
||||
</div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payment</span>->toJSON(128);<span class="hljs-preprocessor">?></span></pre>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payment</span>->toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
</html></div></div></div></div></body></html>
|
||||
@@ -8,26 +8,24 @@ API used: POST '/v1/payments/payment/<payment-id>/execute'.</p></div></d
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">ExecutePayment</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Payment</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">PaymentExecution</span>;
|
||||
session_start();
|
||||
<span class="hljs-keyword">if</span>(<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$_GET</span>[<span class="hljs-string">'success'</span>]) && <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'success'</span>] == <span class="hljs-string">'true'</span>) {
|
||||
</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Get the payment Object by passing paymentId
|
||||
|
||||
<span class="hljs-keyword">if</span> (<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$_GET</span>[<span class="hljs-string">'success'</span>]) && <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'success'</span>] == <span class="hljs-string">'true'</span>) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Get the payment Object by passing paymentId
|
||||
payment id was previously stored in session in
|
||||
CreatePaymentUsingPayPal.php</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$paymentId</span> = <span class="hljs-variable">$_SESSION</span>[<span class="hljs-string">'paymentId'</span>];
|
||||
<span class="hljs-variable">$payment</span> = Payment::get(<span class="hljs-variable">$paymentId</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>PaymentExecution object includes information necessary
|
||||
to execute a PayPal account payment.
|
||||
CreatePaymentUsingPayPal.php</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$paymentId</span> = <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'paymentId'</span>];
|
||||
<span class="hljs-variable">$payment</span> = Payment::get(<span class="hljs-variable">$paymentId</span>, <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>PaymentExecution object includes information necessary
|
||||
to execute a PayPal account payment.
|
||||
The payer_id is added to the request query parameters
|
||||
when the user is redirected from paypal back to your site</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$execution</span> = <span class="hljs-keyword">new</span> PaymentExecution();
|
||||
<span class="hljs-variable">$execution</span>->setPayerId(<span class="hljs-variable">$_GET</span>[<span class="hljs-string">'PayerID'</span>]);
|
||||
|
||||
<span class="hljs-comment">//Execute the payment</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>(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>);
|
||||
when the user is redirected from paypal back to your site</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$execution</span> = <span class="hljs-keyword">new</span> PaymentExecution();
|
||||
<span class="hljs-variable">$execution</span>->setPayerId(<span class="hljs-variable">$_GET</span>[<span class="hljs-string">'PayerID'</span>]);
|
||||
|
||||
<span class="hljs-comment">//Execute the payment</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>(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>);
|
||||
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"<html><body><pre>"</span>;
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-variable">$result</span>->toJSON(128);
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"</pre><a href='../index.html'>Back</a></body></html>"</span>;
|
||||
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-variable">$result</span>->toJSON(<span class="hljs-number">128</span>);
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"</pre><a href='../index.html'>Back</a></body></html>"</span>;
|
||||
|
||||
} <span class="hljs-keyword">else</span> {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"<html><body><h1>"</span>;
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"User cancelled payment."</span>;
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"User cancelled payment."</span>;
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"</h1><a href='../index.html'>Back</a></body></html>"</span>;
|
||||
}</div></div></div></div></body></html>
|
||||
}</div></div></div></div></body></html>
|
||||
@@ -25,7 +25,7 @@ createAuthorization is defined in common.php</p></div></div><div class="code"><d
|
||||
Retrieved Authorization:
|
||||
<span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$authorization</span>->getId();<span class="hljs-preprocessor">?></span>
|
||||
</div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$authorization</span>->toJSON(128);<span class="hljs-preprocessor">?></span></pre>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$authorization</span>->toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
</html></div></div></div></div></body></html>
|
||||
@@ -41,7 +41,7 @@ with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)<
|
||||
Capture Id:
|
||||
<span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$capture</span>->getId();<span class="hljs-preprocessor">?></span>
|
||||
</div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$capture</span>->toJSON(128);<span class="hljs-preprocessor">?></span></pre>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$capture</span>->toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
</html></div></div></div></div></body></html>
|
||||
@@ -27,7 +27,7 @@ Payment ID
|
||||
</head>
|
||||
<body>
|
||||
<div>Retrieving Payment ID: <span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$paymentId</span>;<span class="hljs-preprocessor">?></span></div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payment</span>->toJSON(128);<span class="hljs-preprocessor">?></span></pre>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payment</span>->toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
</html></div></div></div></div></body></html>
|
||||
@@ -26,7 +26,7 @@ Refer the method doc for valid values for keys
|
||||
</head>
|
||||
<body>
|
||||
<div>Got <span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payments</span>->getCount(); <span class="hljs-preprocessor">?></span> matching payments </div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payments</span>->toJSON(128);<span class="hljs-preprocessor">?></span></pre>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$payments</span>->toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
</html></div></div></div></div></body></html>
|
||||
@@ -30,8 +30,8 @@ has expired.</p></div></div><div class="code"><div class="wrapper"><span class="
|
||||
<span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$reauthorization</span>->getId();<span class="hljs-preprocessor">?></span>
|
||||
</div>
|
||||
<pre>
|
||||
<span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$reauthorization</span>->toJSON(128);<span class="hljs-preprocessor">?></span>
|
||||
<span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$reauthorization</span>->toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?></span>
|
||||
</pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
</html></div></div></div></div></body></html>
|
||||
@@ -46,7 +46,7 @@ PayPal-Request-Id (idempotency) header for this resource</p></div></div><div cla
|
||||
</head>
|
||||
<body>
|
||||
<div>Refund Capture:</div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$captureRefund</span>->toJSON(128);<span class="hljs-preprocessor">?></span></pre>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$captureRefund</span>->toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
</html></div></div></div></div></body></html>
|
||||
@@ -22,7 +22,7 @@ createAuthorization is defined in common.php</p></div></div><div class="code"><d
|
||||
<div>
|
||||
Voided authorization
|
||||
</div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$voidedAuth</span>->toJSON(128);<span class="hljs-preprocessor">?></span></pre>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$voidedAuth</span>->toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
</html></div></div></div></div></body></html>
|
||||
@@ -22,7 +22,7 @@ transaction from your payment resource.</p></div></div><div class="code"><div cl
|
||||
</head>
|
||||
<body>
|
||||
<div>Retrieving sale id: <span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$saleId</span>;<span class="hljs-preprocessor">?></span></div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$sale</span>->toJSON(128)<span class="hljs-preprocessor">?></span></pre>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$sale</span>->toJSON(<span class="hljs-number">128</span>)<span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
</html></div></div></div></div></body></html>
|
||||
@@ -32,7 +32,7 @@ given sale transaction id.</p></div></div><div class="code"><div class="wrapper"
|
||||
</head>
|
||||
<body>
|
||||
<div>Refunding sale id: <span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$saleId</span>;<span class="hljs-preprocessor">?></span></div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$sale</span>->toJSON(128);<span class="hljs-preprocessor">?></span></pre>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$sale</span>->toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
</html></div></div></div></div></body></html>
|
||||
@@ -31,7 +31,7 @@ in future payments.
|
||||
</head>
|
||||
<body>
|
||||
<div>Saved a <span class="hljs-keyword">new</span> credit card with id: <span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$card</span>->getId();<span class="hljs-preprocessor">?></span></div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$card</span>->toJSON(128);<span class="hljs-preprocessor">?></span></pre>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$card</span>->toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
</html></div></div></div></div></body></html>
|
||||
@@ -21,7 +21,7 @@ card operation. Use $card->getId()</p></div></div><div class="code"><div clas
|
||||
</head>
|
||||
<body>
|
||||
<div>Retrieving saved credit card: <span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$cardId</span>;<span class="hljs-preprocessor">?></span></div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$card</span>->toJSON(128);<span class="hljs-preprocessor">?></span></pre>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$card</span>->toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
</html></div></div></div></div></body></html>
|
||||
Reference in New Issue
Block a user