From 47cd78172ce9207c4cf3c75af9895da867a01321 Mon Sep 17 00:00:00 2001
From: japatel
Date: Wed, 4 Feb 2015 15:54:30 -0600
Subject: [PATCH] Order API Support
- Added Order API Support
- Updated Sample Code to demonstrate
- Updated Sample Docs
- Fixes #237
---
lib/PayPal/Api/Order.php | 293 +++---
sample/doc/assets/behavior.js | 831 ++++++++++++++----
.../CreateBillingAgreementWithPayPal.html | 2 +-
sample/doc/payments/ExecutePayment.html | 19 +-
sample/doc/payments/OrderAuthorize.html | 37 +
sample/doc/payments/OrderCapture.html | 37 +
.../payments/OrderCreateForAuthorization.html | 77 ++
.../doc/payments/OrderCreateForCapture.html | 77 ++
sample/doc/payments/OrderCreateForVoid.html | 77 ++
.../doc/payments/OrderCreateUsingPayPal.html | 77 ++
sample/doc/payments/OrderDoVoid.html | 29 +
sample/doc/payments/OrderGet.html | 26 +
sample/index.php | 125 +++
sample/payments/ExecutePayment.php | 22 +-
sample/payments/OrderAuthorize.php | 51 ++
sample/payments/OrderCapture.php | 51 ++
.../payments/OrderCreateForAuthorization.php | 112 +++
sample/payments/OrderCreateForCapture.php | 112 +++
sample/payments/OrderCreateForVoid.php | 112 +++
sample/payments/OrderCreateUsingPayPal.php | 112 +++
sample/payments/OrderDoVoid.php | 40 +
sample/payments/OrderGet.php | 32 +
22 files changed, 2045 insertions(+), 306 deletions(-)
create mode 100644 sample/doc/payments/OrderAuthorize.html
create mode 100644 sample/doc/payments/OrderCapture.html
create mode 100644 sample/doc/payments/OrderCreateForAuthorization.html
create mode 100644 sample/doc/payments/OrderCreateForCapture.html
create mode 100644 sample/doc/payments/OrderCreateForVoid.html
create mode 100644 sample/doc/payments/OrderCreateUsingPayPal.html
create mode 100644 sample/doc/payments/OrderDoVoid.html
create mode 100644 sample/doc/payments/OrderGet.html
create mode 100644 sample/payments/OrderAuthorize.php
create mode 100644 sample/payments/OrderCapture.php
create mode 100644 sample/payments/OrderCreateForAuthorization.php
create mode 100644 sample/payments/OrderCreateForCapture.php
create mode 100644 sample/payments/OrderCreateForVoid.php
create mode 100644 sample/payments/OrderCreateUsingPayPal.php
create mode 100644 sample/payments/OrderDoVoid.php
create mode 100644 sample/payments/OrderGet.php
diff --git a/lib/PayPal/Api/Order.php b/lib/PayPal/Api/Order.php
index 9db965b..54761f8 100644
--- a/lib/PayPal/Api/Order.php
+++ b/lib/PayPal/Api/Order.php
@@ -2,8 +2,10 @@
namespace PayPal\Api;
-use PayPal\Common\PayPalModel;
+use PayPal\Common\PayPalResourceModel;
use PayPal\Rest\ApiContext;
+use PayPal\Transport\PayPalRestCall;
+use PayPal\Validation\ArgumentValidator;
/**
* Class Order
@@ -14,21 +16,20 @@ use PayPal\Rest\ApiContext;
*
* @property string id
* @property string purchase_unit_reference_id
- * @property string create_time
- * @property string update_time
* @property \PayPal\Api\Amount amount
- * @property string payment_mode
* @property string state
* @property string reason_code
+ * @property string pending_reason
* @property string protection_eligibility
* @property string protection_eligibility_type
- * @property \PayPal\Api\Links links
+ * @property string parent_payment
+ * @property string create_time
+ * @property string update_time
*/
-class Order extends PayPalModel
+class Order extends PayPalResourceModel
{
/**
* Identifier of the order transaction.
- *
*
* @param string $id
*
@@ -51,8 +52,7 @@ class Order extends PayPalModel
}
/**
- * Identifier to the purchase unit associated with this object
- *
+ * Identifier to the purchase unit associated with this object. Obsolete. Use one in cart_base.
*
* @param string $purchase_unit_reference_id
*
@@ -65,7 +65,7 @@ class Order extends PayPalModel
}
/**
- * Identifier to the purchase unit associated with this object
+ * Identifier to the purchase unit associated with this object. Obsolete. Use one in cart_base.
*
* @return string
*/
@@ -74,57 +74,8 @@ class Order extends PayPalModel
return $this->purchase_unit_reference_id;
}
- /**
- * Time the resource was created in UTC ISO8601 format.
- *
- *
- * @param string $create_time
- *
- * @return $this
- */
- public function setCreateTime($create_time)
- {
- $this->create_time = $create_time;
- return $this;
- }
-
- /**
- * Time the resource was created in UTC ISO8601 format.
- *
- * @return string
- */
- public function getCreateTime()
- {
- return $this->create_time;
- }
-
- /**
- * Time the resource was last updated in UTC ISO8601 format.
- *
- *
- * @param string $update_time
- *
- * @return $this
- */
- public function setUpdateTime($update_time)
- {
- $this->update_time = $update_time;
- return $this;
- }
-
- /**
- * Time the resource was last updated in UTC ISO8601 format.
- *
- * @return string
- */
- public function getUpdateTime()
- {
- return $this->update_time;
- }
-
/**
* Amount being collected.
- *
*
* @param \PayPal\Api\Amount $amount
*
@@ -146,33 +97,10 @@ class Order extends PayPalModel
return $this->amount;
}
- /**
- * specifies payment mode of the transaction
- * Valid Values: ["INSTANT_TRANSFER", "MANUAL_BANK_TRANSFER", "DELAYED_TRANSFER", "ECHECK"]
- *
- * @param string $payment_mode
- *
- * @return $this
- */
- public function setPaymentMode($payment_mode)
- {
- $this->payment_mode = $payment_mode;
- return $this;
- }
-
- /**
- * specifies payment mode of the transaction
- *
- * @return string
- */
- public function getPaymentMode()
- {
- return $this->payment_mode;
- }
/**
* State of the order transaction.
- * Valid Values: ["PENDING", "COMPLETED", "REFUNDED", "PARTIALLY_REFUNDED"]
+ * Valid Values: ["pending", "completed", "refunded", "partially_refunded"]
*
* @param string $state
*
@@ -195,8 +123,8 @@ class Order extends PayPalModel
}
/**
- * Reason code for the transaction state being Pending or Reversed.
- * Valid Values: ["CHARGEBACK", "GUARANTEE", "BUYER_COMPLAINT", "REFUND", "UNCONFIRMED_SHIPPING_ADDRESS", "ECHECK", "INTERNATIONAL_WITHDRAWAL", "RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION", "PAYMENT_REVIEW", "REGULATORY_REVIEW", "UNILATERAL", "VERIFICATION_REQUIRED"]
+ * Reason code for the transaction state being Pending or Reversed. This field will replace pending_reason field eventually
+ * Valid Values: ["PAYER_SHIPPING_UNCONFIRMED", "MULTI_CURRENCY", "RISK_REVIEW", "REGULATORY_REVIEW", "VERIFICATION_REQUIRED", "ORDER", "OTHER"]
*
* @param string $reason_code
*
@@ -209,7 +137,7 @@ class Order extends PayPalModel
}
/**
- * Reason code for the transaction state being Pending or Reversed.
+ * Reason code for the transaction state being Pending or Reversed. This field will replace pending_reason field eventually
*
* @return string
*/
@@ -218,9 +146,33 @@ class Order extends PayPalModel
return $this->reason_code;
}
+ /**
+ * Reason code for the transaction state being Pending. Obsolete. Retained for backward compatability. Use reason_code field above instead.
+ * Valid Values: ["payer_shipping_unconfirmed", "multi_currency", "risk_review", "regulatory_review", "verification_required", "order", "other"]
+ *
+ * @param string $pending_reason
+ *
+ * @return $this
+ */
+ public function setPendingReason($pending_reason)
+ {
+ $this->pending_reason = $pending_reason;
+ return $this;
+ }
+
+ /**
+ * Reason code for the transaction state being Pending. Obsolete. Retained for backward compatability. Use reason_code field above instead.
+ *
+ * @return string
+ */
+ public function getPendingReason()
+ {
+ return $this->pending_reason;
+ }
+
/**
* Protection Eligibility of the Payer
- * Valid Values: ["ELIGIBLE", "PARTIALLY_ELIGIBLE", "INELIGIBLE"]
+ * Valid Values: ["ELIGIBLE", "PARTIALLY_ELIGIBLE", "INELIGIBLE"]
*
* @param string $protection_eligibility
*
@@ -244,7 +196,7 @@ class Order extends PayPalModel
/**
* Protection Eligibility Type of the Payer
- * Valid Values: ["ELIGIBLE", "ITEM_NOT_RECEIVED_ELIGIBLE", "INELIGIBLE", "UNAUTHORIZED_PAYMENT_ELIGIBLE"]
+ * Valid Values: ["ELIGIBLE", "ITEM_NOT_RECEIVED_ELIGIBLE", "INELIGIBLE", "UNAUTHORIZED_PAYMENT_ELIGIBLE"]
*
* @param string $protection_eligibility_type
*
@@ -267,27 +219,172 @@ class Order extends PayPalModel
}
/**
- * Sets Links
- *
+ * ID of the Payment resource that this transaction is based on.
*
- * @param \PayPal\Api\Links $links
- *
+ * @param string $parent_payment
* @return $this
*/
- public function setLinks($links)
+ public function setParentPayment($parent_payment)
{
- $this->links = $links;
+ $this->parent_payment = $parent_payment;
return $this;
}
/**
- * Gets Links
+ * ID of the Payment resource that this transaction is based on.
*
- * @return \PayPal\Api\Links[]
+ * @return string
*/
- public function getLinks()
+ public function getParentPayment()
{
- return $this->links;
+ return $this->parent_payment;
+ }
+
+
+ /**
+ * Time the resource was created in UTC ISO8601 format.
+ *
+ * @param string $create_time
+ *
+ * @return $this
+ */
+ public function setCreateTime($create_time)
+ {
+ $this->create_time = $create_time;
+ return $this;
+ }
+
+ /**
+ * Time the resource was created in UTC ISO8601 format.
+ *
+ * @return string
+ */
+ public function getCreateTime()
+ {
+ return $this->create_time;
+ }
+
+ /**
+ * Time the resource was last updated in UTC ISO8601 format.
+ *
+ * @param string $update_time
+ *
+ * @return $this
+ */
+ public function setUpdateTime($update_time)
+ {
+ $this->update_time = $update_time;
+ return $this;
+ }
+
+ /**
+ * Time the resource was last updated in UTC ISO8601 format.
+ *
+ * @return string
+ */
+ public function getUpdateTime()
+ {
+ return $this->update_time;
+ }
+
+ /**
+ * Retrieve details about an order by passing the order_id in the request URI.
+ *
+ * @param string $orderId
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
+ * @return Order
+ */
+ public static function get($orderId, $apiContext = null, $restCall = null)
+ {
+ ArgumentValidator::validate($orderId, 'orderId');
+ $payLoad = "";
+ $json = self::executeCall(
+ "/v1/payments/orders/$orderId",
+ "GET",
+ $payLoad,
+ null,
+ $apiContext,
+ $restCall
+ );
+ $ret = new Order();
+ $ret->fromJson($json);
+ return $ret;
+ }
+
+ /**
+ * Capture a payment on an order by passing the order_id in the request URI. In addition, include the amount of the payment and indicate whether this is a final capture for the given authorization in the body of the request JSON. To issue this request, an original payment call must specify an intent of order.
+ *
+ * @param Capture $capture
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
+ * @return Capture
+ */
+ public function capture($capture, $apiContext = null, $restCall = null)
+ {
+ ArgumentValidator::validate($this->getId(), "Id");
+ ArgumentValidator::validate($capture, 'capture');
+ $payLoad = $capture->toJSON();
+ $json = self::executeCall(
+ "/v1/payments/orders/{$this->getId()}/capture",
+ "POST",
+ $payLoad,
+ null,
+ $apiContext,
+ $restCall
+ );
+ $ret = new Capture();
+ $ret->fromJson($json);
+ return $ret;
+ }
+
+ /**
+ * Void (cancel) an order by passing the order_id in the request URI. Note that an order cannot be voided if payment has already been partially or fully captured.
+ *
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
+ * @return Order
+ */
+ public function void($apiContext = null, $restCall = null)
+ {
+ ArgumentValidator::validate($this->getId(), "Id");
+ $payLoad = "";
+ $json = self::executeCall(
+ "/v1/payments/orders/{$this->getId()}/do-void",
+ "POST",
+ $payLoad,
+ null,
+ $apiContext,
+ $restCall
+ );
+ $this->fromJson($json);
+ return $this;
+ }
+
+ /**
+ * Authorize an order by passing the order_id in the request URI. In addition, include an amount object in the body of the request JSON.
+ *
+ * @param Authorization $authorization Authorization Object with Amount value to be authorized
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
+ * @return Authorization
+ */
+ public function authorize($authorization, $apiContext = null, $restCall = null)
+ {
+ ArgumentValidator::validate($this->getId(), "Id");
+ ArgumentValidator::validate($authorization, 'Authorization');
+ $payLoad = $authorization->toJSON();
+ $json = self::executeCall(
+ "/v1/payments/orders/{$this->getId()}/authorize",
+ "POST",
+ $payLoad,
+ null,
+ $apiContext,
+ $restCall
+ );
+ $ret = new Authorization();
+ $ret->fromJson($json);
+ return $ret;
}
}
diff --git a/sample/doc/assets/behavior.js b/sample/doc/assets/behavior.js
index 4b31526..3668619 100644
--- a/sample/doc/assets/behavior.js
+++ b/sample/doc/assets/behavior.js
@@ -48,37 +48,7 @@ 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
"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
- }
- ]
- }
- ]
+ "depth": 2
}, {
"type": "file",
"data": {
@@ -1010,14 +980,298 @@ 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
"pageTitle": "payments/CreatePaymentUsingPayPal",
"title": "CreatePaymentUsingPayPal"
},
+ "depth": 2
+ }, {
+ "type": "file",
+ "data": {
+ "language": {
+ "nameMatchers": [{}, ".fbp"],
+ "pygmentsLexer": "php",
+ "singleLineComment": ["//"],
+ "ignorePrefix": "}",
+ "foldPrefix": "^",
+ "name": "PHP"
+ },
+ "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payments/CreatePaymentUsingSavedCard.php",
+ "projectPath": "payments/CreatePaymentUsingSavedCard.php",
+ "targetPath": "payments/CreatePaymentUsingSavedCard",
+ "pageTitle": "payments/CreatePaymentUsingSavedCard",
+ "title": "CreatePaymentUsingSavedCard"
+ },
+ "depth": 2
+ }, {
+ "type": "file",
+ "data": {
+ "language": {
+ "nameMatchers": [{}, ".fbp"],
+ "pygmentsLexer": "php",
+ "singleLineComment": ["//"],
+ "ignorePrefix": "}",
+ "foldPrefix": "^",
+ "name": "PHP"
+ },
+ "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payments/ExecutePayment.php",
+ "projectPath": "payments/ExecutePayment.php",
+ "targetPath": "payments/ExecutePayment",
+ "pageTitle": "payments/ExecutePayment",
+ "title": "ExecutePayment"
+ },
"depth": 2,
"outline": [
{
"type": "heading",
"data": {
"level": 1,
- "title": "Create Payment using PayPal as payment method",
- "slug": "create-payment-using-paypal-as-payment-method"
+ "title": "Execute Payment Sample",
+ "slug": "execute-payment-sample"
+ },
+ "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
+ }
+ ]
+ }
+ ]
+ }, {
+ "type": "file",
+ "data": {
+ "language": {
+ "nameMatchers": [{}, ".fbp"],
+ "pygmentsLexer": "php",
+ "singleLineComment": ["//"],
+ "ignorePrefix": "}",
+ "foldPrefix": "^",
+ "name": "PHP"
+ },
+ "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payments/GetAuthorization.php",
+ "projectPath": "payments/GetAuthorization.php",
+ "targetPath": "payments/GetAuthorization",
+ "pageTitle": "payments/GetAuthorization",
+ "title": "GetAuthorization"
+ },
+ "depth": 2
+ }, {
+ "type": "file",
+ "data": {
+ "language": {
+ "nameMatchers": [{}, ".fbp"],
+ "pygmentsLexer": "php",
+ "singleLineComment": ["//"],
+ "ignorePrefix": "}",
+ "foldPrefix": "^",
+ "name": "PHP"
+ },
+ "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payments/GetCapture.php",
+ "projectPath": "payments/GetCapture.php",
+ "targetPath": "payments/GetCapture",
+ "pageTitle": "payments/GetCapture",
+ "title": "GetCapture"
+ },
+ "depth": 2
+ }, {
+ "type": "file",
+ "data": {
+ "language": {
+ "nameMatchers": [{}, ".fbp"],
+ "pygmentsLexer": "php",
+ "singleLineComment": ["//"],
+ "ignorePrefix": "}",
+ "foldPrefix": "^",
+ "name": "PHP"
+ },
+ "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payments/GetPayment.php",
+ "projectPath": "payments/GetPayment.php",
+ "targetPath": "payments/GetPayment",
+ "pageTitle": "payments/GetPayment",
+ "title": "GetPayment"
+ },
+ "depth": 2
+ }, {
+ "type": "file",
+ "data": {
+ "language": {
+ "nameMatchers": [{}, ".fbp"],
+ "pygmentsLexer": "php",
+ "singleLineComment": ["//"],
+ "ignorePrefix": "}",
+ "foldPrefix": "^",
+ "name": "PHP"
+ },
+ "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payments/ListPayments.php",
+ "projectPath": "payments/ListPayments.php",
+ "targetPath": "payments/ListPayments",
+ "pageTitle": "payments/ListPayments",
+ "title": "ListPayments"
+ },
+ "depth": 2
+ }, {
+ "type": "file",
+ "data": {
+ "language": {
+ "nameMatchers": [{}, ".fbp"],
+ "pygmentsLexer": "php",
+ "singleLineComment": ["//"],
+ "ignorePrefix": "}",
+ "foldPrefix": "^",
+ "name": "PHP"
+ },
+ "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payments/OrderAuthorize.php",
+ "projectPath": "payments/OrderAuthorize.php",
+ "targetPath": "payments/OrderAuthorize",
+ "pageTitle": "payments/OrderAuthorize",
+ "title": "OrderAuthorize"
+ },
+ "depth": 2,
+ "outline": [
+ {
+ "type": "heading",
+ "data": {
+ "level": 1,
+ "title": "Authorize Order Sample",
+ "slug": "authorize-order-sample"
+ },
+ "depth": 1,
+ "children": [
+ {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Approval Status",
+ "slug": "approval-status"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Retrieve the order",
+ "slug": "retrieve-the-order"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Create Authorization Object",
+ "slug": "create-authorization-object"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Authorize Order",
+ "slug": "authorize-order"
+ },
+ "depth": 3
+ }
+ ]
+ }
+ ]
+ }, {
+ "type": "file",
+ "data": {
+ "language": {
+ "nameMatchers": [{}, ".fbp"],
+ "pygmentsLexer": "php",
+ "singleLineComment": ["//"],
+ "ignorePrefix": "}",
+ "foldPrefix": "^",
+ "name": "PHP"
+ },
+ "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payments/OrderCapture.php",
+ "projectPath": "payments/OrderCapture.php",
+ "targetPath": "payments/OrderCapture",
+ "pageTitle": "payments/OrderCapture",
+ "title": "OrderCapture"
+ },
+ "depth": 2,
+ "outline": [
+ {
+ "type": "heading",
+ "data": {
+ "level": 1,
+ "title": "Capture Order Sample",
+ "slug": "capture-order-sample"
+ },
+ "depth": 1,
+ "children": [
+ {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Approval Status",
+ "slug": "approval-status"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Retrieve the order",
+ "slug": "retrieve-the-order"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Create Capture Object",
+ "slug": "create-capture-object"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Capture Order",
+ "slug": "capture-order"
+ },
+ "depth": 3
+ }
+ ]
+ }
+ ]
+ }, {
+ "type": "file",
+ "data": {
+ "language": {
+ "nameMatchers": [{}, ".fbp"],
+ "pygmentsLexer": "php",
+ "singleLineComment": ["//"],
+ "ignorePrefix": "}",
+ "foldPrefix": "^",
+ "name": "PHP"
+ },
+ "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payments/OrderCreateForAuthorization.php",
+ "projectPath": "payments/OrderCreateForAuthorization.php",
+ "targetPath": "payments/OrderCreateForAuthorization",
+ "pageTitle": "payments/OrderCreateForAuthorization",
+ "title": "OrderCreateForAuthorization"
+ },
+ "depth": 2,
+ "outline": [
+ {
+ "type": "heading",
+ "data": {
+ "level": 1,
+ "title": "Order Create Using PayPal",
+ "slug": "order-create-using-paypal"
},
"depth": 1,
"children": [
@@ -1108,13 +1362,99 @@ 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
"foldPrefix": "^",
"name": "PHP"
},
- "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payments/CreatePaymentUsingSavedCard.php",
- "projectPath": "payments/CreatePaymentUsingSavedCard.php",
- "targetPath": "payments/CreatePaymentUsingSavedCard",
- "pageTitle": "payments/CreatePaymentUsingSavedCard",
- "title": "CreatePaymentUsingSavedCard"
+ "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payments/OrderCreateForCapture.php",
+ "projectPath": "payments/OrderCreateForCapture.php",
+ "targetPath": "payments/OrderCreateForCapture",
+ "pageTitle": "payments/OrderCreateForCapture",
+ "title": "OrderCreateForCapture"
},
- "depth": 2
+ "depth": 2,
+ "outline": [
+ {
+ "type": "heading",
+ "data": {
+ "level": 1,
+ "title": "Order Create Using PayPal",
+ "slug": "order-create-using-paypal"
+ },
+ "depth": 1,
+ "children": [
+ {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Payer",
+ "slug": "payer"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Itemized information",
+ "slug": "itemized-information"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Additional payment details",
+ "slug": "additional-payment-details"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Amount",
+ "slug": "amount"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Transaction",
+ "slug": "transaction"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Redirect urls",
+ "slug": "redirect-urls"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Payment",
+ "slug": "payment"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Create Payment",
+ "slug": "create-payment"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Get redirect url",
+ "slug": "get-redirect-url"
+ },
+ "depth": 3
+ }
+ ]
+ }
+ ]
}, {
"type": "file",
"data": {
@@ -1126,13 +1466,99 @@ 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
"foldPrefix": "^",
"name": "PHP"
},
- "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payments/ExecutePayment.php",
- "projectPath": "payments/ExecutePayment.php",
- "targetPath": "payments/ExecutePayment",
- "pageTitle": "payments/ExecutePayment",
- "title": "ExecutePayment"
+ "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payments/OrderCreateForVoid.php",
+ "projectPath": "payments/OrderCreateForVoid.php",
+ "targetPath": "payments/OrderCreateForVoid",
+ "pageTitle": "payments/OrderCreateForVoid",
+ "title": "OrderCreateForVoid"
},
- "depth": 2
+ "depth": 2,
+ "outline": [
+ {
+ "type": "heading",
+ "data": {
+ "level": 1,
+ "title": "Order Create Using PayPal",
+ "slug": "order-create-using-paypal"
+ },
+ "depth": 1,
+ "children": [
+ {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Payer",
+ "slug": "payer"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Itemized information",
+ "slug": "itemized-information"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Additional payment details",
+ "slug": "additional-payment-details"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Amount",
+ "slug": "amount"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Transaction",
+ "slug": "transaction"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Redirect urls",
+ "slug": "redirect-urls"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Payment",
+ "slug": "payment"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Create Payment",
+ "slug": "create-payment"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Get redirect url",
+ "slug": "get-redirect-url"
+ },
+ "depth": 3
+ }
+ ]
+ }
+ ]
}, {
"type": "file",
"data": {
@@ -1144,13 +1570,99 @@ 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
"foldPrefix": "^",
"name": "PHP"
},
- "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payments/GetAuthorization.php",
- "projectPath": "payments/GetAuthorization.php",
- "targetPath": "payments/GetAuthorization",
- "pageTitle": "payments/GetAuthorization",
- "title": "GetAuthorization"
+ "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payments/OrderCreateUsingPayPal.php",
+ "projectPath": "payments/OrderCreateUsingPayPal.php",
+ "targetPath": "payments/OrderCreateUsingPayPal",
+ "pageTitle": "payments/OrderCreateUsingPayPal",
+ "title": "OrderCreateUsingPayPal"
},
- "depth": 2
+ "depth": 2,
+ "outline": [
+ {
+ "type": "heading",
+ "data": {
+ "level": 1,
+ "title": "Order Create Using PayPal",
+ "slug": "order-create-using-paypal"
+ },
+ "depth": 1,
+ "children": [
+ {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Payer",
+ "slug": "payer"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Itemized information",
+ "slug": "itemized-information"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Additional payment details",
+ "slug": "additional-payment-details"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Amount",
+ "slug": "amount"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Transaction",
+ "slug": "transaction"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Redirect urls",
+ "slug": "redirect-urls"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Payment",
+ "slug": "payment"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Create Payment",
+ "slug": "create-payment"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Get redirect url",
+ "slug": "get-redirect-url"
+ },
+ "depth": 3
+ }
+ ]
+ }
+ ]
}, {
"type": "file",
"data": {
@@ -1162,13 +1674,51 @@ 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
"foldPrefix": "^",
"name": "PHP"
},
- "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payments/GetCapture.php",
- "projectPath": "payments/GetCapture.php",
- "targetPath": "payments/GetCapture",
- "pageTitle": "payments/GetCapture",
- "title": "GetCapture"
+ "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payments/OrderDoVoid.php",
+ "projectPath": "payments/OrderDoVoid.php",
+ "targetPath": "payments/OrderDoVoid",
+ "pageTitle": "payments/OrderDoVoid",
+ "title": "OrderDoVoid"
},
- "depth": 2
+ "depth": 2,
+ "outline": [
+ {
+ "type": "heading",
+ "data": {
+ "level": 1,
+ "title": "Void Order Sample",
+ "slug": "void-order-sample"
+ },
+ "depth": 1,
+ "children": [
+ {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Approval Status",
+ "slug": "approval-status"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Retrieve the order",
+ "slug": "retrieve-the-order"
+ },
+ "depth": 3
+ }, {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Void Order",
+ "slug": "void-order"
+ },
+ "depth": 3
+ }
+ ]
+ }
+ ]
}, {
"type": "file",
"data": {
@@ -1180,31 +1730,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
"foldPrefix": "^",
"name": "PHP"
},
- "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payments/GetPayment.php",
- "projectPath": "payments/GetPayment.php",
- "targetPath": "payments/GetPayment",
- "pageTitle": "payments/GetPayment",
- "title": "GetPayment"
+ "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payments/OrderGet.php",
+ "projectPath": "payments/OrderGet.php",
+ "targetPath": "payments/OrderGet",
+ "pageTitle": "payments/OrderGet",
+ "title": "OrderGet"
},
- "depth": 2
- }, {
- "type": "file",
- "data": {
- "language": {
- "nameMatchers": [{}, ".fbp"],
- "pygmentsLexer": "php",
- "singleLineComment": ["//"],
- "ignorePrefix": "}",
- "foldPrefix": "^",
- "name": "PHP"
- },
- "sourcePath": "/Users/japatel/Documents/workspace/paypal/PayPal-PHP-SDK/sample/payments/ListPayments.php",
- "projectPath": "payments/ListPayments.php",
- "targetPath": "payments/ListPayments",
- "pageTitle": "payments/ListPayments",
- "title": "ListPayments"
- },
- "depth": 2
+ "depth": 2,
+ "outline": [
+ {
+ "type": "heading",
+ "data": {
+ "level": 1,
+ "title": "Get Order Sample",
+ "slug": "get-order-sample"
+ },
+ "depth": 1,
+ "children": [
+ {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Approval Status",
+ "slug": "approval-status"
+ },
+ "depth": 3
+ }
+ ]
+ }
+ ]
}, {
"type": "file",
"data": {
@@ -1340,56 +1894,7 @@ 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
"pageTitle": "payouts/CreateSinglePayout",
"title": "CreateSinglePayout"
},
- "depth": 2,
- "outline": [
- {
- "type": "heading",
- "data": {
- "level": 1,
- "title": "Create Single Synchronous Payout Sample",
- "slug": "create-single-synchronous-payout-sample"
- },
- "depth": 1,
- "children": [
- {
- "type": "heading",
- "data": {
- "level": 3,
- "title": "NOTE:",
- "slug": "note"
- },
- "depth": 3,
- "children": [
- {
- "type": "heading",
- "data": {
- "level": 4,
- "title": "Batch Header Instance",
- "slug": "batch-header-instance"
- },
- "depth": 4
- }, {
- "type": "heading",
- "data": {
- "level": 4,
- "title": "Sender Item",
- "slug": "sender-item"
- },
- "depth": 4
- }
- ]
- }, {
- "type": "heading",
- "data": {
- "level": 3,
- "title": "Create Payout",
- "slug": "create-payout"
- },
- "depth": 3
- }
- ]
- }
- ]
+ "depth": 2
}, {
"type": "file",
"data": {
@@ -1517,37 +2022,7 @@ 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
"pageTitle": "vault/CreateCreditCard",
"title": "CreateCreditCard"
},
- "depth": 2,
- "outline": [
- {
- "type": "heading",
- "data": {
- "level": 1,
- "title": "Create Credit Card Sample",
- "slug": "create-credit-card-sample"
- },
- "depth": 1,
- "children": [
- {
- "type": "heading",
- "data": {
- "level": 3,
- "title": "CreditCard",
- "slug": "creditcard"
- },
- "depth": 3
- }, {
- "type": "heading",
- "data": {
- "level": 3,
- "title": "Save card",
- "slug": "save-card"
- },
- "depth": 3
- }
- ]
- }
- ]
+ "depth": 2
}, {
"type": "file",
"data": {
@@ -1637,37 +2112,7 @@ 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
"pageTitle": "vault/UpdateCreditCard",
"title": "UpdateCreditCard"
},
- "depth": 2,
- "outline": [
- {
- "type": "heading",
- "data": {
- "level": 1,
- "title": "Update Credit Card Sample",
- "slug": "update-credit-card-sample"
- },
- "depth": 1,
- "children": [
- {
- "type": "heading",
- "data": {
- "level": 3,
- "title": "Patch Object",
- "slug": "patch-object"
- },
- "depth": 3
- }, {
- "type": "heading",
- "data": {
- "level": 3,
- "title": "Another Patch Object",
- "slug": "another-patch-object"
- },
- "depth": 3
- }
- ]
- }
- ]
+ "depth": 2
}
]
}
diff --git a/sample/doc/billing/CreateBillingAgreementWithPayPal.html b/sample/doc/billing/CreateBillingAgreementWithPayPal.html
index 1e07903..af586ee 100644
--- a/sample/doc/billing/CreateBillingAgreementWithPayPal.html
+++ b/sample/doc/billing/CreateBillingAgreementWithPayPal.html
@@ -47,7 +47,7 @@ Please note that the plan Id should be only set in this case.
$agreement->setShippingAddress($shippingAddress);$request = clone $agreement;
$agreement = $agreement->create($apiContext);
$approvalUrl = $agreement->getApprovalLink();
+method
$approvalUrl = $agreement->getApprovalLink();
} catch (Exception $ex) {
ResultPrinter::printError("Created Billing Agreement.", "Agreement", null, $request, $ex);
diff --git a/sample/doc/payments/ExecutePayment.html b/sample/doc/payments/ExecutePayment.html
index ba7c7e5..02df941 100644
--- a/sample/doc/payments/ExecutePayment.html
+++ b/sample/doc/payments/ExecutePayment.html
@@ -19,15 +19,21 @@ CreatePaymentUsingPayPal.php
$execution = new PaymentExecution();
- $execution->setPayerId($_GET['PayerID']);
$result = $payment->execute($execution, $apiContext);
+ $execution->setPayerId($_GET['PayerID']);
- ResultPrinter::printResult("Executed Payment", "Payment", $payment->getId(), $execution, $result);
+ try {
$result = $payment->execute($execution, $apiContext);
- try {
- $payment = Payment::get($paymentId, $apiContext);
+ ResultPrinter::printResult("Executed Payment", "Payment", $payment->getId(), $execution, $result);
+
+ try {
+ $payment = Payment::get($paymentId, $apiContext);
+ } catch (Exception $ex) {
+ ResultPrinter::printError("Get Payment", "Payment", null, null, $ex);
+ exit(1);
+ }
} catch (Exception $ex) {
- ResultPrinter::printError("Get Payment", "Payment", null, null, $ex);
+ ResultPrinter::printError("Executed Payment", "Payment", null, null, $ex);
exit(1);
}
@@ -38,4 +44,5 @@ when the user is redirected from paypal back to your site
else {
ResultPrinter::printResult("User Cancelled the Approval", null);
+ exit;
}
For Sample Purposes Only.