Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Commit

Permalink
More Vault API Samples
Browse files Browse the repository at this point in the history
- Updated Samples for Vault APIs
- Updated Payment Execute to be more verbose
- Delete Plan Sample Update
- Fixes #168
  • Loading branch information
japatel committed Dec 1, 2014
1 parent ff5588b commit 6cf15ab
Show file tree
Hide file tree
Showing 22 changed files with 523 additions and 56 deletions.
Empty file.
2 changes: 1 addition & 1 deletion lib/PayPal/Core/PPConstants.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PPConstants
{

const SDK_NAME = 'PayPal-PHP-SDK';
const SDK_VERSION = '0.15.0';
const SDK_VERSION = '0.15.1';

const REST_SANDBOX_ENDPOINT = "https://api.sandbox.paypal.com/";
const OPENID_REDIRECT_SANDBOX_URL = "https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect";
Expand Down
5 changes: 5 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
PayPal PHP SDK release notes
============================
v0.15.1
----
* Enabled Deleting Billing Plans
* Updated Samples

v0.15.0
----
* Extended Invoicing Capabilities
Expand Down
6 changes: 3 additions & 3 deletions sample/billing/DeletePlan.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
try {
$result = $createdPlan->delete($apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Deleted a Plan", "Plan", $plan->getId(), null, $ex);
ResultPrinter::printError("Deleted a Plan", "Plan", $createdPlan->getId(), null, $ex);
exit(1);
}

ResultPrinter::printResult("Deleted a Plan", "Plan", $plan->getId(), null, null);
ResultPrinter::printResult("Deleted a Plan", "Plan", $createdPlan->getId(), null, null);

return $plan;
return $createdPlan;
11 changes: 8 additions & 3 deletions sample/billing/ExecuteAgreement.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
<?php

// #Execute Agreement
// This is the second part of CreateAgreement Sample.
// Use this call to execute an agreement after the buyer approves it
require __DIR__ . '/../bootstrap.php';
session_start();

// ## Approval Status
// Determine if the user accepted or denied the request
if (isset($_GET['success']) && $_GET['success'] == 'true') {

$token = $_GET['token'];

$agreement = new \PayPal\Api\Agreement();

try {
// ## Execute Agreement
// Execute the agreement by passing in the token
$agreement->execute($token, $apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Executed an Agreement", "Agreement", $agreement->getId(), $_GET['token'], $ex);
Expand Down
169 changes: 167 additions & 2 deletions sample/doc/assets/behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,36 @@ 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
"title": "ExecuteAgreement"
},
"depth": 2,
"outline": []
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Execute Agreement",
"slug": "execute-agreement"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 2,
"title": "Approval Status",
"slug": "approval-status"
},
"depth": 2
}, {
"type": "heading",
"data": {
"level": 2,
"title": "Execute Agreement",
"slug": "execute-agreement"
},
"depth": 2
}
]
}
]
}, {
"type": "file",
"data": {
Expand Down Expand Up @@ -1914,7 +1943,26 @@ 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
"title": "Execute Payment Sample",
"slug": "execute-payment-sample"
},
"depth": 1
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "Approval Status",
"slug": "approval-status"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Payment Execute",
"slug": "payment-execute"
},
"depth": 3
}
]
}
]
}, {
Expand Down Expand Up @@ -2330,6 +2378,54 @@ 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
"depth": 1,
"children": [
{
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/PayPal-PHP-SDK/sample/vault/CreateBankAccount.php",
"projectPath": "vault/CreateBankAccount.php",
"targetPath": "vault/CreateBankAccount",
"pageTitle": "vault/CreateBankAccount",
"title": "CreateBankAccount"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Create Bank Account Sample",
"slug": "create-bank-account-sample"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "Bank Account",
"slug": "bank-account"
},
"depth": 3
}, {
"type": "heading",
"data": {
"level": 3,
"title": "Save bank account",
"slug": "save-bank-account"
},
"depth": 3
}
]
}
]
}, {
"type": "file",
"data": {
"language": {
Expand Down Expand Up @@ -2377,6 +2473,46 @@ 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
]
}
]
}, {
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/PayPal-PHP-SDK/sample/vault/DeleteBankAccount.php",
"projectPath": "vault/DeleteBankAccount.php",
"targetPath": "vault/DeleteBankAccount",
"pageTitle": "vault/DeleteBankAccount",
"title": "DeleteBankAccount"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Delete Bank Account Sample",
"slug": "delete-bank-account-sample"
},
"depth": 1,
"children": [
{
"type": "heading",
"data": {
"level": 3,
"title": "Delete Card",
"slug": "delete-card"
},
"depth": 3
}
]
}
]
}, {
"type": "file",
"data": {
Expand Down Expand Up @@ -2417,6 +2553,35 @@ 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
]
}
]
}, {
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/PayPal-PHP-SDK/sample/vault/GetBankAccount.php",
"projectPath": "vault/GetBankAccount.php",
"targetPath": "vault/GetBankAccount",
"pageTitle": "vault/GetBankAccount",
"title": "GetBankAccount"
},
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
"title": "Get Bank Account Sample",
"slug": "get-bank-account-sample"
},
"depth": 1
}
]
}, {
"type": "file",
"data": {
Expand Down
6 changes: 3 additions & 3 deletions sample/doc/billing/DeletePlan.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<span class="hljs-keyword">try</span> {
<span class="hljs-variable">$result</span> = <span class="hljs-variable">$createdPlan</span>-&gt;delete(<span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
ResultPrinter::printError(<span class="hljs-string">"Deleted a Plan"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-variable">$plan</span>-&gt;getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
ResultPrinter::printError(<span class="hljs-string">"Deleted a Plan"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-variable">$createdPlan</span>-&gt;getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}

ResultPrinter::printResult(<span class="hljs-string">"Deleted a Plan"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-variable">$plan</span>-&gt;getId(), <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>);
ResultPrinter::printResult(<span class="hljs-string">"Deleted a Plan"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-variable">$createdPlan</span>-&gt;getId(), <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>);

<span class="hljs-keyword">return</span> <span class="hljs-variable">$plan</span>;</div></div></div></div></body></html>
<span class="hljs-keyword">return</span> <span class="hljs-variable">$createdPlan</span>;</div></div></div></div></body></html>
15 changes: 6 additions & 9 deletions sample/doc/billing/ExecuteAgreement.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
<!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">&lt;?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>]) &amp;&amp; <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'success'</span>] == <span class="hljs-string">'true'</span>) {
<!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">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="execute-agreement">Execute Agreement</h1>
<p>This is the second part of CreateAgreement Sample.
Use this call to execute an agreement after the buyer approves it</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>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h2 id="approval-status">Approval Status</h2>
<p>Determine if the user accepted or denied the request</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">if</span> (<span class="hljs-keyword">isset</span>(<span class="hljs-variable">$_GET</span>[<span class="hljs-string">'success'</span>]) &amp;&amp; <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>-&gt;execute(<span class="hljs-variable">$token</span>, <span class="hljs-variable">$apiContext</span>);
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h2 id="execute-agreement">Execute Agreement</h2>
<p>Execute the agreement by passing in the token</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$agreement</span>-&gt;execute(<span class="hljs-variable">$token</span>, <span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
ResultPrinter::printError(<span class="hljs-string">"Executed an Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>-&gt;getId(), <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'token'</span>], <span class="hljs-variable">$ex</span>);
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
Expand Down
2 changes: 1 addition & 1 deletion sample/doc/billing/GetBillingAgreement.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<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-string">'I-NH3BT1XF0G93'</span>, <span class="hljs-variable">$apiContext</span>);
<span class="hljs-variable">$agreement</span> = Agreement::get(<span class="hljs-variable">$createdAgreement</span>-&gt;getId(), <span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
ResultPrinter::printError(<span class="hljs-string">"Retrieved an Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>-&gt;getId(), <span class="hljs-variable">$createdAgreement</span>-&gt;getId(), <span class="hljs-variable">$ex</span>);
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
Expand Down
Loading

0 comments on commit 6cf15ab

Please sign in to comment.