Merge commit '9d5d0beb57227cc31f1072ad37ddea57f6ea71b7'

Conflicts:
	sample/payments/ExecutePayment.php
This commit is contained in:
Gerd Katzenbeisser
2014-09-12 15:02:22 +02:00
81 changed files with 11950 additions and 3497 deletions

View File

@@ -2,7 +2,7 @@ Rest API Samples
===================
This sample project is a simple web app that you can explore to understand what the payment APIs can do for you. To try out the sample, run `composer update --no-dev` from the samples folder and you are all set. In case you cannot install composer on your machine, you can fetch the SDK download bundle from https://github.com/paypal/sdk-packages/raw/gh-pages/rest-api-sdk/php/rest-api-sdk-php-0.7.1.zip and unzip the contents to the samples folder.
This sample project is a simple web app that you can explore to understand what the payment APIs can do for you. To try out the sample, run `composer update --no-dev` from the samples folder and you are all set.
The sample comes pre-configured with a test account but in case you need to try them against your account, you must

View File

@@ -9,6 +9,6 @@
"php": ">=5.3.0",
"ext-curl": "*",
"ext-json": "*",
"paypal/rest-api-sdk-php" : "0.7.*"
"paypal/rest-api-sdk-php" : "0.8.*"
}
}

View File

@@ -0,0 +1,37 @@
<?php
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Invoice;
use PayPal\Api\CancelNotification;
try {
$invoice = Invoice::get("INV2-CJL7-PF4G-BLQF-5FWG", $apiContext);
$notify = new CancelNotification();
$notify
->setSubject("Past due")
->setNote("Canceling invoice")
->setSendToMerchant(true)
->setSendToPayer(true);
$cancelStatus = $invoice->cancel($notify, $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
?>
<html>
<head>
<title>Cancel Invoice</title>
</head>
<body>
<div>Cancel Invoice:</div>
<pre><?php var_dump($invoice);?></pre>
<a href='../index.html'>Back</a>
</body>
</html>

View File

@@ -0,0 +1,100 @@
<?php
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Invoice;
use PayPal\Api\MerchantInfo;
use PayPal\Api\BillingInfo;
use PayPal\Api\InvoiceItem;
use PayPal\Api\Phone;
use PayPal\Api\Address;
use PayPal\Api\Currency;
use PayPal\Api\PaymentTerm;
use PayPal\Api\ShippingInfo;
$invoice = new Invoice();
$invoice
->setMerchantInfo(new MerchantInfo())
->setBillingInfo(array(new BillingInfo()))
->setItems(array(new InvoiceItem()))
->setNote("Medical Invoice 16 Jul, 2013 PST")
->setPaymentTerm(new PaymentTerm())
->setShippingInfo(new ShippingInfo());
$invoice->getMerchantInfo()
->setEmail("PPX.DevNet-facilitator@gmail.com")
->setFirstName("Dennis")
->setLastName("Doctor")
->setbusinessName("Medical Professionals, LLC")
->setPhone(new Phone())
->setAddress(new Address());
$invoice->getMerchantInfo()->getPhone()
->setCountryCode("001")
->setNationalNumber("5032141716");
$invoice->getMerchantInfo()->getAddress()
->setLine1("1234 Main St.")
->setCity("Portland")
->setState("OR")
->setPostalCode("97217")
->setCountryCode("US");
$billing = $invoice->getBillingInfo();
$billing[0]
->setEmail("example@example.com");
$items = $invoice->getItems();
$items[0]
->setName("Sutures")
->setQuantity(100)
->setUnitPrice(new Currency());
$items[0]->getUnitPrice()
->setCurrency("USD")
->setValue(5);
$invoice->getPaymentTerm()
->setTermType("NET_45");
$invoice->getShippingInfo()
->setFirstName("Sally")
->setLastName("Patient")
->setBusinessName("Not applicable")
->setPhone(new Phone())
->setAddress(new Address());
$invoice->getShippingInfo()->getPhone()
->setCountryCode("001")
->setNationalNumber("5039871234");
$invoice->getShippingInfo()->getAddress()
->setLine1("1234 Main St.")
->setCity("Portland")
->setState("OR")
->setPostalCode("97217")
->setCountryCode("US");
print(var_dump($invoice->toArray()));
try {
$invoice->create($apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
?>
<html>
<head>
<title>Direct Credit card payments</title>
</head>
<body>
<div>
Created Invoice:
<?php echo $invoice->getId();?>
</div>
<pre><?php var_dump($invoice->toArray());?></pre>
<a href='../index.html'>Back</a>
</body>
</html>

View File

@@ -0,0 +1,19 @@
<?php
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Invoice;
$invoiceId = "INV2-9DRB-YTHU-2V9Q-7Q24";
$invoice = Invoice::get($invoiceId, $apiContext);
?>
<html>
<head>
<title>Lookup invoice details</title>
</head>
<body>
<div>Retrieving Invoice: <?php echo $invoiceId;?></div>
<pre><?php var_dump($invoice);?></pre>
<a href='../index.html'>Back</a>
</body>
</html>

View File

@@ -0,0 +1,22 @@
<?php
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Invoice;
try {
$invoices = Invoice::get_all($apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception:" . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
?>
<html>
<head>
<title>Lookup invoice history</title>
</head>
<body>
<div>Got invoices </div>
<pre><?php var_dump($invoices->toArray());?></pre>
<a href='../index.html'>Back</a>
</body>
</html>

View File

@@ -0,0 +1,35 @@
<?php
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Invoice;
use PayPal\Api\Notification;
try {
$invoice = Invoice::get("INV2-9CAH-K5G7-2JPL-G4B4", $apiContext);
$notify = new Notification();
$notify
->setSubject("Past due")
->setNote("Please pay soon")
->setSendToMerchant(true);
$remindStatus = $invoice->remind($notify, $apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
?>
<html>
<head>
<title>Remind Invoice</title>
</head>
<body>
<div>Remind Invoice:</div>
<pre><?php var_dump($invoice);?></pre>
<a href='../index.html'>Back</a>
</body>
</html>

View File

@@ -0,0 +1,27 @@
<?php
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Invoice;
try {
$invoice = Invoice::get("INV2-9DRB-YTHU-2V9Q-7Q24", $apiContext);
$sendStatus = $invoice->send($apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
?>
<html>
<head>
<title>Send Invoice</title>
</head>
<body>
<div>Send Invoice:</div>
<pre><?php var_dump($invoice);?></pre>
<a href='../index.html'>Back</a>
</body>
</html>

View File

@@ -29,10 +29,10 @@ if(isset($_GET['success']) && $_GET['success'] == 'true') {
//Execute the payment
// (See bootstrap.php for more on `ApiContext`)
$response = $payment->execute($execution, $apiContext);
$result = $payment->execute($execution, $apiContext);
echo "<html><body><pre>";
var_dump($response->toArray());
var_dump($result);
echo "</pre><a href='../index.html'>Back</a></body></html>";
} else {