forked from LiveCarta/PayPal-PHP-SDK
More Vault API Samples
- Updated Samples for Vault APIs - Updated Payment Execute to be more verbose - Delete Plan Sample Update - Fixes #168
This commit is contained in:
@@ -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": {
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}, {
|
||||
@@ -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": {
|
||||
@@ -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": {
|
||||
@@ -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": {
|
||||
|
||||
@@ -9,10 +9,10 @@ API used: /v1/payments/billing-plans</p></div></div></div><div class="segment"><
|
||||
<span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$result</span> = <span class="hljs-variable">$createdPlan</span>->delete(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Deleted a Plan"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-variable">$plan</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
ResultPrinter::printError(<span class="hljs-string">"Deleted a Plan"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-variable">$createdPlan</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Deleted a Plan"</span>, <span class="hljs-string">"Plan"</span>, <span class="hljs-variable">$plan</span>->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>->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>
|
||||
@@ -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"><?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>) {
|
||||
<!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></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>]) && <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">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h2 id="execute-agreement">Execute Agreement</h2>
|
||||
<p>Execute the agreement by passing in the token</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$agreement</span>->execute(<span class="hljs-variable">$token</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Executed an Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'token'</span>], <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
|
||||
@@ -7,7 +7,7 @@ API used: /v1/payments/billing-agreements/<Agreement-Id></p></div></div></div><d
|
||||
<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>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Retrieved an Agreement"</span>, <span class="hljs-string">"Agreement"</span>, <span class="hljs-variable">$agreement</span>->getId(), <span class="hljs-variable">$createdAgreement</span>->getId(), <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
|
||||
@@ -1,24 +1,26 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>payments/ExecutePayment</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="payments/ExecutePayment"><meta name="groc-project-path" content="payments/ExecutePayment.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">payments/ExecutePayment.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="execute-payment-sample">Execute Payment Sample</h1>
|
||||
<p>This sample shows how you can complete
|
||||
a payment that has been approved by
|
||||
<p>This is the second step required to complete
|
||||
PayPal checkout. Once user completes the payment, paypal
|
||||
redirects the browser to "redirectUrl" provided in the request.
|
||||
This sample will show you how to execute the payment
|
||||
that has been approved by
|
||||
the buyer by logging into paypal site.
|
||||
You can optionally update transaction
|
||||
information by passing in one or more transactions.
|
||||
API used: POST '/v1/payments/payment/<payment-id>/execute'.</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">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>;
|
||||
|
||||
<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">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">PaymentExecution</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="approval-status">Approval Status</h3>
|
||||
<p>Determine if the user approved the payment or not</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>]) && <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">$_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
|
||||
<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"><h3 id="payment-execute">Payment Execute</h3>
|
||||
<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>);
|
||||
<span class="hljs-variable">$execution</span>->setPayerId(<span class="hljs-variable">$_GET</span>[<span class="hljs-string">'PayerID'</span>]);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Execute the payment
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$result</span> = <span class="hljs-variable">$payment</span>->execute(<span class="hljs-variable">$execution</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Executed Payment"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-variable">$payment</span>->getId(), <span class="hljs-variable">$execution</span>, <span class="hljs-variable">$result</span>);
|
||||
|
||||
|
||||
68
sample/doc/vault/CreateBankAccount.html
Normal file
68
sample/doc/vault/CreateBankAccount.html
Normal file
@@ -0,0 +1,68 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>vault/CreateBankAccount</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="vault/CreateBankAccount"><meta name="groc-project-path" content="vault/CreateBankAccount.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">vault/CreateBankAccount.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-bank-account-sample">Create Bank Account Sample</h1>
|
||||
<p>You can store credit card details securely
|
||||
with PayPal. You can then use the returned
|
||||
Bank Account id to process future payments.
|
||||
API used: POST /v1/vault/bank-accounts</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">BankAccount</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="bank-account">Bank Account</h3>
|
||||
<p>A resource representing a bank account that is
|
||||
to be stored with PayPal.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/*
|
||||
{
|
||||
"account_number": "4417119669820331",
|
||||
"account_number_type": "IBAN",
|
||||
"account_type": "SAVINGS",
|
||||
"account_name": "Ramraj",
|
||||
"check_type": "PERSONAL",
|
||||
"auth_type": "WEB",
|
||||
"bank_name": "CITI",
|
||||
"country_code": "US",
|
||||
"first_name": "Ramraj",
|
||||
"last_name": "K",
|
||||
"birth_date": "1987-08-13",
|
||||
"billing_address": {
|
||||
"line1": "52 N Main ST",
|
||||
"city": "Johnstown",
|
||||
"country_code": "US",
|
||||
"postal_code": "43210",
|
||||
"state": "OH",
|
||||
"phone": "408-334-8890"
|
||||
},
|
||||
"external_customer_id": "external_id"
|
||||
}
|
||||
*/</span>
|
||||
<span class="hljs-variable">$bankAccount</span> = <span class="hljs-keyword">new</span> BankAccount();
|
||||
<span class="hljs-variable">$bankAccount</span>->setAccountNumber(<span class="hljs-string">"4417119669820331"</span>)
|
||||
->setAccountNumberType(<span class="hljs-string">"IBAN"</span>)
|
||||
->setAccountType(<span class="hljs-string">"SAVINGS"</span>)
|
||||
->setAccountName(<span class="hljs-string">"Ramraj"</span>)
|
||||
->setCheckType(<span class="hljs-string">"PERSONAL"</span>)
|
||||
->setAuthType(<span class="hljs-string">"WEB"</span>)
|
||||
->setBankName(<span class="hljs-string">"CITI"</span>)
|
||||
->setCountryCode(<span class="hljs-string">"US"</span>)
|
||||
->setFirstName(<span class="hljs-string">"Ramraj"</span>)
|
||||
->setLastName(<span class="hljs-string">"K"</span>)
|
||||
->setBirthDate(<span class="hljs-string">"1987-08-13"</span>)
|
||||
->setExternalCustomerId(uniqid());
|
||||
|
||||
<span class="hljs-variable">$billingAddress</span> = <span class="hljs-keyword">new</span> \PayPal\Api\Address();
|
||||
<span class="hljs-variable">$billingAddress</span>->setLine1(<span class="hljs-string">"52 N Main St"</span>)
|
||||
->setCity(<span class="hljs-string">"Johnstown"</span>)
|
||||
->setState(<span class="hljs-string">"OH"</span>)
|
||||
->setCountryCode(<span class="hljs-string">"US"</span>)
|
||||
->setPostalCode(<span class="hljs-string">"43210"</span>)
|
||||
->setPhone(<span class="hljs-string">"408-334-8890"</span>);
|
||||
|
||||
<span class="hljs-variable">$bankAccount</span>->setBillingAddress(<span class="hljs-variable">$billingAddress</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">$bankAccount</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="save-bank-account">Save bank account</h3>
|
||||
<p>Creates the bank account as a resource
|
||||
in the PayPal vault. The response contains
|
||||
an 'id' that you can use to refer to it
|
||||
in future payments.
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
|
||||
<span class="hljs-variable">$bankAccount</span>->create(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Create Bank Account"</span>, <span class="hljs-string">"Bank Account"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Create Bank Account"</span>, <span class="hljs-string">"Bank Account"</span>, <span class="hljs-variable">$bankAccount</span>->getId(), <span class="hljs-variable">$request</span>, <span class="hljs-variable">$bankAccount</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$bankAccount</span>;</div></div></div></div></body></html>
|
||||
16
sample/doc/vault/DeleteBankAccount.html
Normal file
16
sample/doc/vault/DeleteBankAccount.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>vault/DeleteBankAccount</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="vault/DeleteBankAccount"><meta name="groc-project-path" content="vault/DeleteBankAccount.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">vault/DeleteBankAccount.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="delete-bank-account-sample">Delete Bank Account Sample</h1>
|
||||
<p>This sample code demonstrate how you can
|
||||
delete a saved bank account
|
||||
API used: /v1/vault/bank-accounts/{<bankAccountId>}
|
||||
NOTE: HTTP method used here is DELETE</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> \PayPal\Api\BankAccount $card */</span>
|
||||
<span class="hljs-variable">$bankAccount</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateBankAccount.php'</span>;
|
||||
|
||||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="delete-card">Delete Card</h3>
|
||||
<p>Lookup and delete a saved credit card.
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$bankAccount</span>->delete(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Delete Bank Account"</span>, <span class="hljs-string">"Bank Account"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Delete Bank Account"</span>, <span class="hljs-string">"Bank Account"</span>, <span class="hljs-variable">$bankAccount</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>);</div></div></div></div></body></html>
|
||||
@@ -8,12 +8,10 @@ NOTE: HTTP method used here is DELETE</p></div></div><div class="code"><div clas
|
||||
|
||||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="delete-card">Delete Card</h3>
|
||||
<p>Lookup and delete a saved credit card.
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$creditCard</span> = CreditCard::get(<span class="hljs-variable">$card</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
|
||||
<span class="hljs-variable">$creditCard</span>->delete(<span class="hljs-variable">$apiContext</span>);
|
||||
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$card</span>->delete(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Delete Credit Card"</span>, <span class="hljs-string">"Credit Card"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Delete Credit Card"</span>, <span class="hljs-string">"Credit Card"</span>, <span class="hljs-variable">$card</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$creditCard</span>);</div></div></div></div></body></html>
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Delete Credit Card"</span>, <span class="hljs-string">"Credit Card"</span>, <span class="hljs-variable">$card</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>);</div></div></div></div></body></html>
|
||||
17
sample/doc/vault/GetBankAccount.html
Normal file
17
sample/doc/vault/GetBankAccount.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>vault/GetBankAccount</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="vault/GetBankAccount"><meta name="groc-project-path" content="vault/GetBankAccount.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">vault/GetBankAccount.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-bank-account-sample">Get Bank Account Sample</h1>
|
||||
<p>The Bank Account resource allows you to
|
||||
retrieve previously saved Bank Accounts.
|
||||
API called: '/v1/vault/bank-accounts'</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>The following code takes you through
|
||||
the process of retrieving a saved Bank Account</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> \PayPal\Api\BankAccount $bankAccount */</span>
|
||||
<span class="hljs-variable">$bankAccount</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateBankAccount.php'</span>;
|
||||
|
||||
<span class="hljs-comment">/// ### Retrieve Bank Account</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-keyword">try</span> {
|
||||
<span class="hljs-variable">$bankAccount</span> = \PayPal\Api\BankAccount::get(<span class="hljs-variable">$bankAccount</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Get Bank Account"</span>, <span class="hljs-string">"Bank Account"</span>, <span class="hljs-variable">$bankAccount</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get Bank Account"</span>, <span class="hljs-string">"Bank Account"</span>, <span class="hljs-variable">$bankAccount</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$bankAccount</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$bankAccount</span>;</div></div></div></div></body></html>
|
||||
@@ -5,6 +5,7 @@ API called: '/v1/vault/credit-card'
|
||||
The following code takes you through
|
||||
the process of retrieving a saved CreditCard</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> CreditCard $card */</span>
|
||||
<span class="hljs-variable">$card</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateCreditCard.php'</span>;
|
||||
<span class="hljs-variable">$id</span> = <span class="hljs-variable">$card</span>->getId();
|
||||
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">CreditCard</span>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user