iways_paypalplus - Version 1.7.0

Version Notes

==== 1.7.0 ====
Update PayPal Rest SDK to 1.6.4
Fixed parent transaction id
Fixed wrong PayPal payment id in Idev_OSC
Added partial refund
Show payment instructions for manual banktransfer payments on order success page
Added totals to patchPayment
Possible MagentoConnect File->directory fix

==== 1.6.2 ====
Enable/disable loading indicator for PayPal Plus iframe
Fixed order status if PayPal payment is still pending (Now payment_review until Webhooks approves payment)
==== 1.6.1 ====
Fixed suspected fraud for different currency
Changed payment method title for germany in frontend

==== 1.6.0 ====
Added support for IWD_OSC
Fixed problem with store code in url
Changed first recieved transaction id from PayPal to transaction id from payment id

==== 1.5.2 ====
Fixed state/status of authorizations and gateway-confirmation
Added last transaction number to order information
Added transfer order's id as invoice number setting

==== 1.5.1 ====
Fixed paymentmethod choice for Idev_OSC
Updated PayPal SDK to 1.6

==== 1.5.0 ====
Added support for Payment upon Invoice

==== 1.4.5 ====
Added information block to checkout/success

==== 1.4.4 ====
Fixed wrong locale code in presentation error

==== 1.4.3 ====
Fixed empty order status Magento 1.7
Added localisation

==== 1.4.2 ====
Force webhooks url to be https even if not
Fixed tax calculation with discount

==== 1.4.1 ====
Fixed none responding payment method select
Removed unnecessary code line

==== 1.4.0 ====
Added support for TM_Firecheckout and Magestore_Onestepcheckout
Added form key validateion for Magento 1.9

Download this release

Release Info

Developer i-ways sales solutions GmbH
Extension iways_paypalplus
Version 1.7.0
Comparing to
See all releases


Version 1.7.0

Files changed (193) hide show
  1. app/code/community/Iways/PayPalPlus/Block/Adminhtml/System/Config/Fieldset/Payment.php +41 -0
  2. app/code/community/Iways/PayPalPlus/Block/Adminhtml/System/Config/Thirdpartyinfo.php +140 -0
  3. app/code/community/Iways/PayPalPlus/Block/Onepage/Payment/Methods.php +81 -0
  4. app/code/community/Iways/PayPalPlus/Block/Onepage/Success.php +97 -0
  5. app/code/community/Iways/PayPalPlus/Block/Payment/Form.php +331 -0
  6. app/code/community/Iways/PayPalPlus/Block/Payment/Info.php +86 -0
  7. app/code/community/Iways/PayPalPlus/Helper/Data.php +202 -0
  8. app/code/community/Iways/PayPalPlus/Model/Api.php +775 -0
  9. app/code/community/Iways/PayPalPlus/Model/Api2/Order.php +59 -0
  10. app/code/community/Iways/PayPalPlus/Model/Api2/Order/Rest.php +74 -0
  11. app/code/community/Iways/PayPalPlus/Model/Api2/Order/Rest/Admin/V1.php +31 -0
  12. app/code/community/Iways/PayPalPlus/Model/Api2/Order/Rest/Customer/V1.php +66 -0
  13. app/code/community/Iways/PayPalPlus/Model/Autoloader.php +62 -0
  14. app/code/community/Iways/PayPalPlus/Model/Observer.php +113 -0
  15. app/code/community/Iways/PayPalPlus/Model/Payment.php +189 -0
  16. app/code/community/Iways/PayPalPlus/Model/System/Config/Source/Mode.php +66 -0
  17. app/code/community/Iways/PayPalPlus/Model/System/Config/Source/Thirdpartymoduls.php +81 -0
  18. app/code/community/Iways/PayPalPlus/Model/Webhook/Event.php +259 -0
  19. app/code/community/Iways/PayPalPlus/RELEASE_NOTES.txt +111 -0
  20. app/code/community/Iways/PayPalPlus/controllers/IndexController.php +176 -0
  21. app/code/community/Iways/PayPalPlus/etc/api2.xml +49 -0
  22. app/code/community/Iways/PayPalPlus/etc/config.xml +184 -0
  23. app/code/community/Iways/PayPalPlus/etc/system.xml +226 -0
  24. app/code/community/Iways/PayPalPlus/etc/wsdl.xml +24 -0
  25. app/code/community/Iways/PayPalPlus/etc/wsi.xml +27 -0
  26. app/code/community/Iways/PayPalPlus/sql/iways_paypalplus_setup/install-1.5.0.php +95 -0
  27. app/code/community/Iways/PayPalPlus/sql/iways_paypalplus_setup/upgrade-1.4.5-1.5.0.php +95 -0
  28. app/design/adminhtml/default/default/template/paypalplus/payment/info.phtml +47 -0
  29. app/design/adminhtml/default/default/template/paypalplus/payment/pdf/info.phtml +42 -0
  30. app/design/frontend/base/default/layout/iways_paypalplus.xml +56 -0
  31. app/design/frontend/base/default/template/paypalplus/form/payment.phtml +134 -0
  32. app/design/frontend/base/default/template/paypalplus/methods.phtml +134 -0
  33. app/design/frontend/base/default/template/paypalplus/payment/info.phtml +22 -0
  34. app/design/frontend/base/default/template/paypalplus/review/button.phtml +85 -0
  35. app/design/frontend/base/default/template/paypalplus/success.phtml +65 -0
  36. app/etc/modules/Iways_PayPalPlus.xml +14 -0
  37. app/locale/de_DE/Iways_PayPalPlus.csv +43 -0
  38. lib/PayPal/Api/Address.php +39 -0
  39. lib/PayPal/Api/Agreement.php +647 -0
  40. lib/PayPal/Api/AgreementDetails.php +209 -0
  41. lib/PayPal/Api/AgreementStateDescriptor.php +65 -0
  42. lib/PayPal/Api/AgreementTransaction.php +257 -0
  43. lib/PayPal/Api/AgreementTransactions.php +71 -0
  44. lib/PayPal/Api/AlternatePayment.php +89 -0
  45. lib/PayPal/Api/Amount.php +93 -0
  46. lib/PayPal/Api/Authorization.php +459 -0
  47. lib/PayPal/Api/BankAccount.php +630 -0
  48. lib/PayPal/Api/BankAccountsList.php +119 -0
  49. lib/PayPal/Api/BankToken.php +89 -0
  50. lib/PayPal/Api/BaseAddress.php +211 -0
  51. lib/PayPal/Api/Billing.php +41 -0
  52. lib/PayPal/Api/BillingAgreementToken.php +17 -0
  53. lib/PayPal/Api/BillingInfo.php +235 -0
  54. lib/PayPal/Api/CancelNotification.php +113 -0
  55. lib/PayPal/Api/Capture.php +264 -0
  56. lib/PayPal/Api/CarrierAccount.php +138 -0
  57. lib/PayPal/Api/CarrierAccountToken.php +65 -0
  58. lib/PayPal/Api/CartBase.php +391 -0
  59. lib/PayPal/Api/ChargeModel.php +89 -0
  60. lib/PayPal/Api/Cost.php +69 -0
  61. lib/PayPal/Api/CountryCode.php +41 -0
  62. lib/PayPal/Api/CreateProfileResponse.php +40 -0
  63. lib/PayPal/Api/Credit.php +66 -0
  64. lib/PayPal/Api/CreditCard.php +559 -0
  65. lib/PayPal/Api/CreditCardHistory.php +91 -0
  66. lib/PayPal/Api/CreditCardList.php +120 -0
  67. lib/PayPal/Api/CreditCardToken.php +161 -0
  68. lib/PayPal/Api/CreditFinancingOffered.php +161 -0
  69. lib/PayPal/Api/Currency.php +69 -0
  70. lib/PayPal/Api/CurrencyConversion.php +268 -0
  71. lib/PayPal/Api/CustomAmount.php +65 -0
  72. lib/PayPal/Api/Details.php +227 -0
  73. lib/PayPal/Api/Error.php +321 -0
  74. lib/PayPal/Api/ErrorDetails.php +115 -0
  75. lib/PayPal/Api/ExtendedBankAccount.php +40 -0
  76. lib/PayPal/Api/ExternalFunding.php +137 -0
  77. lib/PayPal/Api/FlowConfig.php +69 -0
  78. lib/PayPal/Api/FmfDetails.php +115 -0
  79. lib/PayPal/Api/FundingDetail.php +114 -0
  80. lib/PayPal/Api/FundingInstrument.php +339 -0
  81. lib/PayPal/Api/FundingOption.php +221 -0
  82. lib/PayPal/Api/FundingSource.php +289 -0
  83. lib/PayPal/Api/FuturePayment.php +75 -0
  84. lib/PayPal/Api/HyperSchema.php +191 -0
  85. lib/PayPal/Api/Image.php +56 -0
  86. lib/PayPal/Api/Incentive.php +236 -0
  87. lib/PayPal/Api/InputFields.php +92 -0
  88. lib/PayPal/Api/InstallmentInfo.php +144 -0
  89. lib/PayPal/Api/InstallmentOption.php +113 -0
  90. lib/PayPal/Api/Invoice.php +1020 -0
  91. lib/PayPal/Api/InvoiceAddress.php +39 -0
  92. lib/PayPal/Api/InvoiceItem.php +189 -0
  93. lib/PayPal/Api/InvoiceSearchResponse.php +95 -0
  94. lib/PayPal/Api/Item.php +456 -0
  95. lib/PayPal/Api/ItemList.php +143 -0
  96. lib/PayPal/Api/Links.php +161 -0
  97. lib/PayPal/Api/Measurement.php +65 -0
  98. lib/PayPal/Api/MerchantInfo.php +257 -0
  99. lib/PayPal/Api/MerchantPreferences.php +261 -0
  100. lib/PayPal/Api/Metadata.php +259 -0
  101. lib/PayPal/Api/NameValuePair.php +65 -0
  102. lib/PayPal/Api/Notification.php +89 -0
  103. lib/PayPal/Api/OpenIdAddress.php +133 -0
  104. lib/PayPal/Api/OpenIdError.php +85 -0
  105. lib/PayPal/Api/OpenIdSession.php +107 -0
  106. lib/PayPal/Api/OpenIdTokeninfo.php +253 -0
  107. lib/PayPal/Api/OpenIdUserinfo.php +538 -0
  108. lib/PayPal/Api/Order.php +438 -0
  109. lib/PayPal/Api/OverrideChargeModel.php +65 -0
  110. lib/PayPal/Api/Patch.php +114 -0
  111. lib/PayPal/Api/PatchRequest.php +86 -0
  112. lib/PayPal/Api/Payee.php +165 -0
  113. lib/PayPal/Api/Payer.php +270 -0
  114. lib/PayPal/Api/PayerInfo.php +428 -0
  115. lib/PayPal/Api/Payment.php +693 -0
  116. lib/PayPal/Api/PaymentCard.php +457 -0
  117. lib/PayPal/Api/PaymentCardToken.php +162 -0
  118. lib/PayPal/Api/PaymentDefinition.php +239 -0
  119. lib/PayPal/Api/PaymentDetail.php +164 -0
  120. lib/PayPal/Api/PaymentExecution.php +119 -0
  121. lib/PayPal/Api/PaymentHistory.php +119 -0
  122. lib/PayPal/Api/PaymentInstruction.php +190 -0
  123. lib/PayPal/Api/PaymentOptions.php +92 -0
  124. lib/PayPal/Api/PaymentTerm.php +66 -0
  125. lib/PayPal/Api/Payout.php +166 -0
  126. lib/PayPal/Api/PayoutBatch.php +120 -0
  127. lib/PayPal/Api/PayoutBatchHeader.php +263 -0
  128. lib/PayPal/Api/PayoutItem.php +190 -0
  129. lib/PayPal/Api/PayoutItemDetails.php +287 -0
  130. lib/PayPal/Api/PayoutSenderBatchHeader.php +89 -0
  131. lib/PayPal/Api/Phone.php +89 -0
  132. lib/PayPal/Api/Plan.php +445 -0
  133. lib/PayPal/Api/PlanList.php +173 -0
  134. lib/PayPal/Api/PotentialPayerInfo.php +112 -0
  135. lib/PayPal/Api/Presentation.php +92 -0
  136. lib/PayPal/Api/PrivateLabelCard.php +137 -0
  137. lib/PayPal/Api/ProcessorResponse.php +162 -0
  138. lib/PayPal/Api/RecipientBankingInstruction.php +161 -0
  139. lib/PayPal/Api/RedirectUrls.php +68 -0
  140. lib/PayPal/Api/Refund.php +286 -0
  141. lib/PayPal/Api/RefundDetail.php +90 -0
  142. lib/PayPal/Api/RelatedResources.php +137 -0
  143. lib/PayPal/Api/Sale.php +611 -0
  144. lib/PayPal/Api/Search.php +474 -0
  145. lib/PayPal/Api/ShippingAddress.php +111 -0
  146. lib/PayPal/Api/ShippingCost.php +65 -0
  147. lib/PayPal/Api/ShippingInfo.php +158 -0
  148. lib/PayPal/Api/Tax.php +117 -0
  149. lib/PayPal/Api/Terms.php +161 -0
  150. lib/PayPal/Api/Transaction.php +62 -0
  151. lib/PayPal/Api/TransactionBase.php +40 -0
  152. lib/PayPal/Api/Transactions.php +42 -0
  153. lib/PayPal/Api/WebProfile.php +286 -0
  154. lib/PayPal/Api/Webhook.php +241 -0
  155. lib/PayPal/Api/WebhookEvent.php +282 -0
  156. lib/PayPal/Api/WebhookEventList.php +149 -0
  157. lib/PayPal/Api/WebhookEventType.php +116 -0
  158. lib/PayPal/Api/WebhookEventTypeList.php +71 -0
  159. lib/PayPal/Api/WebhookList.php +71 -0
  160. lib/PayPal/Auth/OAuthTokenCredential.php +313 -0
  161. lib/PayPal/Cache/AuthorizationCache.php +121 -0
  162. lib/PayPal/Common/ArrayUtil.php +27 -0
  163. lib/PayPal/Common/PayPalModel.php +307 -0
  164. lib/PayPal/Common/PayPalResourceModel.php +105 -0
  165. lib/PayPal/Common/PayPalUserAgent.php +58 -0
  166. lib/PayPal/Common/ReflectionUtil.php +154 -0
  167. lib/PayPal/Converter/FormatConverter.php +62 -0
  168. lib/PayPal/Core/PayPalConfigManager.php +163 -0
  169. lib/PayPal/Core/PayPalConstants.php +27 -0
  170. lib/PayPal/Core/PayPalCredentialManager.php +168 -0
  171. lib/PayPal/Core/PayPalHttpConfig.php +302 -0
  172. lib/PayPal/Core/PayPalHttpConnection.php +191 -0
  173. lib/PayPal/Core/PayPalLoggingLevel.php +26 -0
  174. lib/PayPal/Core/PayPalLoggingManager.php +166 -0
  175. lib/PayPal/Core/cacert.pem +171 -0
  176. lib/PayPal/Exception/PayPalConfigurationException.php +23 -0
  177. lib/PayPal/Exception/PayPalConnectionException.php +68 -0
  178. lib/PayPal/Exception/PayPalInvalidCredentialException.php +36 -0
  179. lib/PayPal/Exception/PayPalMissingCredentialException.php +37 -0
  180. lib/PayPal/Handler/IPayPalHandler.php +20 -0
  181. lib/PayPal/Handler/OauthHandler.php +103 -0
  182. lib/PayPal/Handler/RestHandler.php +125 -0
  183. lib/PayPal/Rest/ApiContext.php +165 -0
  184. lib/PayPal/Rest/IResource.php +12 -0
  185. lib/PayPal/Security/Cipher.php +57 -0
  186. lib/PayPal/Transport/PayPalRestCall.php +79 -0
  187. lib/PayPal/Validation/ArgumentValidator.php +32 -0
  188. lib/PayPal/Validation/JsonValidator.php +35 -0
  189. lib/PayPal/Validation/NumericValidator.php +28 -0
  190. lib/PayPal/Validation/UrlValidator.php +26 -0
  191. package.xml +74 -0
  192. skin/frontend/base/default/css/iways-paypalplus.css +70 -0
  193. skin/frontend/base/default/images/iways/checkmark.png +0 -0
app/code/community/Iways/PayPalPlus/Block/Adminhtml/System/Config/Fieldset/Payment.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com and you will be sent a copy immediately.
13
+ *
14
+ * Created on 02.03.2015
15
+ * Author Robert Hillebrand - hillebrand@i-ways.de - i-ways sales solutions GmbH
16
+ * Copyright i-ways sales solutions GmbH © 2015. All Rights Reserved.
17
+ * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ *
19
+ */
20
+
21
+ /**
22
+ * Iways PayPalPlus Payment Block
23
+ *
24
+ * @category Iways
25
+ * @package Iways_PayPalPlus
26
+ * @author robert
27
+ */
28
+ class Iways_PayPalPlus_Block_Adminhtml_System_Config_Fieldset_Payment
29
+ extends Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Payment
30
+ {
31
+ /**
32
+ * Get collapsed state on-load
33
+ *
34
+ * @param Varien_Data_Form_Element_Abstract $element
35
+ * @return bool
36
+ */
37
+ protected function _getCollapseState($element)
38
+ {
39
+ return true;
40
+ }
41
+ }
app/code/community/Iways/PayPalPlus/Block/Adminhtml/System/Config/Thirdpartyinfo.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com and you will be sent a copy immediately.
13
+ *
14
+ * Created on 02.03.2015
15
+ * Author Robert Hillebrand - hillebrand@i-ways.de - i-ways sales solutions GmbH
16
+ * Copyright i-ways sales solutions GmbH © 2015. All Rights Reserved.
17
+ * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ *
19
+ */
20
+
21
+ /**
22
+ * Iways PayPalPlus Payment Block Adminhtml System Config Fieldset Payment THridparty Info
23
+ *
24
+ * @category Iways
25
+ * @package Iways_PayPalPlus
26
+ * @author robert
27
+ */
28
+ class Iways_PayPalPlus_Block_Adminhtml_System_Config_Thirdpartyinfo
29
+ extends Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Expanded
30
+ {
31
+ /**
32
+ * @var
33
+ */
34
+ protected $_dummyElement;
35
+ /**
36
+ * @var
37
+ */
38
+ protected $_fieldRenderer;
39
+ /**
40
+ * @var
41
+ */
42
+ protected $_values;
43
+
44
+ /**
45
+ * Renders dynamic textfields.
46
+ *
47
+ * @param Varien_Data_Form_Element_Abstract $element
48
+ * @return string
49
+ */
50
+ public function render(Varien_Data_Form_Element_Abstract $element)
51
+ {
52
+ $html = $this->_getHeaderHtml($element);
53
+
54
+ $thirdPartyMethods = Mage::getStoreConfig('payment/iways_paypalplus_payment/third_party_moduls');
55
+ $thirdPartyMethods = explode(',', $thirdPartyMethods);
56
+
57
+ $payments = Mage::getSingleton('payment/config')->getActiveMethods();
58
+
59
+ foreach ($payments as $paymentCode => $paymentModel) {
60
+ if (in_array($paymentCode, $thirdPartyMethods)) {
61
+ $html .= $this->_getFieldHtml($element, $paymentModel);
62
+ }
63
+ }
64
+ $html .= $this->_getFooterHtml($element);
65
+
66
+ return $html;
67
+ }
68
+
69
+
70
+ /**
71
+ * Creates a dummy element
72
+ * @return Varien_Object
73
+ */
74
+ protected function _getDummyElement()
75
+ {
76
+ if (empty($this->_dummyElement)) {
77
+ $this->_dummyElement = new Varien_Object(array(
78
+ 'show_in_default' => 1,
79
+ 'show_in_website' => 1,
80
+ 'show_in_store' => 1
81
+ ));
82
+ }
83
+ return $this->_dummyElement;
84
+ }
85
+
86
+
87
+ /**
88
+ * Returns field renderer
89
+ *
90
+ * @return Mage_Adminhtml_Block_System_Config_Form_Field
91
+ */
92
+ protected function _getFieldRenderer()
93
+ {
94
+ if (empty($this->_fieldRenderer)) {
95
+ $this->_fieldRenderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
96
+ }
97
+ return $this->_fieldRenderer;
98
+ }
99
+
100
+
101
+ /**
102
+ * Renders a dynamic textfield
103
+ *
104
+ * @param $fieldset
105
+ * @param $paymentModel
106
+ * @return mixed
107
+ */
108
+ protected function _getFieldHtml($fieldset, $paymentModel)
109
+ {
110
+ $configData = $this->getConfigData();
111
+ $path = 'payment/third_party_modul_info/text_' . $paymentModel->getCode();
112
+ if (isset($configData[$path])) {
113
+ $data = $configData[$path];
114
+ $inherit = false;
115
+ } else {
116
+ $data = (int)(string)$this->getForm()->getConfigRoot()->descend($path);
117
+ $inherit = true;
118
+ }
119
+ if (!$data) {
120
+ $data = '';
121
+ }
122
+
123
+ $e = $this->_getDummyElement();
124
+
125
+ $field = $fieldset->addField(
126
+ $paymentModel->getCode(),
127
+ 'text',
128
+ array(
129
+ 'name' => 'groups[third_party_modul_info][fields][text_' . $paymentModel->getCode() . '][value]',
130
+ 'label' => $paymentModel->getTitle(),
131
+ 'value' => $data,
132
+ 'inherit' => $inherit,
133
+ 'can_use_default_value' => $this->getForm()->canUseDefaultValue($e),
134
+ 'can_use_website_value' => $this->getForm()->canUseWebsiteValue($e),
135
+ )
136
+ )->setRenderer($this->_getFieldRenderer());
137
+
138
+ return $field->toHtml();
139
+ }
140
+ }
app/code/community/Iways/PayPalPlus/Block/Onepage/Payment/Methods.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com and you will be sent a copy immediately.
13
+ *
14
+ * Created on 02.03.2015
15
+ * Author Robert Hillebrand - hillebrand@i-ways.de - i-ways sales solutions GmbH
16
+ * Copyright i-ways sales solutions GmbH © 2015. All Rights Reserved.
17
+ * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ *
19
+ */
20
+
21
+ /**
22
+ * Iways PayPalPlus Onepage Payment Methods Block
23
+ *
24
+ * @category Iways
25
+ * @package Iways_PayPalPlus
26
+ * @author robert
27
+ */
28
+ class Iways_PayPalPlus_Block_Onepage_Payment_Methods extends Mage_Checkout_Block_Onepage_Payment_Methods
29
+ {
30
+ /**
31
+ * Builds third party methods array
32
+ *
33
+ * @return array
34
+ */
35
+ public function getThirdPartyMethods()
36
+ {
37
+ $thirdPartyMethods = Mage::getStoreConfig('payment/iways_paypalplus_payment/third_party_moduls');
38
+
39
+ if (!empty($thirdPartyMethods)) {
40
+ $thirdPartyMethods = explode(',', $thirdPartyMethods);
41
+ } else {
42
+ $thirdPartyMethods = array();
43
+ }
44
+ $thirdPartyMethods = array_merge(
45
+ $thirdPartyMethods,
46
+ array(
47
+ 'paypaluk_direct',
48
+ 'paypaluk_express',
49
+ 'paypal_standard',
50
+ 'paypal_direct',
51
+ 'paypal_express_bml',
52
+ 'paypal_express'
53
+ )
54
+ );
55
+ $thirdPartyPayPalMethods = array();
56
+ foreach ($thirdPartyMethods as $thirdPartyMethod) {
57
+ $thirdPartyPayPalMethods[$thirdPartyMethod] = true;
58
+ }
59
+ return $thirdPartyPayPalMethods;
60
+ }
61
+
62
+
63
+ /**
64
+ * Checks if iways_paypalplus_payment is active and a payment experience could be retrieved from PayPal
65
+ *
66
+ * @return bool
67
+ */
68
+ public function isPPPActive()
69
+ {
70
+ $paymentExperience = Mage::helper('iways_paypalplus')->getPaymentExperience();
71
+
72
+ if ($paymentExperience) {
73
+ foreach ($this->getMethods() as $_method) {
74
+ if ($_method->getCode() == Iways_PayPalPlus_Model_Payment::METHOD_CODE) {
75
+ return true;
76
+ }
77
+ }
78
+ }
79
+ return false;
80
+ }
81
+ }
app/code/community/Iways/PayPalPlus/Block/Onepage/Success.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com and you will be sent a copy immediately.
13
+ *
14
+ * Created on 02.03.2015
15
+ * Author Robert Hillebrand - hillebrand@i-ways.de - i-ways sales solutions GmbH
16
+ * Copyright i-ways sales solutions GmbH © 2015. All Rights Reserved.
17
+ * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ *
19
+ */
20
+
21
+ /**
22
+ * Iways PayPalPlus Onepage Success
23
+ *
24
+ * @category Iways
25
+ * @package Iways_PayPalPlus
26
+ * @author robert
27
+ */
28
+ class Iways_PayPalPlus_Block_Onepage_Success extends Mage_Checkout_Block_Onepage_Review
29
+ {
30
+ /**
31
+ * Current order to work with.
32
+ *
33
+ * @var Mage_Sales_Model_Order
34
+ */
35
+ protected $_order;
36
+
37
+ /**
38
+ * Caches given order.
39
+ *
40
+ * @return void
41
+ */
42
+ public function _construct()
43
+ {
44
+ parent::_construct();
45
+ $orderId = Mage::getSingleton('checkout/type_onepage')->getCheckout()->getLastOrderId();
46
+ $this->_order = Mage::getModel('sales/order')->load($orderId);
47
+ }
48
+
49
+ /**
50
+ * Check if last order is PayPalPlus
51
+ * @return bool
52
+ */
53
+ public function isPPP()
54
+ {
55
+ if ($this->_order->getPayment()->getMethodInstance()->getCode() == Iways_PayPalPlus_Model_Payment::METHOD_CODE) {
56
+ return true;
57
+ }
58
+ return false;
59
+ }
60
+
61
+ /**
62
+ * Checks if order is PayPal Plus and PuI
63
+ *
64
+ * @return bool
65
+ */
66
+ public function isPUI()
67
+ {
68
+ return (
69
+ $this->isPPP()
70
+ && (
71
+ $this->_order->getPayment()->getData('ppp_pui_instruction_type')
72
+ == Iways_PayPalPlus_Model_Payment::PPP_PUI_INSTRUCTION_TYPE
73
+ )
74
+ ) ? true : false;
75
+ }
76
+
77
+ /**
78
+ * Checks if order is PayPal Plus and has payment instructions
79
+ *
80
+ * @return bool
81
+ */
82
+ public function hasPaymentInstruction()
83
+ {
84
+ return ($this->isPPP() && $this->_order->getPayment()->getData('ppp_pui_instruction_type')) ? true : false;
85
+ }
86
+
87
+ /**
88
+ * Wrapper for $payment->getData($key)
89
+ *
90
+ * @param $key
91
+ * @return array|mixed|null
92
+ */
93
+ public function getAdditionalInformation($key)
94
+ {
95
+ return $this->_order->getPayment()->getData($key);
96
+ }
97
+ }
app/code/community/Iways/PayPalPlus/Block/Payment/Form.php ADDED
@@ -0,0 +1,331 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com and you will be sent a copy immediately.
13
+ *
14
+ * Created on 02.03.2015
15
+ * Author Robert Hillebrand - hillebrand@i-ways.de - i-ways sales solutions GmbH
16
+ * Copyright i-ways sales solutions GmbH © 2015. All Rights Reserved.
17
+ * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ *
19
+ */
20
+
21
+ /**
22
+ * Iways PayPalPlus Payment Block
23
+ *
24
+ * @category Iways
25
+ * @package Iways_PayPalPlus
26
+ * @author robert
27
+ */
28
+ class Iways_PayPalPlus_Block_Payment_Form extends Mage_Payment_Block_Form
29
+ {
30
+ /**
31
+ * PayPalPlus Payment method code
32
+ */
33
+ const IWAYS_PAYPALPLUS_PAYMENT = 'iways_paypalplus_payment';
34
+
35
+ /**
36
+ * Templates for third party methods
37
+ */
38
+ const THIRDPARTY_TEMPLATE = 'thirdPartyPaymentMethods: [%s],';
39
+ const THIRDPARTY_METHOD_TEMPLATE =
40
+ '{"redirectUrl":"%s", "methodName": "%s", "imageUrl": "%s", "description": "%s"}';
41
+
42
+ /**
43
+ * Byte marks to check payment method availability.
44
+ */
45
+ const CHECK_USE_FOR_COUNTRY = 1;
46
+ const CHECK_USE_FOR_CURRENCY = 2;
47
+ const CHECK_USE_CHECKOUT = 4;
48
+ const CHECK_USE_FOR_MULTISHIPPING = 8;
49
+ const CHECK_USE_INTERNAL = 16;
50
+ const CHECK_ORDER_TOTAL_MIN_MAX = 32;
51
+ const CHECK_RECURRING_PROFILES = 64;
52
+ const CHECK_ZERO_TOTAL = 128;
53
+
54
+ protected function _construct()
55
+ {
56
+ parent::_construct();
57
+ $this->setTemplate('paypalplus/form/payment.phtml');
58
+ }
59
+
60
+ /**
61
+ * Request payment experience from PayPal for current quote.
62
+ *
63
+ * @return string
64
+ */
65
+ public function getPaymentEperience()
66
+ {
67
+ return Mage::helper('iways_paypalplus')->getPaymentExperience();
68
+ }
69
+
70
+ /**
71
+ * Construct third party method json string with all needed information for PayPal.
72
+ *
73
+ * @return string
74
+ */
75
+ public function getThirdPartyMethods()
76
+ {
77
+ $thirdPartyMethods = Mage::getStoreConfig('payment/iways_paypalplus_payment/third_party_moduls');
78
+ if (!empty($thirdPartyMethods)) {
79
+ $thirdPartyMethods = explode(',', $thirdPartyMethods);
80
+ $activePamentMethods = $this->getMethods();
81
+ $renderMethods = array();
82
+ foreach ($activePamentMethods as $activePaymentMethod) {
83
+ if (in_array($activePaymentMethod->getCode(), $thirdPartyMethods)) {
84
+ $renderMethods[] = sprintf(
85
+ self::THIRDPARTY_METHOD_TEMPLATE,
86
+ $this->getCheckoutUrl() . $activePaymentMethod->getCode(),
87
+ $activePaymentMethod->getTitle(),
88
+ '',
89
+ Mage::getStoreConfig('payment/third_party_modul_info/text_' . $activePaymentMethod->getCode())
90
+ );
91
+ }
92
+ }
93
+ return sprintf(
94
+ self::THIRDPARTY_TEMPLATE,
95
+ implode(', ', $renderMethods)
96
+ );
97
+ }
98
+ return '';
99
+ }
100
+
101
+ /**
102
+ * Build Json Object for payment name and code.
103
+ *
104
+ * Used for third party method selection.
105
+ *
106
+ * @return string
107
+ */
108
+ public function getThirdPartyJsonObject()
109
+ {
110
+ $methods = $this->getMethods();
111
+ $methodsArray = array();
112
+ foreach ($methods as $method) {
113
+ $methodsArray[$method->getTitle()] = $method->getCode();
114
+ }
115
+ return json_encode($methodsArray);
116
+ }
117
+
118
+ /**
119
+ * Build Method Json Object for payment code and name.
120
+ *
121
+ * Used for third party method selection.
122
+ *
123
+ * @return string
124
+ */
125
+ public function getThirdPartyMethodJsonObject()
126
+ {
127
+ $thirdPartyMethods = Mage::getStoreConfig('payment/iways_paypalplus_payment/third_party_moduls');
128
+ $renderMethods = array();
129
+ if (!empty($thirdPartyMethods)) {
130
+ $thirdPartyMethods = explode(',', $thirdPartyMethods);
131
+ $activePaymentMethods = $this->getMethods();
132
+ foreach ($activePaymentMethods as $activePaymentMethod) {
133
+ if (in_array($activePaymentMethod->getCode(), $thirdPartyMethods)) {
134
+ $renderMethods[$activePaymentMethod->getCode()] = $activePaymentMethod->getTitle();
135
+ }
136
+ }
137
+ }
138
+ return json_encode($renderMethods);
139
+ }
140
+
141
+ /**
142
+ * Check payment method model
143
+ *
144
+ * @param Mage_Payment_Model_Method_Abstract $method
145
+ * @return bool
146
+ */
147
+ protected function _canUseNewMethod($method)
148
+ {
149
+ return $method->isApplicableToQuote(
150
+ $this->getQuote(),
151
+ self::CHECK_USE_FOR_COUNTRY | self::CHECK_USE_FOR_CURRENCY | self::CHECK_ORDER_TOTAL_MIN_MAX
152
+ );
153
+ }
154
+
155
+ /**
156
+ * Retrieve available payment methods
157
+ *
158
+ * with versionswitch
159
+ *
160
+ * @return array
161
+ */
162
+ public function getMethods()
163
+ {
164
+ $methods = $this->getData('methods');
165
+ if ($methods === null) {
166
+ if (version_compare(Mage::getVersion(), '1.8.0', '>=')) {
167
+ $methods = $this->getNewMethods();
168
+ } else {
169
+ $methods = $this->getOldMethods();
170
+ }
171
+ $this->setData('methods', $methods);
172
+ }
173
+ return $methods;
174
+ }
175
+
176
+ /**
177
+ * Returns all payment methods which are allowed for current quote
178
+ *
179
+ * Magento > 1.8.0
180
+ *
181
+ * @return array
182
+ */
183
+ public function getNewMethods()
184
+ {
185
+ $quote = $this->getQuote();
186
+ $store = $quote ? $quote->getStoreId() : null;
187
+ $methods = array();
188
+ foreach (Mage::helper('payment')->getStoreMethods($store, $quote) as $method) {
189
+ if ($method->getCode() == self::IWAYS_PAYPALPLUS_PAYMENT) {
190
+ continue;
191
+ }
192
+ if ($this->_canUseNewMethod($method)
193
+ && $method->isApplicableToQuote($quote, Mage_Payment_Model_Method_Abstract::CHECK_ZERO_TOTAL)
194
+ ) {
195
+ $methods[] = $method;
196
+ }
197
+ }
198
+ return $methods;
199
+ }
200
+
201
+ /**
202
+ * Returns all payment methods which are allowed for current quote
203
+ *
204
+ * Magento < 1.8.0
205
+ *
206
+ * @return array
207
+ */
208
+ public function getOldMethods()
209
+ {
210
+ $quote = $this->getQuote();
211
+ $store = $quote ? $quote->getStoreId() : null;
212
+ $methods = Mage::helper('payment')->getStoreMethods($store, $quote);
213
+ $total = $quote->getBaseSubtotal() + $quote->getShippingAddress()->getBaseShippingAmount();
214
+ foreach ($methods as $key => $method) {
215
+ if (!$this->_canUseOldMethod($method) && !($total != 0 || $method->getCode()
216
+ == 'free' || ($quote->hasRecurringItems() && $method->canManageRecurringProfiles()))
217
+ ) {
218
+ unset($methods[$key]);
219
+ }
220
+ }
221
+ return $methods;
222
+ }
223
+
224
+ /**
225
+ * Check payment method model
226
+ *
227
+ * Magento < 1.8.0
228
+ *
229
+ * @param Mage_Payment_Model_Method_Abstract $method
230
+ * @return bool
231
+ */
232
+ protected function _canUseOldMethod($method)
233
+ {
234
+ if (!$method->canUseForCountry($this->getQuote()->getBillingAddress()->getCountry())) {
235
+ return false;
236
+ }
237
+
238
+ if (!$method->canUseForCurrency($this->getQuote()->getStore()->getBaseCurrencyCode())) {
239
+ return false;
240
+ }
241
+
242
+ /**
243
+ * Checking for min/max order total for assigned payment method
244
+ */
245
+ $total = $this->getQuote()->getBaseGrandTotal();
246
+ $minTotal = $method->getConfigData('min_order_total');
247
+ $maxTotal = $method->getConfigData('max_order_total');
248
+
249
+ if ((!empty($minTotal) && ($total < $minTotal)) || (!empty($maxTotal) && ($total
250
+ > $maxTotal))
251
+ ) {
252
+ return false;
253
+ }
254
+ return true;
255
+ }
256
+
257
+ /**
258
+ * Get frontend language
259
+ *
260
+ * @return string
261
+ */
262
+ public function getLanguage()
263
+ {
264
+ return Mage::getStoreConfig('general/locale/code');
265
+ }
266
+
267
+ /**
268
+ * Get country for current quote
269
+ *
270
+ * @return string
271
+ */
272
+ public function getCountryId()
273
+ {
274
+ $billingAddress = Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress();
275
+ if ($billingAddress) {
276
+ $countryId = $billingAddress->getCountryId();
277
+ } else {
278
+ $countryId = Mage::helper('iways_paypalplus')->getDefaultCountryId();
279
+ }
280
+ return $countryId;
281
+ }
282
+
283
+ /**
284
+ * Return quote for current customer.
285
+ *
286
+ * @return Mage_Sales_Model_Quote
287
+ */
288
+ public function getQuote()
289
+ {
290
+ return Mage::getSingleton('checkout/session')->getQuote();
291
+ }
292
+
293
+ /**
294
+ * Return Magento checkout url
295
+ *
296
+ * @return string
297
+ */
298
+ public function getCheckoutUrl()
299
+ {
300
+ return Mage::helper('checkout/url')->getCheckoutUrl();
301
+ }
302
+
303
+ /**
304
+ * Checks if pui should be forced in sandbox mode
305
+ *
306
+ * @return mixed
307
+ */
308
+ public function isPuiSandboxMode()
309
+ {
310
+ return Mage::getStoreConfig('iways_paypalplus/dev/pui_sandbox');
311
+ }
312
+
313
+ /**
314
+ * Should show loading indicator?
315
+ * @return mixed
316
+ */
317
+ public function showLoadingIndicator()
318
+ {
319
+ return Mage::getStoreConfig('payment/iways_paypalplus_payment/show_loading_indicator');
320
+ }
321
+
322
+ /**
323
+ * Get current PayPal payment id
324
+ *
325
+ * @return mixed
326
+ */
327
+ public function getPayPalPaymentId() {
328
+ return Mage::getSingleton('customer/session')->getPayPalPaymentId();
329
+ }
330
+
331
+ }
app/code/community/Iways/PayPalPlus/Block/Payment/Info.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com and you will be sent a copy immediately.
13
+ *
14
+ * Created on 02.03.2015
15
+ * Author Robert Hillebrand - hillebrand@i-ways.de - i-ways sales solutions GmbH
16
+ * Copyright i-ways sales solutions GmbH © 2015. All Rights Reserved.
17
+ * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ *
19
+ */
20
+
21
+ /**
22
+ * Iways PayPalPlus Payment Block
23
+ *
24
+ * @category Iways
25
+ * @package Iways_PayPalPlus
26
+ * @author robert
27
+ */
28
+ class Iways_PayPalPlus_Block_Payment_Info extends Mage_Payment_Block_Info
29
+ {
30
+
31
+ /**
32
+ * Set PayPal Plus template in construct
33
+ */
34
+ protected function _construct()
35
+ {
36
+ parent::_construct();
37
+ $this->setTemplate('paypalplus/payment/info.phtml');
38
+ }
39
+
40
+ /**
41
+ * Render as PDF
42
+ * @return string
43
+ */
44
+ public function toPdf()
45
+ {
46
+ $this->setTemplate('paypalplus/payment/pdf/info.phtml');
47
+ return $this->toHtml();
48
+ }
49
+
50
+ /**
51
+ * Prepare information specific to current payment method
52
+ *
53
+ * @param Varien_Object|array $transport
54
+ * @return Varien_Object
55
+ */
56
+ protected function _prepareSpecificInformation($transport = null)
57
+ {
58
+ $transport = parent::_prepareSpecificInformation($transport);
59
+ $payment = $this->getInfo();
60
+ $info = array();
61
+
62
+ if (!$this->getIsSecureMode()) {
63
+ $info[Mage::helper('iways_paypalplus')->__('Transaction ID')] = $this->getInfo()->getLastTransId();
64
+ }
65
+
66
+ if($this->isPUI()) {
67
+ $info[Mage::helper('iways_paypalplus')->__('Account holder')] = $payment->getData('ppp_pui_account_holder_name');
68
+ $info[Mage::helper('iways_paypalplus')->__('Bank')] = $payment->getData('ppp_pui_bank_name');
69
+ $info[Mage::helper('iways_paypalplus')->__('IBAN')] = $payment->getData('ppp_pui_international_bank_account_number');
70
+ $info[Mage::helper('iways_paypalplus')->__('BIC')] = $payment->getData('ppp_pui_bank_identifier_code');
71
+ $info[Mage::helper('iways_paypalplus')->__('Reference number')] = $payment->getData('ppp_pui_reference_number');
72
+ $info[Mage::helper('iways_paypalplus')->__('Payment due date')] = $payment->getData('ppp_pui_payment_due_date');
73
+ }
74
+ return $transport->addData($info);
75
+ }
76
+
77
+ /**
78
+ * Checks if PayPal Plus payment is PUI
79
+ *
80
+ * @return bool
81
+ */
82
+ public function isPUI()
83
+ {
84
+ return ($this->getInfo()->getData('ppp_pui_instruction_type') == Iways_PayPalPlus_Model_Payment::PPP_PUI_INSTRUCTION_TYPE) ? true : false;
85
+ }
86
+ }
app/code/community/Iways/PayPalPlus/Helper/Data.php ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com and you will be sent a copy immediately.
13
+ *
14
+ * Created on 02.03.2015
15
+ * Author Robert Hillebrand - hillebrand@i-ways.de - i-ways sales solutions GmbH
16
+ * Copyright i-ways sales solutions GmbH © 2015. All Rights Reserved.
17
+ * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ *
19
+ */
20
+
21
+ /**
22
+ * Iways PayPalPlus Helper
23
+ *
24
+ * @category Iways
25
+ * @package Iways_PayPalPlus
26
+ * @author robert
27
+ */
28
+ class Iways_PayPalPlus_Helper_Data extends Mage_Payment_Helper_Data
29
+ {
30
+
31
+ /**
32
+ * Show Exception if debug mode.
33
+ *
34
+ * @param Exception $e
35
+ */
36
+ public function handleException(Exception $e)
37
+ {
38
+ if (Mage::getStoreConfig('iways_paypalplus/dev/debug')) {
39
+ Mage::getSingleton('core/session')->addWarning($e->getData());
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Build webhook listener url
45
+ *
46
+ * @return string
47
+ */
48
+ public function getWebhooksUrl()
49
+ {
50
+ return str_replace(
51
+ 'http://',
52
+ 'https://',
53
+ Mage::getUrl(
54
+ 'paypalplus/index/webhooks',
55
+ array(
56
+ '_forced_secure' => true,
57
+ '_nosid' => true,
58
+ '_store' => Mage::app()->getDefaultStoreView()->getCode()
59
+ )
60
+ )
61
+ );
62
+ }
63
+
64
+
65
+ /**
66
+ * Get url wrapper for security urls and form key
67
+ *
68
+ * @param $url
69
+ * @param array $params
70
+ * @param bool|true $formKey
71
+ * @return string
72
+ */
73
+ public function getUrl($url, $params = array(), $formKey = true)
74
+ {
75
+ $isSecure = Mage::app()->getRequest()->isSecure();
76
+ if ($isSecure) {
77
+ $params['_forced_secure'] = true;
78
+ } else {
79
+ $params['_secure'] = true;
80
+ }
81
+ if ($formKey) {
82
+ $params['form_key'] = Mage::getSingleton('core/session')->getFormKey();
83
+ }
84
+ return Mage::getUrl($url, $params);
85
+ }
86
+
87
+ /**
88
+ * Get deafult country id for different supported checkouts
89
+ *
90
+ * @return mixed
91
+ */
92
+ public function getDefaultCountryId()
93
+ {
94
+ if ($this->isFirecheckout()) {
95
+ return Mage::getStoreConfig('firecheckout/general/country');
96
+ }
97
+ if ($this->isMagestoreOsc()) {
98
+ return Mage::getStoreConfig('onestepcheckout/general/country_id');
99
+ }
100
+ if ($this->isIdevOsc()) {
101
+ return Mage::getStoreConfig('onestepcheckout/general/default_country');
102
+ }
103
+ return Mage::getStoreConfig('payment/account/merchant_country');
104
+ }
105
+
106
+ /**
107
+ * Helper for saving store configuration programmatically
108
+ *
109
+ * @param $key
110
+ * @param $value
111
+ * @return boolean
112
+ */
113
+ public function saveStoreConfig($key, $value)
114
+ {
115
+ Mage::getModel('core/config')->saveConfig(
116
+ $key,
117
+ $value,
118
+ 'stores',
119
+ Mage::app()->getStore()->getId()
120
+ );
121
+ Mage::app()->getCacheInstance()->cleanType('config');
122
+ return true;
123
+ }
124
+
125
+ /**
126
+ * Request payment experience from PayPal for current quote.
127
+ *
128
+ * @return string
129
+ */
130
+ public function getPaymentExperience()
131
+ {
132
+ if (Mage::getStoreConfig('payment/iways_paypalplus_payment/active')) {
133
+ return Mage::getModel('iways_paypalplus/api')->getPaymentExperience();
134
+ }
135
+ return false;
136
+ }
137
+
138
+ /**
139
+ * Check if Idev_OneStepCheckout is enabled and active
140
+ *
141
+ * @return bool
142
+ */
143
+ public function isIdevOsc()
144
+ {
145
+ return (
146
+ Mage::helper('core')->isModuleEnabled('Idev_OneStepCheckout')
147
+ && Mage::getStoreConfig('onestepcheckout/general/rewrite_checkout_links')
148
+ );
149
+ }
150
+
151
+ /**
152
+ * Checks if TM_Firecheckout is enabled and active
153
+ *
154
+ * @return bool
155
+ */
156
+ public function isFirecheckout()
157
+ {
158
+ return (
159
+ Mage::helper('core')->isModuleEnabled('TM_FireCheckout')
160
+ && Mage::getStoreConfig('firecheckout/general/enabled')
161
+ );
162
+ }
163
+
164
+ /**
165
+ * Checks if Magestore_Onestepcheckout is enabled and active
166
+ *
167
+ * @return bool
168
+ */
169
+ public function isMagestoreOsc()
170
+ {
171
+ return (
172
+ Mage::helper('core')->isModuleEnabled('Magestore_Onestepcheckout')
173
+ && Mage::getStoreConfig('onestepcheckout/general/active')
174
+ );
175
+ }
176
+
177
+ /**
178
+ * Checks if Iwd_Onestepcheckout is enabled and active
179
+ *
180
+ * @return bool
181
+ */
182
+ public function isIwdOsc()
183
+ {
184
+ return (
185
+ Mage::helper('core')->isModuleEnabled('IWD_Opc')
186
+ && Mage::getStoreConfig('opc/global/status')
187
+ );
188
+ }
189
+
190
+ /**
191
+ * Convert due date
192
+ *
193
+ * @param $date
194
+ * @return string
195
+ */
196
+ public function convertDueDate($date)
197
+ {
198
+ $dateArray = explode('-', $date);
199
+ $dateArray = array_reverse($dateArray);
200
+ return implode('.', $dateArray);
201
+ }
202
+ }
app/code/community/Iways/PayPalPlus/Model/Api.php ADDED
@@ -0,0 +1,775 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com and you will be sent a copy immediately.
14
+ *
15
+ * Created on 02.03.2015
16
+ * Author Robert Hillebrand - hillebrand@i-ways.de - i-ways sales solutions GmbH
17
+ * Copyright i-ways sales solutions GmbH © 2015. All Rights Reserved.
18
+ * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ *
20
+ */
21
+ use PayPal\Rest\ApiContext;
22
+ use PayPal\Auth\OAuthTokenCredential;
23
+ use PayPal\Api\Address;
24
+ use PayPal\Api\WebProfile;
25
+ use PayPal\Api\Presentation;
26
+ use PayPal\Api\Payment;
27
+ use PayPal\Api\Amount;
28
+ use PayPal\Api\Details;
29
+ use PayPal\Api\InputFields;
30
+ use PayPal\Api\Item;
31
+ use PayPal\Api\ItemList;
32
+ use PayPal\Api\Payer;
33
+ use PayPal\Api\RedirectUrls;
34
+ use PayPal\Api\Transaction;
35
+ use PayPal\Api\PayerInfo;
36
+ use PayPal\Api\ShippingAddress;
37
+ use PayPal\Api\PatchRequest;
38
+ use PayPal\Api\Patch;
39
+ use PayPal\Api\PaymentExecution;
40
+
41
+ /**
42
+ * Iways PayPal Rest Api wrapper
43
+ *
44
+ * @category Iways
45
+ * @package Iways_PayPalPlus
46
+ * @author robert
47
+ */
48
+ class Iways_PayPalPlus_Model_Api
49
+ {
50
+ /**
51
+ * Webhook url already exists error code
52
+ */
53
+ const WEBHOOK_URL_ALREADY_EXISTS = 'WEBHOOK_URL_ALREADY_EXISTS';
54
+
55
+ const PATCH_ADD = 'add';
56
+ const PATCH_REPLACE = 'replace';
57
+
58
+ /**
59
+ * @var null|ApiContext
60
+ */
61
+ protected $_apiContext = null;
62
+
63
+ /**
64
+ * @var mixed|null
65
+ */
66
+ protected $_mode = null;
67
+
68
+ /**
69
+ * Prepare PayPal REST SDK ApiContent
70
+ */
71
+ public function __construct()
72
+ {
73
+ $this->setApiContext(null);
74
+ }
75
+
76
+ /**
77
+ * Set api context
78
+ *
79
+ * @param $website
80
+ * @return $this
81
+ */
82
+ public function setApiContext($website = null)
83
+ {
84
+ $this->_apiContext = new ApiContext(
85
+ new OAuthTokenCredential(
86
+ Mage::getStoreConfig('iways_paypalplus/api/client_id', $website),
87
+ Mage::getStoreConfig('iways_paypalplus/api/client_secret', $website)
88
+ )
89
+ );
90
+
91
+ $this->_mode = Mage::getStoreConfig('iways_paypalplus/api/mode', $website);
92
+ $this->_apiContext->setConfig(
93
+ array(
94
+ 'http.ConnectionTimeOut' => 30,
95
+ 'http.Retry' => 1,
96
+ 'mode' => $this->_mode,
97
+ 'log.LogEnabled' => Mage::getStoreConfig('dev/log/active', $website),
98
+ 'log.FileName' => Mage::getBaseDir('log') . DS . 'PayPal.log',
99
+ 'log.LogLevel' => 'INFO'
100
+ )
101
+ );
102
+ $this->_apiContext->addRequestHeader('PayPal-Partner-Attribution-Id', 'Magento_Cart_PayPalPlus');
103
+ return $this;
104
+ }
105
+
106
+ /**
107
+ * Get ApprovalLink for curretn Quote
108
+ *
109
+ * @return string
110
+ */
111
+ public function getPaymentExperience()
112
+ {
113
+ $paymentExperience = Mage::registry('payment_experience');
114
+ if ($paymentExperience === null) {
115
+ $webProfile = $this->buildWebProfile();
116
+ if ($webProfile) {
117
+ $payment = $this->createPayment($webProfile, $this->getQuote());
118
+ $paymentExperience = $payment ? $payment->getApprovalLink() : false;
119
+ } else {
120
+ $paymentExperience = false;
121
+ }
122
+ Mage::register('payment_experience', $paymentExperience);
123
+ }
124
+ return $paymentExperience;
125
+ }
126
+
127
+ /**
128
+ * Get a payment
129
+ *
130
+ * @param string $paymentId
131
+ * @return Payment
132
+ */
133
+ public function getPayment($paymentId)
134
+ {
135
+ return Payment::get($paymentId, $this->_apiContext);
136
+ }
137
+
138
+ /**
139
+ * Create payment for curretn quote
140
+ *
141
+ * @param WebProfile $webProfile
142
+ * @param Mage_Sales_Model_Quote $quote
143
+ * @return boolean
144
+ */
145
+ public function createPayment($webProfile, $quote, $taxFailure = false)
146
+ {
147
+ $payer = $this->buildPayer($quote);
148
+
149
+ $itemList = $this->buildItemList($quote, $taxFailure);
150
+ $shippingAddress = $this->buildShippingAddress($quote);
151
+ if ($shippingAddress) {
152
+ $itemList->setShippingAddress($shippingAddress);
153
+ }
154
+
155
+ $amount = $this->buildAmount($quote);
156
+
157
+ $transaction = new Transaction();
158
+ $transaction->setAmount($amount);
159
+ $transaction->setItemList($itemList);
160
+
161
+ $baseUrl = Mage::getBaseUrl();
162
+ $redirectUrls = new RedirectUrls();
163
+ $redirectUrls->setReturnUrl($baseUrl . 'paypalplus/index/success')
164
+ ->setCancelUrl(Mage::helper('checkout/url')->getCheckoutUrl());
165
+
166
+ $payment = new Payment();
167
+ $payment->setIntent("sale")
168
+ ->setExperienceProfileId($webProfile->getId())
169
+ ->setPayer($payer)
170
+ ->setRedirectUrls($redirectUrls)
171
+ ->setTransactions(array($transaction));
172
+
173
+ try {
174
+ $response = $payment->create($this->_apiContext);
175
+ Mage::getSingleton('customer/session')->setPayPalPaymentId($response->getId());
176
+ Mage::getSingleton('customer/session')->setPayPalPaymentPatched(null);
177
+ } catch (PayPal\Exception\PayPalConnectionException $ex) {
178
+ if (!$taxFailure) {
179
+ return $this->createPayment($webProfile, $quote, true);
180
+ }
181
+ Mage::helper('iways_paypalplus')->handleException($ex);
182
+ return false;
183
+ } catch (Exception $e) {
184
+ Mage::logException($e);
185
+ return false;
186
+ }
187
+ return $response;
188
+ }
189
+
190
+ /**
191
+ * Adding shipping address to an existing payment.
192
+ *
193
+ * @param Mage_Sales_Model_Quote $quote
194
+ * @return boolean
195
+ */
196
+ public function patchPayment($quote)
197
+ {
198
+ if (Mage::getSingleton('customer/session')->getPayPalPaymentId()) {
199
+ $payment = Payment::get(Mage::getSingleton('customer/session')->getPayPalPaymentId(), $this->_apiContext);
200
+ $patchRequest = new PatchRequest();
201
+
202
+ $transactions = $payment->getTransactions();
203
+ if ($transactions[0]->getItemList()->getShippingAddress() === null) {
204
+ $addressMode = self::PATCH_ADD;
205
+ } else {
206
+ $addressMode = self::PATCH_REPLACE;
207
+ }
208
+ $shippingAddress = $this->buildShippingAddress($quote);
209
+ $addressPatch = new Patch();
210
+ $addressPatch->setOp($addressMode);
211
+ $addressPatch->setPath('/transactions/0/item_list/shipping_address');
212
+ $addressPatch->setValue($shippingAddress);
213
+ $patchRequest->addPatch($addressPatch);
214
+
215
+ $payerInfo = $this->buildBillingAddress($quote);
216
+ $payerInfoPatch = new Patch();
217
+ $payerInfoPatch->setOp(self::PATCH_ADD);
218
+ $payerInfoPatch->setPath('/potential_payer_info/billing_address');
219
+ $payerInfoPatch->setValue($payerInfo);
220
+ $patchRequest->addPatch($payerInfoPatch);
221
+
222
+ $amount = $this->buildAmount($quote);
223
+ $amountPatch = new Patch();
224
+ $amountPatch->setOp(self::PATCH_REPLACE);
225
+ $amountPatch->setPath('/transactions/0/amount');
226
+ $amountPatch->setValue($amount);
227
+ $patchRequest->addPatch($amountPatch);
228
+
229
+ $response = $payment->update(
230
+ $patchRequest,
231
+ $this->_apiContext
232
+ );
233
+
234
+ return $response;
235
+ }
236
+ return false;
237
+ }
238
+
239
+
240
+ /**
241
+ * Patches invoice number to PayPal transaction
242
+ * (Magento order increment id)
243
+ *
244
+ * @param $paymentId
245
+ * @param $invoiceNumber
246
+ * @return bool
247
+ */
248
+ public function patchInvoiceNumber($paymentId, $invoiceNumber)
249
+ {
250
+ $payment = Payment::get($paymentId, $this->_apiContext);
251
+
252
+ $patchRequest = new PatchRequest();
253
+
254
+ $invoiceNumberPatch = new Patch();
255
+ $invoiceNumberPatch->setOp('add');
256
+ $invoiceNumberPatch->setPath('/transactions/0/invoice_number');
257
+ $invoiceNumberPatch->setValue($invoiceNumber);
258
+ $patchRequest->addPatch($invoiceNumberPatch);
259
+
260
+ $response = $payment->update($patchRequest,
261
+ $this->_apiContext);
262
+
263
+ return $response;
264
+ }
265
+
266
+ /**
267
+ * Execute an existing payment
268
+ *
269
+ * @param string $paymentId
270
+ * @param string $payerId
271
+ * @return boolean
272
+ */
273
+ public function executePayment($paymentId, $payerId)
274
+ {
275
+ try {
276
+ $payment = $this->getPayment($paymentId);
277
+ $paymentExecution = new PaymentExecution();
278
+ $paymentExecution->setPayerId($payerId);
279
+ return $payment->execute($paymentExecution, $this->_apiContext);
280
+ } catch (PayPal\Exception\PayPalConnectionException $ex) {
281
+ Mage::helper('iways_paypalplus')->handleException($ex);
282
+ return false;
283
+ } catch (Exception $e) {
284
+ Mage::logException($e);
285
+ return false;
286
+ }
287
+ return false;
288
+ }
289
+
290
+ /**
291
+ * Refund a payment
292
+ *
293
+ * @param type $paymentId
294
+ * @param type $amount
295
+ * @return type
296
+ */
297
+ public function refundPayment($paymentId, $amount)
298
+ {
299
+ $transactions = $this->getPayment($paymentId)->getTransactions();
300
+ $relatedResources = $transactions[0]->getRelatedResources();
301
+ $sale = $relatedResources[0]->getSale();
302
+ $refund = new \PayPal\Api\Refund();
303
+
304
+ $ppAmount = new Amount();
305
+ $ppAmount->setCurrency(Mage::app()->getStore()->getCurrentCurrencyCode())->setTotal($amount);
306
+ $refund->setAmount($ppAmount);
307
+
308
+ return $sale->refund($refund, $this->_apiContext);
309
+ }
310
+
311
+ /**
312
+ * Get a list of all registrated webhooks for $this->_apiContext
313
+ *
314
+ * @return bool|\PayPal\Api\WebhookList
315
+ */
316
+ public function getWebhooks()
317
+ {
318
+ $webhooks = new \PayPal\Api\Webhook();
319
+ try {
320
+ return $webhooks->getAll($this->_apiContext);
321
+ } catch (PayPal\Exception\PayPalConnectionException $ex) {
322
+ Mage::helper('iways_paypalplus')->handleException($ex);
323
+ return false;
324
+ } catch (Exception $e) {
325
+ Mage::logException($e);
326
+ return false;
327
+ }
328
+ return false;
329
+ }
330
+
331
+ /**
332
+ * Retrive an webhook event
333
+ *
334
+ * @param $webhookEventId
335
+ * @return bool|\PayPal\Api\WebhookEvent
336
+ */
337
+ public function getWebhookEvent($webhookEventId)
338
+ {
339
+ try {
340
+ $webhookEvent = new \PayPal\Api\WebhookEvent();
341
+ return $webhookEvent->get($webhookEventId, $this->_apiContext);
342
+ } catch (PayPal\Exception\PayPalConnectionException $ex) {
343
+ Mage::helper('iways_paypalplus')->handleException($ex);
344
+ return false;
345
+ } catch (Exception $e) {
346
+ Mage::logException($e);
347
+ return false;
348
+ }
349
+ return false;
350
+ }
351
+
352
+ /**
353
+ * Get a list of all available event types
354
+ *
355
+ * @return bool|\PayPal\Api\WebhookEventTypeList
356
+ */
357
+ public function getWebhooksEventTypes()
358
+ {
359
+ $webhookEventType = new \PayPal\Api\WebhookEventType();
360
+ try {
361
+ return $webhookEventType->availableEventTypes($this->_apiContext);
362
+ } catch (PayPal\Exception\PayPalConnectionException $ex) {
363
+ Mage::helper('iways_paypalplus')->handleException($ex);
364
+ return false;
365
+ } catch (Exception $e) {
366
+ Mage::logException($e);
367
+ return false;
368
+ }
369
+ return false;
370
+ }
371
+
372
+ /**
373
+ * Creates a webhook
374
+ *
375
+ * @return bool|\PayPal\Api\Webhook
376
+ */
377
+ public function createWebhook()
378
+ {
379
+ $webhook = new \PayPal\Api\Webhook();
380
+ $webhook->setUrl(Mage::helper('iways_paypalplus')->getWebhooksUrl());
381
+ $webhookEventTypes = array();
382
+ foreach (Mage::getModel('iways_paypalplus/webhook_event')->getSupportedWebhookEvents() as $webhookEvent) {
383
+ $webhookEventType = new \PayPal\Api\WebhookEventType();
384
+ $webhookEventType->setName($webhookEvent);
385
+ $webhookEventTypes[] = $webhookEventType;
386
+ }
387
+ $webhook->setEventTypes($webhookEventTypes);
388
+ try {
389
+ $webhookData = $webhook->create($this->_apiContext);
390
+ $this->saveWebhookId($webhookData->getId());
391
+ return $webhookData;
392
+ } catch (PayPal\Exception\PayPalConnectionException $ex) {
393
+ if ($ex->getData()) {
394
+ $data = Mage::helper('core')->jsonDecode($ex->getData());
395
+ if (isset($data['name']) && $data['name'] == self::WEBHOOK_URL_ALREADY_EXISTS) {
396
+ return true;
397
+ }
398
+ }
399
+ Mage::helper('iways_paypalplus')->handleException($ex);
400
+ return false;
401
+ } catch (Exception $e) {
402
+ Mage::logException($e);
403
+ return false;
404
+ }
405
+ return false;
406
+ }
407
+
408
+ /**
409
+ * Delete webhook with webhookId for PayPal APP $this->_apiContext
410
+ *
411
+ * @param $webhookId
412
+ * @return bool
413
+ */
414
+ public function deleteWebhook($webhookId)
415
+ {
416
+ $webhook = new \PayPal\Api\Webhook();
417
+ $webhook->setId($webhookId);
418
+ try {
419
+ return $webhook->delete($this->_apiContext);
420
+ } catch (PayPal\Exception\PayPalConnectionException $ex) {
421
+ Mage::helper('iways_paypalplus')->handleException($ex);
422
+ return false;
423
+ } catch (Exception $e) {
424
+ Mage::logException($e);
425
+ return false;
426
+ }
427
+ return false;
428
+ }
429
+
430
+ /**
431
+ * Validate WebhookEvent
432
+ *
433
+ * @param $rawBody Raw request string
434
+ * @return bool|\PayPal\Api\WebhookEvent
435
+ */
436
+ public function validateWebhook($rawBody)
437
+ {
438
+ try {
439
+ $webhookEvent = new \PayPal\Api\WebhookEvent();
440
+ return $webhookEvent->validateAndGetReceivedEvent($rawBody, $this->_apiContext);
441
+ } catch (Exception $ex) {
442
+ Mage::logException($ex);
443
+ return false;
444
+ }
445
+ }
446
+
447
+
448
+ /**
449
+ * Build ShippingAddress from quote
450
+ *
451
+ * @param Mage_Sales_Model_Quote $quote
452
+ * @return ShippingAddress
453
+ */
454
+ protected function buildShippingAddress($quote)
455
+ {
456
+ $address = $quote->getShippingAddress();
457
+ $addressCheckerArray = array(
458
+ 'setRecipientName' => $this->buildFullName($address),
459
+ 'setLine1' => implode(' ', $address->getStreet()),
460
+ 'setCity' => $address->getCity(),
461
+ 'setCountryCode' => $address->getCountryId(),
462
+ 'setPostalCode' => $address->getPostcode(),
463
+ 'setState' => $address->getRegion(),
464
+ );
465
+ $allowedEmpty = array('setPhone', 'setState');
466
+ $shippingAddress = new ShippingAddress();
467
+ foreach ($addressCheckerArray as $setter => $value) {
468
+ if (empty($value) && !in_array($setter, $allowedEmpty)) {
469
+ return false;
470
+ }
471
+ $shippingAddress->{$setter}($value);
472
+ }
473
+ return $shippingAddress;
474
+ }
475
+
476
+ /**
477
+ * Build BillingAddress from quote
478
+ *
479
+ * @param Mage_Sales_Model_Quote $quote
480
+ * @return ShippingAddress
481
+ */
482
+ protected function buildBillingAddress($quote)
483
+ {
484
+ $address = $quote->getBillingAddress();
485
+ $addressCheckerArray = array(
486
+ 'setLine1' => implode(' ', $address->getStreet()),
487
+ 'setCity' => $address->getCity(),
488
+ 'setCountryCode' => $address->getCountryId(),
489
+ 'setPostalCode' => $address->getPostcode(),
490
+ 'setState' => $address->getRegion(),
491
+ );
492
+ $allowedEmpty = array('setPhone', 'setState');
493
+ $billingAddress = new Address();
494
+ foreach ($addressCheckerArray as $setter => $value) {
495
+ if (empty($value) && !in_array($setter, $allowedEmpty)) {
496
+ return false;
497
+ }
498
+ $billingAddress->{$setter}($value);
499
+ }
500
+
501
+ return $billingAddress;
502
+ }
503
+
504
+ /**
505
+ * Build Payer for payment
506
+ *
507
+ * @param $quote
508
+ * @return Payer
509
+ */
510
+ protected function buildPayer($quote)
511
+ {
512
+ $payer = new Payer();
513
+ $payer->setPaymentMethod("paypal");
514
+ $payerInfo = $this->buildPayerInfo($quote);
515
+ if ($payerInfo) {
516
+ $payer->setPayerInfo($payerInfo);
517
+ }
518
+ return $payer;
519
+ }
520
+
521
+ /**
522
+ * Build PayerInfo for Payer
523
+ *
524
+ * @param $quote
525
+ * @return PayerInfo
526
+ */
527
+ protected function buildPayerInfo($quote)
528
+ {
529
+ $payerInfo = new PayerInfo();
530
+ $address = $quote->getBillingAddress();
531
+ if ($address->getFirstname()) {
532
+ $payerInfo->setFirstName($address->getFirstname());
533
+ }
534
+ if ($address->getMiddlename()) {
535
+ $payerInfo->setMiddleName($address->getMiddlename());
536
+ }
537
+ if ($address->getLastname()) {
538
+ $payerInfo->setLastName($address->getLastname());
539
+ }
540
+
541
+ $billingAddress = $this->buildBillingAddress($quote);
542
+ if ($billingAddress) {
543
+ $payerInfo->setBillingAddress($billingAddress);
544
+ }
545
+ return $payerInfo;
546
+ }
547
+
548
+ /**
549
+ * Get fullname from address
550
+ *
551
+ * @param Mage_Sales_Model_Quote_Address $address
552
+ * @return type
553
+ */
554
+ protected function buildFullName($address)
555
+ {
556
+ $name = array();
557
+ if ($address->getFirstname()) {
558
+ $name[] = $address->getFirstname();
559
+ }
560
+ if ($address->getMiddlename()) {
561
+ $name[] = $address->getMiddlename();
562
+ }
563
+ if ($address->getLastname()) {
564
+ $name[] = $address->getLastname();
565
+ }
566
+ return implode(' ', $name);
567
+ }
568
+
569
+ /**
570
+ * Build ItemList
571
+ *
572
+ * @param Mage_Sales_Model_Quote $quote
573
+ * @return ItemList
574
+ */
575
+ protected function buildItemList($quote, $taxFailure)
576
+ {
577
+ $itemArray = array();
578
+ $itemList = new ItemList();
579
+ $currencyCode = $quote->getBaseCurrencyCode();
580
+
581
+ if (!$taxFailure) {
582
+ foreach ($quote->getAllVisibleItems() as $quoteItem) {
583
+ $item = new Item();
584
+ if ($quoteItem->getQty() > 1) {
585
+ $item->setName($quoteItem->getName() . ' x' . $quoteItem->getQty());
586
+ } else {
587
+ $item->setName($quoteItem->getName());
588
+ }
589
+ $item
590
+ ->setSku($quoteItem->getSku())
591
+ ->setCurrency($currencyCode)
592
+ ->setQuantity(1)
593
+ ->setPrice($quoteItem->getBaseRowTotal());
594
+
595
+ $itemArray[] = $item;
596
+ }
597
+
598
+ $itemList->setItems($itemArray);
599
+ }
600
+ return $itemList;
601
+ }
602
+
603
+ /**
604
+ * Build Amount
605
+ *
606
+ * @param Mage_Sales_Model_Quote $quote
607
+ * @return Amount
608
+ */
609
+ protected function buildAmount($quote)
610
+ {
611
+ $details = new Details();
612
+ $details->setShipping($quote->getShippingAddress()->getBaseShippingAmount())
613
+ ->setTax($quote->getShippingAddress()->getBaseTaxAmount())
614
+ ->setSubtotal(
615
+ $quote->getBaseSubtotalWithDiscount() + $quote->getShippingAddress()->getBaseHiddenTaxAmount()
616
+ );
617
+
618
+ $amount = new Amount();
619
+ $amount->setCurrency($quote->getBaseCurrencyCode())
620
+ ->setDetails($details)
621
+ ->setTotal($quote->getBaseGrandTotal());
622
+
623
+ return $amount;
624
+ }
625
+
626
+
627
+ /**
628
+ * Build WebProfile
629
+ *
630
+ * @return boolean|WebProfile
631
+ */
632
+ protected function buildWebProfile()
633
+ {
634
+ $webProfile = new WebProfile();
635
+ if (Mage::getStoreConfig('iways_paypalplus/dev/web_profile_id')) {
636
+ $webProfile->setId(Mage::getStoreConfig('iways_paypalplus/dev/web_profile_id'));
637
+ return $webProfile;
638
+ }
639
+ try {
640
+ $webProfile->setName('magento_' . microtime());
641
+ $webProfile->setPresentation($this->buildWebProfilePresentation());
642
+ $inputFields = new InputFields();
643
+ $inputFields->setAddressOverride(1);
644
+ $webProfile->setInputFields($inputFields);
645
+ $response = $webProfile->create($this->_apiContext);
646
+ $this->saveWebProfileId($response->getId());
647
+ return $response;
648
+ } catch (\PayPal\Exception\PayPalConnectionException $ex) {
649
+ Mage::helper('iways_paypalplus')->handleException($ex);
650
+ }
651
+ return false;
652
+ }
653
+
654
+ /**
655
+ * Build presentation
656
+ *
657
+ * @return Presentation
658
+ */
659
+ protected function buildWebProfilePresentation()
660
+ {
661
+ $presentation = new Presentation();
662
+ $presentation->setBrandName(Mage::app()->getWebsite()->getName());
663
+ $presentation->setLogoImage($this->getHeaderImage());
664
+ $presentation->setLocaleCode(
665
+ substr(
666
+ Mage::getStoreConfig('general/locale/code'),
667
+ 3,
668
+ 2
669
+ )
670
+ );
671
+ return $presentation;
672
+ }
673
+
674
+ /**
675
+ * Get Header Logo for Web experience
676
+ *
677
+ * @return string
678
+ */
679
+ protected function getHeaderImage()
680
+ {
681
+ if (Mage::getStoreConfig('iways_paypalplus/api/hdrimg')) {
682
+ return Mage::getStoreConfig('iways_paypalplus/api/hdrimg');
683
+ }
684
+ return Mage::getDesign()->getSkinUrl(
685
+ Mage::getStoreConfig('design/header/logo_src'),
686
+ array('_secure' => true)
687
+ );
688
+ }
689
+
690
+ /**
691
+ * Reset web profile id
692
+ *
693
+ * @return type
694
+ */
695
+ public function resetWebProfileId()
696
+ {
697
+ foreach (Mage::app()->getStores() as $store) {
698
+ Mage::getModel('core/config')->saveConfig(
699
+ 'iways_paypalplus/dev/web_profile_id',
700
+ false,
701
+ 'stores',
702
+ $store->getId()
703
+ );
704
+ }
705
+ Mage::app()->getCacheInstance()->cleanType('config');
706
+ return true;
707
+ }
708
+
709
+ /**
710
+ * Save WebProfileId
711
+ *
712
+ * @param string $id
713
+ * @return boolean
714
+ */
715
+ protected function saveWebProfileId($id)
716
+ {
717
+ return Mage::helper('iways_paypalplus')->saveStoreConfig('iways_paypalplus/dev/web_profile_id', $id);
718
+ }
719
+
720
+ /**
721
+ * Save WebhookId
722
+ *
723
+ * @param string $id
724
+ * @return boolean
725
+ */
726
+ protected function saveWebhookId($id)
727
+ {
728
+ return Mage::helper('iways_paypalplus')->saveStoreConfig('iways_paypalplus/dev/webhook_id', $id);
729
+ }
730
+
731
+ /**
732
+ * Get current quote
733
+ *
734
+ * @return Mage_Sales_Model_Quote
735
+ */
736
+ protected function getQuote()
737
+ {
738
+ return Mage::getSingleton('checkout/type_onepage')->getQuote();
739
+ }
740
+
741
+ /**
742
+ * Get current customer
743
+ *
744
+ * @return Mage_Customer_Model_Customer
745
+ */
746
+ protected function getCustomer()
747
+ {
748
+ return Mage::helper('customer')->getCustomer();
749
+ }
750
+
751
+ /**
752
+ * Check if PayPal credentails are valid for given configuration.
753
+ *
754
+ * Uses WebProfile::get_list()
755
+ *
756
+ * @param $website
757
+ * @return bool
758
+ */
759
+ public function testCredentials($website)
760
+ {
761
+ try {
762
+ $this->setApiContext($website);
763
+ WebProfile::get_list($this->_apiContext);
764
+ return true;
765
+ } catch (PayPal\Exception\PayPalConnectionException $ex) {
766
+ Mage::getSingleton('adminhtml/session')->addError(
767
+ Mage::helper('iways_paypalplus')->__('Provided credentials not valid.')
768
+ );
769
+ return false;
770
+ } catch (Exception $e) {
771
+ Mage::logException($e);
772
+ return false;
773
+ }
774
+ }
775
+ }
app/code/community/Iways/PayPalPlus/Model/Api2/Order.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com and you will be sent a copy immediately.
13
+ *
14
+ * Created on 02.03.2015
15
+ * Author Robert Hillebrand - hillebrand@i-ways.de - i-ways sales solutions GmbH
16
+ * Copyright i-ways sales solutions GmbH © 2015. All Rights Reserved.
17
+ * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ *
19
+ */
20
+
21
+ /**
22
+ * Iways PayPalPlus Model Api2 Order
23
+ *
24
+ * @category Iways
25
+ * @package Iways_PayPalPlus
26
+ * @author robert
27
+ */
28
+ class Iways_PayPalPlus_Model_Api2_Order extends Mage_Sales_Model_Api2_Order
29
+ {
30
+ /**
31
+ * Add order payment method field to select
32
+ *
33
+ * @param Mage_Sales_Model_Resource_Order_Collection $collection
34
+ * @return Iways_PayPalPlus_Model_Api2_Order
35
+ */
36
+ protected function _addPaymentMethodInfo(Mage_Sales_Model_Resource_Order_Collection $collection)
37
+ {
38
+ $collection->getSelect()->joinLeft(
39
+ array('payment_method' => $collection->getTable('sales/order_payment')),
40
+ 'main_table.entity_id = payment_method.parent_id',
41
+ array(
42
+ 'payment_method' => 'payment_method.method',
43
+ 'ppp_pui_reference_number',
44
+ 'ppp_pui_instruction_type',
45
+ 'ppp_pui_payment_due_date',
46
+ 'ppp_pui_note',
47
+ 'ppp_pui_bank_name',
48
+ 'ppp_pui_account_holder_name',
49
+ 'ppp_pui_international_bank_account_number',
50
+ 'ppp_pui_bank_identifier_code',
51
+ 'ppp_pui_routing_number',
52
+ 'ppp_pui_amount',
53
+ 'ppp_pui_currency'
54
+ )
55
+ );
56
+
57
+ return $this;
58
+ }
59
+ }
app/code/community/Iways/PayPalPlus/Model/Api2/Order/Rest.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com and you will be sent a copy immediately.
13
+ *
14
+ * Created on 02.03.2015
15
+ * Author Robert Hillebrand - hillebrand@i-ways.de - i-ways sales solutions GmbH
16
+ * Copyright i-ways sales solutions GmbH © 2015. All Rights Reserved.
17
+ * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ *
19
+ */
20
+
21
+
22
+ /**
23
+ * Abstract API2 class for order item
24
+ *
25
+ * @category Mage
26
+ * @package Mage_Sales
27
+ * @author Magento Core Team <core@magentocommerce.com>
28
+ */
29
+ abstract class Iways_PayPalPlus_Model_Api2_Order_Rest extends Iways_PayPalPlus_Model_Api2_Order
30
+ {
31
+ /**
32
+ * Retrieve information about specified order item
33
+ *
34
+ * @throws Mage_Api2_Exception
35
+ * @return array
36
+ */
37
+ protected function _retrieve()
38
+ {
39
+ $orderId = $this->getRequest()->getParam('id');
40
+ $collection = $this->_getCollectionForSingleRetrieve($orderId);
41
+
42
+ if ($this->_isPaymentMethodAllowed()) {
43
+
44
+ $this->_addPaymentMethodInfo($collection);
45
+ }
46
+ if ($this->_isGiftMessageAllowed()) {
47
+ $this->_addGiftMessageInfo($collection);
48
+ }
49
+ $this->_addTaxInfo($collection);
50
+
51
+ $order = $collection->getItemById($orderId);
52
+
53
+ if (!$order) {
54
+ $this->_critical(self::RESOURCE_NOT_FOUND);
55
+ }
56
+ $orderData = $order->getData();
57
+
58
+ $addresses = $this->_getAddresses(array($orderId));
59
+ $items = $this->_getItems(array($orderId));
60
+ $comments = $this->_getComments(array($orderId));
61
+
62
+ if ($addresses) {
63
+ $orderData['addresses'] = $addresses[$orderId];
64
+ }
65
+ if ($items) {
66
+ $orderData['order_items'] = $items[$orderId];
67
+ }
68
+ if ($comments) {
69
+ $orderData['order_comments'] = $comments[$orderId];
70
+ }
71
+
72
+ return $orderData;
73
+ }
74
+ }
app/code/community/Iways/PayPalPlus/Model/Api2/Order/Rest/Admin/V1.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com and you will be sent a copy immediately.
13
+ *
14
+ * Created on 02.03.2015
15
+ * Author Robert Hillebrand - hillebrand@i-ways.de - i-ways sales solutions GmbH
16
+ * Copyright i-ways sales solutions GmbH © 2015. All Rights Reserved.
17
+ * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ *
19
+ */
20
+
21
+
22
+ /**
23
+ * API2 class for orders (admin)
24
+ *
25
+ * @category Iways
26
+ * @package Iways_PayPalPlus
27
+ * @author robert
28
+ */
29
+ class Iways_PayPalPlus_Model_Api2_Order_Rest_Admin_V1 extends Iways_PayPalPlus_Model_Api2_Order_Rest
30
+ {
31
+ }
app/code/community/Iways/PayPalPlus/Model/Api2/Order/Rest/Customer/V1.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com and you will be sent a copy immediately.
13
+ *
14
+ * Created on 02.03.2015
15
+ * Author Robert Hillebrand - hillebrand@i-ways.de - i-ways sales solutions GmbH
16
+ * Copyright i-ways sales solutions GmbH © 2015. All Rights Reserved.
17
+ * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ *
19
+ */
20
+
21
+
22
+ /**
23
+ * API2 class for orders (customer)
24
+ *
25
+ * @category Iways
26
+ * @package Iways_PayPalPlus
27
+ * @author robert
28
+ */
29
+ class Iways_PayPalPlus_Model_Api2_Order_Rest_Customer_V1 extends Iways_PayPalPlus_Model_Api2_Order_Rest
30
+ {
31
+ /**
32
+ * Retrieve collection instance for orders
33
+ *
34
+ * @return Mage_Sales_Model_Resource_Order_Collection
35
+ */
36
+ protected function _getCollectionForRetrieve()
37
+ {
38
+ return parent::_getCollectionForRetrieve()->addAttributeToFilter(
39
+ 'customer_id', array('eq' => $this->getApiUser()->getUserId())
40
+ );
41
+ }
42
+
43
+ /**
44
+ * Retrieve collection instance for single order
45
+ *
46
+ * @param int $orderId Order identifier
47
+ * @return Mage_Sales_Model_Resource_Order_Collection
48
+ */
49
+ protected function _getCollectionForSingleRetrieve($orderId)
50
+ {
51
+ return parent::_getCollectionForSingleRetrieve($orderId)->addAttributeToFilter(
52
+ 'customer_id', array('eq' => $this->getApiUser()->getUserId())
53
+ );
54
+ }
55
+
56
+ /**
57
+ * Prepare and return order comments collection
58
+ *
59
+ * @param array $orderIds Orders' identifiers
60
+ * @return Mage_Sales_Model_Resource_Order_Status_History_Collection|Object
61
+ */
62
+ protected function _getCommentsCollection(array $orderIds)
63
+ {
64
+ return parent::_getCommentsCollection($orderIds)->addFieldToFilter('is_visible_on_front', 1);
65
+ }
66
+ }
app/code/community/Iways/PayPalPlus/Model/Autoloader.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com and you will be sent a copy immediately.
13
+ *
14
+ * Created on 02.03.2015
15
+ * Author Robert Hillebrand - hillebrand@i-ways.de - i-ways sales solutions GmbH
16
+ * Copyright i-ways sales solutions GmbH © 2015. All Rights Reserved.
17
+ * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ *
19
+ */
20
+
21
+ /**
22
+ * Autoloader for namespaces
23
+ *
24
+ * @category Iways
25
+ * @package Iways_PayPalPlus
26
+ * @author robert
27
+ */
28
+ class Iways_PayPalPlus_Model_Autoloader
29
+ {
30
+ protected static $_registered = false;
31
+
32
+ /**
33
+ * Add autoloader
34
+ *
35
+ * @param Varien_Event_Observer $observer
36
+ * @return \Iways_PayPalPlus_Model_Autoloader
37
+ */
38
+ public function addAutoloader(Varien_Event_Observer $observer)
39
+ {
40
+ if (self::$_registered) {
41
+ return $this;
42
+ }
43
+ spl_autoload_register(array($this, 'autoload'), false, true);
44
+
45
+ self::$_registered = true;
46
+ return $this;
47
+ }
48
+
49
+ /**
50
+ * Autoload
51
+ *
52
+ * @param string $class
53
+ */
54
+ public function autoload($class)
55
+ {
56
+ $classFile = str_replace('\\', DS, $class) . '.php';
57
+ // Only include a namespaced class. This should leave the regular Magento autoloader alone
58
+ if (strpos($classFile, DS) !== false) {
59
+ include $classFile;
60
+ }
61
+ }
62
+ }
app/code/community/Iways/PayPalPlus/Model/Observer.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com and you will be sent a copy immediately.
13
+ *
14
+ * Created on 03.03.2015
15
+ * Author Robert Hillebrand - hillebrand@i-ways.de - i-ways sales solutions GmbH
16
+ * Copyright i-ways sales solutions GmbH © 2015. All Rights Reserved.
17
+ * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ *
19
+ */
20
+
21
+ /**
22
+ * Iways PayPalPlus Observer
23
+ *
24
+ * @category Iways
25
+ * @package Iways_PayPalPlus
26
+ * @author robert
27
+ */
28
+ class Iways_PayPalPlus_Model_Observer
29
+ {
30
+
31
+ /**
32
+ * Add shipping address if payment is iways_paypalplus_payment
33
+ *
34
+ * @param Varien_Event_Observer $observer
35
+ * @return Iways_PayPalPlus_Model_Observer
36
+ */
37
+ public function patchPayment(Varien_Event_Observer $observer)
38
+ {
39
+ try {
40
+ $quote = $observer->getEvent()->getQuote();
41
+ if (
42
+ !Mage::getSingleton('customer/session')->getPayPalPaymentPatched()
43
+ && $quote->getPayment()
44
+ && $quote->getPayment()->getMethodInstance()->getCode() == Iways_PayPalPlus_Model_Payment::METHOD_CODE
45
+ ) {
46
+ Mage::getModel('iways_paypalplus/api')->patchPayment($quote);
47
+ }
48
+ } catch (Exception $ex) {
49
+ if ($ex->getMessage() != 'The requested Payment Method is not available.') {
50
+ Mage::logException($ex);
51
+ }
52
+ }
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * Resets WebProfile ID on config save
58
+ * @param Varien_Event_Observer $observer
59
+ * @return \Iways_PayPalPlus_Model_Observer
60
+ */
61
+ public function resetWebProfile(Varien_Event_Observer $observer)
62
+ {
63
+ $this->validateCredentials($observer);
64
+ Mage::getModel('iways_paypalplus/api')->resetWebProfileId();
65
+ return $this;
66
+ }
67
+
68
+ /**
69
+ * Check Webhook
70
+ *
71
+ * @param Varien_Event_Observer $observer
72
+ */
73
+ public function checkWebhook(Varien_Event_Observer $observer)
74
+ {
75
+ $api = Mage::getModel('iways_paypalplus/api')->setApiContext($this->getDefaultStoreId($observer));
76
+ $webhook = $api->createWebhook();
77
+ if ($webhook === false) {
78
+ Mage::getSingleton('adminhtml/session')->addError(
79
+ Mage::helper('iways_paypalplus')->__('Webhook creation failed.')
80
+ );
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Validate PayPal credentials
86
+ *
87
+ * @param Varien_Event_Observer $observer
88
+ * @throws Mage_Core_Exception
89
+ */
90
+ protected function validateCredentials(Varien_Event_Observer $observer)
91
+ {
92
+ Mage::getModel('iways_paypalplus/api')->testCredentials($this->getDefaultStoreId($observer));
93
+ }
94
+
95
+ /**
96
+ * Try to get default store id from observer
97
+ *
98
+ * @param Varien_Event_Observer $observer
99
+ * @return mixed
100
+ * @throws Mage_Core_Exception
101
+ */
102
+ protected function getDefaultStoreId(Varien_Event_Observer $observer)
103
+ {
104
+ $website = $observer->getWebsite();
105
+ if ($website) {
106
+ $website = Mage::app()
107
+ ->getWebsite($website)
108
+ ->getDefaultGroup()
109
+ ->getDefaultStoreId();
110
+ }
111
+ return $website;
112
+ }
113
+ }
app/code/community/Iways/PayPalPlus/Model/Payment.php ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com and you will be sent a copy immediately.
13
+ *
14
+ * Created on 02.03.2015
15
+ * Author Robert Hillebrand - hillebrand@i-ways.de - i-ways sales solutions GmbH
16
+ * Copyright i-ways sales solutions GmbH © 2015. All Rights Reserved.
17
+ * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ *
19
+ */
20
+
21
+ /**
22
+ * Description of Payment
23
+ *
24
+ * @category Iways
25
+ * @package Iways_PayPalPlus
26
+ * @author robert
27
+ */
28
+ class Iways_PayPalPlus_Model_Payment extends Mage_Payment_Model_Method_Abstract
29
+ {
30
+ const PPP_STATUS_APPROVED = 'approved';
31
+ const METHOD_CODE = 'iways_paypalplus_payment';
32
+ const PENDING = 'pending';
33
+
34
+ const PPP_PUI_INSTRUCTION_TYPE = 'PAY_UPON_INVOICE';
35
+
36
+ protected $_code = self::METHOD_CODE;
37
+ protected $_formBlockType = 'iways_paypalplus/payment_form';
38
+ protected $_infoBlockType = 'iways_paypalplus/payment_info';
39
+
40
+ /**
41
+ * Payment Method features
42
+ * @var bool
43
+ */
44
+ protected $_isGateway = true;
45
+ protected $_canOrder = false;
46
+ protected $_canAuthorize = true;
47
+ protected $_canCapture = true;
48
+ protected $_canCapturePartial = false;
49
+ protected $_canCaptureOnce = false;
50
+ protected $_canRefund = true;
51
+ protected $_canRefundInvoicePartial = true;
52
+ protected $_canUseCheckout = true;
53
+
54
+
55
+ /**
56
+ * Authorize payment method
57
+ *
58
+ * @param Varien_Object $payment
59
+ * @param float $amount
60
+ *
61
+ * @throws Exception Payment could not be executed
62
+ *
63
+ * @return Iways_PayPalPlus_Model_Payment
64
+ */
65
+ public function authorize(Varien_Object $payment, $amount)
66
+ {
67
+ $paymentId = Mage::app()->getRequest()->getParam('paymentId');
68
+ $payerId = Mage::app()->getRequest()->getParam('PayerID');
69
+ try {
70
+ if (Mage::getStoreConfig('payment/iways_paypalplus_payment/transfer_reserved_order_id')) {
71
+ Mage::getModel('iways_paypalplus/api')->patchInvoiceNumber(
72
+ $paymentId,
73
+ $payment->getOrder()->getIncrementId()
74
+ );
75
+ }
76
+ }catch (\Exception $e) {
77
+ Mage::logException($e);
78
+ }
79
+ /**
80
+ * @var \PayPal\Api\Payment $ppPayment
81
+ */
82
+ $ppPayment = Mage::getModel('iways_paypalplus/api')->executePayment(
83
+ $paymentId,
84
+ $payerId
85
+ );
86
+
87
+ Mage::getSingleton('customer/session')->setPayPalPaymentId(null);
88
+ Mage::getSingleton('customer/session')->setPayPalPaymentPatched(null);
89
+
90
+ if (!$ppPayment) {
91
+ Mage::throwException('Payment could not be executed.');
92
+ }
93
+
94
+ if($paymentInstructions = $ppPayment->getPaymentInstruction()) {
95
+ $payment->setData('ppp_pui_reference_number', $paymentInstructions->getReferenceNumber());
96
+ $payment->setData('ppp_pui_instruction_type', $paymentInstructions->getInstructionType());
97
+ $payment->setData(
98
+ 'ppp_pui_payment_due_date',
99
+ Mage::helper('iways_paypalplus')->convertDueDate($paymentInstructions->getPaymentDueDate())
100
+ );
101
+ $payment->setData('ppp_pui_note', $paymentInstructions->getNote());
102
+
103
+ $bankInsctructions = $paymentInstructions->getRecipientBankingInstruction();
104
+ $payment->setData('ppp_pui_bank_name', $bankInsctructions->getBankName());
105
+ $payment->setData('ppp_pui_account_holder_name', $bankInsctructions->getAccountHolderName());
106
+ $payment->setData(
107
+ 'ppp_pui_international_bank_account_number',
108
+ $bankInsctructions->getInternationalBankAccountNumber()
109
+ );
110
+ $payment->setData('ppp_pui_bank_identifier_code', $bankInsctructions->getBankIdentifierCode());
111
+ $payment->setData('ppp_pui_routing_number', $bankInsctructions->getRoutingNumber());
112
+
113
+ $ppAmount = $paymentInstructions->getAmount();
114
+ $payment->setData('ppp_pui_amount', $ppAmount->getValue());
115
+ $payment->setData('ppp_pui_currency', $ppAmount->getCurrency());
116
+ }
117
+
118
+ $transactionId = null;
119
+ try {
120
+ $transactions = $ppPayment->getTransactions();
121
+
122
+ if($transactions && isset($transactions[0])) {
123
+ $resource = $transactions[0]->getRelatedResources();
124
+ if($resource && isset($resource[0])) {
125
+ $sale = $resource[0]->getSale();
126
+ $transactionId = $sale->getId();
127
+ if($sale->getState() == self::PENDING) {
128
+ $payment->setIsTransactionPending(true);
129
+ }
130
+ }
131
+ }
132
+
133
+ } catch (Exception $e) {
134
+ $transactionId = $ppPayment->getId();
135
+ }
136
+ $payment->setTransactionId($transactionId);
137
+ $payment->setParentTransactionId($ppPayment->getId());
138
+
139
+ if($ppPayment->getState() == self::PPP_STATUS_APPROVED) {
140
+ $payment->setStatus(self::STATUS_APPROVED);
141
+ }
142
+
143
+ return $this;
144
+ }
145
+
146
+ /**
147
+ * Refund specified amount for payment
148
+ *
149
+ * @param Varien_Object $payment
150
+ * @param float $amount
151
+ *
152
+ * @return Iways_PayPalPlus_Model_Payment
153
+ */
154
+ public function refund(Varien_Object $payment, $amount)
155
+ {
156
+ $ppRefund = Mage::getModel('iways_paypalplus/api')->refundPayment(
157
+ $this->_getParentTransactionId($payment),
158
+ $amount
159
+ );
160
+ $payment->setTransactionId($ppRefund->getId())->setTransactionClosed(1);
161
+ return $this;
162
+ }
163
+
164
+ /**
165
+ * Parent transaction id getter
166
+ *
167
+ * @param Varien_Object $payment
168
+ * @return string
169
+ */
170
+ protected function _getParentTransactionId(Varien_Object $payment)
171
+ {
172
+ return $this->_getLastParentTransactionId($payment->getLastTransId());
173
+ }
174
+
175
+
176
+ /**
177
+ * Retrieves the last parent transaction id without a transaction (PayPal Pay-Id)
178
+ *
179
+ * @param $transactionId
180
+ * @return mixed
181
+ */
182
+ protected function _getLastParentTransactionId($transactionId) {
183
+ $transaction = Mage::getModel('sales/order_payment_transaction')->load($transactionId, 'txn_id');
184
+ if($transaction && $transaction->getParentTxnId()) {
185
+ return $this->_getLastParentTransactionId($transaction->getParentTxnId());
186
+ }
187
+ return $transactionId;
188
+ }
189
+ }
app/code/community/Iways/PayPalPlus/Model/System/Config/Source/Mode.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com and you will be sent a copy immediately.
13
+ *
14
+ * Created on 02.03.2015
15
+ * Author Robert Hillebrand - hillebrand@i-ways.de - i-ways sales solutions GmbH
16
+ * Copyright i-ways sales solutions GmbH © 2015. All Rights Reserved.
17
+ * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ *
19
+ */
20
+
21
+ /**
22
+ * PayPal Api Mode resource class
23
+ *
24
+ * @category Iways
25
+ * @package Iways_PayPalPlus
26
+ * @author robert
27
+ */
28
+ class Iways_PayPalPlus_Model_System_Config_Source_Mode
29
+ {
30
+
31
+ /**
32
+ * Live string
33
+ */
34
+ const LIVE = 'live';
35
+
36
+ /**
37
+ * Sandbox string
38
+ */
39
+ const SANDBOX = 'sandbox';
40
+
41
+ /**
42
+ * Options getter
43
+ *
44
+ * @return array
45
+ */
46
+ public function toOptionArray()
47
+ {
48
+ return array(
49
+ array('value' => self::LIVE, 'label' => Mage::helper('iways_paypalplus')->__('Live')),
50
+ array('value' => self::SANDBOX, 'label' => Mage::helper('iways_paypalplus')->__('Sandbox')),
51
+ );
52
+ }
53
+
54
+ /**
55
+ * Get options in "key-value" format
56
+ *
57
+ * @return array
58
+ */
59
+ public function toArray()
60
+ {
61
+ return array(
62
+ self::SANDBOX => Mage::helper('iways_paypalplus')->__('Sandbox'),
63
+ self::LIVE => Mage::helper('iways_paypalplus')->__('Live'),
64
+ );
65
+ }
66
+ }
app/code/community/Iways/PayPalPlus/Model/System/Config/Source/Thirdpartymoduls.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com and you will be sent a copy immediately.
13
+ *
14
+ * Created on 02.03.2015
15
+ * Author Robert Hillebrand - hillebrand@i-ways.de - i-ways sales solutions GmbH
16
+ * Copyright i-ways sales solutions GmbH © 2015. All Rights Reserved.
17
+ * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ *
19
+ */
20
+
21
+ /**
22
+ * Magento payment methods for admin config
23
+ *
24
+ * @author robert
25
+ */
26
+ class Iways_PayPalPlus_Model_System_Config_Source_Thirdpartymoduls
27
+ {
28
+
29
+ /**
30
+ * Options getter
31
+ *
32
+ * @return array
33
+ */
34
+ public function toOptionArray()
35
+ {
36
+ $payments = Mage::getSingleton('payment/config')->getActiveMethods();
37
+
38
+ $methods = array(array('value' => '', 'label' => Mage::helper('adminhtml')->__('--Please Select--')));
39
+
40
+ foreach ($payments as $paymentCode => $paymentModel) {
41
+ if (strpos($paymentCode, 'paypal') !== false) {
42
+ continue;
43
+ }
44
+
45
+ $paymentTitle = Mage::getStoreConfig('payment/' . $paymentCode . '/title');
46
+ if (empty($paymentTitle)) {
47
+ $paymentTitle = $paymentCode;
48
+ }
49
+ $methods[$paymentCode] = array(
50
+ 'label' => $paymentTitle,
51
+ 'value' => $paymentCode,
52
+ );
53
+ }
54
+ return $methods;
55
+ }
56
+
57
+ /**
58
+ * Get options in "key-value" format
59
+ *
60
+ * @return array
61
+ */
62
+ public function toArray()
63
+ {
64
+ $payments = Mage::getSingleton('payment/config')->getAllMethods();
65
+
66
+ $methods = array();
67
+
68
+ foreach ($payments as $paymentCode => $paymentModel) {
69
+ if ($paymentCode == Iways_PayPalPlus_Model_Payment::METHOD_CODE) {
70
+ continue;
71
+ }
72
+ $paymentTitle = Mage::getStoreConfig('payment/' . $paymentCode . '/title');
73
+
74
+ if (empty($paymentTitle)) {
75
+ $paymentTitle = $paymentCode;
76
+ }
77
+ $methods[$paymentCode] = $paymentTitle;
78
+ }
79
+ return $methods;
80
+ }
81
+ }
app/code/community/Iways/PayPalPlus/Model/Webhook/Event.php ADDED
@@ -0,0 +1,259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com and you will be sent a copy immediately.
14
+ *
15
+ * Created on 02.03.2015
16
+ * Author Robert Hillebrand - hillebrand@i-ways.de - i-ways sales solutions GmbH
17
+ * Copyright i-ways sales solutions GmbH © 2015. All Rights Reserved.
18
+ * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ *
20
+ */
21
+
22
+ /**
23
+ * Iways PayPalPlus Event Handler
24
+ *
25
+ * @category Iways
26
+ * @package Iways_PayPalPlus
27
+ * @author robert
28
+ */
29
+ class Iways_PayPalPlus_Model_Webhook_Event
30
+ {
31
+
32
+ /**
33
+ * Payment sale completed event type code
34
+ */
35
+ const PAYMENT_SALE_COMPLETED = 'PAYMENT.SALE.COMPLETED';
36
+ /**
37
+ * Payment sale pending event type code
38
+ */
39
+ const PAYMENT_SALE_PENDING = 'PAYMENT.SALE.PENDING';
40
+ /**
41
+ * Payment sale refunded event type
42
+ */
43
+ const PAYMENT_SALE_REFUNDED = 'PAYMENT.SALE.REFUNDED';
44
+ /**
45
+ * Payment sale reversed event type code
46
+ */
47
+ const PAYMENT_SALE_REVERSED = 'PAYMENT.SALE.REVERSED';
48
+ /**
49
+ * Risk dispute created event type code
50
+ */
51
+ const RISK_DISPUTE_CREATED = 'RISK.DISPUTE.CREATED';
52
+
53
+ /**
54
+ * Store order instance
55
+ *
56
+ * @var Mage_Sales_Model_Order
57
+ */
58
+ protected $_order = null;
59
+
60
+ /**
61
+ * Process the given $webhookEvent
62
+ *
63
+ * @param \PayPal\Api\WebhookEvent $webhookEvent
64
+ */
65
+ public function processWebhookRequest(\PayPal\Api\WebhookEvent $webhookEvent)
66
+ {
67
+ if ($webhookEvent->getEventType() !== null && in_array($webhookEvent->getEventType(),
68
+ $this->getSupportedWebhookEvents())
69
+ ) {
70
+ $this->getOrder($webhookEvent);
71
+ $this->{$this->eventTypeToHandler($webhookEvent->getEventType())}($webhookEvent);
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Get supported webhook events
77
+ *
78
+ * @return array
79
+ */
80
+ public function getSupportedWebhookEvents()
81
+ {
82
+ return array(
83
+ self::PAYMENT_SALE_COMPLETED,
84
+ self::PAYMENT_SALE_PENDING,
85
+ self::PAYMENT_SALE_REFUNDED,
86
+ self::PAYMENT_SALE_REVERSED,
87
+ self::RISK_DISPUTE_CREATED
88
+ );
89
+ }
90
+
91
+ /**
92
+ * Parse event type to handler function
93
+ *
94
+ * @param $eventType
95
+ * @return string
96
+ */
97
+ protected function eventTypeToHandler($eventType)
98
+ {
99
+ $eventParts = explode('.', $eventType);
100
+ foreach ($eventParts as $key => $eventPart) {
101
+ if (!$key) {
102
+ $eventParts[$key] = strtolower($eventPart);
103
+ continue;
104
+ }
105
+ $eventParts[$key] = ucfirst(strtolower($eventPart));
106
+ }
107
+ return implode('', $eventParts);
108
+ }
109
+
110
+ /**
111
+ * Mark transaction as completed
112
+ *
113
+ * @param \PayPal\Api\WebhookEvent $webhookEvent
114
+ */
115
+ protected function paymentSaleCompleted(\PayPal\Api\WebhookEvent $webhookEvent)
116
+ {
117
+ $paymentResource = $webhookEvent->getResource();
118
+ $parentTransactionId = $paymentResource->parent_payment;
119
+ $payment = $this->_order->getPayment();
120
+
121
+ $payment->setTransactionId($paymentResource->id)
122
+ ->setCurrencyCode($paymentResource->amount->currency)
123
+ ->setParentTransactionId($parentTransactionId)
124
+ ->setIsTransactionClosed(true)
125
+ ->registerCaptureNotification(
126
+ $paymentResource->amount->total,
127
+ true
128
+ );
129
+ $this->_order->save();
130
+
131
+ // notify customer
132
+ $invoice = $payment->getCreatedInvoice();
133
+ if ($invoice && !$this->_order->getEmailSent()) {
134
+ $this->_order->queueNewOrderEmail()
135
+ ->addStatusHistoryComment(
136
+ Mage::helper('iways_paypalplus')->__(
137
+ 'Notified customer about invoice #%s.',
138
+ $invoice->getIncrementId()
139
+ )
140
+ )->setIsCustomerNotified(true)
141
+ ->save();
142
+ }
143
+
144
+ }
145
+
146
+ /**
147
+ * Mark transaction as refunded
148
+ *
149
+ * @param \PayPal\Api\WebhookEvent $webhookEvent
150
+ * @throws Exception
151
+ */
152
+ protected function paymentSaleRefunded(\PayPal\Api\WebhookEvent $webhookEvent)
153
+ {
154
+
155
+ $paymentResource = $webhookEvent->getResource();
156
+ $parentTransactionId = $paymentResource->parent_payment;
157
+ /** @var Mage_Sales_Model_Order_Payment $payment */
158
+ $payment = $this->_order->getPayment();
159
+ $amount = $paymentResource->amount->total;
160
+
161
+ $transactionId = $paymentResource->id;
162
+
163
+ $payment->setPreparedMessage('')
164
+ ->setTransactionId($transactionId)
165
+ ->setParentTransactionId($parentTransactionId)
166
+ ->setIsTransactionClosed(1)
167
+ ->registerRefundNotification($amount);
168
+
169
+ $this->_order->save();
170
+
171
+ $creditmemo = $payment->getCreatedCreditmemo();
172
+ if ($creditmemo) {
173
+ $creditmemo->sendEmail();
174
+ $this->_order
175
+ ->addStatusHistoryComment(
176
+ Mage::helper('iways_paypalplus')->__(
177
+ 'Notified customer about creditmemo #%s.',
178
+ $creditmemo->getIncrementId()
179
+ )
180
+ )->setIsCustomerNotified(true)
181
+ ->save();
182
+ }
183
+ }
184
+
185
+ /**
186
+ * Mark transaction as pending
187
+ *
188
+ * @param \PayPal\Api\WebhookEvent $webhookEvent
189
+ */
190
+ protected function paymentSalePending(\PayPal\Api\WebhookEvent $webhookEvent)
191
+ {
192
+ $paymentResource = $webhookEvent->getResource();
193
+ $this->_order->getPayment()
194
+ ->setPreparedMessage($webhookEvent->getSummary())
195
+ ->setTransactionId($paymentResource->id)
196
+ ->setIsTransactionClosed(0)
197
+ ->registerPaymentReviewAction(Mage_Sales_Model_Order_Payment::REVIEW_ACTION_UPDATE, false);
198
+ $this->_order->save();
199
+ }
200
+
201
+ /**
202
+ * Mark transaction as reversed
203
+ *
204
+ * @param \PayPal\Api\WebhookEvent $webhookEvent
205
+ */
206
+ protected function paymentSaleReversed(\PayPal\Api\WebhookEvent $webhookEvent)
207
+ {
208
+ $this->_order->setStatus(Mage_Paypal_Model_Info::ORDER_STATUS_REVERSED);
209
+ $this->_order->save();
210
+
211
+ $this->_order
212
+ ->addStatusHistoryComment(
213
+ $webhookEvent->getSummary(),
214
+ Mage_Paypal_Model_Info::ORDER_STATUS_REVERSED
215
+ )->setIsCustomerNotified(false)
216
+ ->save();
217
+ }
218
+
219
+ /**
220
+ * Add risk dispute to order comment
221
+ *
222
+ * @param \PayPal\Api\WebhookEvent $webhookEvent
223
+ */
224
+ protected function riskDisputeCreated(\PayPal\Api\WebhookEvent $webhookEvent)
225
+ {
226
+ //Add IPN comment about registered dispute
227
+ $this->_order->addStatusHistoryComment($webhookEvent->getSummary())
228
+ ->setIsCustomerNotified(false)
229
+ ->save();
230
+
231
+ }
232
+
233
+
234
+ /**
235
+ * Load and validate order, instantiate proper configuration
236
+ *
237
+ * @return Mage_Sales_Model_Order
238
+ * @throws Exception
239
+ */
240
+ protected function getOrder(\PayPal\Api\WebhookEvent $webhookEvent)
241
+ {
242
+ if (empty($this->_order)) {
243
+ // get proper order
244
+ $resource = $webhookEvent->getResource();
245
+ if (!$resource) {
246
+ throw new Exception('Event resource not found.');
247
+ }
248
+
249
+ $transactionId = $resource->id;
250
+
251
+ $transaction = Mage::getModel('sales/order_payment_transaction')->load($transactionId, 'txn_id');
252
+ $this->_order = Mage::getModel('sales/order')->load($transaction->getOrderId());
253
+ if (!$this->_order->getId()) {
254
+ Mage::throwException('Order not found.');
255
+ }
256
+ }
257
+ return $this->_order;
258
+ }
259
+ }
app/code/community/Iways/PayPalPlus/RELEASE_NOTES.txt ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ==== 1.7.0 ====
2
+ Update PayPal Rest SDK to 1.6.4
3
+ Fixed parent transaction id
4
+ Fixed wrong PayPal payment id in Idev_OSC
5
+ Added partial refund
6
+ Show payment instructions for manual banktransfer payments on order success page
7
+ Added totals to patchPayment
8
+ Possible MagentoConnect File->directory fix
9
+
10
+ ==== 1.6.2 ====
11
+ Enable/disable loading indicator for PayPal Plus iframe
12
+ Fixed order status if PayPal payment is still pending (Now payment_review until Webhooks approves payment)
13
+
14
+ ==== 1.6.1 ====
15
+ Fixed suspected fraud for different currency
16
+ Changed payment method title for germany in frontend
17
+
18
+ ==== 1.6.0 ====
19
+ Added support for IWD_OSC
20
+ Fixed problem with store code in url
21
+ Changed first recieved transaction id from PayPal to transaction id from payment id
22
+
23
+ ==== 1.5.2 ====
24
+ Fixed state/status of authorizations and gateway-confirmation
25
+ Added last transaction number to order information
26
+ Added transfer order's id as invoice number setting
27
+
28
+ ==== 1.5.1 ====
29
+ Fixed paymentmethod choice for Idev_OSC
30
+ Updated PayPal SDK to 1.6
31
+
32
+ ==== 1.5.0 ====
33
+ Added support for Payment upon Invoice
34
+
35
+ ==== 1.4.5 ====
36
+ Added information block to checkout/success
37
+
38
+ ==== 1.4.4 ====
39
+ Fixed wrong locale code in presentation error
40
+
41
+ ==== 1.4.3 ====
42
+ Fixed empty order status Magento 1.7
43
+ Fixed suspected froud for Magento 1.7
44
+ Added localisation
45
+
46
+ ==== 1.4.2 ====
47
+ Force webhooks url to be https even if not
48
+ Fixed tax calculation with discount
49
+
50
+ ==== 1.4.1 ====
51
+ Fixed none responding payment method select
52
+ Removed unnecessary code line
53
+
54
+ ==== 1.4.0 ====
55
+ Added support for TM_Firecheckout and Magestore_Onestepcheckout
56
+ Added form key validateion for Magento 1.9
57
+
58
+ ==== 1.3.3 ====
59
+ Fixed not shown payment method information for Idev_OneStepCheckout
60
+
61
+ ==== 1.3.2 ====
62
+ Fixed agreements validate url and webhooks endpoint url (use force secure)
63
+
64
+ ==== 1.3.1 ====
65
+ Fixed observer config
66
+
67
+ ==== 1.3.0 ====
68
+ Added webhooks support:
69
+ - PAYMENT.SALE.REFUNDED
70
+ - PAYMENT.SALE.PENDING
71
+ - PAYMENT.SALE.COMPLETED
72
+ - RISK.DISPUTE.CREATED
73
+ Improved compatibility with Idev_OneStepCheckout
74
+ Updated PayPal REST SDK to 1.5.0
75
+ Hide all PayPal payment methods if PayPalPlus is active and rendered
76
+
77
+ ==== 1.2.3 ====
78
+ Changed help link to retrieve your api credentials
79
+ Fixed agreement validation
80
+
81
+ ==== 1.2.2 ====
82
+ Added credential validation on payment configuration save
83
+
84
+ ==== 1.2.1 ====
85
+ Added validation for billing agreements
86
+ Fixed single payment method view for Idev_OneStepCheckout
87
+
88
+ ==== 1.2.0 ====
89
+ Added better third party payment support and design
90
+ Fixed tax calculation errors
91
+ Fixed payment method rendering for Idev_OneStepCheckout
92
+
93
+ ==== 1.1.3 ====
94
+ Fixed directory path constant
95
+
96
+ ==== 1.1.2 ====
97
+ Added language information
98
+
99
+ ==== 1.1.1 ====
100
+ Fixed Javascript for payment select
101
+
102
+ ==== 1.1.0 ====
103
+ Added Idev_OneStepCheckout compatibility
104
+ Added Billsafe compatibility
105
+ Updated PayPal REST SDK to 1.3.0
106
+ Changed PayPalPlus Javascript library to online version
107
+ Fixed disappearing payment methods
108
+
109
+ ==== 1.0.0 ====
110
+ PayPal PLUS is a solution where PayPal offers PayPal, Credit Card and ELV (pay upon invoice will be added in a later phase) as individual payment options on the payment selection page.
111
+ Based on the payment method selected by the buyer, he will at a later stage be presented with either the PayPal Login page or an input mask for bank / credit card details.
app/code/community/Iways/PayPalPlus/controllers/IndexController.php ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com and you will be sent a copy immediately.
13
+ *
14
+ * Created on 05.03.2015
15
+ * Author Robert Hillebrand - hillebrand@i-ways.de - i-ways sales solutions GmbH
16
+ * Copyright i-ways sales solutions GmbH © 2015. All Rights Reserved.
17
+ * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ *
19
+ */
20
+
21
+ /**
22
+ * PayPalPlus checkout controller
23
+ *
24
+ * @category Iways
25
+ * @package Iways_PayPalPlus
26
+ * @author robert
27
+ */
28
+ class Iways_PayPalPlus_IndexController extends Mage_Checkout_Controller_Action
29
+ {
30
+ /**
31
+ * Index
32
+ */
33
+ public function indexAction()
34
+ {
35
+ $this->_redirect('checkout/cart');
36
+ }
37
+
38
+ /**
39
+ * success
40
+ */
41
+ public function successAction()
42
+ {
43
+ try {
44
+ $this->getOnepage()->getQuote()->collectTotals()->save();
45
+ $this->getOnepage()->saveOrder();
46
+ $this->getOnepage()->getQuote()->save();
47
+ $this->_redirect('checkout/onepage/success');
48
+ return true;
49
+ } catch (Exception $ex) {
50
+ Mage::logException($ex);
51
+ }
52
+ Mage::getSingleton('checkout/session')->addError($this->__('There was an error with your payment.'));
53
+ $this->_redirect('checkout/cart');
54
+ }
55
+
56
+ /**
57
+ * Validate agreements bevor redirect to PayPal
58
+ */
59
+ public function validateAction()
60
+ {
61
+ if (version_compare(Mage::getVersion(), '1.8.0', '>=') && !$this->_validateFormKey()) {
62
+ $response = array('status' => 'error', 'message' => 'Invalid form key.');
63
+ $this->getResponse()->setHeader('Content-type', 'application/json');
64
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
65
+ return;
66
+ }
67
+ $requiredAgreements = Mage::helper('checkout')->getRequiredAgreementIds();
68
+ if ($requiredAgreements) {
69
+ $postedAgreements = array_keys($this->getRequest()->getPost('agreement', array()));
70
+ $diff = array_diff($requiredAgreements, $postedAgreements);
71
+ if ($diff) {
72
+ $result['success'] = false;
73
+ $result['error'] = true;
74
+ $result['error_messages'] =
75
+ $this->__('Please agree to all the terms and conditions before placing the order.');
76
+
77
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
78
+ return;
79
+ }
80
+ }
81
+ $result['success'] = true;
82
+ $result['error'] = false;
83
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
84
+ }
85
+
86
+ /**
87
+ * Get Onepage checkout
88
+ *
89
+ * @return Mage_Checkout_Model_Type_Onepage
90
+ */
91
+ protected function getOnepage()
92
+ {
93
+ return Mage::getSingleton('checkout/type_onepage');
94
+ }
95
+
96
+ /**
97
+ * @return Mage_Sales_Model_Quote
98
+ */
99
+ protected function getQuote()
100
+ {
101
+ return $this->getOnepage()->getQuote();
102
+ }
103
+
104
+ /**
105
+ * Patch PayPalPayment
106
+ */
107
+ public function patchAction()
108
+ {
109
+ try {
110
+ if (version_compare(Mage::getVersion(), '1.8.0', '>=') && !$this->_validateFormKey()) {
111
+ $response = array('status' => 'error', 'message' => 'Invalid form key.');
112
+ $this->getResponse()->setHeader('Content-type', 'application/json');
113
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
114
+ return;
115
+ }
116
+
117
+ $billing = $this->getRequest()->getPost('billing', array());
118
+ $customerBillingAddressId = $this->getRequest()->getPost('billing_address_id', false);
119
+
120
+
121
+ if (isset($billing['email'])) {
122
+ $billing['email'] = trim($billing['email']);
123
+ }
124
+ $this->getOnepage()->saveBilling($billing, $customerBillingAddressId);
125
+
126
+ $shipping = $this->getRequest()->getPost('shipping', array());
127
+ if ($billing['use_for_shipping']) {
128
+ $shipping = $billing;
129
+ }
130
+ $customerShippingAddressId = $this->getRequest()->getPost('shipping_address_id', false);
131
+ $this->getOnepage()->saveShipping($shipping, $customerShippingAddressId);
132
+
133
+ $this->getOnepage()->saveShippingMethod($this->getRequest()->getPost('shipping_method', ''));
134
+
135
+ $this->getOnepage()->savePayment($this->getRequest()->getPost('payment', array()));
136
+
137
+ $responsePayPal = Mage::getModel('iways_paypalplus/api')->patchPayment($this->getOnepage()->getQuote());
138
+ if ($responsePayPal) {
139
+ $response = array('status' => 'success');
140
+ } else {
141
+ $response = array(
142
+ 'status' => 'error',
143
+ 'message' => $this->__('Please select an other payment method.')
144
+ );
145
+ }
146
+ } catch (Exception $ex) {
147
+ $response = array('status' => 'error', 'message' => $ex->getMessage());
148
+ }
149
+
150
+ $this->getResponse()->setHeader('Content-type', 'application/json');
151
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
152
+ }
153
+
154
+ /**
155
+ * Listener for PayPal REST Webhooks
156
+ */
157
+ public
158
+ function webhooksAction()
159
+ {
160
+ if (!$this->getRequest()->isPost()) {
161
+ return;
162
+ }
163
+ try {
164
+ /** @var \PayPal\Api\WebhookEvent $webhookEvent */
165
+ $webhookEvent =
166
+ Mage::getSingleton('iways_paypalplus/api')->validateWebhook($this->getRequest()->getRawBody());
167
+ if(!$webhookEvent) {
168
+ Mage::throwException('Event not found.');
169
+ }
170
+ Mage::getModel('iways_paypalplus/webhook_event')->processWebhookRequest($webhookEvent);
171
+ } catch (Exception $e) {
172
+ Mage::logException($e);
173
+ $this->getResponse()->setHeader('HTTP/1.1', '503 Service Unavailable')->sendResponse();
174
+ }
175
+ }
176
+ }
app/code/community/Iways/PayPalPlus/etc/api2.xml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magento.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magento.com for more information.
21
+ *
22
+ * @category Mage
23
+ * @package Mage_Sales
24
+ * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
25
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
+ */
27
+ -->
28
+ <config>
29
+ <api2>
30
+ <resources>
31
+ <order translate="title" module="api2">
32
+ <model>iways_paypalplus/api2_order</model>
33
+ <attributes>
34
+ <ppp_pui_reference_number>PPP PUI Reference Number</ppp_pui_reference_number>
35
+ <ppp_pui_instruction_type>PPP PUI Insctruction Type</ppp_pui_instruction_type>
36
+ <ppp_pui_payment_due_date>PPP PUI Payment Due Date</ppp_pui_payment_due_date>
37
+ <ppp_pui_note>PPP PUI Note</ppp_pui_note>
38
+ <ppp_pui_bank_name>PPP PUI Bank Name</ppp_pui_bank_name>
39
+ <ppp_pui_account_holder_name>PPP PUI Account Holder Name</ppp_pui_account_holder_name>
40
+ <ppp_pui_international_bank_account_number>PPP PUI IBAN</ppp_pui_international_bank_account_number>
41
+ <ppp_pui_bank_identifier_code>PPP PUI BIC</ppp_pui_bank_identifier_code>
42
+ <ppp_pui_routing_number>PPP PUI Routing Number</ppp_pui_routing_number>
43
+ <ppp_pui_amount>PPP PUI Amount</ppp_pui_amount>
44
+ <ppp_pui_currency>PPP PUI Currency</ppp_pui_currency>
45
+ </attributes>
46
+ </order>
47
+ </resources>
48
+ </api2>
49
+ </config>
app/code/community/Iways/PayPalPlus/etc/config.xml ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Iways_PayPalPlus>
5
+ <version>1.7.0</version>
6
+ </Iways_PayPalPlus>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <iways_paypalplus>
11
+ <class>Iways_PayPalPlus_Model</class>
12
+ </iways_paypalplus>
13
+ <sales>
14
+ <rewrite>
15
+ <api2_order>Iways_PayPalPlus_Model_Api2_Order</api2_order>
16
+ </rewrite>
17
+ </sales>
18
+ </models>
19
+ <helpers>
20
+ <iways_paypalplus>
21
+ <class>Iways_PayPalPlus_Helper</class>
22
+ </iways_paypalplus>
23
+ </helpers>
24
+ <blocks>
25
+ <iways_paypalplus>
26
+ <class>Iways_PayPalPlus_Block</class>
27
+ </iways_paypalplus>
28
+ <checkout>
29
+ <rewrite>
30
+ <onepage_payment_methods>Iways_PayPalPlus_Block_Onepage_Payment_Methods</onepage_payment_methods>
31
+ </rewrite>
32
+ </checkout>
33
+ </blocks>
34
+ <events>
35
+ <controller_front_init_before>
36
+ <observers>
37
+ <iways_paypalplus>
38
+ <class>iways_paypalplus/autoloader</class>
39
+ <method>addAutoloader</method>
40
+ </iways_paypalplus>
41
+ </observers>
42
+ </controller_front_init_before>
43
+ </events>
44
+ <resources>
45
+ <iways_paypalplus_setup>
46
+ <setup>
47
+ <module>Iways_PayPalPlus</module>
48
+ <class>Mage_Sales_Model_Entity_Setup</class>
49
+ </setup>
50
+ </iways_paypalplus_setup>
51
+ </resources>
52
+ <sales>
53
+ <order>
54
+ <states>
55
+ <payment_review>
56
+ <statuses>
57
+ <pending_paypal />
58
+ </statuses>
59
+ </payment_review>
60
+ </states>
61
+ </order>
62
+ </sales>
63
+ </global>
64
+ <frontend>
65
+ <layout>
66
+ <updates>
67
+ <iways_paypalplus>
68
+ <file>iways_paypalplus.xml</file>
69
+ </iways_paypalplus>
70
+ </updates>
71
+ </layout>
72
+ <routers>
73
+ <iways_paypalplus>
74
+ <use>standard</use>
75
+ <args>
76
+ <module>Iways_PayPalPlus</module>
77
+ <frontName>paypalplus</frontName>
78
+ </args>
79
+ </iways_paypalplus>
80
+ </routers>
81
+ <translate>
82
+ <modules>
83
+ <Iways_PayPalPlus>
84
+ <files>
85
+ <default>Iways_PayPalPlus.csv</default>
86
+ </files>
87
+ </Iways_PayPalPlus>
88
+ </modules>
89
+ </translate>
90
+ </frontend>
91
+ <adminhtml>
92
+ <events>
93
+ <admin_system_config_changed_section_payment>
94
+ <observers>
95
+ <reset_web_profile>
96
+ <class>iways_paypalplus/observer</class>
97
+ <method>resetWebProfile</method>
98
+ </reset_web_profile>
99
+ </observers>
100
+ </admin_system_config_changed_section_payment>
101
+ <admin_system_config_changed_section_payment>
102
+ <observers>
103
+ <check_webhook>
104
+ <class>iways_paypalplus/observer</class>
105
+ <method>checkWebhook</method>
106
+ </check_webhook>
107
+ </observers>
108
+ </admin_system_config_changed_section_payment>
109
+ <admin_system_config_changed_section_design>
110
+ <observers>
111
+ <reset_web_profile>
112
+ <class>iways_paypalplus/observer</class>
113
+ <method>resetWebProfile</method>
114
+ </reset_web_profile>
115
+ </observers>
116
+ </admin_system_config_changed_section_design>
117
+ <admin_system_config_changed_section_general>
118
+ <observers>
119
+ <reset_web_profile>
120
+ <class>iways_paypalplus/observer</class>
121
+ <method>resetWebProfile</method>
122
+ </reset_web_profile>
123
+ </observers>
124
+ </admin_system_config_changed_section_general>
125
+ <admin_system_config_changed_section_web>
126
+ <observers>
127
+ <reset_web_profile>
128
+ <class>iways_paypalplus/observer</class>
129
+ <method>checkWebhook</method>
130
+ </reset_web_profile>
131
+ </observers>
132
+ </admin_system_config_changed_section_web>
133
+ </events>
134
+ <translate>
135
+ <modules>
136
+ <Iways_PayPalPlus>
137
+ <files>
138
+ <default>Iways_PayPalPlus.csv</default>
139
+ </files>
140
+ </Iways_PayPalPlus>
141
+ </modules>
142
+ </translate>
143
+ <acl>
144
+ <resources>
145
+ <admin>
146
+ <children>
147
+ <system>
148
+ <children>
149
+ <config>
150
+ <children>
151
+ <iways_paypalplus translate="title" module="iways_paypalplus">
152
+ <title>Iways PayPalPlus Modul Section</title>
153
+ </iways_paypalplus>
154
+ </children>
155
+ </config>
156
+ </children>
157
+ </system>
158
+ </children>
159
+ </admin>
160
+ </resources>
161
+ </acl>
162
+ </adminhtml>
163
+ <default>
164
+ <iways_paypalplus>
165
+ <api>
166
+ <mode>sandbox</mode>
167
+ <client_id backend_model="adminhtml/system_config_backend_encrypted"></client_id>
168
+ <client_secret backend_model="adminhtml/system_config_backend_encrypted"></client_secret>
169
+ </api>
170
+ </iways_paypalplus>
171
+ <payment>
172
+ <iways_paypalplus_payment>
173
+ <active>0</active>
174
+ <transfer_reserved_order_id>0</transfer_reserved_order_id>
175
+ <sort_order>-1</sort_order>
176
+ <model>iways_paypalplus/payment</model>
177
+ <order_status>processing</order_status>
178
+ <title>PayPal Plus</title>
179
+ <allowspecific>0</allowspecific>
180
+ <payment_action>authorize</payment_action>
181
+ </iways_paypalplus_payment>
182
+ </payment>
183
+ </default>
184
+ </config>
app/code/community/Iways/PayPalPlus/etc/system.xml ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <payment>
5
+ <groups>
6
+ <iways_paypalplus_solution translate="label comment" module="iways_paypalplus">
7
+ <label>PayPalPlus Settings</label>
8
+ <sort_order>10</sort_order>
9
+ <expanded>1</expanded>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>1</show_in_store>
13
+ <frontend_class>complex</frontend_class>
14
+ <frontend_model>paypal/adminhtml_system_config_fieldset_group</frontend_model>
15
+ <comment></comment>
16
+ <paypal_title>Select a Payment Solution</paypal_title>
17
+ <fields/>
18
+ </iways_paypalplus_solution>
19
+ <paypal_payments>
20
+ <iways_paypalplus_payment type="group" translate="label" module="iways_paypalplus">
21
+ <label>PayPalPlus Payment Settings</label>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>1</show_in_store>
25
+ <sort_order>6</sort_order>
26
+ <group>iways_paypalplus_solution</group>
27
+ <include>0</include>
28
+ <frontend_model>iways_paypalplus/adminhtml_system_config_fieldset_payment</frontend_model>
29
+ <activity_path>payment/iways_paypalplus_payment/active</activity_path>
30
+ <backend_config>
31
+ <DE>
32
+ <include>1</include>
33
+ </DE>
34
+ </backend_config>
35
+ <fields>
36
+ <api type="group" translate="label">
37
+ <label>PayPalPlus Api Settings</label>
38
+ <sort_order>10</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <frontend_type>text</frontend_type>
42
+ <frontend_model>paypal/adminhtml_system_config_fieldset_expanded</frontend_model>
43
+ <fields>
44
+ <client_id translate="label">
45
+ <label>Client ID</label>
46
+ <frontend_type>obscure</frontend_type>
47
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
48
+ <config_path>iways_paypalplus/api/client_id</config_path>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <sort_order>20</sort_order>
52
+ </client_id>
53
+ <client_secret translate="label comment">
54
+ <label>Client Secret</label>
55
+ <frontend_type>obscure</frontend_type>
56
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
57
+ <config_path>iways_paypalplus/api/client_secret</config_path>
58
+ <comment>
59
+ <![CDATA[<a href="https://www.paypalobjects.com/webstatic/de_DE/downloads/PayPal_Nutzung_der_REST_API.pdf" target="_blank">How to retrieve your PayPal API credentials.</a>]]></comment>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <sort_order>30</sort_order>
63
+ </client_secret>
64
+ <mode translate="label" module="iways_paypalplus">
65
+ <label>Mode</label>
66
+ <show_in_default>1</show_in_default>
67
+ <show_in_website>1</show_in_website>
68
+ <sort_order>40</sort_order>
69
+ <frontend_type>select</frontend_type>
70
+ <config_path>iways_paypalplus/api/mode</config_path>
71
+ <source_model>iways_paypalplus/system_config_source_mode</source_model>
72
+ </mode>
73
+ <paypalplus_hdrimg translate="label tooltip" module="iways_paypalplus">
74
+ <label>Header Image URL</label>
75
+ <config_path>iways_paypalplus/api/hdrimg</config_path>
76
+ <tooltip>
77
+ <![CDATA[The image at the top left of the checkout page. Max size is 750x90-pixel. <strong style="color:red">https</strong> is highly encouraged.]]></tooltip>
78
+ <sort_order>50</sort_order>
79
+ <show_in_default>1</show_in_default>
80
+ <show_in_website>1</show_in_website>
81
+ <show_in_store>1</show_in_store>
82
+ <shared>1</shared>
83
+ </paypalplus_hdrimg>
84
+ </fields>
85
+ </api>
86
+ <payment type="group" translate="label" module="iways_paypalplus">
87
+ <label>PayPalPlus Payment Settings</label>
88
+ <sort_order>20</sort_order>
89
+ <show_in_default>1</show_in_default>
90
+ <show_in_website>1</show_in_website>
91
+ <frontend_type>text</frontend_type>
92
+ <frontend_model>paypal/adminhtml_system_config_fieldset_expanded</frontend_model>
93
+ <fields>
94
+ <active translate="label">
95
+ <label>Enabled</label>
96
+ <frontend_type>select</frontend_type>
97
+ <config_path>payment/iways_paypalplus_payment/active</config_path>
98
+ <source_model>adminhtml/system_config_source_yesno</source_model>
99
+ <sort_order>10</sort_order>
100
+ <show_in_default>1</show_in_default>
101
+ <show_in_website>1</show_in_website>
102
+ <show_in_store>1</show_in_store>
103
+ </active>
104
+ <show_loading_indicator translate="label">
105
+ <label>Show loading indicator</label>
106
+ <frontend_type>select</frontend_type>
107
+ <config_path>payment/iways_paypalplus_payment/show_loading_indicator</config_path>
108
+ <source_model>adminhtml/system_config_source_yesno</source_model>
109
+ <sort_order>15</sort_order>
110
+ <show_in_default>1</show_in_default>
111
+ <show_in_website>1</show_in_website>
112
+ <show_in_store>1</show_in_store>
113
+ </show_loading_indicator>
114
+ <transfer_reserved_order_id translate="label">
115
+ <label>Transfer order's ID as PayPal invoice number</label>
116
+ <frontend_type>select</frontend_type>
117
+ <config_path>payment/iways_paypalplus_payment/transfer_reserved_order_id</config_path>
118
+ <source_model>adminhtml/system_config_source_yesno</source_model>
119
+ <sort_order>20</sort_order>
120
+ <show_in_default>1</show_in_default>
121
+ <show_in_website>1</show_in_website>
122
+ <show_in_store>1</show_in_store>
123
+ </transfer_reserved_order_id>
124
+ <allowspecific translate="label">
125
+ <label>Payment from Applicable Countries</label>
126
+ <frontend_type>allowspecific</frontend_type>
127
+ <config_path>payment/iways_paypalplus_payment/allowspecific</config_path>
128
+ <sort_order>30</sort_order>
129
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries
130
+ </source_model>
131
+ <show_in_default>1</show_in_default>
132
+ <show_in_website>1</show_in_website>
133
+ <show_in_store>1</show_in_store>
134
+ </allowspecific>
135
+ <specificcountry translate="label">
136
+ <label>Payment from Specific Countries</label>
137
+ <frontend_type>multiselect</frontend_type>
138
+ <config_path>payment/iways_paypalplus_payment/specificcountry</config_path>
139
+ <sort_order>40</sort_order>
140
+ <source_model>adminhtml/system_config_source_country</source_model>
141
+ <show_in_default>1</show_in_default>
142
+ <show_in_website>1</show_in_website>
143
+ <show_in_store>1</show_in_store>
144
+ <can_be_empty>1</can_be_empty>
145
+ </specificcountry>
146
+ <third_party_moduls translate="label comment">
147
+ <label>Allowed Third-Party Moduls</label>
148
+ <frontend_type>multiselect</frontend_type>
149
+ <comment>Only select payment methods which doesn't require extra input in
150
+ checkout.
151
+ </comment>
152
+ <config_path>payment/iways_paypalplus_payment/third_party_moduls</config_path>
153
+ <sort_order>50</sort_order>
154
+ <source_model>iways_paypalplus/system_config_source_thirdpartymoduls
155
+ </source_model>
156
+ <show_in_default>1</show_in_default>
157
+ <show_in_website>1</show_in_website>
158
+ <show_in_store>1</show_in_store>
159
+ <can_be_empty>1</can_be_empty>
160
+ </third_party_moduls>
161
+ </fields>
162
+ </payment>
163
+ <third_party_modul_info type="group" translate="label comment">
164
+ <label>PayPalPlus Third party methods info text</label>
165
+ <comment>Only selected and saved third party payments will be shown.</comment>
166
+ <frontend_type>text</frontend_type>
167
+ <frontend_model>iways_paypalplus/adminhtml_system_config_thirdpartyinfo</frontend_model>
168
+ <expanded>0</expanded>
169
+ <sort_order>25</sort_order>
170
+ <show_in_default>1</show_in_default>
171
+ <show_in_website>1</show_in_website>
172
+ <show_in_store>1</show_in_store>
173
+ </third_party_modul_info>
174
+ <dev type="group" translate="label">
175
+ <label>PayPalPlus Development Settings</label>
176
+ <expanded>0</expanded>
177
+ <sort_order>30</sort_order>
178
+ <show_in_default>1</show_in_default>
179
+ <show_in_website>1</show_in_website>
180
+ <show_in_store>1</show_in_store>
181
+ <fields>
182
+ <debug translate="label">
183
+ <label>Debug</label>
184
+ <frontend_type>select</frontend_type>
185
+ <source_model>adminhtml/system_config_source_yesno</source_model>
186
+ <show_in_default>1</show_in_default>
187
+ <show_in_website>0</show_in_website>
188
+ <show_in_store>0</show_in_store>
189
+ <config_path>iways_paypalplus/dev/debug</config_path>
190
+ <sort_order>10</sort_order>
191
+ </debug>
192
+ <pui_sandbox translate="label">
193
+ <label>Show PuI in Sandbox</label>
194
+ <frontend_type>select</frontend_type>
195
+ <source_model>adminhtml/system_config_source_yesno</source_model>
196
+ <show_in_default>1</show_in_default>
197
+ <show_in_website>1</show_in_website>
198
+ <show_in_store>0</show_in_store>
199
+ <config_path>iways_paypalplus/dev/pui_sandbox</config_path>
200
+ <sort_order>20</sort_order>
201
+ </pui_sandbox>
202
+ <web_profile_id>
203
+ <label>Web-Profile ID</label>
204
+ <show_in_default>0</show_in_default>
205
+ <show_in_website>0</show_in_website>
206
+ <show_in_store>0</show_in_store>
207
+ <config_path>iways_paypalplus/dev/web_profile_id</config_path>
208
+ <sort_order>20</sort_order>
209
+ </web_profile_id>
210
+ <webhook_id>
211
+ <label>Webhook ID</label>
212
+ <show_in_default>0</show_in_default>
213
+ <show_in_website>0</show_in_website>
214
+ <show_in_store>0</show_in_store>
215
+ <config_path>iways_paypalplus/dev/webhook_id</config_path>
216
+ <sort_order>30</sort_order>
217
+ </webhook_id>
218
+ </fields>
219
+ </dev>
220
+ </fields>
221
+ </iways_paypalplus_payment>
222
+ </paypal_payments>
223
+ </groups>
224
+ </payment>
225
+ </sections>
226
+ </config>
app/code/community/Iways/PayPalPlus/etc/wsdl.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <definitions xmlns:typens="urn:{{var wsdl.name}}" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
3
+ xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"
4
+ name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}">
5
+ <types>
6
+ <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
7
+ <import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />
8
+ <complexType name="salesOrderPaymentEntity">
9
+ <all>
10
+ <element name="ppp_pui_reference_number" type="xsd:string" minOccurs="0" />
11
+ <element name="ppp_pui_instruction_type" type="xsd:string" minOccurs="0" />
12
+ <element name="ppp_pui_note" type="xsd:string" minOccurs="0" />
13
+ <element name="ppp_pui_bank_name" type="xsd:string" minOccurs="0" />
14
+ <element name="ppp_pui_account_holder_name" type="xsd:string" minOccurs="0" />
15
+ <element name="ppp_pui_international_bank_account_number" type="xsd:string" minOccurs="0" />
16
+ <element name="ppp_pui_bank_identifier_code" type="xsd:string" minOccurs="0" />
17
+ <element name="ppp_pui_routing_number" type="xsd:string" minOccurs="0" />
18
+ <element name="ppp_pui_amount" type="xsd:string" minOccurs="0" />
19
+ <element name="ppp_pui_currency" type="xsd:string" minOccurs="0" />
20
+ </all>
21
+ </complexType>
22
+ </schema>
23
+ </types>
24
+ </definitions>
app/code/community/Iways/PayPalPlus/etc/wsi.xml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <wsdl:definitions xmlns:typens="urn:{{var wsdl.name}}"
3
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
4
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
5
+ xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
6
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
7
+ name="{{var wsdl.name}}"
8
+ targetNamespace="urn:{{var wsdl.name}}">
9
+ <wsdl:types>
10
+ <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:{{var wsdl.name}}">
11
+ <xsd:complexType name="salesOrderPaymentEntity">
12
+ <xsd:sequence>
13
+ <xsd:element name="ppp_pui_reference_number" type="xsd:string" minOccurs="0" />
14
+ <xsd:element name="ppp_pui_instruction_type" type="xsd:string" minOccurs="0" />
15
+ <xsd:element name="ppp_pui_note" type="xsd:string" minOccurs="0" />
16
+ <xsd:element name="ppp_pui_bank_name" type="xsd:string" minOccurs="0" />
17
+ <xsd:element name="ppp_pui_account_holder_name" type="xsd:string" minOccurs="0" />
18
+ <xsd:element name="ppp_pui_international_bank_account_number" type="xsd:string" minOccurs="0" />
19
+ <xsd:element name="ppp_pui_bank_identifier_code" type="xsd:string" minOccurs="0" />
20
+ <xsd:element name="ppp_pui_routing_number" type="xsd:string" minOccurs="0" />
21
+ <xsd:element name="ppp_pui_amount" type="xsd:string" minOccurs="0" />
22
+ <xsd:element name="ppp_pui_currency" type="xsd:string" minOccurs="0" />
23
+ </xsd:sequence>
24
+ </xsd:complexType>
25
+ </xsd:schema>
26
+ </wsdl:types>
27
+ </wsdl:definitions>
app/code/community/Iways/PayPalPlus/sql/iways_paypalplus_setup/install-1.5.0.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Sales
23
+ * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /* @var $installer Mage_Sales_Model_Entity_Setup */
28
+ $installer = $this;
29
+ $installer->getConnection()
30
+ ->addColumn($installer->getTable('sales/order_payment'), 'ppp_pui_reference_number', array(
31
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
32
+ 'length' => 255,
33
+ 'comment' => 'PayPal Plus PuI Reference Number',
34
+ ));
35
+ $installer->getConnection()
36
+ ->addColumn($installer->getTable('sales/order_payment'), 'ppp_pui_instruction_type', array(
37
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
38
+ 'length' => 255,
39
+ 'comment' => 'PayPal Plus PuI Insctruction Type',
40
+ ));
41
+ $installer->getConnection()
42
+ ->addColumn($installer->getTable('sales/order_payment'), 'ppp_pui_payment_due_date', array(
43
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
44
+ 'length' => 255,
45
+ 'comment' => 'PayPal Plus PuI Payment Due Date',
46
+ ));
47
+ $installer->getConnection()
48
+ ->addColumn($installer->getTable('sales/order_payment'), 'ppp_pui_note', array(
49
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
50
+ 'length' => 255,
51
+ 'comment' => 'PayPal Plus PuI Note',
52
+ ));
53
+ $installer->getConnection()
54
+ ->addColumn($installer->getTable('sales/order_payment'), 'ppp_pui_bank_name', array(
55
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
56
+ 'length' => 255,
57
+ 'comment' => 'PayPal Plus PuI Bank Name',
58
+ ));
59
+ $installer->getConnection()
60
+ ->addColumn($installer->getTable('sales/order_payment'), 'ppp_pui_account_holder_name', array(
61
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
62
+ 'length' => 255,
63
+ 'comment' => 'PayPal Plus PuI Holder Name',
64
+ ));
65
+ $installer->getConnection()
66
+ ->addColumn($installer->getTable('sales/order_payment'), 'ppp_pui_international_bank_account_number', array(
67
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
68
+ 'length' => 255,
69
+ 'comment' => 'PayPal Plus PuI International Bank Account Number',
70
+ ));
71
+ $installer->getConnection()
72
+ ->addColumn($installer->getTable('sales/order_payment'), 'ppp_pui_bank_identifier_code', array(
73
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
74
+ 'length' => 255,
75
+ 'comment' => 'PayPal Plus PuI Bank Identifier Code',
76
+ ));
77
+ $installer->getConnection()
78
+ ->addColumn($installer->getTable('sales/order_payment'), 'ppp_pui_routing_number', array(
79
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
80
+ 'length' => 255,
81
+ 'comment' => 'PayPal Plus PuI Routing Number',
82
+ ));
83
+ $installer->getConnection()
84
+ ->addColumn($installer->getTable('sales/order_payment'), 'ppp_pui_amount', array(
85
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
86
+ 'length' => 255,
87
+ 'comment' => 'PayPal Plus PuI Amount',
88
+ ));
89
+ $installer->getConnection()
90
+ ->addColumn($installer->getTable('sales/order_payment'), 'ppp_pui_currency', array(
91
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
92
+ 'length' => 255,
93
+ 'comment' => 'PayPal Plus PuI Currency',
94
+ ));
95
+ $installer->endSetup();
app/code/community/Iways/PayPalPlus/sql/iways_paypalplus_setup/upgrade-1.4.5-1.5.0.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Sales
23
+ * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /* @var $installer Mage_Sales_Model_Entity_Setup */
28
+ $installer = $this;
29
+ $installer->getConnection()
30
+ ->addColumn($installer->getTable('sales/order_payment'), 'ppp_pui_reference_number', array(
31
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
32
+ 'length' => 255,
33
+ 'comment' => 'PayPal Plus PuI Reference Number',
34
+ ));
35
+ $installer->getConnection()
36
+ ->addColumn($installer->getTable('sales/order_payment'), 'ppp_pui_instruction_type', array(
37
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
38
+ 'length' => 255,
39
+ 'comment' => 'PayPal Plus PuI Insctruction Type',
40
+ ));
41
+ $installer->getConnection()
42
+ ->addColumn($installer->getTable('sales/order_payment'), 'ppp_pui_payment_due_date', array(
43
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
44
+ 'length' => 255,
45
+ 'comment' => 'PayPal Plus PuI Payment Due Date',
46
+ ));
47
+ $installer->getConnection()
48
+ ->addColumn($installer->getTable('sales/order_payment'), 'ppp_pui_note', array(
49
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
50
+ 'length' => 255,
51
+ 'comment' => 'PayPal Plus PuI Note',
52
+ ));
53
+ $installer->getConnection()
54
+ ->addColumn($installer->getTable('sales/order_payment'), 'ppp_pui_bank_name', array(
55
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
56
+ 'length' => 255,
57
+ 'comment' => 'PayPal Plus PuI Bank Name',
58
+ ));
59
+ $installer->getConnection()
60
+ ->addColumn($installer->getTable('sales/order_payment'), 'ppp_pui_account_holder_name', array(
61
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
62
+ 'length' => 255,
63
+ 'comment' => 'PayPal Plus PuI Holder Name',
64
+ ));
65
+ $installer->getConnection()
66
+ ->addColumn($installer->getTable('sales/order_payment'), 'ppp_pui_international_bank_account_number', array(
67
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
68
+ 'length' => 255,
69
+ 'comment' => 'PayPal Plus PuI International Bank Account Number',
70
+ ));
71
+ $installer->getConnection()
72
+ ->addColumn($installer->getTable('sales/order_payment'), 'ppp_pui_bank_identifier_code', array(
73
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
74
+ 'length' => 255,
75
+ 'comment' => 'PayPal Plus PuI Bank Identifier Code',
76
+ ));
77
+ $installer->getConnection()
78
+ ->addColumn($installer->getTable('sales/order_payment'), 'ppp_pui_routing_number', array(
79
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
80
+ 'length' => 255,
81
+ 'comment' => 'PayPal Plus PuI Routing Number',
82
+ ));
83
+ $installer->getConnection()
84
+ ->addColumn($installer->getTable('sales/order_payment'), 'ppp_pui_amount', array(
85
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
86
+ 'length' => 255,
87
+ 'comment' => 'PayPal Plus PuI Amount',
88
+ ));
89
+ $installer->getConnection()
90
+ ->addColumn($installer->getTable('sales/order_payment'), 'ppp_pui_currency', array(
91
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
92
+ 'length' => 255,
93
+ 'comment' => 'PayPal Plus PuI Currency',
94
+ ));
95
+ $installer->endSetup();
app/design/adminhtml/default/default/template/paypalplus/payment/info.phtml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category design
22
+ * @package default_default
23
+ * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ /**
29
+ * @see Mage_Payment_Block_Info
30
+ */
31
+ ?>
32
+ <?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?>
33
+ <?php if($this->isPUI()): ?>
34
+ <p><?php echo Mage::helper('iways_paypalplus')->__('Pay upon Invoice'); ?></p>
35
+ <?php endif; ?>
36
+ <?php if ($_specificInfo = $this->getSpecificInformation()):?>
37
+ <table>
38
+ <?php foreach ($_specificInfo as $_label => $_value):?>
39
+ <tr>
40
+ <td><?php echo $this->escapeHtml($_label)?>:</td>
41
+ <td><?php echo nl2br(implode($this->getValueAsArray($_value, true), "\n"))?></td>
42
+ </tr>
43
+ <?php endforeach; ?>
44
+ </table>
45
+ <?php endif; ?>
46
+
47
+ <?php echo $this->getChildHtml()?>
app/design/adminhtml/default/default/template/paypalplus/payment/pdf/info.phtml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category design
22
+ * @package default_default
23
+ * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ /**
29
+ * @see Mage_Payment_Block_Info
30
+ */
31
+ ?>
32
+ <?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?>{{pdf_row_separator}}
33
+ <?php if ($_specificInfo = $this->getSpecificInformation()):?>
34
+ {{pdf_row_separator}}
35
+ <?php echo Mage::helper('iways_paypalplus')->__('Please transfer the invoice amount to the given account within the payment deadline.'); ?>{{pdf_row_separator}}
36
+ {{pdf_row_separator}}
37
+ <?php foreach ($_specificInfo as $_label => $_value):?>
38
+ <?php echo $_label ?>: <?php echo implode($this->getValueAsArray($_value), ' ')?>{{pdf_row_separator}}
39
+ <?php endforeach; ?>
40
+ <?php endif;?>
41
+
42
+ <?php echo implode($this->getChildPdfAsArray(), '{{pdf_row_separator}}') ?>
app/design/frontend/base/default/layout/iways_paypalplus.xml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the Open Software License (OSL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://opensource.org/licenses/osl-3.0.php
9
+ * If you did not receive a copy of the license and are unable to
10
+ * obtain it through the world-wide-web, please send an email
11
+ * to license@magentocommerce.com and you will be sent a copy immediately.
12
+ *
13
+ * Created on 05.03.2015
14
+ * Author Robert Hillebrand - hillebrand@i-ways.de - i-ways sales solutions GmbH
15
+ * Copyright i-ways sales solutions GmbH © 2015. All Rights Reserved.
16
+ * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ -->
18
+ <layout>
19
+ <checkout_onepage_index>
20
+ <reference name="head">
21
+ <block type="core/text" name="ppplus" ifconfig="payment/iways_paypalplus_payment/active">
22
+ <action method="setText"><text><![CDATA[<script src="//www.paypalobjects.com/webstatic/ppplus/ppplus.min.js" type="text/javascript"></script>]]></text></action>
23
+ </block>
24
+ <action method="addCss" ifconfig="payment/iways_paypalplus_payment/active">
25
+ <stylesheet>css/iways-paypalplus.css</stylesheet>
26
+ </action>
27
+ </reference>
28
+ </checkout_onepage_index>
29
+ <checkout_onepage_success>
30
+ <reference name="head">
31
+ <action method="addCss" ifconfig="payment/iways_paypalplus_payment/active">
32
+ <stylesheet>css/iways-paypalplus.css</stylesheet>
33
+ </action>
34
+ </reference>
35
+ <reference name="content">
36
+ <block type="iways_paypalplus/onepage_success"
37
+ name="ppp-success"
38
+ template="paypalplus/success.phtml"
39
+ after="-" />
40
+ </reference>
41
+ </checkout_onepage_success>
42
+ <checkout_onepage_paymentmethod>
43
+ <reference name="root">
44
+ <action method="setTemplate" ifconfig="payment/iways_paypalplus_payment/active">
45
+ <template>paypalplus/methods.phtml</template>
46
+ </action>
47
+ </reference>
48
+ </checkout_onepage_paymentmethod>
49
+ <checkout_onepage_review>
50
+ <reference name="checkout.onepage.review.button">
51
+ <action method="setTemplate" ifconfig="payment/iways_paypalplus_payment/active">
52
+ <template>paypalplus/review/button.phtml</template>
53
+ </action>
54
+ </reference>
55
+ </checkout_onepage_review>
56
+ </layout>
app/design/frontend/base/default/template/paypalplus/form/payment.phtml ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com and you will be sent a copy immediately.
13
+ *
14
+ * Created on 02.03.2015
15
+ * Author Robert Hillebrand - hillebrand@i-ways.de - i-ways sales solutions GmbH
16
+ * Copyright i-ways sales solutions GmbH © 2015. All Rights Reserved.
17
+ * License http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ *
19
+ */
20
+ $paymentExperience = $this->getPaymentEperience();
21
+ if ($paymentExperience) :
22
+ ?>
23
+ <div id="ppplus"></div>
24
+ <script type="text/javascript">
25
+ if(typeof payment == 'undefined') {
26
+ var payment = {};
27
+ }
28
+ function selectMethod(code) {
29
+ document.getElementById('p_method_' + code).click();
30
+ }
31
+ window.externMethodEnabled = false;
32
+ window.startPPP = function () {
33
+ if(typeof window.thirdPartyObject == 'undefined') {
34
+ window.thirdPartyObject = <?php echo $this->getThirdPartyJsonObject(); ?>;
35
+ window.thirdPartyMethodObject = <?php echo $this->getThirdPartyMethodJsonObject(); ?>;
36
+ }
37
+ document.cookie = 'paypalplus_session=; Path=/checkout/onepage; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
38
+ document.cookie = 'paypalplus_session=; Path=/checkout; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
39
+ document.cookie = 'paypalplus_session=; Path=/firecheckout; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
40
+ document.cookie = 'paypalplus_session=; Path=/onestepcheckout; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
41
+ window.pppId = '<?php echo $this->getPayPalPaymentId(); ?>';
42
+ selectMethod('<?php echo Iways_PayPalPlus_Model_Payment::METHOD_CODE; ?>');
43
+ window.ppp = PAYPAL.apps.PPP(
44
+ {
45
+ approvalUrl: "<?php echo $paymentExperience; ?>",
46
+ placeholder: "ppplus",
47
+ mode: "<?php echo Mage::getStoreConfig('iways_paypalplus/api/mode'); ?>",
48
+ useraction:"commit",
49
+ buttonLocation:"outside",
50
+ <?php if($this->isPuiSandboxMode()) : ?>
51
+ showPuiOnSandbox: true,
52
+ <?php endif; ?>
53
+ <?php if($this->showLoadingIndicator()) : ?>
54
+ showLoadingIndicator: true,
55
+ <?php endif; ?>
56
+ country:"<?php echo $this->getCountryId(); ?>",
57
+ language:"<?php echo $this->getLanguage(); ?>",
58
+ onContinue: function () {
59
+ payment.save()
60
+ },
61
+ onThirdPartyPaymentMethodSelected:function (data) {
62
+ this.lastCall = 'onThirdPartyPaymentMethodSelected';
63
+ selectMethod(window.thirdPartyObject[data.thirdPartyPaymentMethod]);
64
+ },
65
+ enableContinue: function (data) {
66
+ if(this.lastCall != 'onThirdPartyPaymentMethodSelected') {
67
+ selectMethod('<?php echo Iways_PayPalPlus_Model_Payment::METHOD_CODE; ?>');
68
+ }
69
+ this.lastCall = 'enableContinue';
70
+ try {
71
+ if($$('#payment-buttons-container > button').length > 0) {
72
+ $$('#payment-buttons-container > button')[0].enable();
73
+ }
74
+ if($('onestepcheckout-place-order') != null) {
75
+ $('onestepcheckout-place-order').enable();
76
+ }
77
+ if($$('#review-buttons-container > button').length > 0) {
78
+ $$('#review-buttons-container > button')[0].enable();
79
+ }
80
+ if($('onestepcheckout-button-place-order') != null) {
81
+ $('onestepcheckout-button-place-order').enable();
82
+ }
83
+ if($$('#checkout-review-submit > button.opc-btn-checkout').length > 0) {
84
+ $$('#checkout-review-submit > button.opc-btn-checkout')[0].enable();
85
+ }
86
+ }catch (e) {
87
+ console.log(e);
88
+ }
89
+ },
90
+ disableContinue: function (data) {
91
+ if(!window.externMethodEnabled) {
92
+ try {
93
+ if($$('#payment-buttons-container > button').length > 0) {
94
+ $$('#payment-buttons-container > button')[0].disable();
95
+ }
96
+ if($('onestepcheckout-place-order') != null) {
97
+ $('onestepcheckout-place-order').disable();
98
+ }
99
+ if($$('#review-buttons-container > button').length > 0) {
100
+ $$('#review-buttons-container > button')[0].disable();
101
+ }
102
+ if($('onestepcheckout-button-place-order') != null) {
103
+ $('onestepcheckout-button-place-order').disable();
104
+ }
105
+ if($$('#checkout-review-submit > button.opc-btn-checkout').length > 0) {
106
+ $$('#checkout-review-submit > button.opc-btn-checkout')[0].disable();
107
+ }
108
+ }catch (e) {
109
+ console.log(e);
110
+ }
111
+ }
112
+ },
113
+ <?php echo $this->getThirdPartyMethods(); ?>
114
+ });
115
+ }
116
+ window.startPPP();
117
+ function checkStep() {
118
+ try {
119
+ if(typeof window.checkout != 'undefined' && typeof window.lastStep == 'undefined') {
120
+ window.lastStep = window.checkout.accordion.currentSection;
121
+ }
122
+ if (typeof window.lastStep != 'undefined' && window.lastStep != window.checkout.accordion.currentSection) {
123
+ window.lastStep = checkout.accordion.currentSection;
124
+ if (checkout.accordion.currentSection == "opc-payment") {
125
+ window.startPPP();
126
+ }
127
+ }
128
+ } catch(e) {
129
+ }
130
+ }
131
+ window.setInterval(checkStep, 1000);
132
+
133
+ </script>
134
+ <?php endif; ?>
app/design/frontend/base/default/template/paypalplus/methods.phtml ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2006-2014 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ /**
29
+ * One page checkout payment methods
30
+ *
31
+ * @var $this Mage_Checkout_Block_Onepage_Payment_Methods
32
+ */
33
+ ?>
34
+ <script type="text/javascript">delete window.ppp;
35
+ if (typeof payment.parentSwitchMethod == 'undefined') {
36
+ payment.parentSwitchMethod = payment.switchMethod;
37
+ payment.switchMethod = function (method) {
38
+ if (
39
+ window.ppp != null && method != '<?php echo Iways_PayPalPlus_Model_Payment::METHOD_CODE; ?>'
40
+ && typeof window.thirdPartyMethodObject[method] == 'undefined'
41
+ ) {
42
+ window.externMethodEnabled = true;
43
+ window.ppp.deselectPaymentMethod();
44
+ } else {
45
+ window.externMethodEnabled = false;
46
+ }
47
+ try {
48
+ $$('.ppp').each(function (element) {
49
+ element.removeClassName('ppp-selected')
50
+ });
51
+ $$('.ppp.' + method).each(function (element) {
52
+ element.addClassName('ppp-selected')
53
+ });
54
+ } catch (e) {
55
+ console.log(e);
56
+ }
57
+ try {
58
+ console.log('enable');
59
+ if ($$('#payment-buttons-container > button').length > 0) {
60
+ $$('#payment-buttons-container > button')[0].enable();
61
+ }
62
+ if ($('onestepcheckout-place-order') != null) {
63
+ $('onestepcheckout-place-order').enable();
64
+ }
65
+ if ($$('#review-buttons-container > button').length > 0) {
66
+ $$('#review-buttons-container > button')[0].enable();
67
+ }
68
+ } catch (e) {
69
+ console.log(e);
70
+ }
71
+ return this.parentSwitchMethod(method);
72
+ }
73
+ }
74
+ </script>
75
+ <?php
76
+ $methods = $this->getMethods();
77
+ $oneMethod = count($methods) <= 1;
78
+
79
+ $thirdPartyMethods = $this->getThirdPartyMethods();
80
+ $pppActive = $this->isPPPActive();
81
+
82
+ $hideStyle = ' style="display:none;"';
83
+ ?>
84
+ <?php if (empty($methods) && !$pppActive): ?>
85
+ <dt>
86
+ <?php echo $this->__('No Payment Methods') ?>
87
+ </dt>
88
+ <?php else: ?>
89
+
90
+ <?php //else:
91
+ foreach ($methods as $_method) :
92
+ $_code = $_method->getCode();
93
+ if (isset($thirdPartyMethods[$_code]) && $pppActive) {
94
+ $hide = true;
95
+ } else {
96
+ $hide = false;
97
+ }
98
+ ?>
99
+ <dt class="ppp <?php echo $_code ?>"<?php if ($hide || $_code == Iways_PayPalPlus_Model_Payment::METHOD_CODE) {
100
+ echo $hideStyle;
101
+ } ?>>
102
+ <?php if (!$oneMethod): ?>
103
+ <input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio"
104
+ name="payment[method]" title="<?php echo $this->escapeHtml($_method->getTitle()) ?>"
105
+ onclick="payment.switchMethod('<?php echo $_code ?>')"
106
+ <?php if ($this->getSelectedMethodCode() == $_code): ?> checked="checked"<?php endif; ?>
107
+ class="radio"/>
108
+ <?php else: ?>
109
+ <span class="no-display"><input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>"
110
+ type="radio" name="payment[method]" checked="checked"
111
+ class="radio"/></span>
112
+ <?php $oneMethod = $_code; ?>
113
+ <?php endif; ?>
114
+ <label for="p_method_<?php echo $_code ?>">
115
+ <?php echo $this->escapeHtml($this->getMethodTitle($_method)) ?>
116
+ <?php echo $this->getMethodLabelAfterHtml($_method) ?>
117
+ </label>
118
+ </dt>
119
+ <dd class="ppp <?php echo $_code ?>"<?php if ($hide) {
120
+ echo $hideStyle;
121
+ } ?>><?php if ($html = $this->getPaymentMethodFormHtml($_method)): ?><?php echo $html; ?><?php endif; ?></dd>
122
+ <?php endforeach;
123
+ endif;
124
+ ?>
125
+ <?php echo $this->getChildChildHtml('additional'); ?>
126
+ <script type="text/javascript">
127
+ //<![CDATA[
128
+ <?php echo $this->getChildChildHtml('scripts'); ?>
129
+ payment.init();
130
+ <?php if (is_string($oneMethod)): ?>
131
+ payment.switchMethod('<?php echo $oneMethod ?>');
132
+ <?php endif; ?>
133
+ //]]>
134
+ </script>
app/design/frontend/base/default/template/paypalplus/payment/info.phtml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @see Iways_PayPalPlus_Block_Payment_Info
4
+ */
5
+ ?>
6
+ <p><strong><?php echo Mage::helper('iways_paypalplus')->__('PayPal Plus'); ?></strong></p>
7
+ <?php if ($_specificInfo = $this->getSpecificInformation()):?>
8
+ <p><?php echo Mage::helper('iways_paypalplus')->__('Please transfer the invoice amount to the given account within the payment deadline.'); ?></p>
9
+ <table>
10
+ <tbody>
11
+ <?php foreach ($_specificInfo as $_label => $_value):?>
12
+ <tr>
13
+ <th><strong><?php echo $this->escapeHtml($_label)?>:</strong></th>
14
+ </tr>
15
+ <tr>
16
+ <td><?php echo nl2br(implode($this->getValueAsArray($_value, true), "\n"))?></td>
17
+ </tr>
18
+ <?php endforeach; ?>
19
+ </tbody>
20
+ </table>
21
+ <?php endif;?>
22
+ <?php echo $this->getChildHtml()?>
app/design/frontend/base/default/template/paypalplus/review/button.phtml ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2006-2014 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <button type="submit" id="place-order-button" title="<?php echo $this->__('Place Order') ?>"
28
+ class="button btn-checkout"
29
+ onclick="return false;">
30
+ <span>
31
+ <span><?php echo $this->__('Place Order') ?></span>
32
+ </span>
33
+ </button>
34
+ <script type="text/javascript">
35
+ $('place-order-button').observe('click', function () {
36
+ if (payment.currentMethod == '<?php echo Iways_PayPalPlus_Model_Payment::METHOD_CODE; ?>') {
37
+ if ($('checkout-agreements') != null) {
38
+ if (checkout.loadWaiting != false) return;
39
+ checkout.setLoadWaiting('review');
40
+ params = Form.serialize($('checkout-agreements'));
41
+ params.validate = true;
42
+ var request = new Ajax.Request(
43
+ '<?php echo Mage::helper('iways_paypalplus')->getUrl('paypalplus/index/validate'); ?>',
44
+ {
45
+ method: 'post',
46
+ parameters: params,
47
+ onSuccess: function (transport) {
48
+ try {
49
+ response = eval('(' + transport.responseText + ')');
50
+ }
51
+ catch (e) {
52
+ response = {};
53
+ }
54
+ if (response.redirect) {
55
+ review.isSuccess = true;
56
+ window.ppp.doCheckout();
57
+ return;
58
+ }
59
+ if (response.success) {
60
+ review.isSuccess = true;
61
+ window.ppp.doCheckout();
62
+ }
63
+ else {
64
+ var msg = response.error_messages;
65
+ if (typeof(msg) == 'object') {
66
+ msg = msg.join("\n");
67
+ }
68
+ if (msg) {
69
+ alert(msg);
70
+ }
71
+ review.resetLoadWaiting(transport);
72
+ }
73
+ },
74
+ onFailure: checkout.ajaxFailure.bind(checkout)
75
+ }
76
+ );
77
+ } else {
78
+ review.isSuccess = true;
79
+ window.ppp.doCheckout();
80
+ }
81
+ } else {
82
+ review.save();
83
+ }
84
+ });
85
+ </script>
app/design/frontend/base/default/template/paypalplus/success.phtml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ($this->hasPaymentInstruction()) : ?>
2
+ <div class="ppp-pui">
3
+ <?php if ($this->isPUI()) : ?>
4
+ <p><?php echo Mage::helper('iways_paypalplus')->__(
5
+ 'Please transfer the invoice amount to the given account within the payment deadline.'
6
+ ); ?></p>
7
+ <?php endif; ?>
8
+ <table>
9
+ <tbody>
10
+ <tr>
11
+ <td class="ppp-pui-label">
12
+ <?php echo Mage::helper('iways_paypalplus')->__('Account holder:'); ?>
13
+ </td>
14
+ <td class="ppp-pui-value">
15
+ <?php echo $this->getAdditionalInformation('ppp_pui_account_holder_name'); ?>
16
+ </td>
17
+ </tr>
18
+ <tr>
19
+ <td class="ppp-pui-label">
20
+ <?php echo Mage::helper('iways_paypalplus')->__('Bank:'); ?>
21
+ </td>
22
+ <td class="ppp-pui-value">
23
+ <?php echo $this->getAdditionalInformation('ppp_pui_bank_name'); ?>
24
+ </td>
25
+ </tr>
26
+ <tr>
27
+ <td class="ppp-pui-label">
28
+ <?php echo Mage::helper('iways_paypalplus')->__('IBAN:'); ?>
29
+ </td>
30
+ <td class="ppp-pui-value">
31
+ <?php echo $this->getAdditionalInformation('ppp_pui_international_bank_account_number'); ?>
32
+ </td>
33
+ </tr>
34
+ <tr>
35
+ <td class="ppp-pui-label">
36
+ <?php echo Mage::helper('iways_paypalplus')->__('BIC:'); ?>
37
+ </td>
38
+ <td class="ppp-pui-value">
39
+ <?php echo $this->getAdditionalInformation('ppp_pui_bank_identifier_code'); ?>
40
+ </td>
41
+ </tr>
42
+ <tr>
43
+ <td class="ppp-pui-label">
44
+ <?php echo Mage::helper('iways_paypalplus')->__('Reference number:'); ?>
45
+ </td>
46
+ <td class="ppp-pui-value">
47
+ <?php echo $this->getAdditionalInformation('ppp_pui_reference_number'); ?>
48
+ </td>
49
+ </tr>
50
+ <?php if ($this->isPUI()) : ?>
51
+ <tr>
52
+ <td class="ppp-pui-label">
53
+ <?php echo Mage::helper('iways_paypalplus')->__('Payment due date:'); ?>
54
+ </td>
55
+ <td class="ppp-pui-value">
56
+ <?php echo $this->getAdditionalInformation('ppp_pui_payment_due_date'); ?>
57
+ </td>
58
+ </tr>
59
+ <?php endif; ?>
60
+ </tbody>
61
+ </table>
62
+ </div>
63
+ <?php elseif ($this->isPPP()): ?>
64
+ <div class="ppp-success"><?php echo $this->__('<i>processed by PayPal</i>'); ?></div>
65
+ <?php endif; ?>
app/etc/modules/Iways_PayPalPlus.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Iways_PayPalPlus>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Paypal />
9
+ <Mage_Api />
10
+ <Mage_Api2 />
11
+ </depends>
12
+ </Iways_PayPalPlus>
13
+ </modules>
14
+ </config>
app/locale/de_DE/Iways_PayPalPlus.csv ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "PayPalPlus Settings","PayPalPlus-Einstellungen"
2
+ "PayPalPlus Payment Settings","PayPalPlus-Einstellungen"
3
+ "PayPalPlus Third party methods info text","PayPalPlus Drittanbieterinformationstexte"
4
+ "Only selected and saved third party payments will be shown.","Nur ausgewählte und gespeicherte Zahlungsmethoden von Drittanbietern werden angezeigt."
5
+ "PayPalPlus Api Settings","PayPalPlus API-Einstellungen"
6
+ "Client ID","Klienten-ID"
7
+ "Client Secret","Klienten-Schlüssel"
8
+ "Mode","Modus"
9
+ "Enabled","Aktiviert"
10
+ "Payment from Applicable Countries","Ländereinstellung"
11
+ "Payment from Specific Countries","Erlaubte Länder"
12
+ "Allowed Third-Party Moduls","Erlaubte Zahlungsmethoden von Drittanbietern"
13
+ "Only select payment methods which doesn't require extra input in checkout.","Bitte wählen Sie nur Zahlungsmethoden aus, die keine weiteren Eingaben im Checkout benötigen."
14
+ "PayPalPlus Development Settings","PayPalPlus Entwicklereinstellungen"
15
+ "Enable autoloader for PayPal SDK","PayPalSDK-Autoloader aktiv"
16
+ "Disable if you have problems with other autoloaders.","Bei Problemen mit anderen PHP-Autoloader deaktivieren."
17
+ "Debug","Debug"
18
+ "<a href=""http://www.paypal.de"" target=""_blank"">How to retrieve your PayPal API credentials.</a>","<a href=""http://www.paypal.de"" target=""_blank"">Wie Sie Ihre Zugangsdaten erhalten.</a>"
19
+ "<a href=""https://www.paypalobjects.com/webstatic/de_DE/downloads/PayPal_Nutzung_der_REST_API.pdf"" target=""_blank"">How to retrieve your PayPal API credentials.</a>","<a href=""https://www.paypalobjects.com/webstatic/de_DE/downloads/PayPal_Nutzung_der_REST_API.pdf"" target=""_blank"">Wie Sie Ihre Zugangsdaten erhalten.</a>"
20
+ "Header Image URL","Kopfbereich-Bild-URL"
21
+ "The image at the top left of the checkout page. Max size is 750x90-pixel. <strong style=""color:red"">https</strong> is highly encouraged.","Das Bild oben links auf der Bezahlseite. Max. 750px × 90px. <strong style=""color:red"">https</strong> wird dringend empfohlen."
22
+ "Please select an other payment method.","Bitte wählen Sie eine andere Zahlungsmethode."
23
+ "Provided credentials not valid.","Ihre Zugangsdaten können nicht validiert werden."
24
+ "<i>processed by PayPal</i>","<i>wurde von PayPal prozessiert</i>"
25
+ "Account holder","Kontobesitzer"
26
+ "Bank","Bank"
27
+ "IBAN","IBAN"
28
+ "BIC","BIC"
29
+ "Transaction ID","Transaktionsnummer"
30
+ "Reference number","Verwendungszweck"
31
+ "Payment due date","Fälligkeitsdatum"
32
+ "Account holder:","Kontobesitzer:"
33
+ "Bank:","Bank:"
34
+ "IBAN:","IBAN:"
35
+ "BIC:","BIC:"
36
+ "Reference number:","Verwendungszweck:"
37
+ "Payment due date:","Fälligkeitsdatum:"
38
+ "Pay upon Invoice","Kauf auf Rechnung"
39
+ "Show PuI in Sandbox","Kauf auf Rechnung in der Sandbox anzeigen"
40
+ "Please transfer the invoice amount to the given account within the payment deadline.","Bitte überweisen Sie den Rechnungsbetrag auf das angegebene Konto innerhalb der Zahlungsfrist."
41
+ "Transfer order's ID as PayPal invoice number","Bestellnummer als PayPal Rechnungsnummer übertragen"
42
+ "PayPal Plus","PayPal, Lastschrift, Kreditkarte, Kauf auf Rechnung"
43
+ "Show loading indicator","Loading Indicator anzeigen"
lib/PayPal/Api/Address.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ /**
6
+ * Class Address
7
+ *
8
+ * Base Address object used as billing address in a payment or extended for Shipping Address.
9
+ *
10
+ * @package PayPal\Api
11
+ *
12
+ * @property string phone
13
+ */
14
+ class Address extends BaseAddress
15
+ {
16
+ /**
17
+ * Phone number in E.123 format.
18
+ *
19
+ * @param string $phone
20
+ *
21
+ * @return $this
22
+ */
23
+ public function setPhone($phone)
24
+ {
25
+ $this->phone = $phone;
26
+ return $this;
27
+ }
28
+
29
+ /**
30
+ * Phone number in E.123 format.
31
+ *
32
+ * @return string
33
+ */
34
+ public function getPhone()
35
+ {
36
+ return $this->phone;
37
+ }
38
+
39
+ }
lib/PayPal/Api/Agreement.php ADDED
@@ -0,0 +1,647 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalResourceModel;
6
+ use PayPal\Core\PayPalConstants;
7
+ use PayPal\Rest\ApiContext;
8
+ use PayPal\Transport\PayPalRestCall;
9
+ use PayPal\Validation\ArgumentValidator;
10
+
11
+ /**
12
+ * Class Agreement
13
+ *
14
+ * A resource representing an agreement.
15
+ *
16
+ * @package PayPal\Api
17
+ *
18
+ * @property string id
19
+ * @property string state
20
+ * @property string name
21
+ * @property string description
22
+ * @property string start_date
23
+ * @property \PayPal\Api\Payer payer
24
+ * @property \PayPal\Api\Address shipping_address
25
+ * @property \PayPal\Api\MerchantPreferences override_merchant_preferences
26
+ * @property \PayPal\Api\OverrideChargeModel[] override_charge_models
27
+ * @property \PayPal\Api\Plan plan
28
+ * @property string create_time
29
+ * @property string update_time
30
+ * @property \PayPal\Api\AgreementDetails agreement_details
31
+ */
32
+ class Agreement extends PayPalResourceModel
33
+ {
34
+ /**
35
+ * Identifier of the agreement.
36
+ *
37
+ * @param string $id
38
+ *
39
+ * @return $this
40
+ */
41
+ public function setId($id)
42
+ {
43
+ $this->id = $id;
44
+ return $this;
45
+ }
46
+
47
+ /**
48
+ * Identifier of the agreement.
49
+ *
50
+ * @return string
51
+ */
52
+ public function getId()
53
+ {
54
+ return $this->id;
55
+ }
56
+
57
+ /**
58
+ * State of the agreement.
59
+ *
60
+ * @param string $state
61
+ *
62
+ * @return $this
63
+ */
64
+ public function setState($state)
65
+ {
66
+ $this->state = $state;
67
+ return $this;
68
+ }
69
+
70
+ /**
71
+ * State of the agreement.
72
+ *
73
+ * @return string
74
+ */
75
+ public function getState()
76
+ {
77
+ return $this->state;
78
+ }
79
+
80
+ /**
81
+ * Name of the agreement.
82
+ *
83
+ * @param string $name
84
+ *
85
+ * @return $this
86
+ */
87
+ public function setName($name)
88
+ {
89
+ $this->name = $name;
90
+ return $this;
91
+ }
92
+
93
+ /**
94
+ * Name of the agreement.
95
+ *
96
+ * @return string
97
+ */
98
+ public function getName()
99
+ {
100
+ return $this->name;
101
+ }
102
+
103
+ /**
104
+ * Description of the agreement.
105
+ *
106
+ * @param string $description
107
+ *
108
+ * @return $this
109
+ */
110
+ public function setDescription($description)
111
+ {
112
+ $this->description = $description;
113
+ return $this;
114
+ }
115
+
116
+ /**
117
+ * Description of the agreement.
118
+ *
119
+ * @return string
120
+ */
121
+ public function getDescription()
122
+ {
123
+ return $this->description;
124
+ }
125
+
126
+ /**
127
+ * Start date of the agreement. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
128
+ *
129
+ * @param string $start_date
130
+ *
131
+ * @return $this
132
+ */
133
+ public function setStartDate($start_date)
134
+ {
135
+ $this->start_date = $start_date;
136
+ return $this;
137
+ }
138
+
139
+ /**
140
+ * Start date of the agreement. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
141
+ *
142
+ * @return string
143
+ */
144
+ public function getStartDate()
145
+ {
146
+ return $this->start_date;
147
+ }
148
+
149
+ /**
150
+ * Details of the buyer who is enrolling in this agreement. This information is gathered from execution of the approval URL.
151
+ *
152
+ * @param \PayPal\Api\Payer $payer
153
+ *
154
+ * @return $this
155
+ */
156
+ public function setPayer($payer)
157
+ {
158
+ $this->payer = $payer;
159
+ return $this;
160
+ }
161
+
162
+ /**
163
+ * Details of the buyer who is enrolling in this agreement. This information is gathered from execution of the approval URL.
164
+ *
165
+ * @return \PayPal\Api\Payer
166
+ */
167
+ public function getPayer()
168
+ {
169
+ return $this->payer;
170
+ }
171
+
172
+ /**
173
+ * Shipping address object of the agreement, which should be provided if it is different from the default address.
174
+ *
175
+ * @param \PayPal\Api\Address $shipping_address
176
+ *
177
+ * @return $this
178
+ */
179
+ public function setShippingAddress($shipping_address)
180
+ {
181
+ $this->shipping_address = $shipping_address;
182
+ return $this;
183
+ }
184
+
185
+ /**
186
+ * Shipping address object of the agreement, which should be provided if it is different from the default address.
187
+ *
188
+ * @return \PayPal\Api\Address
189
+ */
190
+ public function getShippingAddress()
191
+ {
192
+ return $this->shipping_address;
193
+ }
194
+
195
+ /**
196
+ * Default merchant preferences from the billing plan are used, unless override preferences are provided here.
197
+ *
198
+ * @param \PayPal\Api\MerchantPreferences $override_merchant_preferences
199
+ *
200
+ * @return $this
201
+ */
202
+ public function setOverrideMerchantPreferences($override_merchant_preferences)
203
+ {
204
+ $this->override_merchant_preferences = $override_merchant_preferences;
205
+ return $this;
206
+ }
207
+
208
+ /**
209
+ * Default merchant preferences from the billing plan are used, unless override preferences are provided here.
210
+ *
211
+ * @return \PayPal\Api\MerchantPreferences
212
+ */
213
+ public function getOverrideMerchantPreferences()
214
+ {
215
+ return $this->override_merchant_preferences;
216
+ }
217
+
218
+ /**
219
+ * Array of override_charge_model for this agreement if needed to change the default models from the billing plan.
220
+ *
221
+ * @param \PayPal\Api\OverrideChargeModel[] $override_charge_models
222
+ *
223
+ * @return $this
224
+ */
225
+ public function setOverrideChargeModels($override_charge_models)
226
+ {
227
+ $this->override_charge_models = $override_charge_models;
228
+ return $this;
229
+ }
230
+
231
+ /**
232
+ * Array of override_charge_model for this agreement if needed to change the default models from the billing plan.
233
+ *
234
+ * @return \PayPal\Api\OverrideChargeModel[]
235
+ */
236
+ public function getOverrideChargeModels()
237
+ {
238
+ return $this->override_charge_models;
239
+ }
240
+
241
+ /**
242
+ * Append OverrideChargeModels to the list.
243
+ *
244
+ * @param \PayPal\Api\OverrideChargeModel $overrideChargeModel
245
+ * @return $this
246
+ */
247
+ public function addOverrideChargeModel($overrideChargeModel)
248
+ {
249
+ if (!$this->getOverrideChargeModels()) {
250
+ return $this->setOverrideChargeModels(array($overrideChargeModel));
251
+ } else {
252
+ return $this->setOverrideChargeModels(
253
+ array_merge($this->getOverrideChargeModels(), array($overrideChargeModel))
254
+ );
255
+ }
256
+ }
257
+
258
+ /**
259
+ * Remove OverrideChargeModels from the list.
260
+ *
261
+ * @param \PayPal\Api\OverrideChargeModel $overrideChargeModel
262
+ * @return $this
263
+ */
264
+ public function removeOverrideChargeModel($overrideChargeModel)
265
+ {
266
+ return $this->setOverrideChargeModels(
267
+ array_diff($this->getOverrideChargeModels(), array($overrideChargeModel))
268
+ );
269
+ }
270
+
271
+ /**
272
+ * Plan details for this agreement.
273
+ *
274
+ * @param \PayPal\Api\Plan $plan
275
+ *
276
+ * @return $this
277
+ */
278
+ public function setPlan($plan)
279
+ {
280
+ $this->plan = $plan;
281
+ return $this;
282
+ }
283
+
284
+ /**
285
+ * Plan details for this agreement.
286
+ *
287
+ * @return \PayPal\Api\Plan
288
+ */
289
+ public function getPlan()
290
+ {
291
+ return $this->plan;
292
+ }
293
+
294
+ /**
295
+ * Date and time that this resource was created. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
296
+ *
297
+ * @param string $create_time
298
+ *
299
+ * @return $this
300
+ */
301
+ public function setCreateTime($create_time)
302
+ {
303
+ $this->create_time = $create_time;
304
+ return $this;
305
+ }
306
+
307
+ /**
308
+ * Date and time that this resource was created. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
309
+ *
310
+ * @return string
311
+ */
312
+ public function getCreateTime()
313
+ {
314
+ return $this->create_time;
315
+ }
316
+
317
+ /**
318
+ * Date and time that this resource was updated. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
319
+ *
320
+ * @param string $update_time
321
+ *
322
+ * @return $this
323
+ */
324
+ public function setUpdateTime($update_time)
325
+ {
326
+ $this->update_time = $update_time;
327
+ return $this;
328
+ }
329
+
330
+ /**
331
+ * Date and time that this resource was updated. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
332
+ *
333
+ * @return string
334
+ */
335
+ public function getUpdateTime()
336
+ {
337
+ return $this->update_time;
338
+ }
339
+
340
+ /**
341
+ * Agreement Details
342
+ *
343
+ * @param \PayPal\Api\AgreementDetails $agreement_details
344
+ *
345
+ * @return $this
346
+ */
347
+ public function setAgreementDetails($agreement_details)
348
+ {
349
+ $this->agreement_details = $agreement_details;
350
+ return $this;
351
+ }
352
+
353
+ /**
354
+ * Agreement Details
355
+ *
356
+ * @return \PayPal\Api\AgreementDetails
357
+ */
358
+ public function getAgreementDetails()
359
+ {
360
+ return $this->agreement_details;
361
+ }
362
+
363
+ /**
364
+ * Get Approval Link
365
+ *
366
+ * @return null|string
367
+ */
368
+ public function getApprovalLink()
369
+ {
370
+ return $this->getLink(PayPalConstants::APPROVAL_URL);
371
+ }
372
+
373
+ /**
374
+ * Create a new billing agreement by passing the details for the agreement, including the name, description, start date, payer, and billing plan in the request JSON.
375
+ *
376
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
377
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
378
+ * @return Agreement
379
+ */
380
+ public function create($apiContext = null, $restCall = null)
381
+ {
382
+ $payLoad = $this->toJSON();
383
+ $json = self::executeCall(
384
+ "/v1/payments/billing-agreements/",
385
+ "POST",
386
+ $payLoad,
387
+ null,
388
+ $apiContext,
389
+ $restCall
390
+ );
391
+ $this->fromJson($json);
392
+ return $this;
393
+ }
394
+
395
+ /**
396
+ * Execute a billing agreement after buyer approval by passing the payment token to the request URI.
397
+ *
398
+ * @param $paymentToken
399
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
400
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
401
+ * @return Agreement
402
+ */
403
+ public function execute($paymentToken, $apiContext = null, $restCall = null)
404
+ {
405
+ ArgumentValidator::validate($paymentToken, 'paymentToken');
406
+ $payLoad = "";
407
+ $json = self::executeCall(
408
+ "/v1/payments/billing-agreements/$paymentToken/agreement-execute",
409
+ "POST",
410
+ $payLoad,
411
+ null,
412
+ $apiContext,
413
+ $restCall
414
+ );
415
+ $this->fromJson($json);
416
+ return $this;
417
+ }
418
+
419
+ /**
420
+ * Retrieve details for a particular billing agreement by passing the ID of the agreement to the request URI.
421
+ *
422
+ * @param string $agreementId
423
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
424
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
425
+ * @return Agreement
426
+ */
427
+ public static function get($agreementId, $apiContext = null, $restCall = null)
428
+ {
429
+ ArgumentValidator::validate($agreementId, 'agreementId');
430
+ $payLoad = "";
431
+ $json = self::executeCall(
432
+ "/v1/payments/billing-agreements/$agreementId",
433
+ "GET",
434
+ $payLoad,
435
+ null,
436
+ $apiContext,
437
+ $restCall
438
+ );
439
+ $ret = new Agreement();
440
+ $ret->fromJson($json);
441
+ return $ret;
442
+ }
443
+
444
+ /**
445
+ * Update details of a billing agreement, such as the description, shipping address, and start date, by passing the ID of the agreement to the request URI.
446
+ *
447
+ * @param PatchRequest $patchRequest
448
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
449
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
450
+ * @return bool
451
+ */
452
+ public function update($patchRequest, $apiContext = null, $restCall = null)
453
+ {
454
+ ArgumentValidator::validate($this->getId(), "Id");
455
+ ArgumentValidator::validate($patchRequest, 'patchRequest');
456
+ $payLoad = $patchRequest->toJSON();
457
+ self::executeCall(
458
+ "/v1/payments/billing-agreements/{$this->getId()}",
459
+ "PATCH",
460
+ $payLoad,
461
+ null,
462
+ $apiContext,
463
+ $restCall
464
+ );
465
+ return true;
466
+ }
467
+
468
+ /**
469
+ * Suspend a particular billing agreement by passing the ID of the agreement to the request URI.
470
+ *
471
+ * @param AgreementStateDescriptor $agreementStateDescriptor
472
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
473
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
474
+ * @return bool
475
+ */
476
+ public function suspend($agreementStateDescriptor, $apiContext = null, $restCall = null)
477
+ {
478
+ ArgumentValidator::validate($this->getId(), "Id");
479
+ ArgumentValidator::validate($agreementStateDescriptor, 'agreementStateDescriptor');
480
+ $payLoad = $agreementStateDescriptor->toJSON();
481
+ self::executeCall(
482
+ "/v1/payments/billing-agreements/{$this->getId()}/suspend",
483
+ "POST",
484
+ $payLoad,
485
+ null,
486
+ $apiContext,
487
+ $restCall
488
+ );
489
+ return true;
490
+ }
491
+
492
+ /**
493
+ * Reactivate a suspended billing agreement by passing the ID of the agreement to the appropriate URI. In addition, pass an agreement_state_descriptor object in the request JSON that includes a note about the reason for changing the state of the agreement and the amount and currency for the agreement.
494
+ *
495
+ * @param AgreementStateDescriptor $agreementStateDescriptor
496
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
497
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
498
+ * @return bool
499
+ */
500
+ public function reActivate($agreementStateDescriptor, $apiContext = null, $restCall = null)
501
+ {
502
+ ArgumentValidator::validate($this->getId(), "Id");
503
+ ArgumentValidator::validate($agreementStateDescriptor, 'agreementStateDescriptor');
504
+ $payLoad = $agreementStateDescriptor->toJSON();
505
+ self::executeCall(
506
+ "/v1/payments/billing-agreements/{$this->getId()}/re-activate",
507
+ "POST",
508
+ $payLoad,
509
+ null,
510
+ $apiContext,
511
+ $restCall
512
+ );
513
+ return true;
514
+ }
515
+
516
+ /**
517
+ * Cancel a billing agreement by passing the ID of the agreement to the request URI. In addition, pass an agreement_state_descriptor object in the request JSON that includes a note about the reason for changing the state of the agreement and the amount and currency for the agreement.
518
+ *
519
+ * @param AgreementStateDescriptor $agreementStateDescriptor
520
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
521
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
522
+ * @return bool
523
+ */
524
+ public function cancel($agreementStateDescriptor, $apiContext = null, $restCall = null)
525
+ {
526
+ ArgumentValidator::validate($this->getId(), "Id");
527
+ ArgumentValidator::validate($agreementStateDescriptor, 'agreementStateDescriptor');
528
+ $payLoad = $agreementStateDescriptor->toJSON();
529
+ self::executeCall(
530
+ "/v1/payments/billing-agreements/{$this->getId()}/cancel",
531
+ "POST",
532
+ $payLoad,
533
+ null,
534
+ $apiContext,
535
+ $restCall
536
+ );
537
+ return true;
538
+ }
539
+
540
+ /**
541
+ * Bill an outstanding amount for an agreement by passing the ID of the agreement to the request URI. In addition, pass an agreement_state_descriptor object in the request JSON that includes a note about the reason for changing the state of the agreement and the amount and currency for the agreement.
542
+ *
543
+ * @param AgreementStateDescriptor $agreementStateDescriptor
544
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
545
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
546
+ * @return bool
547
+ */
548
+ public function billBalance($agreementStateDescriptor, $apiContext = null, $restCall = null)
549
+ {
550
+ ArgumentValidator::validate($this->getId(), "Id");
551
+ ArgumentValidator::validate($agreementStateDescriptor, 'agreementStateDescriptor');
552
+ $payLoad = $agreementStateDescriptor->toJSON();
553
+ self::executeCall(
554
+ "/v1/payments/billing-agreements/{$this->getId()}/bill-balance",
555
+ "POST",
556
+ $payLoad,
557
+ null,
558
+ $apiContext,
559
+ $restCall
560
+ );
561
+ return true;
562
+ }
563
+
564
+ /**
565
+ * Set the balance for an agreement by passing the ID of the agreement to the request URI. In addition, pass a common_currency object in the request JSON that specifies the currency type and value of the balance.
566
+ *
567
+ * @param Currency $currency
568
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
569
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
570
+ * @return bool
571
+ */
572
+ public function setBalance($currency, $apiContext = null, $restCall = null)
573
+ {
574
+ ArgumentValidator::validate($this->getId(), "Id");
575
+ ArgumentValidator::validate($currency, 'currency');
576
+ $payLoad = $currency->toJSON();
577
+ self::executeCall(
578
+ "/v1/payments/billing-agreements/{$this->getId()}/set-balance",
579
+ "POST",
580
+ $payLoad,
581
+ null,
582
+ $apiContext,
583
+ $restCall
584
+ );
585
+ return true;
586
+ }
587
+
588
+ /**
589
+ * List transactions for a billing agreement by passing the ID of the agreement, as well as the start and end dates of the range of transactions to list, to the request URI.
590
+ *
591
+ * @deprecated Please use searchTransactions Instead
592
+ * @param string $agreementId
593
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
594
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
595
+ * @return AgreementTransactions
596
+ */
597
+ public static function transactions($agreementId, $apiContext = null, $restCall = null)
598
+ {
599
+ ArgumentValidator::validate($agreementId, 'agreementId');
600
+ $payLoad = "";
601
+ $json = self::executeCall(
602
+ "/v1/payments/billing-agreements/$agreementId/transactions",
603
+ "GET",
604
+ $payLoad,
605
+ null,
606
+ $apiContext,
607
+ $restCall
608
+ );
609
+ $ret = new AgreementTransactions();
610
+ $ret->fromJson($json);
611
+ return $ret;
612
+ }
613
+
614
+ /**
615
+ * List transactions for a billing agreement by passing the ID of the agreement, as well as the start and end dates of the range of transactions to list, to the request URI.
616
+ *
617
+ * @param string $agreementId
618
+ * @param array $params Parameters for search string. Options: start_date, and end_date
619
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
620
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
621
+ * @return AgreementTransactions
622
+ */
623
+ public static function searchTransactions($agreementId, $params = array(), $apiContext = null, $restCall = null)
624
+ {
625
+ ArgumentValidator::validate($agreementId, 'agreementId');
626
+ ArgumentValidator::validate($params, 'params');
627
+
628
+ $allowedParams = array(
629
+ 'start_date' => 1,
630
+ 'end_date' => 1,
631
+ );
632
+
633
+ $payLoad = "";
634
+ $json = self::executeCall(
635
+ "/v1/payments/billing-agreements/$agreementId/transactions?" . http_build_query(array_intersect_key($params, $allowedParams)),
636
+ "GET",
637
+ $payLoad,
638
+ null,
639
+ $apiContext,
640
+ $restCall
641
+ );
642
+ $ret = new AgreementTransactions();
643
+ $ret->fromJson($json);
644
+ return $ret;
645
+ }
646
+
647
+ }
lib/PayPal/Api/AgreementDetails.php ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class AgreementDetails
9
+ *
10
+ * A resource representing the agreement details.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property \PayPal\Api\Currency outstanding_balance
15
+ * @property string cycles_remaining
16
+ * @property string cycles_completed
17
+ * @property string next_billing_date
18
+ * @property string last_payment_date
19
+ * @property \PayPal\Api\Currency last_payment_amount
20
+ * @property string final_payment_date
21
+ * @property string failed_payment_count
22
+ */
23
+ class AgreementDetails extends PayPalModel
24
+ {
25
+ /**
26
+ * The outstanding balance for this agreement.
27
+ *
28
+ * @param \PayPal\Api\Currency $outstanding_balance
29
+ *
30
+ * @return $this
31
+ */
32
+ public function setOutstandingBalance($outstanding_balance)
33
+ {
34
+ $this->outstanding_balance = $outstanding_balance;
35
+ return $this;
36
+ }
37
+
38
+ /**
39
+ * The outstanding balance for this agreement.
40
+ *
41
+ * @return \PayPal\Api\Currency
42
+ */
43
+ public function getOutstandingBalance()
44
+ {
45
+ return $this->outstanding_balance;
46
+ }
47
+
48
+ /**
49
+ * Number of cycles remaining for this agreement.
50
+ *
51
+ * @param string $cycles_remaining
52
+ *
53
+ * @return $this
54
+ */
55
+ public function setCyclesRemaining($cycles_remaining)
56
+ {
57
+ $this->cycles_remaining = $cycles_remaining;
58
+ return $this;
59
+ }
60
+
61
+ /**
62
+ * Number of cycles remaining for this agreement.
63
+ *
64
+ * @return string
65
+ */
66
+ public function getCyclesRemaining()
67
+ {
68
+ return $this->cycles_remaining;
69
+ }
70
+
71
+ /**
72
+ * Number of cycles completed for this agreement.
73
+ *
74
+ * @param string $cycles_completed
75
+ *
76
+ * @return $this
77
+ */
78
+ public function setCyclesCompleted($cycles_completed)
79
+ {
80
+ $this->cycles_completed = $cycles_completed;
81
+ return $this;
82
+ }
83
+
84
+ /**
85
+ * Number of cycles completed for this agreement.
86
+ *
87
+ * @return string
88
+ */
89
+ public function getCyclesCompleted()
90
+ {
91
+ return $this->cycles_completed;
92
+ }
93
+
94
+ /**
95
+ * The next billing date for this agreement, represented as 2014-02-19T10:00:00Z format.
96
+ *
97
+ * @param string $next_billing_date
98
+ *
99
+ * @return $this
100
+ */
101
+ public function setNextBillingDate($next_billing_date)
102
+ {
103
+ $this->next_billing_date = $next_billing_date;
104
+ return $this;
105
+ }
106
+
107
+ /**
108
+ * The next billing date for this agreement, represented as 2014-02-19T10:00:00Z format.
109
+ *
110
+ * @return string
111
+ */
112
+ public function getNextBillingDate()
113
+ {
114
+ return $this->next_billing_date;
115
+ }
116
+
117
+ /**
118
+ * Last payment date for this agreement, represented as 2014-06-09T09:42:31Z format.
119
+ *
120
+ * @param string $last_payment_date
121
+ *
122
+ * @return $this
123
+ */
124
+ public function setLastPaymentDate($last_payment_date)
125
+ {
126
+ $this->last_payment_date = $last_payment_date;
127
+ return $this;
128
+ }
129
+
130
+ /**
131
+ * Last payment date for this agreement, represented as 2014-06-09T09:42:31Z format.
132
+ *
133
+ * @return string
134
+ */
135
+ public function getLastPaymentDate()
136
+ {
137
+ return $this->last_payment_date;
138
+ }
139
+
140
+ /**
141
+ * Last payment amount for this agreement.
142
+ *
143
+ * @param \PayPal\Api\Currency $last_payment_amount
144
+ *
145
+ * @return $this
146
+ */
147
+ public function setLastPaymentAmount($last_payment_amount)
148
+ {
149
+ $this->last_payment_amount = $last_payment_amount;
150
+ return $this;
151
+ }
152
+
153
+ /**
154
+ * Last payment amount for this agreement.
155
+ *
156
+ * @return \PayPal\Api\Currency
157
+ */
158
+ public function getLastPaymentAmount()
159
+ {
160
+ return $this->last_payment_amount;
161
+ }
162
+
163
+ /**
164
+ * Last payment date for this agreement, represented as 2015-02-19T10:00:00Z format.
165
+ *
166
+ * @param string $final_payment_date
167
+ *
168
+ * @return $this
169
+ */
170
+ public function setFinalPaymentDate($final_payment_date)
171
+ {
172
+ $this->final_payment_date = $final_payment_date;
173
+ return $this;
174
+ }
175
+
176
+ /**
177
+ * Last payment date for this agreement, represented as 2015-02-19T10:00:00Z format.
178
+ *
179
+ * @return string
180
+ */
181
+ public function getFinalPaymentDate()
182
+ {
183
+ return $this->final_payment_date;
184
+ }
185
+
186
+ /**
187
+ * Total number of failed payments for this agreement.
188
+ *
189
+ * @param string $failed_payment_count
190
+ *
191
+ * @return $this
192
+ */
193
+ public function setFailedPaymentCount($failed_payment_count)
194
+ {
195
+ $this->failed_payment_count = $failed_payment_count;
196
+ return $this;
197
+ }
198
+
199
+ /**
200
+ * Total number of failed payments for this agreement.
201
+ *
202
+ * @return string
203
+ */
204
+ public function getFailedPaymentCount()
205
+ {
206
+ return $this->failed_payment_count;
207
+ }
208
+
209
+ }
lib/PayPal/Api/AgreementStateDescriptor.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class AgreementStateDescriptor
9
+ *
10
+ * Description of the current state of the agreement.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string note
15
+ * @property \PayPal\Api\Currency amount
16
+ */
17
+ class AgreementStateDescriptor extends PayPalModel
18
+ {
19
+ /**
20
+ * Reason for changing the state of the agreement.
21
+ *
22
+ * @param string $note
23
+ *
24
+ * @return $this
25
+ */
26
+ public function setNote($note)
27
+ {
28
+ $this->note = $note;
29
+ return $this;
30
+ }
31
+
32
+ /**
33
+ * Reason for changing the state of the agreement.
34
+ *
35
+ * @return string
36
+ */
37
+ public function getNote()
38
+ {
39
+ return $this->note;
40
+ }
41
+
42
+ /**
43
+ * The amount and currency of the agreement.
44
+ *
45
+ * @param \PayPal\Api\Currency $amount
46
+ *
47
+ * @return $this
48
+ */
49
+ public function setAmount($amount)
50
+ {
51
+ $this->amount = $amount;
52
+ return $this;
53
+ }
54
+
55
+ /**
56
+ * The amount and currency of the agreement.
57
+ *
58
+ * @return \PayPal\Api\Currency
59
+ */
60
+ public function getAmount()
61
+ {
62
+ return $this->amount;
63
+ }
64
+
65
+ }
lib/PayPal/Api/AgreementTransaction.php ADDED
@@ -0,0 +1,257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class AgreementTransaction
9
+ *
10
+ * A resource representing an agreement_transaction that is returned during a transaction search.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string transaction_id
15
+ * @property string status
16
+ * @property string transaction_type
17
+ * @property \PayPal\Api\Currency amount
18
+ * @property \PayPal\Api\Currency fee_amount
19
+ * @property \PayPal\Api\Currency net_amount
20
+ * @property string payer_email
21
+ * @property string payer_name
22
+ * @property string time_stamp
23
+ * @property string time_zone
24
+ */
25
+ class AgreementTransaction extends PayPalModel
26
+ {
27
+ /**
28
+ * Id corresponding to this transaction.
29
+ *
30
+ * @param string $transaction_id
31
+ *
32
+ * @return $this
33
+ */
34
+ public function setTransactionId($transaction_id)
35
+ {
36
+ $this->transaction_id = $transaction_id;
37
+ return $this;
38
+ }
39
+
40
+ /**
41
+ * Id corresponding to this transaction.
42
+ *
43
+ * @return string
44
+ */
45
+ public function getTransactionId()
46
+ {
47
+ return $this->transaction_id;
48
+ }
49
+
50
+ /**
51
+ * State of the subscription at this time.
52
+ *
53
+ * @param string $status
54
+ *
55
+ * @return $this
56
+ */
57
+ public function setStatus($status)
58
+ {
59
+ $this->status = $status;
60
+ return $this;
61
+ }
62
+
63
+ /**
64
+ * State of the subscription at this time.
65
+ *
66
+ * @return string
67
+ */
68
+ public function getStatus()
69
+ {
70
+ return $this->status;
71
+ }
72
+
73
+ /**
74
+ * Type of transaction, usually Recurring Payment.
75
+ *
76
+ * @param string $transaction_type
77
+ *
78
+ * @return $this
79
+ */
80
+ public function setTransactionType($transaction_type)
81
+ {
82
+ $this->transaction_type = $transaction_type;
83
+ return $this;
84
+ }
85
+
86
+ /**
87
+ * Type of transaction, usually Recurring Payment.
88
+ *
89
+ * @return string
90
+ */
91
+ public function getTransactionType()
92
+ {
93
+ return $this->transaction_type;
94
+ }
95
+
96
+ /**
97
+ * Amount for this transaction.
98
+ *
99
+ * @param \PayPal\Api\Currency $amount
100
+ *
101
+ * @return $this
102
+ */
103
+ public function setAmount($amount)
104
+ {
105
+ $this->amount = $amount;
106
+ return $this;
107
+ }
108
+
109
+ /**
110
+ * Amount for this transaction.
111
+ *
112
+ * @return \PayPal\Api\Currency
113
+ */
114
+ public function getAmount()
115
+ {
116
+ return $this->amount;
117
+ }
118
+
119
+ /**
120
+ * Fee amount for this transaction.
121
+ *
122
+ * @param \PayPal\Api\Currency $fee_amount
123
+ *
124
+ * @return $this
125
+ */
126
+ public function setFeeAmount($fee_amount)
127
+ {
128
+ $this->fee_amount = $fee_amount;
129
+ return $this;
130
+ }
131
+
132
+ /**
133
+ * Fee amount for this transaction.
134
+ *
135
+ * @return \PayPal\Api\Currency
136
+ */
137
+ public function getFeeAmount()
138
+ {
139
+ return $this->fee_amount;
140
+ }
141
+
142
+ /**
143
+ * Net amount for this transaction.
144
+ *
145
+ * @param \PayPal\Api\Currency $net_amount
146
+ *
147
+ * @return $this
148
+ */
149
+ public function setNetAmount($net_amount)
150
+ {
151
+ $this->net_amount = $net_amount;
152
+ return $this;
153
+ }
154
+
155
+ /**
156
+ * Net amount for this transaction.
157
+ *
158
+ * @return \PayPal\Api\Currency
159
+ */
160
+ public function getNetAmount()
161
+ {
162
+ return $this->net_amount;
163
+ }
164
+
165
+ /**
166
+ * Email id of payer.
167
+ *
168
+ * @param string $payer_email
169
+ *
170
+ * @return $this
171
+ */
172
+ public function setPayerEmail($payer_email)
173
+ {
174
+ $this->payer_email = $payer_email;
175
+ return $this;
176
+ }
177
+
178
+ /**
179
+ * Email id of payer.
180
+ *
181
+ * @return string
182
+ */
183
+ public function getPayerEmail()
184
+ {
185
+ return $this->payer_email;
186
+ }
187
+
188
+ /**
189
+ * Business name of payer.
190
+ *
191
+ * @param string $payer_name
192
+ *
193
+ * @return $this
194
+ */
195
+ public function setPayerName($payer_name)
196
+ {
197
+ $this->payer_name = $payer_name;
198
+ return $this;
199
+ }
200
+
201
+ /**
202
+ * Business name of payer.
203
+ *
204
+ * @return string
205
+ */
206
+ public function getPayerName()
207
+ {
208
+ return $this->payer_name;
209
+ }
210
+
211
+ /**
212
+ * Time at which this transaction happened.
213
+ *
214
+ * @param string $time_stamp
215
+ *
216
+ * @return $this
217
+ */
218
+ public function setTimeStamp($time_stamp)
219
+ {
220
+ $this->time_stamp = $time_stamp;
221
+ return $this;
222
+ }
223
+
224
+ /**
225
+ * Time at which this transaction happened.
226
+ *
227
+ * @return string
228
+ */
229
+ public function getTimeStamp()
230
+ {
231
+ return $this->time_stamp;
232
+ }
233
+
234
+ /**
235
+ * Time zone of time_updated field.
236
+ *
237
+ * @param string $time_zone
238
+ *
239
+ * @return $this
240
+ */
241
+ public function setTimeZone($time_zone)
242
+ {
243
+ $this->time_zone = $time_zone;
244
+ return $this;
245
+ }
246
+
247
+ /**
248
+ * Time zone of time_updated field.
249
+ *
250
+ * @return string
251
+ */
252
+ public function getTimeZone()
253
+ {
254
+ return $this->time_zone;
255
+ }
256
+
257
+ }
lib/PayPal/Api/AgreementTransactions.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class AgreementTransactions
9
+ *
10
+ * A resource representing agreement_transactions that is returned during a transaction search.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property \PayPal\Api\AgreementTransaction[] agreement_transaction_list
15
+ */
16
+ class AgreementTransactions extends PayPalModel
17
+ {
18
+ /**
19
+ * Array of agreement_transaction object.
20
+ *
21
+ * @param \PayPal\Api\AgreementTransaction[] $agreement_transaction_list
22
+ *
23
+ * @return $this
24
+ */
25
+ public function setAgreementTransactionList($agreement_transaction_list)
26
+ {
27
+ $this->agreement_transaction_list = $agreement_transaction_list;
28
+ return $this;
29
+ }
30
+
31
+ /**
32
+ * Array of agreement_transaction object.
33
+ *
34
+ * @return \PayPal\Api\AgreementTransaction[]
35
+ */
36
+ public function getAgreementTransactionList()
37
+ {
38
+ return $this->agreement_transaction_list;
39
+ }
40
+
41
+ /**
42
+ * Append AgreementTransactionList to the list.
43
+ *
44
+ * @param \PayPal\Api\AgreementTransaction $agreementTransaction
45
+ * @return $this
46
+ */
47
+ public function addAgreementTransactionList($agreementTransaction)
48
+ {
49
+ if (!$this->getAgreementTransactionList()) {
50
+ return $this->setAgreementTransactionList(array($agreementTransaction));
51
+ } else {
52
+ return $this->setAgreementTransactionList(
53
+ array_merge($this->getAgreementTransactionList(), array($agreementTransaction))
54
+ );
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Remove AgreementTransactionList from the list.
60
+ *
61
+ * @param \PayPal\Api\AgreementTransaction $agreementTransaction
62
+ * @return $this
63
+ */
64
+ public function removeAgreementTransactionList($agreementTransaction)
65
+ {
66
+ return $this->setAgreementTransactionList(
67
+ array_diff($this->getAgreementTransactionList(), array($agreementTransaction))
68
+ );
69
+ }
70
+
71
+ }
lib/PayPal/Api/AlternatePayment.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class AlternatePayment
9
+ *
10
+ * A resource representing a alternate payment account that can be used to fund a payment.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string alternate_payment_account_id
15
+ * @property string external_customer_id
16
+ * @property string alternate_payment_provider_id
17
+ */
18
+ class AlternatePayment extends PayPalModel
19
+ {
20
+ /**
21
+ * The unique identifier of the alternate payment account.
22
+ *
23
+ * @param string $alternate_payment_account_id
24
+ *
25
+ * @return $this
26
+ */
27
+ public function setAlternatePaymentAccountId($alternate_payment_account_id)
28
+ {
29
+ $this->alternate_payment_account_id = $alternate_payment_account_id;
30
+ return $this;
31
+ }
32
+
33
+ /**
34
+ * The unique identifier of the alternate payment account.
35
+ *
36
+ * @return string
37
+ */
38
+ public function getAlternatePaymentAccountId()
39
+ {
40
+ return $this->alternate_payment_account_id;
41
+ }
42
+
43
+ /**
44
+ * The unique identifier of the payer
45
+ *
46
+ * @param string $external_customer_id
47
+ *
48
+ * @return $this
49
+ */
50
+ public function setExternalCustomerId($external_customer_id)
51
+ {
52
+ $this->external_customer_id = $external_customer_id;
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * The unique identifier of the payer
58
+ *
59
+ * @return string
60
+ */
61
+ public function getExternalCustomerId()
62
+ {
63
+ return $this->external_customer_id;
64
+ }
65
+
66
+ /**
67
+ * Alternate Payment provider id. This is an optional attribute needed only for certain alternate providers e.g Ideal
68
+ *
69
+ * @param string $alternate_payment_provider_id
70
+ *
71
+ * @return $this
72
+ */
73
+ public function setAlternatePaymentProviderId($alternate_payment_provider_id)
74
+ {
75
+ $this->alternate_payment_provider_id = $alternate_payment_provider_id;
76
+ return $this;
77
+ }
78
+
79
+ /**
80
+ * Alternate Payment provider id. This is an optional attribute needed only for certain alternate providers e.g Ideal
81
+ *
82
+ * @return string
83
+ */
84
+ public function getAlternatePaymentProviderId()
85
+ {
86
+ return $this->alternate_payment_provider_id;
87
+ }
88
+
89
+ }
lib/PayPal/Api/Amount.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+ use PayPal\Converter\FormatConverter;
7
+ use PayPal\Validation\NumericValidator;
8
+
9
+ /**
10
+ * Class Amount
11
+ *
12
+ * payment amount with break-ups.
13
+ *
14
+ * @package PayPal\Api
15
+ *
16
+ * @property string currency
17
+ * @property string total
18
+ * @property \PayPal\Api\Details details
19
+ */
20
+ class Amount extends PayPalModel
21
+ {
22
+ /**
23
+ * 3-letter [currency code](https://developer.paypal.com/docs/integration/direct/rest_api_payment_country_currency_support/). PayPal does not support all currencies.
24
+ *
25
+ * @param string $currency
26
+ *
27
+ * @return $this
28
+ */
29
+ public function setCurrency($currency)
30
+ {
31
+ $this->currency = $currency;
32
+ return $this;
33
+ }
34
+
35
+ /**
36
+ * 3-letter [currency code](https://developer.paypal.com/docs/integration/direct/rest_api_payment_country_currency_support/). PayPal does not support all currencies.
37
+ *
38
+ * @return string
39
+ */
40
+ public function getCurrency()
41
+ {
42
+ return $this->currency;
43
+ }
44
+
45
+ /**
46
+ * Total amount charged from the payer to the payee. In case of a refund, this is the refunded amount to the original payer from the payee. 10 characters max with support for 2 decimal places.
47
+ *
48
+ * @param string|double $total
49
+ *
50
+ * @return $this
51
+ */
52
+ public function setTotal($total)
53
+ {
54
+ NumericValidator::validate($total, "Total");
55
+ $total = FormatConverter::formatToPrice($total, $this->getCurrency());
56
+ $this->total = $total;
57
+ return $this;
58
+ }
59
+
60
+ /**
61
+ * Total amount charged from the payer to the payee. In case of a refund, this is the refunded amount to the original payer from the payee. 10 characters max with support for 2 decimal places.
62
+ *
63
+ * @return string
64
+ */
65
+ public function getTotal()
66
+ {
67
+ return $this->total;
68
+ }
69
+
70
+ /**
71
+ * Additional details of the payment amount.
72
+ *
73
+ * @param \PayPal\Api\Details $details
74
+ *
75
+ * @return $this
76
+ */
77
+ public function setDetails($details)
78
+ {
79
+ $this->details = $details;
80
+ return $this;
81
+ }
82
+
83
+ /**
84
+ * Additional details of the payment amount.
85
+ *
86
+ * @return \PayPal\Api\Details
87
+ */
88
+ public function getDetails()
89
+ {
90
+ return $this->details;
91
+ }
92
+
93
+ }
lib/PayPal/Api/Authorization.php ADDED
@@ -0,0 +1,459 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalResourceModel;
6
+ use PayPal\Rest\ApiContext;
7
+ use PayPal\Validation\ArgumentValidator;
8
+
9
+ /**
10
+ * Class Authorization
11
+ *
12
+ * An authorization transaction.
13
+ *
14
+ * @package PayPal\Api
15
+ *
16
+ * @property string id
17
+ * @property \PayPal\Api\Amount amount
18
+ * @property string payment_mode
19
+ * @property string state
20
+ * @property string reason_code
21
+ * @property string pending_reason
22
+ * @property string protection_eligibility
23
+ * @property string protection_eligibility_type
24
+ * @property \PayPal\Api\FmfDetails fmf_details
25
+ * @property string parent_payment
26
+ * @property \PayPal\Api\ProcessorResponse processor_response
27
+ * @property string valid_until
28
+ * @property string create_time
29
+ * @property string update_time
30
+ * @property \PayPal\Api\Links[] links
31
+ */
32
+ class Authorization extends PayPalResourceModel
33
+ {
34
+ /**
35
+ * ID of the authorization transaction.
36
+ *
37
+ * @param string $id
38
+ *
39
+ * @return $this
40
+ */
41
+ public function setId($id)
42
+ {
43
+ $this->id = $id;
44
+ return $this;
45
+ }
46
+
47
+ /**
48
+ * ID of the authorization transaction.
49
+ *
50
+ * @return string
51
+ */
52
+ public function getId()
53
+ {
54
+ return $this->id;
55
+ }
56
+
57
+ /**
58
+ * Amount being authorized.
59
+ *
60
+ * @param \PayPal\Api\Amount $amount
61
+ *
62
+ * @return $this
63
+ */
64
+ public function setAmount($amount)
65
+ {
66
+ $this->amount = $amount;
67
+ return $this;
68
+ }
69
+
70
+ /**
71
+ * Amount being authorized.
72
+ *
73
+ * @return \PayPal\Api\Amount
74
+ */
75
+ public function getAmount()
76
+ {
77
+ return $this->amount;
78
+ }
79
+
80
+ /**
81
+ * Specifies the payment mode of the transaction.
82
+ * Valid Values: ["INSTANT_TRANSFER"]
83
+ *
84
+ * @param string $payment_mode
85
+ *
86
+ * @return $this
87
+ */
88
+ public function setPaymentMode($payment_mode)
89
+ {
90
+ $this->payment_mode = $payment_mode;
91
+ return $this;
92
+ }
93
+
94
+ /**
95
+ * Specifies the payment mode of the transaction.
96
+ *
97
+ * @return string
98
+ */
99
+ public function getPaymentMode()
100
+ {
101
+ return $this->payment_mode;
102
+ }
103
+
104
+ /**
105
+ * State of the authorization.
106
+ * Valid Values: ["pending", "authorized", "partially_captured", "captured", "expired", "voided"]
107
+ *
108
+ * @param string $state
109
+ *
110
+ * @return $this
111
+ */
112
+ public function setState($state)
113
+ {
114
+ $this->state = $state;
115
+ return $this;
116
+ }
117
+
118
+ /**
119
+ * State of the authorization.
120
+ *
121
+ * @return string
122
+ */
123
+ public function getState()
124
+ {
125
+ return $this->state;
126
+ }
127
+
128
+ /**
129
+ * Reason code, `AUTHORIZATION`, for a transaction state of `pending`.
130
+ * Valid Values: ["AUTHORIZATION"]
131
+ *
132
+ * @param string $reason_code
133
+ *
134
+ * @return $this
135
+ */
136
+ public function setReasonCode($reason_code)
137
+ {
138
+ $this->reason_code = $reason_code;
139
+ return $this;
140
+ }
141
+
142
+ /**
143
+ * Reason code, `AUTHORIZATION`, for a transaction state of `pending`.
144
+ *
145
+ * @return string
146
+ */
147
+ public function getReasonCode()
148
+ {
149
+ return $this->reason_code;
150
+ }
151
+
152
+ /**
153
+ * [DEPRECATED] Reason code for the transaction state being Pending.Obsolete. use reason_code field instead.
154
+ * Valid Values: ["AUTHORIZATION"]
155
+ *
156
+ * @param string $pending_reason
157
+ *
158
+ * @return $this
159
+ */
160
+ public function setPendingReason($pending_reason)
161
+ {
162
+ $this->pending_reason = $pending_reason;
163
+ return $this;
164
+ }
165
+
166
+ /**
167
+ * @deprecated [DEPRECATED] Reason code for the transaction state being Pending.Obsolete. use reason_code field instead.
168
+ *
169
+ * @return string
170
+ */
171
+ public function getPendingReason()
172
+ {
173
+ return $this->pending_reason;
174
+ }
175
+
176
+ /**
177
+ * The level of seller protection in force for the transaction. Only supported when the `payment_method` is set to `paypal`. Allowed values:<br> `ELIGIBLE`- Merchant is protected by PayPal's Seller Protection Policy for Unauthorized Payments and Item Not Received.<br> `PARTIALLY_ELIGIBLE`- Merchant is protected by PayPal's Seller Protection Policy for Item Not Received or Unauthorized Payments. Refer to `protection_eligibility_type` for specifics. <br> `INELIGIBLE`- Merchant is not protected under the Seller Protection Policy.
178
+ * Valid Values: ["ELIGIBLE", "PARTIALLY_ELIGIBLE", "INELIGIBLE"]
179
+ *
180
+ * @param string $protection_eligibility
181
+ *
182
+ * @return $this
183
+ */
184
+ public function setProtectionEligibility($protection_eligibility)
185
+ {
186
+ $this->protection_eligibility = $protection_eligibility;
187
+ return $this;
188
+ }
189
+
190
+ /**
191
+ * The level of seller protection in force for the transaction. Only supported when the `payment_method` is set to `paypal`. Allowed values:<br> `ELIGIBLE`- Merchant is protected by PayPal's Seller Protection Policy for Unauthorized Payments and Item Not Received.<br> `PARTIALLY_ELIGIBLE`- Merchant is protected by PayPal's Seller Protection Policy for Item Not Received or Unauthorized Payments. Refer to `protection_eligibility_type` for specifics. <br> `INELIGIBLE`- Merchant is not protected under the Seller Protection Policy.
192
+ *
193
+ * @return string
194
+ */
195
+ public function getProtectionEligibility()
196
+ {
197
+ return $this->protection_eligibility;
198
+ }
199
+
200
+ /**
201
+ * The kind of seller protection in force for the transaction. This property is returned only when the `protection_eligibility` property is set to `ELIGIBLE`or `PARTIALLY_ELIGIBLE`. Only supported when the `payment_method` is set to `paypal`. Allowed values:<br> `ITEM_NOT_RECEIVED_ELIGIBLE`- Sellers are protected against claims for items not received.<br> `UNAUTHORIZED_PAYMENT_ELIGIBLE`- Sellers are protected against claims for unauthorized payments.<br> One or both of the allowed values can be returned.
202
+ * Valid Values: ["ITEM_NOT_RECEIVED_ELIGIBLE", "UNAUTHORIZED_PAYMENT_ELIGIBLE", "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE"]
203
+ *
204
+ * @param string $protection_eligibility_type
205
+ *
206
+ * @return $this
207
+ */
208
+ public function setProtectionEligibilityType($protection_eligibility_type)
209
+ {
210
+ $this->protection_eligibility_type = $protection_eligibility_type;
211
+ return $this;
212
+ }
213
+
214
+ /**
215
+ * The kind of seller protection in force for the transaction. This property is returned only when the `protection_eligibility` property is set to `ELIGIBLE`or `PARTIALLY_ELIGIBLE`. Only supported when the `payment_method` is set to `paypal`. Allowed values:<br> `ITEM_NOT_RECEIVED_ELIGIBLE`- Sellers are protected against claims for items not received.<br> `UNAUTHORIZED_PAYMENT_ELIGIBLE`- Sellers are protected against claims for unauthorized payments.<br> One or both of the allowed values can be returned.
216
+ *
217
+ * @return string
218
+ */
219
+ public function getProtectionEligibilityType()
220
+ {
221
+ return $this->protection_eligibility_type;
222
+ }
223
+
224
+ /**
225
+ * Fraud Management Filter (FMF) details applied for the payment that could result in accept, deny, or pending action. Returned in a payment response only if the merchant has enabled FMF in the profile settings and one of the fraud filters was triggered based on those settings. See [Fraud Management Filters Summary](https://developer.paypal.com/docs/classic/fmf/integration-guide/FMFSummary/) for more information.
226
+ *
227
+ * @param \PayPal\Api\FmfDetails $fmf_details
228
+ *
229
+ * @return $this
230
+ */
231
+ public function setFmfDetails($fmf_details)
232
+ {
233
+ $this->fmf_details = $fmf_details;
234
+ return $this;
235
+ }
236
+
237
+ /**
238
+ * Fraud Management Filter (FMF) details applied for the payment that could result in accept, deny, or pending action. Returned in a payment response only if the merchant has enabled FMF in the profile settings and one of the fraud filters was triggered based on those settings. See [Fraud Management Filters Summary](https://developer.paypal.com/docs/classic/fmf/integration-guide/FMFSummary/) for more information.
239
+ *
240
+ * @return \PayPal\Api\FmfDetails
241
+ */
242
+ public function getFmfDetails()
243
+ {
244
+ return $this->fmf_details;
245
+ }
246
+
247
+ /**
248
+ * ID of the Payment resource that this transaction is based on.
249
+ *
250
+ * @param string $parent_payment
251
+ *
252
+ * @return $this
253
+ */
254
+ public function setParentPayment($parent_payment)
255
+ {
256
+ $this->parent_payment = $parent_payment;
257
+ return $this;
258
+ }
259
+
260
+ /**
261
+ * ID of the Payment resource that this transaction is based on.
262
+ *
263
+ * @return string
264
+ */
265
+ public function getParentPayment()
266
+ {
267
+ return $this->parent_payment;
268
+ }
269
+
270
+ /**
271
+ * Response codes returned by the processor concerning the submitted payment. Only supported when the `payment_method` is set to `credit_card`.
272
+ *
273
+ * @param \PayPal\Api\ProcessorResponse $processor_response
274
+ *
275
+ * @return $this
276
+ */
277
+ public function setProcessorResponse($processor_response)
278
+ {
279
+ $this->processor_response = $processor_response;
280
+ return $this;
281
+ }
282
+
283
+ /**
284
+ * Response codes returned by the processor concerning the submitted payment. Only supported when the `payment_method` is set to `credit_card`.
285
+ *
286
+ * @return \PayPal\Api\ProcessorResponse
287
+ */
288
+ public function getProcessorResponse()
289
+ {
290
+ return $this->processor_response;
291
+ }
292
+
293
+ /**
294
+ * Authorization expiration time and date as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6).
295
+ *
296
+ * @param string $valid_until
297
+ *
298
+ * @return $this
299
+ */
300
+ public function setValidUntil($valid_until)
301
+ {
302
+ $this->valid_until = $valid_until;
303
+ return $this;
304
+ }
305
+
306
+ /**
307
+ * Authorization expiration time and date as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6).
308
+ *
309
+ * @return string
310
+ */
311
+ public function getValidUntil()
312
+ {
313
+ return $this->valid_until;
314
+ }
315
+
316
+ /**
317
+ * Time of authorization as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6).
318
+ *
319
+ * @param string $create_time
320
+ *
321
+ * @return $this
322
+ */
323
+ public function setCreateTime($create_time)
324
+ {
325
+ $this->create_time = $create_time;
326
+ return $this;
327
+ }
328
+
329
+ /**
330
+ * Time of authorization as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6).
331
+ *
332
+ * @return string
333
+ */
334
+ public function getCreateTime()
335
+ {
336
+ return $this->create_time;
337
+ }
338
+
339
+ /**
340
+ * Time that the resource was last updated.
341
+ *
342
+ * @param string $update_time
343
+ *
344
+ * @return $this
345
+ */
346
+ public function setUpdateTime($update_time)
347
+ {
348
+ $this->update_time = $update_time;
349
+ return $this;
350
+ }
351
+
352
+ /**
353
+ * Time that the resource was last updated.
354
+ *
355
+ * @return string
356
+ */
357
+ public function getUpdateTime()
358
+ {
359
+ return $this->update_time;
360
+ }
361
+
362
+ /**
363
+ * Retrieve details about a previously created authorization by passing the authorization_id in the request URI.
364
+ *
365
+ * @param string $authorizationId
366
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
367
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
368
+ * @return Authorization
369
+ */
370
+ public static function get($authorizationId, $apiContext = null, $restCall = null)
371
+ {
372
+ ArgumentValidator::validate($authorizationId, 'authorizationId');
373
+ $payLoad = "";
374
+ $json = self::executeCall(
375
+ "/v1/payments/authorization/$authorizationId",
376
+ "GET",
377
+ $payLoad,
378
+ null,
379
+ $apiContext,
380
+ $restCall
381
+ );
382
+ $ret = new Authorization();
383
+ $ret->fromJson($json);
384
+ return $ret;
385
+ }
386
+
387
+ /**
388
+ * Capture and process a previously created authorization by passing the authorization_id in the request URI. To use this request, the original payment call must have the intent set to authorize.
389
+ *
390
+ * @param Capture $capture
391
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
392
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
393
+ * @return Capture
394
+ */
395
+ public function capture($capture, $apiContext = null, $restCall = null)
396
+ {
397
+ ArgumentValidator::validate($this->getId(), "Id");
398
+ ArgumentValidator::validate($capture, 'capture');
399
+ $payLoad = $capture->toJSON();
400
+ $json = self::executeCall(
401
+ "/v1/payments/authorization/{$this->getId()}/capture",
402
+ "POST",
403
+ $payLoad,
404
+ null,
405
+ $apiContext,
406
+ $restCall
407
+ );
408
+ $ret = new Capture();
409
+ $ret->fromJson($json);
410
+ return $ret;
411
+ }
412
+
413
+ /**
414
+ * Void (cancel) a previously authorized payment by passing the authorization_id in the request URI. Note that a fully captured authorization cannot be voided.
415
+ *
416
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
417
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
418
+ * @return Authorization
419
+ */
420
+ public function void($apiContext = null, $restCall = null)
421
+ {
422
+ ArgumentValidator::validate($this->getId(), "Id");
423
+ $payLoad = "";
424
+ $json = self::executeCall(
425
+ "/v1/payments/authorization/{$this->getId()}/void",
426
+ "POST",
427
+ $payLoad,
428
+ null,
429
+ $apiContext,
430
+ $restCall
431
+ );
432
+ $this->fromJson($json);
433
+ return $this;
434
+ }
435
+
436
+ /**
437
+ * Reauthorize a PayPal account payment by passing the authorization_id in the request URI. You should reauthorize a payment after the initial 3-day honor period to ensure that funds are still available. Request supports only amount field
438
+ *
439
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
440
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
441
+ * @return Authorization
442
+ */
443
+ public function reauthorize($apiContext = null, $restCall = null)
444
+ {
445
+ ArgumentValidator::validate($this->getId(), "Id");
446
+ $payLoad = $this->toJSON();
447
+ $json = self::executeCall(
448
+ "/v1/payments/authorization/{$this->getId()}/reauthorize",
449
+ "POST",
450
+ $payLoad,
451
+ null,
452
+ $apiContext,
453
+ $restCall
454
+ );
455
+ $this->fromJson($json);
456
+ return $this;
457
+ }
458
+
459
+ }
lib/PayPal/Api/BankAccount.php ADDED
@@ -0,0 +1,630 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class BankAccount
9
+ *
10
+ * A resource representing a bank account that can be used to fund a payment.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string account_number
15
+ * @property string account_number_type
16
+ * @property string routing_number
17
+ * @property string account_type
18
+ * @property string account_name
19
+ * @property string check_type
20
+ * @property string auth_type
21
+ * @property string auth_capture_timestamp
22
+ * @property string bank_name
23
+ * @property string country_code
24
+ * @property string first_name
25
+ * @property string last_name
26
+ * @property string birth_date
27
+ * @property \PayPal\Api\Address billing_address
28
+ * @property string state
29
+ * @property string confirmation_status
30
+ * @property string payer_id
31
+ * @property string external_customer_id
32
+ * @property string merchant_id
33
+ * @property string create_time
34
+ * @property string update_time
35
+ * @property string valid_until
36
+ * @property \PayPal\Api\Links[] links
37
+ */
38
+ class BankAccount extends PayPalModel
39
+ {
40
+ /**
41
+ * ID of the bank account being saved for later use.
42
+ *
43
+ * @deprecated Not publicly available
44
+ * @param string $id
45
+ *
46
+ * @return $this
47
+ */
48
+ public function setId($id)
49
+ {
50
+ $this->id = $id;
51
+ return $this;
52
+ }
53
+
54
+ /**
55
+ * ID of the bank account being saved for later use.
56
+ *
57
+ * @deprecated Not publicly available
58
+ * @return string
59
+ */
60
+ public function getId()
61
+ {
62
+ return $this->id;
63
+ }
64
+
65
+ /**
66
+ * Account number in either IBAN (max length 34) or BBAN (max length 17) format.
67
+ *
68
+ * @param string $account_number
69
+ *
70
+ * @return $this
71
+ */
72
+ public function setAccountNumber($account_number)
73
+ {
74
+ $this->account_number = $account_number;
75
+ return $this;
76
+ }
77
+
78
+ /**
79
+ * Account number in either IBAN (max length 34) or BBAN (max length 17) format.
80
+ *
81
+ * @return string
82
+ */
83
+ public function getAccountNumber()
84
+ {
85
+ return $this->account_number;
86
+ }
87
+
88
+ /**
89
+ * Type of the bank account number (International or Basic Bank Account Number). For more information refer to http://en.wikipedia.org/wiki/International_Bank_Account_Number.
90
+ * Valid Values: ["BBAN", "IBAN"]
91
+ *
92
+ * @param string $account_number_type
93
+ *
94
+ * @return $this
95
+ */
96
+ public function setAccountNumberType($account_number_type)
97
+ {
98
+ $this->account_number_type = $account_number_type;
99
+ return $this;
100
+ }
101
+
102
+ /**
103
+ * Type of the bank account number (International or Basic Bank Account Number). For more information refer to http://en.wikipedia.org/wiki/International_Bank_Account_Number.
104
+ *
105
+ * @return string
106
+ */
107
+ public function getAccountNumberType()
108
+ {
109
+ return $this->account_number_type;
110
+ }
111
+
112
+ /**
113
+ * Routing transit number (aka Bank Code) of the bank (typically for domestic use only - for international use, IBAN includes bank code). For more information refer to http://en.wikipedia.org/wiki/Bank_code.
114
+ *
115
+ * @param string $routing_number
116
+ *
117
+ * @return $this
118
+ */
119
+ public function setRoutingNumber($routing_number)
120
+ {
121
+ $this->routing_number = $routing_number;
122
+ return $this;
123
+ }
124
+
125
+ /**
126
+ * Routing transit number (aka Bank Code) of the bank (typically for domestic use only - for international use, IBAN includes bank code). For more information refer to http://en.wikipedia.org/wiki/Bank_code.
127
+ *
128
+ * @return string
129
+ */
130
+ public function getRoutingNumber()
131
+ {
132
+ return $this->routing_number;
133
+ }
134
+
135
+ /**
136
+ * Type of the bank account.
137
+ * Valid Values: ["CHECKING", "SAVINGS"]
138
+ *
139
+ * @param string $account_type
140
+ *
141
+ * @return $this
142
+ */
143
+ public function setAccountType($account_type)
144
+ {
145
+ $this->account_type = $account_type;
146
+ return $this;
147
+ }
148
+
149
+ /**
150
+ * Type of the bank account.
151
+ *
152
+ * @return string
153
+ */
154
+ public function getAccountType()
155
+ {
156
+ return $this->account_type;
157
+ }
158
+
159
+ /**
160
+ * A customer designated name.
161
+ *
162
+ * @param string $account_name
163
+ *
164
+ * @return $this
165
+ */
166
+ public function setAccountName($account_name)
167
+ {
168
+ $this->account_name = $account_name;
169
+ return $this;
170
+ }
171
+
172
+ /**
173
+ * A customer designated name.
174
+ *
175
+ * @return string
176
+ */
177
+ public function getAccountName()
178
+ {
179
+ return $this->account_name;
180
+ }
181
+
182
+ /**
183
+ * Type of the check when this information was obtained through a check by the facilitator or merchant.
184
+ * Valid Values: ["PERSONAL", "COMPANY"]
185
+ *
186
+ * @param string $check_type
187
+ *
188
+ * @return $this
189
+ */
190
+ public function setCheckType($check_type)
191
+ {
192
+ $this->check_type = $check_type;
193
+ return $this;
194
+ }
195
+
196
+ /**
197
+ * Type of the check when this information was obtained through a check by the facilitator or merchant.
198
+ *
199
+ * @return string
200
+ */
201
+ public function getCheckType()
202
+ {
203
+ return $this->check_type;
204
+ }
205
+
206
+ /**
207
+ * How the check was obtained from the customer, if check was the source of the information provided.
208
+ * Valid Values: ["CCD", "PPD", "TEL", "POP", "ARC", "RCK", "WEB"]
209
+ *
210
+ * @param string $auth_type
211
+ *
212
+ * @return $this
213
+ */
214
+ public function setAuthType($auth_type)
215
+ {
216
+ $this->auth_type = $auth_type;
217
+ return $this;
218
+ }
219
+
220
+ /**
221
+ * How the check was obtained from the customer, if check was the source of the information provided.
222
+ *
223
+ * @return string
224
+ */
225
+ public function getAuthType()
226
+ {
227
+ return $this->auth_type;
228
+ }
229
+
230
+ /**
231
+ * Time at which the authorization (or check) was captured. Use this field if the user authorization needs to be captured due to any privacy requirements.
232
+ *
233
+ * @param string $auth_capture_timestamp
234
+ *
235
+ * @return $this
236
+ */
237
+ public function setAuthCaptureTimestamp($auth_capture_timestamp)
238
+ {
239
+ $this->auth_capture_timestamp = $auth_capture_timestamp;
240
+ return $this;
241
+ }
242
+
243
+ /**
244
+ * Time at which the authorization (or check) was captured. Use this field if the user authorization needs to be captured due to any privacy requirements.
245
+ *
246
+ * @return string
247
+ */
248
+ public function getAuthCaptureTimestamp()
249
+ {
250
+ return $this->auth_capture_timestamp;
251
+ }
252
+
253
+ /**
254
+ * Name of the bank.
255
+ *
256
+ * @param string $bank_name
257
+ *
258
+ * @return $this
259
+ */
260
+ public function setBankName($bank_name)
261
+ {
262
+ $this->bank_name = $bank_name;
263
+ return $this;
264
+ }
265
+
266
+ /**
267
+ * Name of the bank.
268
+ *
269
+ * @return string
270
+ */
271
+ public function getBankName()
272
+ {
273
+ return $this->bank_name;
274
+ }
275
+
276
+ /**
277
+ * 2 letter country code of the Bank.
278
+ *
279
+ * @param string $country_code
280
+ *
281
+ * @return $this
282
+ */
283
+ public function setCountryCode($country_code)
284
+ {
285
+ $this->country_code = $country_code;
286
+ return $this;
287
+ }
288
+
289
+ /**
290
+ * 2 letter country code of the Bank.
291
+ *
292
+ * @return string
293
+ */
294
+ public function getCountryCode()
295
+ {
296
+ return $this->country_code;
297
+ }
298
+
299
+ /**
300
+ * Account holder's first name.
301
+ *
302
+ * @param string $first_name
303
+ *
304
+ * @return $this
305
+ */
306
+ public function setFirstName($first_name)
307
+ {
308
+ $this->first_name = $first_name;
309
+ return $this;
310
+ }
311
+
312
+ /**
313
+ * Account holder's first name.
314
+ *
315
+ * @return string
316
+ */
317
+ public function getFirstName()
318
+ {
319
+ return $this->first_name;
320
+ }
321
+
322
+ /**
323
+ * Account holder's last name.
324
+ *
325
+ * @param string $last_name
326
+ *
327
+ * @return $this
328
+ */
329
+ public function setLastName($last_name)
330
+ {
331
+ $this->last_name = $last_name;
332
+ return $this;
333
+ }
334
+
335
+ /**
336
+ * Account holder's last name.
337
+ *
338
+ * @return string
339
+ */
340
+ public function getLastName()
341
+ {
342
+ return $this->last_name;
343
+ }
344
+
345
+ /**
346
+ * Birth date of the bank account holder.
347
+ *
348
+ * @param string $birth_date
349
+ *
350
+ * @return $this
351
+ */
352
+ public function setBirthDate($birth_date)
353
+ {
354
+ $this->birth_date = $birth_date;
355
+ return $this;
356
+ }
357
+
358
+ /**
359
+ * Birth date of the bank account holder.
360
+ *
361
+ * @return string
362
+ */
363
+ public function getBirthDate()
364
+ {
365
+ return $this->birth_date;
366
+ }
367
+
368
+ /**
369
+ * Billing address.
370
+ *
371
+ * @param \PayPal\Api\Address $billing_address
372
+ *
373
+ * @return $this
374
+ */
375
+ public function setBillingAddress($billing_address)
376
+ {
377
+ $this->billing_address = $billing_address;
378
+ return $this;
379
+ }
380
+
381
+ /**
382
+ * Billing address.
383
+ *
384
+ * @return \PayPal\Api\Address
385
+ */
386
+ public function getBillingAddress()
387
+ {
388
+ return $this->billing_address;
389
+ }
390
+
391
+ /**
392
+ * State of this funding instrument.
393
+ * Valid Values: ["ACTIVE", "INACTIVE", "DELETED"]
394
+ *
395
+ * @param string $state
396
+ *
397
+ * @return $this
398
+ */
399
+ public function setState($state)
400
+ {
401
+ $this->state = $state;
402
+ return $this;
403
+ }
404
+
405
+ /**
406
+ * State of this funding instrument.
407
+ *
408
+ * @return string
409
+ */
410
+ public function getState()
411
+ {
412
+ return $this->state;
413
+ }
414
+
415
+ /**
416
+ * Confirmation status of a bank account.
417
+ * Valid Values: ["UNCONFIRMED", "CONFIRMED"]
418
+ *
419
+ * @param string $confirmation_status
420
+ *
421
+ * @return $this
422
+ */
423
+ public function setConfirmationStatus($confirmation_status)
424
+ {
425
+ $this->confirmation_status = $confirmation_status;
426
+ return $this;
427
+ }
428
+
429
+ /**
430
+ * Confirmation status of a bank account.
431
+ *
432
+ * @return string
433
+ */
434
+ public function getConfirmationStatus()
435
+ {
436
+ return $this->confirmation_status;
437
+ }
438
+
439
+ /**
440
+ * [DEPRECATED] Use external_customer_id instead.
441
+ *
442
+ * @param string $payer_id
443
+ *
444
+ * @return $this
445
+ */
446
+ public function setPayerId($payer_id)
447
+ {
448
+ $this->payer_id = $payer_id;
449
+ return $this;
450
+ }
451
+
452
+ /**
453
+ * @deprecated [DEPRECATED] Use external_customer_id instead.
454
+ *
455
+ * @return string
456
+ */
457
+ public function getPayerId()
458
+ {
459
+ return $this->payer_id;
460
+ }
461
+
462
+ /**
463
+ * A unique identifier of the customer to whom this bank account belongs to. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault.
464
+ *
465
+ * @param string $external_customer_id
466
+ *
467
+ * @return $this
468
+ */
469
+ public function setExternalCustomerId($external_customer_id)
470
+ {
471
+ $this->external_customer_id = $external_customer_id;
472
+ return $this;
473
+ }
474
+
475
+ /**
476
+ * A unique identifier of the customer to whom this bank account belongs to. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault.
477
+ *
478
+ * @return string
479
+ */
480
+ public function getExternalCustomerId()
481
+ {
482
+ return $this->external_customer_id;
483
+ }
484
+
485
+ /**
486
+ * A unique identifier of the merchant for which this bank account has been stored for. Generated and provided by the facilitator so it can be used to restrict the usage of the bank account to the specific merchnt.
487
+ *
488
+ * @param string $merchant_id
489
+ *
490
+ * @return $this
491
+ */
492
+ public function setMerchantId($merchant_id)
493
+ {
494
+ $this->merchant_id = $merchant_id;
495
+ return $this;
496
+ }
497
+
498
+ /**
499
+ * A unique identifier of the merchant for which this bank account has been stored for. Generated and provided by the facilitator so it can be used to restrict the usage of the bank account to the specific merchnt.
500
+ *
501
+ * @return string
502
+ */
503
+ public function getMerchantId()
504
+ {
505
+ return $this->merchant_id;
506
+ }
507
+
508
+ /**
509
+ * Time the resource was created.
510
+ *
511
+ * @param string $create_time
512
+ *
513
+ * @return $this
514
+ */
515
+ public function setCreateTime($create_time)
516
+ {
517
+ $this->create_time = $create_time;
518
+ return $this;
519
+ }
520
+
521
+ /**
522
+ * Time the resource was created.
523
+ *
524
+ * @return string
525
+ */
526
+ public function getCreateTime()
527
+ {
528
+ return $this->create_time;
529
+ }
530
+
531
+ /**
532
+ * Time the resource was last updated.
533
+ *
534
+ * @param string $update_time
535
+ *
536
+ * @return $this
537
+ */
538
+ public function setUpdateTime($update_time)
539
+ {
540
+ $this->update_time = $update_time;
541
+ return $this;
542
+ }
543
+
544
+ /**
545
+ * Time the resource was last updated.
546
+ *
547
+ * @return string
548
+ */
549
+ public function getUpdateTime()
550
+ {
551
+ return $this->update_time;
552
+ }
553
+
554
+ /**
555
+ * Date/Time until this resource can be used to fund a payment.
556
+ *
557
+ * @param string $valid_until
558
+ *
559
+ * @return $this
560
+ */
561
+ public function setValidUntil($valid_until)
562
+ {
563
+ $this->valid_until = $valid_until;
564
+ return $this;
565
+ }
566
+
567
+ /**
568
+ * Date/Time until this resource can be used to fund a payment.
569
+ *
570
+ * @return string
571
+ */
572
+ public function getValidUntil()
573
+ {
574
+ return $this->valid_until;
575
+ }
576
+
577
+ /**
578
+ * Sets Links
579
+ *
580
+ * @param \PayPal\Api\Links[] $links
581
+ *
582
+ * @return $this
583
+ */
584
+ public function setLinks($links)
585
+ {
586
+ $this->links = $links;
587
+ return $this;
588
+ }
589
+
590
+ /**
591
+ * Gets Links
592
+ *
593
+ * @return \PayPal\Api\Links[]
594
+ */
595
+ public function getLinks()
596
+ {
597
+ return $this->links;
598
+ }
599
+
600
+ /**
601
+ * Append Links to the list.
602
+ *
603
+ * @param \PayPal\Api\Links $links
604
+ * @return $this
605
+ */
606
+ public function addLink($links)
607
+ {
608
+ if (!$this->getLinks()) {
609
+ return $this->setLinks(array($links));
610
+ } else {
611
+ return $this->setLinks(
612
+ array_merge($this->getLinks(), array($links))
613
+ );
614
+ }
615
+ }
616
+
617
+ /**
618
+ * Remove Links from the list.
619
+ *
620
+ * @param \PayPal\Api\Links $links
621
+ * @return $this
622
+ */
623
+ public function removeLink($links)
624
+ {
625
+ return $this->setLinks(
626
+ array_diff($this->getLinks(), array($links))
627
+ );
628
+ }
629
+
630
+ }
lib/PayPal/Api/BankAccountsList.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class BankAccountsList
9
+ *
10
+ * A list of Bank Account Resources
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property \PayPal\Api\BankAccount[] bank_accounts
15
+ * @property int count
16
+ * @property string next_id
17
+ */
18
+ class BankAccountsList extends PayPalModel
19
+ {
20
+ /**
21
+ * A list of bank account resources
22
+ *
23
+ * @param \PayPal\Api\BankAccount[] $bank_accounts
24
+ *
25
+ * @return $this
26
+ */
27
+ public function setBankAccounts($bank_accounts)
28
+ {
29
+ $this->{"bank-accounts"} = $bank_accounts;
30
+ return $this;
31
+ }
32
+
33
+ /**
34
+ * A list of bank account resources
35
+ *
36
+ * @return \PayPal\Api\BankAccount[]
37
+ */
38
+ public function getBankAccounts()
39
+ {
40
+ return $this->{"bank-accounts"};
41
+ }
42
+
43
+ /**
44
+ * Append BankAccounts to the list.
45
+ *
46
+ * @param \PayPal\Api\BankAccount $bankAccount
47
+ * @return $this
48
+ */
49
+ public function addBankAccount($bankAccount)
50
+ {
51
+ if (!$this->getBankAccounts()) {
52
+ return $this->setBankAccounts(array($bankAccount));
53
+ } else {
54
+ return $this->setBankAccounts(
55
+ array_merge($this->getBankAccounts(), array($bankAccount))
56
+ );
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Remove BankAccounts from the list.
62
+ *
63
+ * @param \PayPal\Api\BankAccount $bankAccount
64
+ * @return $this
65
+ */
66
+ public function removeBankAccount($bankAccount)
67
+ {
68
+ return $this->setBankAccounts(
69
+ array_diff($this->getBankAccounts(), array($bankAccount))
70
+ );
71
+ }
72
+
73
+ /**
74
+ * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items.
75
+ *
76
+ * @param int $count
77
+ *
78
+ * @return $this
79
+ */
80
+ public function setCount($count)
81
+ {
82
+ $this->count = $count;
83
+ return $this;
84
+ }
85
+
86
+ /**
87
+ * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items.
88
+ *
89
+ * @return int
90
+ */
91
+ public function getCount()
92
+ {
93
+ return $this->count;
94
+ }
95
+
96
+ /**
97
+ * Identifier of the next element to get the next range of results.
98
+ *
99
+ * @param string $next_id
100
+ *
101
+ * @return $this
102
+ */
103
+ public function setNextId($next_id)
104
+ {
105
+ $this->next_id = $next_id;
106
+ return $this;
107
+ }
108
+
109
+ /**
110
+ * Identifier of the next element to get the next range of results.
111
+ *
112
+ * @return string
113
+ */
114
+ public function getNextId()
115
+ {
116
+ return $this->next_id;
117
+ }
118
+
119
+ }
lib/PayPal/Api/BankToken.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class BankToken
9
+ *
10
+ * A resource representing a bank that can be used to fund a payment.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string bank_id
15
+ * @property string external_customer_id
16
+ * @property string mandate_reference_number
17
+ */
18
+ class BankToken extends PayPalModel
19
+ {
20
+ /**
21
+ * ID of a previously saved Bank resource using /vault/bank API.
22
+ *
23
+ * @param string $bank_id
24
+ *
25
+ * @return $this
26
+ */
27
+ public function setBankId($bank_id)
28
+ {
29
+ $this->bank_id = $bank_id;
30
+ return $this;
31
+ }
32
+
33
+ /**
34
+ * ID of a previously saved Bank resource using /vault/bank API.
35
+ *
36
+ * @return string
37
+ */
38
+ public function getBankId()
39
+ {
40
+ return $this->bank_id;
41
+ }
42
+
43
+ /**
44
+ * The unique identifier of the payer used when saving this bank using /vault/bank API.
45
+ *
46
+ * @param string $external_customer_id
47
+ *
48
+ * @return $this
49
+ */
50
+ public function setExternalCustomerId($external_customer_id)
51
+ {
52
+ $this->external_customer_id = $external_customer_id;
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * The unique identifier of the payer used when saving this bank using /vault/bank API.
58
+ *
59
+ * @return string
60
+ */
61
+ public function getExternalCustomerId()
62
+ {
63
+ return $this->external_customer_id;
64
+ }
65
+
66
+ /**
67
+ * Identifier of the direct debit mandate to validate. Currently supported only for EU bank accounts(SEPA).
68
+ *
69
+ * @param string $mandate_reference_number
70
+ *
71
+ * @return $this
72
+ */
73
+ public function setMandateReferenceNumber($mandate_reference_number)
74
+ {
75
+ $this->mandate_reference_number = $mandate_reference_number;
76
+ return $this;
77
+ }
78
+
79
+ /**
80
+ * Identifier of the direct debit mandate to validate. Currently supported only for EU bank accounts(SEPA).
81
+ *
82
+ * @return string
83
+ */
84
+ public function getMandateReferenceNumber()
85
+ {
86
+ return $this->mandate_reference_number;
87
+ }
88
+
89
+ }
lib/PayPal/Api/BaseAddress.php ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class BaseAddress
9
+ *
10
+ * Base Address object used as billing address in a payment or extended for Shipping Address.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string line1
15
+ * @property string line2
16
+ * @property string city
17
+ * @property string country_code
18
+ * @property string postal_code
19
+ * @property string state
20
+ * @property string normalization_status
21
+ * @property string status
22
+ */
23
+ class BaseAddress extends PayPalModel
24
+ {
25
+ /**
26
+ * Line 1 of the Address (eg. number, street, etc).
27
+ *
28
+ * @param string $line1
29
+ *
30
+ * @return $this
31
+ */
32
+ public function setLine1($line1)
33
+ {
34
+ $this->line1 = $line1;
35
+ return $this;
36
+ }
37
+
38
+ /**
39
+ * Line 1 of the Address (eg. number, street, etc).
40
+ *
41
+ * @return string
42
+ */
43
+ public function getLine1()
44
+ {
45
+ return $this->line1;
46
+ }
47
+
48
+ /**
49
+ * Optional line 2 of the Address (eg. suite, apt #, etc.).
50
+ *
51
+ * @param string $line2
52
+ *
53
+ * @return $this
54
+ */
55
+ public function setLine2($line2)
56
+ {
57
+ $this->line2 = $line2;
58
+ return $this;
59
+ }
60
+
61
+ /**
62
+ * Optional line 2 of the Address (eg. suite, apt #, etc.).
63
+ *
64
+ * @return string
65
+ */
66
+ public function getLine2()
67
+ {
68
+ return $this->line2;
69
+ }
70
+
71
+ /**
72
+ * City name.
73
+ *
74
+ * @param string $city
75
+ *
76
+ * @return $this
77
+ */
78
+ public function setCity($city)
79
+ {
80
+ $this->city = $city;
81
+ return $this;
82
+ }
83
+
84
+ /**
85
+ * City name.
86
+ *
87
+ * @return string
88
+ */
89
+ public function getCity()
90
+ {
91
+ return $this->city;
92
+ }
93
+
94
+ /**
95
+ * 2 letter country code.
96
+ *
97
+ * @param string $country_code
98
+ *
99
+ * @return $this
100
+ */
101
+ public function setCountryCode($country_code)
102
+ {
103
+ $this->country_code = $country_code;
104
+ return $this;
105
+ }
106
+
107
+ /**
108
+ * 2 letter country code.
109
+ *
110
+ * @return string
111
+ */
112
+ public function getCountryCode()
113
+ {
114
+ return $this->country_code;
115
+ }
116
+
117
+ /**
118
+ * Zip code or equivalent is usually required for countries that have them. For list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code.
119
+ *
120
+ * @param string $postal_code
121
+ *
122
+ * @return $this
123
+ */
124
+ public function setPostalCode($postal_code)
125
+ {
126
+ $this->postal_code = $postal_code;
127
+ return $this;
128
+ }
129
+
130
+ /**
131
+ * Zip code or equivalent is usually required for countries that have them. For list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code.
132
+ *
133
+ * @return string
134
+ */
135
+ public function getPostalCode()
136
+ {
137
+ return $this->postal_code;
138
+ }
139
+
140
+ /**
141
+ * 2 letter code for US states, and the equivalent for other countries.
142
+ *
143
+ * @param string $state
144
+ *
145
+ * @return $this
146
+ */
147
+ public function setState($state)
148
+ {
149
+ $this->state = $state;
150
+ return $this;
151
+ }
152
+
153
+ /**
154
+ * 2 letter code for US states, and the equivalent for other countries.
155
+ *
156
+ * @return string
157
+ */
158
+ public function getState()
159
+ {
160
+ return $this->state;
161
+ }
162
+
163
+ /**
164
+ * Address normalization status
165
+ * Valid Values: ["UNKNOWN", "UNNORMALIZED_USER_PREFERRED", "NORMALIZED", "UNNORMALIZED"]
166
+ *
167
+ * @param string $normalization_status
168
+ *
169
+ * @return $this
170
+ */
171
+ public function setNormalizationStatus($normalization_status)
172
+ {
173
+ $this->normalization_status = $normalization_status;
174
+ return $this;
175
+ }
176
+
177
+ /**
178
+ * Address normalization status
179
+ *
180
+ * @return string
181
+ */
182
+ public function getNormalizationStatus()
183
+ {
184
+ return $this->normalization_status;
185
+ }
186
+
187
+ /**
188
+ * Address status
189
+ * Valid Values: ["CONFIRMED", "UNCONFIRMED"]
190
+ *
191
+ * @param string $status
192
+ *
193
+ * @return $this
194
+ */
195
+ public function setStatus($status)
196
+ {
197
+ $this->status = $status;
198
+ return $this;
199
+ }
200
+
201
+ /**
202
+ * Address status
203
+ *
204
+ * @return string
205
+ */
206
+ public function getStatus()
207
+ {
208
+ return $this->status;
209
+ }
210
+
211
+ }
lib/PayPal/Api/Billing.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class Billing
9
+ *
10
+ * Billing instrument used to charge the payer.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string billing_agreement_id
15
+ */
16
+ class Billing extends PayPalModel
17
+ {
18
+ /**
19
+ * Identifier of the instrument in PayPal Wallet
20
+ *
21
+ * @param string $billing_agreement_id
22
+ *
23
+ * @return $this
24
+ */
25
+ public function setBillingAgreementId($billing_agreement_id)
26
+ {
27
+ $this->billing_agreement_id = $billing_agreement_id;
28
+ return $this;
29
+ }
30
+
31
+ /**
32
+ * Identifier of the instrument in PayPal Wallet
33
+ *
34
+ * @return string
35
+ */
36
+ public function getBillingAgreementId()
37
+ {
38
+ return $this->billing_agreement_id;
39
+ }
40
+
41
+ }
lib/PayPal/Api/BillingAgreementToken.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class BillingAgreementToken
9
+ *
10
+ * PayPal generated billing agreement token. It is a token returned by /v1/billing-agreements/agreement-token API end point.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ */
15
+ class BillingAgreementToken extends PayPalModel
16
+ {
17
+ }
lib/PayPal/Api/BillingInfo.php ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class BillingInfo
9
+ *
10
+ * Billing information for the invoice recipient.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string email
15
+ * @property string first_name
16
+ * @property string last_name
17
+ * @property string business_name
18
+ * @property \PayPal\Api\InvoiceAddress address
19
+ * @property string language
20
+ * @property string additional_info
21
+ * @property string notification_channel
22
+ * @property \PayPal\Api\Phone phone
23
+ */
24
+ class BillingInfo extends PayPalModel
25
+ {
26
+ /**
27
+ * Email address of the invoice recipient. 260 characters max.
28
+ *
29
+ * @param string $email
30
+ *
31
+ * @return $this
32
+ */
33
+ public function setEmail($email)
34
+ {
35
+ $this->email = $email;
36
+ return $this;
37
+ }
38
+
39
+ /**
40
+ * Email address of the invoice recipient. 260 characters max.
41
+ *
42
+ * @return string
43
+ */
44
+ public function getEmail()
45
+ {
46
+ return $this->email;
47
+ }
48
+
49
+ /**
50
+ * First name of the invoice recipient. 30 characters max.
51
+ *
52
+ * @param string $first_name
53
+ *
54
+ * @return $this
55
+ */
56
+ public function setFirstName($first_name)
57
+ {
58
+ $this->first_name = $first_name;
59
+ return $this;
60
+ }
61
+
62
+ /**
63
+ * First name of the invoice recipient. 30 characters max.
64
+ *
65
+ * @return string
66
+ */
67
+ public function getFirstName()
68
+ {
69
+ return $this->first_name;
70
+ }
71
+
72
+ /**
73
+ * Last name of the invoice recipient. 30 characters max.
74
+ *
75
+ * @param string $last_name
76
+ *
77
+ * @return $this
78
+ */
79
+ public function setLastName($last_name)
80
+ {
81
+ $this->last_name = $last_name;
82
+ return $this;
83
+ }
84
+
85
+ /**
86
+ * Last name of the invoice recipient. 30 characters max.
87
+ *
88
+ * @return string
89
+ */
90
+ public function getLastName()
91
+ {
92
+ return $this->last_name;
93
+ }
94
+
95
+ /**
96
+ * Company business name of the invoice recipient. 100 characters max.
97
+ *
98
+ * @param string $business_name
99
+ *
100
+ * @return $this
101
+ */
102
+ public function setBusinessName($business_name)
103
+ {
104
+ $this->business_name = $business_name;
105
+ return $this;
106
+ }
107
+
108
+ /**
109
+ * Company business name of the invoice recipient. 100 characters max.
110
+ *
111
+ * @return string
112
+ */
113
+ public function getBusinessName()
114
+ {
115
+ return $this->business_name;
116
+ }
117
+
118
+ /**
119
+ * Address of the invoice recipient.
120
+ *
121
+ * @param \PayPal\Api\InvoiceAddress $address
122
+ *
123
+ * @return $this
124
+ */
125
+ public function setAddress($address)
126
+ {
127
+ $this->address = $address;
128
+ return $this;
129
+ }
130
+
131
+ /**
132
+ * Address of the invoice recipient.
133
+ *
134
+ * @return \PayPal\Api\InvoiceAddress
135
+ */
136
+ public function getAddress()
137
+ {
138
+ return $this->address;
139
+ }
140
+
141
+ /**
142
+ * Language of the email sent to the payer. Will only be used if payer doesn't have a PayPal account.
143
+ * Valid Values: ["da_DK", "de_DE", "en_AU", "en_GB", "en_US", "es_ES", "es_XC", "fr_CA", "fr_FR", "fr_XC", "he_IL", "id_ID", "it_IT", "ja_JP", "nl_NL", "no_NO", "pl_PL", "pt_BR", "pt_PT", "ru_RU", "sv_SE", "th_TH", "tr_TR", "zh_CN", "zh_HK", "zh_TW", "zh_XC"]
144
+ *
145
+ * @param string $language
146
+ *
147
+ * @return $this
148
+ */
149
+ public function setLanguage($language)
150
+ {
151
+ $this->language = $language;
152
+ return $this;
153
+ }
154
+
155
+ /**
156
+ * Language of the email sent to the payer. Will only be used if payer doesn't have a PayPal account.
157
+ *
158
+ * @return string
159
+ */
160
+ public function getLanguage()
161
+ {
162
+ return $this->language;
163
+ }
164
+
165
+ /**
166
+ * Option to display additional information such as business hours. 40 characters max.
167
+ *
168
+ * @param string $additional_info
169
+ *
170
+ * @return $this
171
+ */
172
+ public function setAdditionalInfo($additional_info)
173
+ {
174
+ $this->additional_info = $additional_info;
175
+ return $this;
176
+ }
177
+
178
+ /**
179
+ * Option to display additional information such as business hours. 40 characters max.
180
+ *
181
+ * @return string
182
+ */
183
+ public function getAdditionalInfo()
184
+ {
185
+ return $this->additional_info;
186
+ }
187
+
188
+ /**
189
+ * Preferred notification channel of the payer. Email by default.
190
+ * Valid Values: ["SMS", "EMAIL"]
191
+ *
192
+ * @param string $notification_channel
193
+ *
194
+ * @return $this
195
+ */
196
+ public function setNotificationChannel($notification_channel)
197
+ {
198
+ $this->notification_channel = $notification_channel;
199
+ return $this;
200
+ }
201
+
202
+ /**
203
+ * Preferred notification channel of the payer. Email by default.
204
+ *
205
+ * @return string
206
+ */
207
+ public function getNotificationChannel()
208
+ {
209
+ return $this->notification_channel;
210
+ }
211
+
212
+ /**
213
+ * Mobile Phone number of the recipient to which SMS will be sent if notification_channel is SMS.
214
+ *
215
+ * @param \PayPal\Api\Phone $phone
216
+ *
217
+ * @return $this
218
+ */
219
+ public function setPhone($phone)
220
+ {
221
+ $this->phone = $phone;
222
+ return $this;
223
+ }
224
+
225
+ /**
226
+ * Mobile Phone number of the recipient to which SMS will be sent if notification_channel is SMS.
227
+ *
228
+ * @return \PayPal\Api\Phone
229
+ */
230
+ public function getPhone()
231
+ {
232
+ return $this->phone;
233
+ }
234
+
235
+ }
lib/PayPal/Api/CancelNotification.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class CancelNotification
9
+ *
10
+ * Email/SMS notification.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string subject
15
+ * @property string note
16
+ * @property bool send_to_merchant
17
+ * @property bool send_to_payer
18
+ */
19
+ class CancelNotification extends PayPalModel
20
+ {
21
+ /**
22
+ * Subject of the notification.
23
+ *
24
+ * @param string $subject
25
+ *
26
+ * @return $this
27
+ */
28
+ public function setSubject($subject)
29
+ {
30
+ $this->subject = $subject;
31
+ return $this;
32
+ }
33
+
34
+ /**
35
+ * Subject of the notification.
36
+ *
37
+ * @return string
38
+ */
39
+ public function getSubject()
40
+ {
41
+ return $this->subject;
42
+ }
43
+
44
+ /**
45
+ * Note to the payer.
46
+ *
47
+ * @param string $note
48
+ *
49
+ * @return $this
50
+ */
51
+ public function setNote($note)
52
+ {
53
+ $this->note = $note;
54
+ return $this;
55
+ }
56
+
57
+ /**
58
+ * Note to the payer.
59
+ *
60
+ * @return string
61
+ */
62
+ public function getNote()
63
+ {
64
+ return $this->note;
65
+ }
66
+
67
+ /**
68
+ * A flag indicating whether a copy of the email has to be sent to the merchant.
69
+ *
70
+ * @param bool $send_to_merchant
71
+ *
72
+ * @return $this
73
+ */
74
+ public function setSendToMerchant($send_to_merchant)
75
+ {
76
+ $this->send_to_merchant = $send_to_merchant;
77
+ return $this;
78
+ }
79
+
80
+ /**
81
+ * A flag indicating whether a copy of the email has to be sent to the merchant.
82
+ *
83
+ * @return bool
84
+ */
85
+ public function getSendToMerchant()
86
+ {
87
+ return $this->send_to_merchant;
88
+ }
89
+
90
+ /**
91
+ * A flag indicating whether a copy of the email has to be sent to the payer.
92
+ *
93
+ * @param bool $send_to_payer
94
+ *
95
+ * @return $this
96
+ */
97
+ public function setSendToPayer($send_to_payer)
98
+ {
99
+ $this->send_to_payer = $send_to_payer;
100
+ return $this;
101
+ }
102
+
103
+ /**
104
+ * A flag indicating whether a copy of the email has to be sent to the payer.
105
+ *
106
+ * @return bool
107
+ */
108
+ public function getSendToPayer()
109
+ {
110
+ return $this->send_to_payer;
111
+ }
112
+
113
+ }
lib/PayPal/Api/Capture.php ADDED
@@ -0,0 +1,264 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalResourceModel;
6
+ use PayPal\Rest\ApiContext;
7
+ use PayPal\Validation\ArgumentValidator;
8
+
9
+ /**
10
+ * Class Capture
11
+ *
12
+ * A capture transaction.
13
+ *
14
+ * @package PayPal\Api
15
+ *
16
+ * @property string id
17
+ * @property \PayPal\Api\Amount amount
18
+ * @property bool is_final_capture
19
+ * @property string state
20
+ * @property string parent_payment
21
+ * @property \PayPal\Api\Currency transaction_fee
22
+ * @property string create_time
23
+ * @property string update_time
24
+ * @property \PayPal\Api\Links[] links
25
+ */
26
+ class Capture extends PayPalResourceModel
27
+ {
28
+ /**
29
+ * ID of the capture transaction.
30
+ *
31
+ * @param string $id
32
+ *
33
+ * @return $this
34
+ */
35
+ public function setId($id)
36
+ {
37
+ $this->id = $id;
38
+ return $this;
39
+ }
40
+
41
+ /**
42
+ * ID of the capture transaction.
43
+ *
44
+ * @return string
45
+ */
46
+ public function getId()
47
+ {
48
+ return $this->id;
49
+ }
50
+
51
+ /**
52
+ * Amount being captured. If the amount matches the orginally authorized amount, the state of the authorization changes to `captured`. If not, the state of the authorization changes to `partially_captured`.
53
+ *
54
+ * @param \PayPal\Api\Amount $amount
55
+ *
56
+ * @return $this
57
+ */
58
+ public function setAmount($amount)
59
+ {
60
+ $this->amount = $amount;
61
+ return $this;
62
+ }
63
+
64
+ /**
65
+ * Amount being captured. If the amount matches the orginally authorized amount, the state of the authorization changes to `captured`. If not, the state of the authorization changes to `partially_captured`.
66
+ *
67
+ * @return \PayPal\Api\Amount
68
+ */
69
+ public function getAmount()
70
+ {
71
+ return $this->amount;
72
+ }
73
+
74
+ /**
75
+ * If set to `true`, all remaining funds held by the authorization will be released in the funding instrument.
76
+ *
77
+ * @param bool $is_final_capture
78
+ *
79
+ * @return $this
80
+ */
81
+ public function setIsFinalCapture($is_final_capture)
82
+ {
83
+ $this->is_final_capture = $is_final_capture;
84
+ return $this;
85
+ }
86
+
87
+ /**
88
+ * If set to `true`, all remaining funds held by the authorization will be released in the funding instrument.
89
+ *
90
+ * @return bool
91
+ */
92
+ public function getIsFinalCapture()
93
+ {
94
+ return $this->is_final_capture;
95
+ }
96
+
97
+ /**
98
+ * State of the capture.
99
+ * Valid Values: ["pending", "completed", "refunded", "partially_refunded"]
100
+ *
101
+ * @param string $state
102
+ *
103
+ * @return $this
104
+ */
105
+ public function setState($state)
106
+ {
107
+ $this->state = $state;
108
+ return $this;
109
+ }
110
+
111
+ /**
112
+ * State of the capture.
113
+ *
114
+ * @return string
115
+ */
116
+ public function getState()
117
+ {
118
+ return $this->state;
119
+ }
120
+
121
+ /**
122
+ * ID of the payment resource on which this transaction is based.
123
+ *
124
+ * @param string $parent_payment
125
+ *
126
+ * @return $this
127
+ */
128
+ public function setParentPayment($parent_payment)
129
+ {
130
+ $this->parent_payment = $parent_payment;
131
+ return $this;
132
+ }
133
+
134
+ /**
135
+ * ID of the payment resource on which this transaction is based.
136
+ *
137
+ * @return string
138
+ */
139
+ public function getParentPayment()
140
+ {
141
+ return $this->parent_payment;
142
+ }
143
+
144
+ /**
145
+ * Transaction fee applicable for this payment.
146
+ *
147
+ * @param \PayPal\Api\Currency $transaction_fee
148
+ *
149
+ * @return $this
150
+ */
151
+ public function setTransactionFee($transaction_fee)
152
+ {
153
+ $this->transaction_fee = $transaction_fee;
154
+ return $this;
155
+ }
156
+
157
+ /**
158
+ * Transaction fee applicable for this payment.
159
+ *
160
+ * @return \PayPal\Api\Currency
161
+ */
162
+ public function getTransactionFee()
163
+ {
164
+ return $this->transaction_fee;
165
+ }
166
+
167
+ /**
168
+ * Time of capture as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6).
169
+ *
170
+ * @param string $create_time
171
+ *
172
+ * @return $this
173
+ */
174
+ public function setCreateTime($create_time)
175
+ {
176
+ $this->create_time = $create_time;
177
+ return $this;
178
+ }
179
+
180
+ /**
181
+ * Time of capture as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6).
182
+ *
183
+ * @return string
184
+ */
185
+ public function getCreateTime()
186
+ {
187
+ return $this->create_time;
188
+ }
189
+
190
+ /**
191
+ * Time that the resource was last updated.
192
+ *
193
+ * @param string $update_time
194
+ *
195
+ * @return $this
196
+ */
197
+ public function setUpdateTime($update_time)
198
+ {
199
+ $this->update_time = $update_time;
200
+ return $this;
201
+ }
202
+
203
+ /**
204
+ * Time that the resource was last updated.
205
+ *
206
+ * @return string
207
+ */
208
+ public function getUpdateTime()
209
+ {
210
+ return $this->update_time;
211
+ }
212
+
213
+ /**
214
+ * Retrieve details about a captured payment by passing the capture_id in the request URI.
215
+ *
216
+ * @param string $captureId
217
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
218
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
219
+ * @return Capture
220
+ */
221
+ public static function get($captureId, $apiContext = null, $restCall = null)
222
+ {
223
+ ArgumentValidator::validate($captureId, 'captureId');
224
+ $payLoad = "";
225
+ $json = self::executeCall(
226
+ "/v1/payments/capture/$captureId",
227
+ "GET",
228
+ $payLoad,
229
+ null,
230
+ $apiContext,
231
+ $restCall
232
+ );
233
+ $ret = new Capture();
234
+ $ret->fromJson($json);
235
+ return $ret;
236
+ }
237
+
238
+ /**
239
+ * Refund a captured payment by passing the capture_id in the request URI. In addition, include an amount object in the body of the request JSON.
240
+ *
241
+ * @param Refund $refund
242
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
243
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
244
+ * @return Refund
245
+ */
246
+ public function refund($refund, $apiContext = null, $restCall = null)
247
+ {
248
+ ArgumentValidator::validate($this->getId(), "Id");
249
+ ArgumentValidator::validate($refund, 'refund');
250
+ $payLoad = $refund->toJSON();
251
+ $json = self::executeCall(
252
+ "/v1/payments/capture/{$this->getId()}/refund",
253
+ "POST",
254
+ $payLoad,
255
+ null,
256
+ $apiContext,
257
+ $restCall
258
+ );
259
+ $ret = new Refund();
260
+ $ret->fromJson($json);
261
+ return $ret;
262
+ }
263
+
264
+ }
lib/PayPal/Api/CarrierAccount.php ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class CarrierAccount
9
+ *
10
+ * Payment Instrument that facilitates carrier billing
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string id
15
+ * @property string phone_number
16
+ * @property string external_customer_id
17
+ * @property string phone_source
18
+ * @property \PayPal\Api\CountryCode country_code
19
+ */
20
+ class CarrierAccount extends PayPalModel
21
+ {
22
+ /**
23
+ * ID that identifies the payer�s carrier account. Can be used in subsequent REST API calls, e.g. for making payments.
24
+ *
25
+ * @param string $id
26
+ *
27
+ * @return $this
28
+ */
29
+ public function setId($id)
30
+ {
31
+ $this->id = $id;
32
+ return $this;
33
+ }
34
+
35
+ /**
36
+ * ID that identifies the payer�s carrier account. Can be used in subsequent REST API calls, e.g. for making payments.
37
+ *
38
+ * @return string
39
+ */
40
+ public function getId()
41
+ {
42
+ return $this->id;
43
+ }
44
+
45
+ /**
46
+ * The payer�s phone number in E.164 format.
47
+ *
48
+ * @param string $phone_number
49
+ *
50
+ * @return $this
51
+ */
52
+ public function setPhoneNumber($phone_number)
53
+ {
54
+ $this->phone_number = $phone_number;
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * The payer�s phone number in E.164 format.
60
+ *
61
+ * @return string
62
+ */
63
+ public function getPhoneNumber()
64
+ {
65
+ return $this->phone_number;
66
+ }
67
+
68
+ /**
69
+ * User identifier as created by the merchant.
70
+ *
71
+ * @param string $external_customer_id
72
+ *
73
+ * @return $this
74
+ */
75
+ public function setExternalCustomerId($external_customer_id)
76
+ {
77
+ $this->external_customer_id = $external_customer_id;
78
+ return $this;
79
+ }
80
+
81
+ /**
82
+ * User identifier as created by the merchant.
83
+ *
84
+ * @return string
85
+ */
86
+ public function getExternalCustomerId()
87
+ {
88
+ return $this->external_customer_id;
89
+ }
90
+
91
+ /**
92
+ * The method of obtaining the phone number (USER_PROVIDED or READ_FROM_DEVICE).
93
+ * Valid Values: ["READ_FROM_DEVICE", "USER_PROVIDED"]
94
+ *
95
+ * @param string $phone_source
96
+ *
97
+ * @return $this
98
+ */
99
+ public function setPhoneSource($phone_source)
100
+ {
101
+ $this->phone_source = $phone_source;
102
+ return $this;
103
+ }
104
+
105
+ /**
106
+ * The method of obtaining the phone number (USER_PROVIDED or READ_FROM_DEVICE).
107
+ *
108
+ * @return string
109
+ */
110
+ public function getPhoneSource()
111
+ {
112
+ return $this->phone_source;
113
+ }
114
+
115
+ /**
116
+ * The country where the phone number is registered. Specified in 2-character IS0-3166-1 format.
117
+ *
118
+ * @param \PayPal\Api\CountryCode $country_code
119
+ *
120
+ * @return $this
121
+ */
122
+ public function setCountryCode($country_code)
123
+ {
124
+ $this->country_code = $country_code;
125
+ return $this;
126
+ }
127
+
128
+ /**
129
+ * The country where the phone number is registered. Specified in 2-character IS0-3166-1 format.
130
+ *
131
+ * @return \PayPal\Api\CountryCode
132
+ */
133
+ public function getCountryCode()
134
+ {
135
+ return $this->country_code;
136
+ }
137
+
138
+ }
lib/PayPal/Api/CarrierAccountToken.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class CarrierAccountToken
9
+ *
10
+ * A resource representing a carrier account that can be used to fund a payment.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string carrier_account_id
15
+ * @property string external_customer_id
16
+ */
17
+ class CarrierAccountToken extends PayPalModel
18
+ {
19
+ /**
20
+ * ID of a previously saved carrier account resource.
21
+ *
22
+ * @param string $carrier_account_id
23
+ *
24
+ * @return $this
25
+ */
26
+ public function setCarrierAccountId($carrier_account_id)
27
+ {
28
+ $this->carrier_account_id = $carrier_account_id;
29
+ return $this;
30
+ }
31
+
32
+ /**
33
+ * ID of a previously saved carrier account resource.
34
+ *
35
+ * @return string
36
+ */
37
+ public function getCarrierAccountId()
38
+ {
39
+ return $this->carrier_account_id;
40
+ }
41
+
42
+ /**
43
+ * The unique identifier of the payer used when saving this carrier account instrument.
44
+ *
45
+ * @param string $external_customer_id
46
+ *
47
+ * @return $this
48
+ */
49
+ public function setExternalCustomerId($external_customer_id)
50
+ {
51
+ $this->external_customer_id = $external_customer_id;
52
+ return $this;
53
+ }
54
+
55
+ /**
56
+ * The unique identifier of the payer used when saving this carrier account instrument.
57
+ *
58
+ * @return string
59
+ */
60
+ public function getExternalCustomerId()
61
+ {
62
+ return $this->external_customer_id;
63
+ }
64
+
65
+ }
lib/PayPal/Api/CartBase.php ADDED
@@ -0,0 +1,391 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+ use PayPal\Validation\UrlValidator;
7
+
8
+ /**
9
+ * Class CartBase
10
+ *
11
+ * Base properties of a cart resource
12
+ *
13
+ * @package PayPal\Api
14
+ *
15
+ * @property string reference_id
16
+ * @property \PayPal\Api\Amount amount
17
+ * @property string description
18
+ * @property string note_to_payee
19
+ * @property string custom
20
+ * @property string invoice_number
21
+ * @property string soft_descriptor
22
+ * @property \PayPal\Api\PaymentOptions payment_options
23
+ * @property \PayPal\Api\ItemList item_list
24
+ * @property string notify_url
25
+ * @property string order_url
26
+ */
27
+ class CartBase extends PayPalModel
28
+ {
29
+ /**
30
+ * Merchant identifier to the purchase unit. Optional parameter
31
+ *
32
+ * @param string $reference_id
33
+ *
34
+ * @return $this
35
+ */
36
+ public function setReferenceId($reference_id)
37
+ {
38
+ $this->reference_id = $reference_id;
39
+ return $this;
40
+ }
41
+
42
+ /**
43
+ * Merchant identifier to the purchase unit. Optional parameter
44
+ *
45
+ * @return string
46
+ */
47
+ public function getReferenceId()
48
+ {
49
+ return $this->reference_id;
50
+ }
51
+
52
+ /**
53
+ * Amount being collected.
54
+ *
55
+ * @param \PayPal\Api\Amount $amount
56
+ *
57
+ * @return $this
58
+ */
59
+ public function setAmount($amount)
60
+ {
61
+ $this->amount = $amount;
62
+ return $this;
63
+ }
64
+
65
+ /**
66
+ * Amount being collected.
67
+ *
68
+ * @return \PayPal\Api\Amount
69
+ */
70
+ public function getAmount()
71
+ {
72
+ return $this->amount;
73
+ }
74
+
75
+ /**
76
+ * Recipient of the funds in this transaction.
77
+ *
78
+ * @deprecated Not publicly available
79
+ * @param \PayPal\Api\Payee $payee
80
+ *
81
+ * @return $this
82
+ */
83
+ public function setPayee($payee)
84
+ {
85
+ $this->payee = $payee;
86
+ return $this;
87
+ }
88
+
89
+ /**
90
+ * Recipient of the funds in this transaction.
91
+ *
92
+ * @deprecated Not publicly available
93
+ * @return \PayPal\Api\Payee
94
+ */
95
+ public function getPayee()
96
+ {
97
+ return $this->payee;
98
+ }
99
+
100
+ /**
101
+ * Description of transaction.
102
+ *
103
+ * @param string $description
104
+ *
105
+ * @return $this
106
+ */
107
+ public function setDescription($description)
108
+ {
109
+ $this->description = $description;
110
+ return $this;
111
+ }
112
+
113
+ /**
114
+ * Description of transaction.
115
+ *
116
+ * @return string
117
+ */
118
+ public function getDescription()
119
+ {
120
+ return $this->description;
121
+ }
122
+
123
+ /**
124
+ * Note to the recipient of the funds in this transaction.
125
+ *
126
+ * @param string $note_to_payee
127
+ *
128
+ * @return $this
129
+ */
130
+ public function setNoteToPayee($note_to_payee)
131
+ {
132
+ $this->note_to_payee = $note_to_payee;
133
+ return $this;
134
+ }
135
+
136
+ /**
137
+ * Note to the recipient of the funds in this transaction.
138
+ *
139
+ * @return string
140
+ */
141
+ public function getNoteToPayee()
142
+ {
143
+ return $this->note_to_payee;
144
+ }
145
+
146
+ /**
147
+ * Free-form field for the use of clients. Only supported when the `payment_method` is set to `paypal`.
148
+ *
149
+ * @param string $custom
150
+ *
151
+ * @return $this
152
+ */
153
+ public function setCustom($custom)
154
+ {
155
+ $this->custom = $custom;
156
+ return $this;
157
+ }
158
+
159
+ /**
160
+ * Free-form field for the use of clients. Only supported when the `payment_method` is set to `paypal`.
161
+ *
162
+ * @return string
163
+ */
164
+ public function getCustom()
165
+ {
166
+ return $this->custom;
167
+ }
168
+
169
+ /**
170
+ * Invoice number used to track the payment. Only supported when the `payment_method` is set to `paypal`.
171
+ *
172
+ * @param string $invoice_number
173
+ *
174
+ * @return $this
175
+ */
176
+ public function setInvoiceNumber($invoice_number)
177
+ {
178
+ $this->invoice_number = $invoice_number;
179
+ return $this;
180
+ }
181
+
182
+ /**
183
+ * Invoice number used to track the payment. Only supported when the `payment_method` is set to `paypal`.
184
+ *
185
+ * @return string
186
+ */
187
+ public function getInvoiceNumber()
188
+ {
189
+ return $this->invoice_number;
190
+ }
191
+
192
+ /**
193
+ * Soft descriptor used when charging this funding source. If length exceeds max length, the value will be truncated
194
+ *
195
+ * @param string $soft_descriptor
196
+ *
197
+ * @return $this
198
+ */
199
+ public function setSoftDescriptor($soft_descriptor)
200
+ {
201
+ $this->soft_descriptor = $soft_descriptor;
202
+ return $this;
203
+ }
204
+
205
+ /**
206
+ * Soft descriptor used when charging this funding source. If length exceeds max length, the value will be truncated
207
+ *
208
+ * @return string
209
+ */
210
+ public function getSoftDescriptor()
211
+ {
212
+ return $this->soft_descriptor;
213
+ }
214
+
215
+ /**
216
+ * Soft descriptor city used when charging this funding source. If length exceeds max length, the value will be truncated. Only supported when the `payment_method` is set to `credit_card`
217
+ *
218
+ * @deprecated Not publicly available
219
+ * @param string $soft_descriptor_city
220
+ *
221
+ * @return $this
222
+ */
223
+ public function setSoftDescriptorCity($soft_descriptor_city)
224
+ {
225
+ $this->soft_descriptor_city = $soft_descriptor_city;
226
+ return $this;
227
+ }
228
+
229
+ /**
230
+ * Soft descriptor city used when charging this funding source. If length exceeds max length, the value will be truncated. Only supported when the `payment_method` is set to `credit_card`
231
+ *
232
+ * @deprecated Not publicly available
233
+ * @return string
234
+ */
235
+ public function getSoftDescriptorCity()
236
+ {
237
+ return $this->soft_descriptor_city;
238
+ }
239
+
240
+ /**
241
+ * Payment options requested for this purchase unit
242
+ *
243
+ * @param \PayPal\Api\PaymentOptions $payment_options
244
+ *
245
+ * @return $this
246
+ */
247
+ public function setPaymentOptions($payment_options)
248
+ {
249
+ $this->payment_options = $payment_options;
250
+ return $this;
251
+ }
252
+
253
+ /**
254
+ * Payment options requested for this purchase unit
255
+ *
256
+ * @return \PayPal\Api\PaymentOptions
257
+ */
258
+ public function getPaymentOptions()
259
+ {
260
+ return $this->payment_options;
261
+ }
262
+
263
+ /**
264
+ * Items and related shipping address within a transaction.
265
+ *
266
+ * @param \PayPal\Api\ItemList $item_list
267
+ *
268
+ * @return $this
269
+ */
270
+ public function setItemList($item_list)
271
+ {
272
+ $this->item_list = $item_list;
273
+ return $this;
274
+ }
275
+
276
+ /**
277
+ * Items and related shipping address within a transaction.
278
+ *
279
+ * @return \PayPal\Api\ItemList
280
+ */
281
+ public function getItemList()
282
+ {
283
+ return $this->item_list;
284
+ }
285
+
286
+ /**
287
+ * URL to send payment notifications
288
+ *
289
+ * @param string $notify_url
290
+ * @throws \InvalidArgumentException
291
+ * @return $this
292
+ */
293
+ public function setNotifyUrl($notify_url)
294
+ {
295
+ UrlValidator::validate($notify_url, "NotifyUrl");
296
+ $this->notify_url = $notify_url;
297
+ return $this;
298
+ }
299
+
300
+ /**
301
+ * URL to send payment notifications
302
+ *
303
+ * @return string
304
+ */
305
+ public function getNotifyUrl()
306
+ {
307
+ return $this->notify_url;
308
+ }
309
+
310
+ /**
311
+ * Url on merchant site pertaining to this payment.
312
+ *
313
+ * @param string $order_url
314
+ * @throws \InvalidArgumentException
315
+ * @return $this
316
+ */
317
+ public function setOrderUrl($order_url)
318
+ {
319
+ UrlValidator::validate($order_url, "OrderUrl");
320
+ $this->order_url = $order_url;
321
+ return $this;
322
+ }
323
+
324
+ /**
325
+ * Url on merchant site pertaining to this payment.
326
+ *
327
+ * @return string
328
+ */
329
+ public function getOrderUrl()
330
+ {
331
+ return $this->order_url;
332
+ }
333
+
334
+ /**
335
+ * List of external funding being applied to the purchase unit. Each external_funding unit should have a unique reference_id
336
+ *
337
+ * @deprecated Not publicly available
338
+ * @param \PayPal\Api\ExternalFunding[] $external_funding
339
+ *
340
+ * @return $this
341
+ */
342
+ public function setExternalFunding($external_funding)
343
+ {
344
+ $this->external_funding = $external_funding;
345
+ return $this;
346
+ }
347
+
348
+ /**
349
+ * List of external funding being applied to the purchase unit. Each external_funding unit should have a unique reference_id
350
+ *
351
+ * @deprecated Not publicly available
352
+ * @return \PayPal\Api\ExternalFunding[]
353
+ */
354
+ public function getExternalFunding()
355
+ {
356
+ return $this->external_funding;
357
+ }
358
+
359
+ /**
360
+ * Append ExternalFunding to the list.
361
+ *
362
+ * @deprecated Not publicly available
363
+ * @param \PayPal\Api\ExternalFunding $externalFunding
364
+ * @return $this
365
+ */
366
+ public function addExternalFunding($externalFunding)
367
+ {
368
+ if (!$this->getExternalFunding()) {
369
+ return $this->setExternalFunding(array($externalFunding));
370
+ } else {
371
+ return $this->setExternalFunding(
372
+ array_merge($this->getExternalFunding(), array($externalFunding))
373
+ );
374
+ }
375
+ }
376
+
377
+ /**
378
+ * Remove ExternalFunding from the list.
379
+ *
380
+ * @deprecated Not publicly available
381
+ * @param \PayPal\Api\ExternalFunding $externalFunding
382
+ * @return $this
383
+ */
384
+ public function removeExternalFunding($externalFunding)
385
+ {
386
+ return $this->setExternalFunding(
387
+ array_diff($this->getExternalFunding(), array($externalFunding))
388
+ );
389
+ }
390
+
391
+ }
lib/PayPal/Api/ChargeModel.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class ChargeModel
9
+ *
10
+ * A resource representing a charge model for a payment definition.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string id
15
+ * @property string type
16
+ * @property \PayPal\Api\Currency amount
17
+ */
18
+ class ChargeModel extends PayPalModel
19
+ {
20
+ /**
21
+ * Identifier of the charge model. 128 characters max.
22
+ *
23
+ * @param string $id
24
+ *
25
+ * @return $this
26
+ */
27
+ public function setId($id)
28
+ {
29
+ $this->id = $id;
30
+ return $this;
31
+ }
32
+
33
+ /**
34
+ * Identifier of the charge model. 128 characters max.
35
+ *
36
+ * @return string
37
+ */
38
+ public function getId()
39
+ {
40
+ return $this->id;
41
+ }
42
+
43
+ /**
44
+ * Type of charge model. Allowed values: `SHIPPING`, `TAX`.
45
+ *
46
+ * @param string $type
47
+ *
48
+ * @return $this
49
+ */
50
+ public function setType($type)
51
+ {
52
+ $this->type = $type;
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * Type of charge model. Allowed values: `SHIPPING`, `TAX`.
58
+ *
59
+ * @return string
60
+ */
61
+ public function getType()
62
+ {
63
+ return $this->type;
64
+ }
65
+
66
+ /**
67
+ * Specific amount for this charge model.
68
+ *
69
+ * @param \PayPal\Api\Currency $amount
70
+ *
71
+ * @return $this
72
+ */
73
+ public function setAmount($amount)
74
+ {
75
+ $this->amount = $amount;
76
+ return $this;
77
+ }
78
+
79
+ /**
80
+ * Specific amount for this charge model.
81
+ *
82
+ * @return \PayPal\Api\Currency
83
+ */
84
+ public function getAmount()
85
+ {
86
+ return $this->amount;
87
+ }
88
+
89
+ }
lib/PayPal/Api/Cost.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+ use PayPal\Converter\FormatConverter;
7
+ use PayPal\Validation\NumericValidator;
8
+
9
+ /**
10
+ * Class Cost
11
+ *
12
+ * Cost as a percent. For example, 10% should be entered as 10. Alternatively, cost as an amount. For example, an amount of 5 should be entered as 5.
13
+ *
14
+ * @package PayPal\Api
15
+ *
16
+ * @property string percent
17
+ * @property \PayPal\Api\Currency amount
18
+ */
19
+ class Cost extends PayPalModel
20
+ {
21
+ /**
22
+ * Cost in percent. Range of 0 to 100.
23
+ *
24
+ * @param string $percent
25
+ *
26
+ * @return $this
27
+ */
28
+ public function setPercent($percent)
29
+ {
30
+ NumericValidator::validate($percent, "Percent");
31
+ $percent = FormatConverter::formatToNumber($percent);
32
+ $this->percent = $percent;
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * Cost in percent. Range of 0 to 100.
38
+ *
39
+ * @return string
40
+ */
41
+ public function getPercent()
42
+ {
43
+ return $this->percent;
44
+ }
45
+
46
+ /**
47
+ * Cost in amount. Range of 0 to 999999.99.
48
+ *
49
+ * @param \PayPal\Api\Currency $amount
50
+ *
51
+ * @return $this
52
+ */
53
+ public function setAmount($amount)
54
+ {
55
+ $this->amount = $amount;
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * Cost in amount. Range of 0 to 999999.99.
61
+ *
62
+ * @return \PayPal\Api\Currency
63
+ */
64
+ public function getAmount()
65
+ {
66
+ return $this->amount;
67
+ }
68
+
69
+ }
lib/PayPal/Api/CountryCode.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class CountryCode
9
+ *
10
+ * Representation of a country code.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string country_code
15
+ */
16
+ class CountryCode extends PayPalModel
17
+ {
18
+ /**
19
+ * ISO country code based on 2-character IS0-3166-1 codes.
20
+ *
21
+ * @param string $country_code
22
+ *
23
+ * @return $this
24
+ */
25
+ public function setCountryCode($country_code)
26
+ {
27
+ $this->country_code = $country_code;
28
+ return $this;
29
+ }
30
+
31
+ /**
32
+ * ISO country code based on 2-character IS0-3166-1 codes.
33
+ *
34
+ * @return string
35
+ */
36
+ public function getCountryCode()
37
+ {
38
+ return $this->country_code;
39
+ }
40
+
41
+ }
lib/PayPal/Api/CreateProfileResponse.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ /**
6
+ * Class CreateProfileResponse
7
+ *
8
+ * Response schema for create profile api
9
+ *
10
+ * @package PayPal\Api
11
+ *
12
+ * @property string id
13
+ */
14
+ class CreateProfileResponse extends WebProfile
15
+ {
16
+ /**
17
+ * ID of the payment web experience profile.
18
+ *
19
+ *
20
+ * @param string $id
21
+ *
22
+ * @return $this
23
+ */
24
+ public function setId($id)
25
+ {
26
+ $this->id = $id;
27
+ return $this;
28
+ }
29
+
30
+ /**
31
+ * ID of the payment web experience profile.
32
+ *
33
+ * @return string
34
+ */
35
+ public function getId()
36
+ {
37
+ return $this->id;
38
+ }
39
+
40
+ }
lib/PayPal/Api/Credit.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class Credit
9
+ *
10
+ * A resource representing a credit instrument.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string id
15
+ * @property string type
16
+ */
17
+ class Credit extends PayPalModel
18
+ {
19
+ /**
20
+ * Unique identifier of credit resource.
21
+ *
22
+ * @param string $id
23
+ *
24
+ * @return $this
25
+ */
26
+ public function setId($id)
27
+ {
28
+ $this->id = $id;
29
+ return $this;
30
+ }
31
+
32
+ /**
33
+ * Unique identifier of credit resource.
34
+ *
35
+ * @return string
36
+ */
37
+ public function getId()
38
+ {
39
+ return $this->id;
40
+ }
41
+
42
+ /**
43
+ * specifies type of credit
44
+ * Valid Values: ["BILL_ME_LATER", "PAYPAL_EXTRAS_MASTERCARD", "EBAY_MASTERCARD", "PAYPAL_SMART_CONNECT"]
45
+ *
46
+ * @param string $type
47
+ *
48
+ * @return $this
49
+ */
50
+ public function setType($type)
51
+ {
52
+ $this->type = $type;
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * specifies type of credit
58
+ *
59
+ * @return string
60
+ */
61
+ public function getType()
62
+ {
63
+ return $this->type;
64
+ }
65
+
66
+ }
lib/PayPal/Api/CreditCard.php ADDED
@@ -0,0 +1,559 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalResourceModel;
6
+ use PayPal\Rest\ApiContext;
7
+ use PayPal\Transport\PayPalRestCall;
8
+ use PayPal\Validation\ArgumentValidator;
9
+
10
+ /**
11
+ * Class CreditCard
12
+ *
13
+ * @package PayPal\Api
14
+ *
15
+ * @property string number
16
+ * @property string type
17
+ * @property int expire_month
18
+ * @property int expire_year
19
+ * @property string cvv2
20
+ * @property string first_name
21
+ * @property string last_name
22
+ * @property \PayPal\Api\Address billing_address
23
+ * @property string external_customer_id
24
+ * @property string state
25
+ * @property string valid_until
26
+ * @property \PayPal\Api\Links[] links
27
+ */
28
+ class CreditCard extends PayPalResourceModel
29
+ {
30
+ /**
31
+ * ID of the credit card. This ID is provided in the response when storing credit cards. **Required if using a stored credit card.**
32
+ *
33
+ * @deprecated Not publicly available
34
+ * @param string $id
35
+ *
36
+ * @return $this
37
+ */
38
+ public function setId($id)
39
+ {
40
+ $this->id = $id;
41
+ return $this;
42
+ }
43
+
44
+ /**
45
+ * ID of the credit card. This ID is provided in the response when storing credit cards. **Required if using a stored credit card.**
46
+ *
47
+ * @deprecated Not publicly available
48
+ * @return string
49
+ */
50
+ public function getId()
51
+ {
52
+ return $this->id;
53
+ }
54
+
55
+ /**
56
+ * Credit card number. Numeric characters only with no spaces or punctuation. The string must conform with modulo and length required by each credit card type. *Redacted in responses.*
57
+ *
58
+ * @param string $number
59
+ *
60
+ * @return $this
61
+ */
62
+ public function setNumber($number)
63
+ {
64
+ $this->number = $number;
65
+ return $this;
66
+ }
67
+
68
+ /**
69
+ * Credit card number. Numeric characters only with no spaces or punctuation. The string must conform with modulo and length required by each credit card type. *Redacted in responses.*
70
+ *
71
+ * @return string
72
+ */
73
+ public function getNumber()
74
+ {
75
+ return $this->number;
76
+ }
77
+
78
+ /**
79
+ * Credit card type. Valid types are: `visa`, `mastercard`, `discover`, `amex`
80
+ *
81
+ * @param string $type
82
+ *
83
+ * @return $this
84
+ */
85
+ public function setType($type)
86
+ {
87
+ $this->type = $type;
88
+ return $this;
89
+ }
90
+
91
+ /**
92
+ * Credit card type. Valid types are: `visa`, `mastercard`, `discover`, `amex`
93
+ *
94
+ * @return string
95
+ */
96
+ public function getType()
97
+ {
98
+ return $this->type;
99
+ }
100
+
101
+ /**
102
+ * Expiration month with no leading zero. Acceptable values are 1 through 12.
103
+ *
104
+ * @param int $expire_month
105
+ *
106
+ * @return $this
107
+ */
108
+ public function setExpireMonth($expire_month)
109
+ {
110
+ $this->expire_month = $expire_month;
111
+ return $this;
112
+ }
113
+
114
+ /**
115
+ * Expiration month with no leading zero. Acceptable values are 1 through 12.
116
+ *
117
+ * @return int
118
+ */
119
+ public function getExpireMonth()
120
+ {
121
+ return $this->expire_month;
122
+ }
123
+
124
+ /**
125
+ * 4-digit expiration year.
126
+ *
127
+ * @param int $expire_year
128
+ *
129
+ * @return $this
130
+ */
131
+ public function setExpireYear($expire_year)
132
+ {
133
+ $this->expire_year = $expire_year;
134
+ return $this;
135
+ }
136
+
137
+ /**
138
+ * 4-digit expiration year.
139
+ *
140
+ * @return int
141
+ */
142
+ public function getExpireYear()
143
+ {
144
+ return $this->expire_year;
145
+ }
146
+
147
+ /**
148
+ * 3-4 digit card validation code.
149
+ *
150
+ * @param string $cvv2
151
+ *
152
+ * @return $this
153
+ */
154
+ public function setCvv2($cvv2)
155
+ {
156
+ $this->cvv2 = $cvv2;
157
+ return $this;
158
+ }
159
+
160
+ /**
161
+ * 3-4 digit card validation code.
162
+ *
163
+ * @return string
164
+ */
165
+ public function getCvv2()
166
+ {
167
+ return $this->cvv2;
168
+ }
169
+
170
+ /**
171
+ * Cardholder's first name.
172
+ *
173
+ * @param string $first_name
174
+ *
175
+ * @return $this
176
+ */
177
+ public function setFirstName($first_name)
178
+ {
179
+ $this->first_name = $first_name;
180
+ return $this;
181
+ }
182
+
183
+ /**
184
+ * Cardholder's first name.
185
+ *
186
+ * @return string
187
+ */
188
+ public function getFirstName()
189
+ {
190
+ return $this->first_name;
191
+ }
192
+
193
+ /**
194
+ * Cardholder's last name.
195
+ *
196
+ * @param string $last_name
197
+ *
198
+ * @return $this
199
+ */
200
+ public function setLastName($last_name)
201
+ {
202
+ $this->last_name = $last_name;
203
+ return $this;
204
+ }
205
+
206
+ /**
207
+ * Cardholder's last name.
208
+ *
209
+ * @return string
210
+ */
211
+ public function getLastName()
212
+ {
213
+ return $this->last_name;
214
+ }
215
+
216
+ /**
217
+ * Billing Address associated with this card.
218
+ *
219
+ * @param \PayPal\Api\Address $billing_address
220
+ *
221
+ * @return $this
222
+ */
223
+ public function setBillingAddress($billing_address)
224
+ {
225
+ $this->billing_address = $billing_address;
226
+ return $this;
227
+ }
228
+
229
+ /**
230
+ * Billing Address associated with this card.
231
+ *
232
+ * @return \PayPal\Api\Address
233
+ */
234
+ public function getBillingAddress()
235
+ {
236
+ return $this->billing_address;
237
+ }
238
+
239
+ /**
240
+ * A unique identifier of the customer to whom this bank account belongs. Generated and provided by the facilitator. **This is now used in favor of `payer_id` when creating or using a stored funding instrument in the vault.**
241
+ *
242
+ * @param string $external_customer_id
243
+ *
244
+ * @return $this
245
+ */
246
+ public function setExternalCustomerId($external_customer_id)
247
+ {
248
+ $this->external_customer_id = $external_customer_id;
249
+ return $this;
250
+ }
251
+
252
+ /**
253
+ * A unique identifier of the customer to whom this bank account belongs. Generated and provided by the facilitator. **This is now used in favor of `payer_id` when creating or using a stored funding instrument in the vault.**
254
+ *
255
+ * @return string
256
+ */
257
+ public function getExternalCustomerId()
258
+ {
259
+ return $this->external_customer_id;
260
+ }
261
+
262
+ /**
263
+ * A user provided, optional convenvience field that functions as a unique identifier for the merchant on behalf of whom this credit card is being stored for. Note that this has no relation to PayPal merchant id
264
+ *
265
+ * @param string $merchant_id
266
+ *
267
+ * @return $this
268
+ */
269
+ public function setMerchantId($merchant_id)
270
+ {
271
+ $this->merchant_id = $merchant_id;
272
+ return $this;
273
+ }
274
+
275
+ /**
276
+ * A user provided, optional convenvience field that functions as a unique identifier for the merchant on behalf of whom this credit card is being stored for. Note that this has no relation to PayPal merchant id
277
+ *
278
+ * @return string
279
+ */
280
+ public function getMerchantId()
281
+ {
282
+ return $this->merchant_id;
283
+ }
284
+
285
+ /**
286
+ * A unique identifier that you can assign and track when storing a credit card or using a stored credit card. This ID can help to avoid unintentional use or misuse of credit cards. This ID can be any value you would like to associate with the saved card, such as a UUID, username, or email address. Required when using a stored credit card if a payer_id was originally provided when storing the credit card in vault.
287
+ *
288
+ * @deprecated This is being deprecated in favor of the `external_customer_id` property.
289
+ * @param string $payer_id
290
+ *
291
+ * @return $this
292
+ */
293
+ public function setPayerId($payer_id)
294
+ {
295
+ $this->payer_id = $payer_id;
296
+ return $this;
297
+ }
298
+
299
+ /**
300
+ * A unique identifier that you can assign and track when storing a credit card or using a stored credit card. This ID can help to avoid unintentional use or misuse of credit cards. This ID can be any value you would like to associate with the saved card, such as a UUID, username, or email address. Required when using a stored credit card if a payer_id was originally provided when storing the credit card in vault.
301
+ *
302
+ * @deprecated This is being deprecated in favor of the `external_customer_id` property.
303
+ * @return string
304
+ */
305
+ public function getPayerId()
306
+ {
307
+ return $this->payer_id;
308
+ }
309
+
310
+ /**
311
+ * A unique identifier of the bank account resource. Generated and provided by the facilitator so it can be used to restrict the usage of the bank account to the specific merchant.
312
+ *
313
+ * @param string $external_card_id
314
+ *
315
+ * @return $this
316
+ */
317
+ public function setExternalCardId($external_card_id)
318
+ {
319
+ $this->external_card_id = $external_card_id;
320
+ return $this;
321
+ }
322
+
323
+ /**
324
+ * A unique identifier of the bank account resource. Generated and provided by the facilitator so it can be used to restrict the usage of the bank account to the specific merchant.
325
+ *
326
+ * @return string
327
+ */
328
+ public function getExternalCardId()
329
+ {
330
+ return $this->external_card_id;
331
+ }
332
+
333
+ /**
334
+ * State of the funding instrument.
335
+ * Valid Values: ["expired", "ok"]
336
+ *
337
+ * @param string $state
338
+ *
339
+ * @return $this
340
+ */
341
+ public function setState($state)
342
+ {
343
+ $this->state = $state;
344
+ return $this;
345
+ }
346
+
347
+ /**
348
+ * State of the credit card funding instrument.
349
+ *
350
+ * @return string
351
+ */
352
+ public function getState()
353
+ {
354
+ return $this->state;
355
+ }
356
+
357
+ /**
358
+ * Funding instrument expiration date.
359
+ *
360
+ * @param string $create_time
361
+ *
362
+ * @return $this
363
+ */
364
+ public function setCreateTime($create_time)
365
+ {
366
+ $this->create_time = $create_time;
367
+ return $this;
368
+ }
369
+
370
+ /**
371
+ * Resource creation time as ISO8601 date-time format (ex: 1994-11-05T13:15:30Z) that indicates creation time.
372
+ *
373
+ * @return string
374
+ */
375
+ public function getCreateTime()
376
+ {
377
+ return $this->create_time;
378
+ }
379
+
380
+ /**
381
+ * Resource creation time as ISO8601 date-time format (ex: 1994-11-05T13:15:30Z) that indicates the updation time.
382
+ *
383
+ * @param string $update_time
384
+ *
385
+ * @return $this
386
+ */
387
+ public function setUpdateTime($update_time)
388
+ {
389
+ $this->update_time = $update_time;
390
+ return $this;
391
+ }
392
+
393
+ /**
394
+ * Resource creation time as ISO8601 date-time format (ex: 1994-11-05T13:15:30Z) that indicates the updation time.
395
+ *
396
+ * @return string
397
+ */
398
+ public function getUpdateTime()
399
+ {
400
+ return $this->update_time;
401
+ }
402
+
403
+ /**
404
+ * Date/Time until this resource can be used fund a payment.
405
+ *
406
+ * @param string $valid_until
407
+ *
408
+ * @return $this
409
+ */
410
+ public function setValidUntil($valid_until)
411
+ {
412
+ $this->valid_until = $valid_until;
413
+ return $this;
414
+ }
415
+
416
+ /**
417
+ * Funding instrument expiration date.
418
+ *
419
+ * @return string
420
+ */
421
+ public function getValidUntil()
422
+ {
423
+ return $this->valid_until;
424
+ }
425
+
426
+ /**
427
+ * Creates a new Credit Card Resource (aka Tokenize).
428
+ *
429
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
430
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
431
+ * @return CreditCard
432
+ */
433
+ public function create($apiContext = null, $restCall = null)
434
+ {
435
+ $payLoad = $this->toJSON();
436
+ $json = self::executeCall(
437
+ "/v1/vault/credit-cards",
438
+ "POST",
439
+ $payLoad,
440
+ null,
441
+ $apiContext,
442
+ $restCall
443
+ );
444
+ $this->fromJson($json);
445
+ return $this;
446
+ }
447
+
448
+ /**
449
+ * Obtain the Credit Card resource for the given identifier.
450
+ *
451
+ * @param string $creditCardId
452
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
453
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
454
+ * @return CreditCard
455
+ */
456
+ public static function get($creditCardId, $apiContext = null, $restCall = null)
457
+ {
458
+ ArgumentValidator::validate($creditCardId, 'creditCardId');
459
+ $payLoad = "";
460
+ $json = self::executeCall(
461
+ "/v1/vault/credit-cards/$creditCardId",
462
+ "GET",
463
+ $payLoad,
464
+ null,
465
+ $apiContext,
466
+ $restCall
467
+ );
468
+ $ret = new CreditCard();
469
+ $ret->fromJson($json);
470
+ return $ret;
471
+ }
472
+
473
+ /**
474
+ * Delete the Credit Card resource for the given identifier.
475
+ *
476
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
477
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
478
+ * @return bool
479
+ */
480
+ public function delete($apiContext = null, $restCall = null)
481
+ {
482
+ ArgumentValidator::validate($this->getId(), "Id");
483
+ $payLoad = "";
484
+ self::executeCall(
485
+ "/v1/vault/credit-cards/{$this->getId()}",
486
+ "DELETE",
487
+ $payLoad,
488
+ null,
489
+ $apiContext,
490
+ $restCall
491
+ );
492
+ return true;
493
+ }
494
+
495
+ /**
496
+ * Update information in a previously saved card. Only the modified fields need to be passed in the request.
497
+ *
498
+ * @param PatchRequest $patchRequest
499
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
500
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
501
+ * @return CreditCard
502
+ */
503
+ public function update($patchRequest, $apiContext = null, $restCall = null)
504
+ {
505
+ ArgumentValidator::validate($this->getId(), "Id");
506
+ ArgumentValidator::validate($patchRequest, 'patch');
507
+ $payload = $patchRequest->toJSON();
508
+ $json = self::executeCall(
509
+ "/v1/vault/credit-cards/{$this->getId()}",
510
+ "PATCH",
511
+ $payload,
512
+ null,
513
+ $apiContext,
514
+ $restCall
515
+ );
516
+ $this->fromJson($json);
517
+ return $this;
518
+ }
519
+
520
+ /**
521
+ * Retrieves a list of Credit Card resources.
522
+ *
523
+ * @param array $params
524
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
525
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
526
+ * @return CreditCardList
527
+ */
528
+ public static function all($params, $apiContext = null, $restCall = null)
529
+ {
530
+ if (is_null($params)) {
531
+ $params = array();
532
+ }
533
+ ArgumentValidator::validate($params, 'params');
534
+ $payLoad = "";
535
+ $allowedParams = array(
536
+ 'page_size' => 1,
537
+ 'page' => 1,
538
+ 'start_time' => 1,
539
+ 'end_time' => 1,
540
+ 'sort_order' => 1,
541
+ 'sort_by' => 1,
542
+ 'merchant_id' => 1,
543
+ 'external_card_id' => 1,
544
+ 'external_customer_id' => 1,
545
+ );
546
+ $json = self::executeCall(
547
+ "/v1/vault/credit-cards" . "?" . http_build_query(array_intersect_key($params, $allowedParams)),
548
+ "GET",
549
+ $payLoad,
550
+ null,
551
+ $apiContext,
552
+ $restCall
553
+ );
554
+ $ret = new CreditCardList();
555
+ $ret->fromJson($json);
556
+ return $ret;
557
+ }
558
+
559
+ }
lib/PayPal/Api/CreditCardHistory.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class CreditCardHistory
9
+ *
10
+ * A list of Credit Card Resources
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property \PayPal\Api\CreditCard[] credit_cards
15
+ * @property int count
16
+ * @property string next_id
17
+ */
18
+ class CreditCardHistory extends PayPalModel
19
+ {
20
+ /**
21
+ * A list of credit card resources
22
+ *
23
+ *
24
+ * @param \PayPal\Api\CreditCard[] $credit_cards
25
+ * @return $this
26
+ */
27
+ public function setCreditCards($credit_cards)
28
+ {
29
+ $this->{"credit-cards"} = $credit_cards;
30
+ return $this;
31
+ }
32
+
33
+ /**
34
+ * A list of credit card resources
35
+ *
36
+ * @return \PayPal\Api\CreditCard
37
+ */
38
+ public function getCreditCards()
39
+ {
40
+ return $this->{"credit-cards"};
41
+ }
42
+
43
+ /**
44
+ * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items.
45
+ *
46
+ *
47
+ * @param int $count
48
+ *
49
+ * @return $this
50
+ */
51
+ public function setCount($count)
52
+ {
53
+ $this->count = $count;
54
+ return $this;
55
+ }
56
+
57
+ /**
58
+ * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items.
59
+ *
60
+ * @return int
61
+ */
62
+ public function getCount()
63
+ {
64
+ return $this->count;
65
+ }
66
+
67
+ /**
68
+ * Identifier of the next element to get the next range of results.
69
+ *
70
+ *
71
+ * @param string $next_id
72
+ *
73
+ * @return $this
74
+ */
75
+ public function setNextId($next_id)
76
+ {
77
+ $this->next_id = $next_id;
78
+ return $this;
79
+ }
80
+
81
+ /**
82
+ * Identifier of the next element to get the next range of results.
83
+ *
84
+ * @return string
85
+ */
86
+ public function getNextId()
87
+ {
88
+ return $this->next_id;
89
+ }
90
+
91
+ }
lib/PayPal/Api/CreditCardList.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalResourceModel;
6
+
7
+ /**
8
+ * Class CreditCardList
9
+ *
10
+ * A list of Credit Card Resources
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property \PayPal\Api\CreditCard[] items
15
+ * @property \PayPal\Api\Links[] links
16
+ * @property int total_items
17
+ * @property int total_pages
18
+ */
19
+ class CreditCardList extends PayPalResourceModel
20
+ {
21
+ /**
22
+ * A list of credit card resources
23
+ *
24
+ * @param \PayPal\Api\CreditCard[] $items
25
+ *
26
+ * @return $this
27
+ */
28
+ public function setItems($items)
29
+ {
30
+ $this->items = $items;
31
+ return $this;
32
+ }
33
+
34
+ /**
35
+ * A list of credit card resources
36
+ *
37
+ * @return \PayPal\Api\CreditCard[]
38
+ */
39
+ public function getItems()
40
+ {
41
+ return $this->items;
42
+ }
43
+
44
+ /**
45
+ * Append Items to the list.
46
+ *
47
+ * @param \PayPal\Api\CreditCard $creditCard
48
+ * @return $this
49
+ */
50
+ public function addItem($creditCard)
51
+ {
52
+ if (!$this->getItems()) {
53
+ return $this->setItems(array($creditCard));
54
+ } else {
55
+ return $this->setItems(
56
+ array_merge($this->getItems(), array($creditCard))
57
+ );
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Remove Items from the list.
63
+ *
64
+ * @param \PayPal\Api\CreditCard $creditCard
65
+ * @return $this
66
+ */
67
+ public function removeItem($creditCard)
68
+ {
69
+ return $this->setItems(
70
+ array_diff($this->getItems(), array($creditCard))
71
+ );
72
+ }
73
+
74
+ /**
75
+ * Total number of items present in the given list. Note that the number of items might be larger than the records in the current page.
76
+ *
77
+ * @param int $total_items
78
+ *
79
+ * @return $this
80
+ */
81
+ public function setTotalItems($total_items)
82
+ {
83
+ $this->total_items = $total_items;
84
+ return $this;
85
+ }
86
+
87
+ /**
88
+ * Total number of items present in the given list. Note that the number of items might be larger than the records in the current page.
89
+ *
90
+ * @return int
91
+ */
92
+ public function getTotalItems()
93
+ {
94
+ return $this->total_items;
95
+ }
96
+
97
+ /**
98
+ * Total number of pages that exist, for the total number of items, with the given page size.
99
+ *
100
+ * @param int $total_pages
101
+ *
102
+ * @return $this
103
+ */
104
+ public function setTotalPages($total_pages)
105
+ {
106
+ $this->total_pages = $total_pages;
107
+ return $this;
108
+ }
109
+
110
+ /**
111
+ * Total number of pages that exist, for the total number of items, with the given page size.
112
+ *
113
+ * @return int
114
+ */
115
+ public function getTotalPages()
116
+ {
117
+ return $this->total_pages;
118
+ }
119
+
120
+ }
lib/PayPal/Api/CreditCardToken.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class CreditCardToken
9
+ *
10
+ * A resource representing a credit card that can be used to fund a payment.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string credit_card_id
15
+ * @property string payer_id
16
+ * @property string last4
17
+ * @property string type
18
+ * @property int expire_month
19
+ * @property int expire_year
20
+ */
21
+ class CreditCardToken extends PayPalModel
22
+ {
23
+ /**
24
+ * ID of credit card previously stored using `/vault/credit-card`.
25
+ *
26
+ * @param string $credit_card_id
27
+ *
28
+ * @return $this
29
+ */
30
+ public function setCreditCardId($credit_card_id)
31
+ {
32
+ $this->credit_card_id = $credit_card_id;
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * ID of credit card previously stored using `/vault/credit-card`.
38
+ *
39
+ * @return string
40
+ */
41
+ public function getCreditCardId()
42
+ {
43
+ return $this->credit_card_id;
44
+ }
45
+
46
+ /**
47
+ * A unique identifier that you can assign and track when storing a credit card or using a stored credit card. This ID can help to avoid unintentional use or misuse of credit cards. This ID can be any value you would like to associate with the saved card, such as a UUID, username, or email address. **Required when using a stored credit card if a payer_id was originally provided when storing the credit card in vault.**
48
+ *
49
+ * @param string $payer_id
50
+ *
51
+ * @return $this
52
+ */
53
+ public function setPayerId($payer_id)
54
+ {
55
+ $this->payer_id = $payer_id;
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * A unique identifier that you can assign and track when storing a credit card or using a stored credit card. This ID can help to avoid unintentional use or misuse of credit cards. This ID can be any value you would like to associate with the saved card, such as a UUID, username, or email address. **Required when using a stored credit card if a payer_id was originally provided when storing the credit card in vault.**
61
+ *
62
+ * @return string
63
+ */
64
+ public function getPayerId()
65
+ {
66
+ return $this->payer_id;
67
+ }
68
+
69
+ /**
70
+ * Last four digits of the stored credit card number.
71
+ *
72
+ * @param string $last4
73
+ *
74
+ * @return $this
75
+ */
76
+ public function setLast4($last4)
77
+ {
78
+ $this->last4 = $last4;
79
+ return $this;
80
+ }
81
+
82
+ /**
83
+ * Last four digits of the stored credit card number.
84
+ *
85
+ * @return string
86
+ */
87
+ public function getLast4()
88
+ {
89
+ return $this->last4;
90
+ }
91
+
92
+ /**
93
+ * Credit card type. Valid types are: `visa`, `mastercard`, `discover`, `amex`. Values are presented in lowercase and not should not be used for display.
94
+ *
95
+ * @param string $type
96
+ *
97
+ * @return $this
98
+ */
99
+ public function setType($type)
100
+ {
101
+ $this->type = $type;
102
+ return $this;
103
+ }
104
+
105
+ /**
106
+ * Credit card type. Valid types are: `visa`, `mastercard`, `discover`, `amex`. Values are presented in lowercase and not should not be used for display.
107
+ *
108
+ * @return string
109
+ */
110
+ public function getType()
111
+ {
112
+ return $this->type;
113
+ }
114
+
115
+ /**
116
+ * Expiration month with no leading zero. Acceptable values are 1 through 12.
117
+ *
118
+ * @param int $expire_month
119
+ *
120
+ * @return $this
121
+ */
122
+ public function setExpireMonth($expire_month)
123
+ {
124
+ $this->expire_month = $expire_month;
125
+ return $this;
126
+ }
127
+
128
+ /**
129
+ * Expiration month with no leading zero. Acceptable values are 1 through 12.
130
+ *
131
+ * @return int
132
+ */
133
+ public function getExpireMonth()
134
+ {
135
+ return $this->expire_month;
136
+ }
137
+
138
+ /**
139
+ * 4-digit expiration year.
140
+ *
141
+ * @param int $expire_year
142
+ *
143
+ * @return $this
144
+ */
145
+ public function setExpireYear($expire_year)
146
+ {
147
+ $this->expire_year = $expire_year;
148
+ return $this;
149
+ }
150
+
151
+ /**
152
+ * 4-digit expiration year.
153
+ *
154
+ * @return int
155
+ */
156
+ public function getExpireYear()
157
+ {
158
+ return $this->expire_year;
159
+ }
160
+
161
+ }
lib/PayPal/Api/CreditFinancingOffered.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class CreditFinancingOffered
9
+ *
10
+ * Credit financing offered to customer on PayPal side with opt-in/opt-out status
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property \PayPal\Api\Currency total_cost
15
+ * @property \PayPal\Api\number term
16
+ * @property \PayPal\Api\Currency monthly_payment
17
+ * @property \PayPal\Api\Currency total_interest
18
+ * @property bool payer_acceptance
19
+ * @property bool cart_amount_immutable
20
+ */
21
+ class CreditFinancingOffered extends PayPalModel
22
+ {
23
+ /**
24
+ * This is the estimated total payment amount including interest and fees the user will pay during the lifetime of the loan.
25
+ *
26
+ * @param \PayPal\Api\Currency $total_cost
27
+ *
28
+ * @return $this
29
+ */
30
+ public function setTotalCost($total_cost)
31
+ {
32
+ $this->total_cost = $total_cost;
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * This is the estimated total payment amount including interest and fees the user will pay during the lifetime of the loan.
38
+ *
39
+ * @return \PayPal\Api\Currency
40
+ */
41
+ public function getTotalCost()
42
+ {
43
+ return $this->total_cost;
44
+ }
45
+
46
+ /**
47
+ * Length of financing terms in month
48
+ *
49
+ * @param \PayPal\Api\number $term
50
+ *
51
+ * @return $this
52
+ */
53
+ public function setTerm($term)
54
+ {
55
+ $this->term = $term;
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * Length of financing terms in month
61
+ *
62
+ * @return \PayPal\Api\number
63
+ */
64
+ public function getTerm()
65
+ {
66
+ return $this->term;
67
+ }
68
+
69
+ /**
70
+ * This is the estimated amount per month that the customer will need to pay including fees and interest.
71
+ *
72
+ * @param \PayPal\Api\Currency $monthly_payment
73
+ *
74
+ * @return $this
75
+ */
76
+ public function setMonthlyPayment($monthly_payment)
77
+ {
78
+ $this->monthly_payment = $monthly_payment;
79
+ return $this;
80
+ }
81
+
82
+ /**
83
+ * This is the estimated amount per month that the customer will need to pay including fees and interest.
84
+ *
85
+ * @return \PayPal\Api\Currency
86
+ */
87
+ public function getMonthlyPayment()
88
+ {
89
+ return $this->monthly_payment;
90
+ }
91
+
92
+ /**
93
+ * Estimated interest or fees amount the payer will have to pay during the lifetime of the loan.
94
+ *
95
+ * @param \PayPal\Api\Currency $total_interest
96
+ *
97
+ * @return $this
98
+ */
99
+ public function setTotalInterest($total_interest)
100
+ {
101
+ $this->total_interest = $total_interest;
102
+ return $this;
103
+ }
104
+
105
+ /**
106
+ * Estimated interest or fees amount the payer will have to pay during the lifetime of the loan.
107
+ *
108
+ * @return \PayPal\Api\Currency
109
+ */
110
+ public function getTotalInterest()
111
+ {
112
+ return $this->total_interest;
113
+ }
114
+
115
+ /**
116
+ * Status on whether the customer ultimately was approved for and chose to make the payment using the approved installment credit.
117
+ *
118
+ * @param bool $payer_acceptance
119
+ *
120
+ * @return $this
121
+ */
122
+ public function setPayerAcceptance($payer_acceptance)
123
+ {
124
+ $this->payer_acceptance = $payer_acceptance;
125
+ return $this;
126
+ }
127
+
128
+ /**
129
+ * Status on whether the customer ultimately was approved for and chose to make the payment using the approved installment credit.
130
+ *
131
+ * @return bool
132
+ */
133
+ public function getPayerAcceptance()
134
+ {
135
+ return $this->payer_acceptance;
136
+ }
137
+
138
+ /**
139
+ * Indicates whether the cart amount is editable after payer's acceptance on PayPal side
140
+ *
141
+ * @param bool $cart_amount_immutable
142
+ *
143
+ * @return $this
144
+ */
145
+ public function setCartAmountImmutable($cart_amount_immutable)
146
+ {
147
+ $this->cart_amount_immutable = $cart_amount_immutable;
148
+ return $this;
149
+ }
150
+
151
+ /**
152
+ * Indicates whether the cart amount is editable after payer's acceptance on PayPal side
153
+ *
154
+ * @return bool
155
+ */
156
+ public function getCartAmountImmutable()
157
+ {
158
+ return $this->cart_amount_immutable;
159
+ }
160
+
161
+ }
lib/PayPal/Api/Currency.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+ use PayPal\Converter\FormatConverter;
7
+ use PayPal\Validation\NumericValidator;
8
+
9
+ /**
10
+ * Class Currency
11
+ *
12
+ * Base object for all financial value related fields (balance, payment due, etc.)
13
+ *
14
+ * @package PayPal\Api
15
+ *
16
+ * @property string currency
17
+ * @property string value
18
+ */
19
+ class Currency extends PayPalModel
20
+ {
21
+ /**
22
+ * 3 letter currency code as defined by ISO 4217.
23
+ *
24
+ * @param string $currency
25
+ *
26
+ * @return $this
27
+ */
28
+ public function setCurrency($currency)
29
+ {
30
+ $this->currency = $currency;
31
+ return $this;
32
+ }
33
+
34
+ /**
35
+ * 3 letter currency code as defined by ISO 4217.
36
+ *
37
+ * @return string
38
+ */
39
+ public function getCurrency()
40
+ {
41
+ return $this->currency;
42
+ }
43
+
44
+ /**
45
+ * amount up to N digit after the decimals separator as defined in ISO 4217 for the appropriate currency code.
46
+ *
47
+ * @param string|double $value
48
+ *
49
+ * @return $this
50
+ */
51
+ public function setValue($value)
52
+ {
53
+ NumericValidator::validate($value, "Value");
54
+ $value = FormatConverter::formatToPrice($value, $this->getCurrency());
55
+ $this->value = $value;
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * amount up to N digit after the decimals separator as defined in ISO 4217 for the appropriate currency code.
61
+ *
62
+ * @return string
63
+ */
64
+ public function getValue()
65
+ {
66
+ return $this->value;
67
+ }
68
+
69
+ }
lib/PayPal/Api/CurrencyConversion.php ADDED
@@ -0,0 +1,268 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+ use PayPal\Validation\UrlValidator;
7
+
8
+ /**
9
+ * Class CurrencyConversion
10
+ *
11
+ * Object used to store the currency conversion rate.
12
+ *
13
+ * @package PayPal\Api
14
+ *
15
+ * @property string conversion_date
16
+ * @property string from_currency
17
+ * @property string from_amount
18
+ * @property string to_currency
19
+ * @property string to_amount
20
+ * @property string conversion_type
21
+ * @property bool conversion_type_changeable
22
+ * @property \PayPal\Api\Links[] links
23
+ */
24
+ class CurrencyConversion extends PayPalModel
25
+ {
26
+ /**
27
+ * Date of validity for the conversion rate.
28
+ *
29
+ * @param string $conversion_date
30
+ *
31
+ * @return $this
32
+ */
33
+ public function setConversionDate($conversion_date)
34
+ {
35
+ $this->conversion_date = $conversion_date;
36
+ return $this;
37
+ }
38
+
39
+ /**
40
+ * Date of validity for the conversion rate.
41
+ *
42
+ * @return string
43
+ */
44
+ public function getConversionDate()
45
+ {
46
+ return $this->conversion_date;
47
+ }
48
+
49
+ /**
50
+ * 3 letter currency code
51
+ *
52
+ * @param string $from_currency
53
+ *
54
+ * @return $this
55
+ */
56
+ public function setFromCurrency($from_currency)
57
+ {
58
+ $this->from_currency = $from_currency;
59
+ return $this;
60
+ }
61
+
62
+ /**
63
+ * 3 letter currency code
64
+ *
65
+ * @return string
66
+ */
67
+ public function getFromCurrency()
68
+ {
69
+ return $this->from_currency;
70
+ }
71
+
72
+ /**
73
+ * Amount participating in currency conversion, set to 1 as default
74
+ *
75
+ * @param string $from_amount
76
+ *
77
+ * @return $this
78
+ */
79
+ public function setFromAmount($from_amount)
80
+ {
81
+ $this->from_amount = $from_amount;
82
+ return $this;
83
+ }
84
+
85
+ /**
86
+ * Amount participating in currency conversion, set to 1 as default
87
+ *
88
+ * @return string
89
+ */
90
+ public function getFromAmount()
91
+ {
92
+ return $this->from_amount;
93
+ }
94
+
95
+ /**
96
+ * 3 letter currency code
97
+ *
98
+ * @param string $to_currency
99
+ *
100
+ * @return $this
101
+ */
102
+ public function setToCurrency($to_currency)
103
+ {
104
+ $this->to_currency = $to_currency;
105
+ return $this;
106
+ }
107
+
108
+ /**
109
+ * 3 letter currency code
110
+ *
111
+ * @return string
112
+ */
113
+ public function getToCurrency()
114
+ {
115
+ return $this->to_currency;
116
+ }
117
+
118
+ /**
119
+ * Amount resulting from currency conversion.
120
+ *
121
+ * @param string $to_amount
122
+ *
123
+ * @return $this
124
+ */
125
+ public function setToAmount($to_amount)
126
+ {
127
+ $this->to_amount = $to_amount;
128
+ return $this;
129
+ }
130
+
131
+ /**
132
+ * Amount resulting from currency conversion.
133
+ *
134
+ * @return string
135
+ */
136
+ public function getToAmount()
137
+ {
138
+ return $this->to_amount;
139
+ }
140
+
141
+ /**
142
+ * Field indicating conversion type applied.
143
+ * Valid Values: ["PAYPAL", "VENDOR"]
144
+ *
145
+ * @param string $conversion_type
146
+ *
147
+ * @return $this
148
+ */
149
+ public function setConversionType($conversion_type)
150
+ {
151
+ $this->conversion_type = $conversion_type;
152
+ return $this;
153
+ }
154
+
155
+ /**
156
+ * Field indicating conversion type applied.
157
+ *
158
+ * @return string
159
+ */
160
+ public function getConversionType()
161
+ {
162
+ return $this->conversion_type;
163
+ }
164
+
165
+ /**
166
+ * Allow Payer to change conversion type.
167
+ *
168
+ * @param bool $conversion_type_changeable
169
+ *
170
+ * @return $this
171
+ */
172
+ public function setConversionTypeChangeable($conversion_type_changeable)
173
+ {
174
+ $this->conversion_type_changeable = $conversion_type_changeable;
175
+ return $this;
176
+ }
177
+
178
+ /**
179
+ * Allow Payer to change conversion type.
180
+ *
181
+ * @return bool
182
+ */
183
+ public function getConversionTypeChangeable()
184
+ {
185
+ return $this->conversion_type_changeable;
186
+ }
187
+
188
+ /**
189
+ * Base URL to web applications endpoint
190
+ * Valid Values: ["https://www.paypal.com/{country_code}/webapps/xocspartaweb/webflow/sparta/proxwebflow", "https://www.paypal.com/{country_code}/proxflow"]
191
+ *
192
+ * @deprecated Not publicly available
193
+ * @param string $web_url
194
+ * @throws \InvalidArgumentException
195
+ * @return $this
196
+ */
197
+ public function setWebUrl($web_url)
198
+ {
199
+ UrlValidator::validate($web_url, "WebUrl");
200
+ $this->web_url = $web_url;
201
+ return $this;
202
+ }
203
+
204
+ /**
205
+ * Base URL to web applications endpoint
206
+ *
207
+ * @deprecated Not publicly available
208
+ * @return string
209
+ */
210
+ public function getWebUrl()
211
+ {
212
+ return $this->web_url;
213
+ }
214
+
215
+ /**
216
+ * Sets Links
217
+ *
218
+ * @param \PayPal\Api\Links[] $links
219
+ *
220
+ * @return $this
221
+ */
222
+ public function setLinks($links)
223
+ {
224
+ $this->links = $links;
225
+ return $this;
226
+ }
227
+
228
+ /**
229
+ * Gets Links
230
+ *
231
+ * @return \PayPal\Api\Links[]
232
+ */
233
+ public function getLinks()
234
+ {
235
+ return $this->links;
236
+ }
237
+
238
+ /**
239
+ * Append Links to the list.
240
+ *
241
+ * @param \PayPal\Api\Links $links
242
+ * @return $this
243
+ */
244
+ public function addLink($links)
245
+ {
246
+ if (!$this->getLinks()) {
247
+ return $this->setLinks(array($links));
248
+ } else {
249
+ return $this->setLinks(
250
+ array_merge($this->getLinks(), array($links))
251
+ );
252
+ }
253
+ }
254
+
255
+ /**
256
+ * Remove Links from the list.
257
+ *
258
+ * @param \PayPal\Api\Links $links
259
+ * @return $this
260
+ */
261
+ public function removeLink($links)
262
+ {
263
+ return $this->setLinks(
264
+ array_diff($this->getLinks(), array($links))
265
+ );
266
+ }
267
+
268
+ }
lib/PayPal/Api/CustomAmount.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class CustomAmount
9
+ *
10
+ * Custom amount applied on an invoice. If a label is included then the amount cannot be empty.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string label
15
+ * @property \PayPal\Api\Currency amount
16
+ */
17
+ class CustomAmount extends PayPalModel
18
+ {
19
+ /**
20
+ * Custom amount label. 25 characters max.
21
+ *
22
+ * @param string $label
23
+ *
24
+ * @return $this
25
+ */
26
+ public function setLabel($label)
27
+ {
28
+ $this->label = $label;
29
+ return $this;
30
+ }
31
+
32
+ /**
33
+ * Custom amount label. 25 characters max.
34
+ *
35
+ * @return string
36
+ */
37
+ public function getLabel()
38
+ {
39
+ return $this->label;
40
+ }
41
+
42
+ /**
43
+ * Custom amount value. Range of 0 to 999999.99.
44
+ *
45
+ * @param \PayPal\Api\Currency $amount
46
+ *
47
+ * @return $this
48
+ */
49
+ public function setAmount($amount)
50
+ {
51
+ $this->amount = $amount;
52
+ return $this;
53
+ }
54
+
55
+ /**
56
+ * Custom amount value. Range of 0 to 999999.99.
57
+ *
58
+ * @return \PayPal\Api\Currency
59
+ */
60
+ public function getAmount()
61
+ {
62
+ return $this->amount;
63
+ }
64
+
65
+ }
lib/PayPal/Api/Details.php ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+ use PayPal\Converter\FormatConverter;
7
+ use PayPal\Validation\NumericValidator;
8
+
9
+ /**
10
+ * Class Details
11
+ *
12
+ * Additional details of the payment amount.
13
+ *
14
+ * @package PayPal\Api
15
+ *
16
+ * @property string subtotal
17
+ * @property string shipping
18
+ * @property string tax
19
+ * @property string handling_fee
20
+ * @property string shipping_discount
21
+ * @property string insurance
22
+ * @property string gift_wrap
23
+ * @property string fee
24
+ */
25
+ class Details extends PayPalModel
26
+ {
27
+ /**
28
+ * Amount of the subtotal of the items. **Required** if line items are specified. 10 characters max, with support for 2 decimal places.
29
+ *
30
+ * @param string|double $subtotal
31
+ *
32
+ * @return $this
33
+ */
34
+ public function setSubtotal($subtotal)
35
+ {
36
+ NumericValidator::validate($subtotal, "Subtotal");
37
+ $subtotal = FormatConverter::formatToPrice($subtotal);
38
+ $this->subtotal = $subtotal;
39
+ return $this;
40
+ }
41
+
42
+ /**
43
+ * Amount of the subtotal of the items. **Required** if line items are specified. 10 characters max, with support for 2 decimal places.
44
+ *
45
+ * @return string
46
+ */
47
+ public function getSubtotal()
48
+ {
49
+ return $this->subtotal;
50
+ }
51
+
52
+ /**
53
+ * Amount charged for shipping. 10 characters max with support for 2 decimal places.
54
+ *
55
+ * @param string|double $shipping
56
+ *
57
+ * @return $this
58
+ */
59
+ public function setShipping($shipping)
60
+ {
61
+ NumericValidator::validate($shipping, "Shipping");
62
+ $shipping = FormatConverter::formatToPrice($shipping);
63
+ $this->shipping = $shipping;
64
+ return $this;
65
+ }
66
+
67
+ /**
68
+ * Amount charged for shipping. 10 characters max with support for 2 decimal places.
69
+ *
70
+ * @return string
71
+ */
72
+ public function getShipping()
73
+ {
74
+ return $this->shipping;
75
+ }
76
+
77
+ /**
78
+ * Amount charged for tax. 10 characters max with support for 2 decimal places.
79
+ *
80
+ * @param string|double $tax
81
+ *
82
+ * @return $this
83
+ */
84
+ public function setTax($tax)
85
+ {
86
+ NumericValidator::validate($tax, "Tax");
87
+ $tax = FormatConverter::formatToPrice($tax);
88
+ $this->tax = $tax;
89
+ return $this;
90
+ }
91
+
92
+ /**
93
+ * Amount charged for tax. 10 characters max with support for 2 decimal places.
94
+ *
95
+ * @return string
96
+ */
97
+ public function getTax()
98
+ {
99
+ return $this->tax;
100
+ }
101
+
102
+ /**
103
+ * Amount being charged for the handling fee. Only supported when the `payment_method` is set to `paypal`.
104
+ *
105
+ * @param string|double $handling_fee
106
+ *
107
+ * @return $this
108
+ */
109
+ public function setHandlingFee($handling_fee)
110
+ {
111
+ NumericValidator::validate($handling_fee, "Handling Fee");
112
+ $handling_fee = FormatConverter::formatToPrice($handling_fee);
113
+ $this->handling_fee = $handling_fee;
114
+ return $this;
115
+ }
116
+
117
+ /**
118
+ * Amount being charged for the handling fee. Only supported when the `payment_method` is set to `paypal`.
119
+ *
120
+ * @return string
121
+ */
122
+ public function getHandlingFee()
123
+ {
124
+ return $this->handling_fee;
125
+ }
126
+
127
+ /**
128
+ * Amount being discounted for the shipping fee. Only supported when the `payment_method` is set to `paypal`.
129
+ *
130
+ * @param string|double $shipping_discount
131
+ *
132
+ * @return $this
133
+ */
134
+ public function setShippingDiscount($shipping_discount)
135
+ {
136
+ NumericValidator::validate($shipping_discount, "Shipping Discount");
137
+ $shipping_discount = FormatConverter::formatToPrice($shipping_discount);
138
+ $this->shipping_discount = $shipping_discount;
139
+ return $this;
140
+ }
141
+
142
+ /**
143
+ * Amount being discounted for the shipping fee. Only supported when the `payment_method` is set to `paypal`.
144
+ *
145
+ * @return string
146
+ */
147
+ public function getShippingDiscount()
148
+ {
149
+ return $this->shipping_discount;
150
+ }
151
+
152
+ /**
153
+ * Amount being charged for the insurance fee. Only supported when the `payment_method` is set to `paypal`.
154
+ *
155
+ * @param string|double $insurance
156
+ *
157
+ * @return $this
158
+ */
159
+ public function setInsurance($insurance)
160
+ {
161
+ NumericValidator::validate($insurance, "Insurance");
162
+ $insurance = FormatConverter::formatToPrice($insurance);
163
+ $this->insurance = $insurance;
164
+ return $this;
165
+ }
166
+
167
+ /**
168
+ * Amount being charged for the insurance fee. Only supported when the `payment_method` is set to `paypal`.
169
+ *
170
+ * @return string
171
+ */
172
+ public function getInsurance()
173
+ {
174
+ return $this->insurance;
175
+ }
176
+
177
+ /**
178
+ * Amount being charged as gift wrap fee.
179
+ *
180
+ * @param string|double $gift_wrap
181
+ *
182
+ * @return $this
183
+ */
184
+ public function setGiftWrap($gift_wrap)
185
+ {
186
+ NumericValidator::validate($gift_wrap, "Gift Wrap");
187
+ $gift_wrap = FormatConverter::formatToPrice($gift_wrap);
188
+ $this->gift_wrap = $gift_wrap;
189
+ return $this;
190
+ }
191
+
192
+ /**
193
+ * Amount being charged as gift wrap fee.
194
+ *
195
+ * @return string
196
+ */
197
+ public function getGiftWrap()
198
+ {
199
+ return $this->gift_wrap;
200
+ }
201
+
202
+ /**
203
+ * Fee charged by PayPal. In case of a refund, this is the fee amount refunded to the original receipient of the payment.
204
+ *
205
+ * @param string|double $fee
206
+ *
207
+ * @return $this
208
+ */
209
+ public function setFee($fee)
210
+ {
211
+ NumericValidator::validate($fee, "Fee");
212
+ $fee = FormatConverter::formatToPrice($fee);
213
+ $this->fee = $fee;
214
+ return $this;
215
+ }
216
+
217
+ /**
218
+ * Fee charged by PayPal. In case of a refund, this is the fee amount refunded to the original receipient of the payment.
219
+ *
220
+ * @return string
221
+ */
222
+ public function getFee()
223
+ {
224
+ return $this->fee;
225
+ }
226
+
227
+ }
lib/PayPal/Api/Error.php ADDED
@@ -0,0 +1,321 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class Error
9
+ *
10
+ * Details of an Error
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string name
15
+ * @property string message
16
+ * @property \PayPal\Api\ErrorDetails[] details
17
+ * @property string information_link
18
+ * @property string debug_id
19
+ * @property \PayPal\Api\Links[] links
20
+ */
21
+ class Error extends PayPalModel
22
+ {
23
+ /**
24
+ * Human readable, unique name of the error.
25
+ *
26
+ * @param string $name
27
+ *
28
+ * @return $this
29
+ */
30
+ public function setName($name)
31
+ {
32
+ $this->name = $name;
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * Human readable, unique name of the error.
38
+ *
39
+ * @return string
40
+ */
41
+ public function getName()
42
+ {
43
+ return $this->name;
44
+ }
45
+
46
+ /**
47
+ * Reference ID of the purchase_unit associated with this error
48
+ *
49
+ * @deprecated Not publicly available
50
+ * @param string $purchase_unit_reference_id
51
+ *
52
+ * @return $this
53
+ */
54
+ public function setPurchaseUnitReferenceId($purchase_unit_reference_id)
55
+ {
56
+ $this->purchase_unit_reference_id = $purchase_unit_reference_id;
57
+ return $this;
58
+ }
59
+
60
+ /**
61
+ * Reference ID of the purchase_unit associated with this error
62
+ *
63
+ * @deprecated Not publicly available
64
+ * @return string
65
+ */
66
+ public function getPurchaseUnitReferenceId()
67
+ {
68
+ return $this->purchase_unit_reference_id;
69
+ }
70
+
71
+ /**
72
+ * Message describing the error.
73
+ *
74
+ * @param string $message
75
+ *
76
+ * @return $this
77
+ */
78
+ public function setMessage($message)
79
+ {
80
+ $this->message = $message;
81
+ return $this;
82
+ }
83
+
84
+ /**
85
+ * Message describing the error.
86
+ *
87
+ * @return string
88
+ */
89
+ public function getMessage()
90
+ {
91
+ return $this->message;
92
+ }
93
+
94
+ /**
95
+ * PayPal internal error code.
96
+ *
97
+ * @deprecated Not publicly available
98
+ * @param string $code
99
+ *
100
+ * @return $this
101
+ */
102
+ public function setCode($code)
103
+ {
104
+ $this->code = $code;
105
+ return $this;
106
+ }
107
+
108
+ /**
109
+ * PayPal internal error code.
110
+ *
111
+ * @deprecated Not publicly available
112
+ * @return string
113
+ */
114
+ public function getCode()
115
+ {
116
+ return $this->code;
117
+ }
118
+
119
+ /**
120
+ * Additional details of the error
121
+ *
122
+ * @param \PayPal\Api\ErrorDetails[] $details
123
+ *
124
+ * @return $this
125
+ */
126
+ public function setDetails($details)
127
+ {
128
+ $this->details = $details;
129
+ return $this;
130
+ }
131
+
132
+ /**
133
+ * Additional details of the error
134
+ *
135
+ * @return \PayPal\Api\ErrorDetails[]
136
+ */
137
+ public function getDetails()
138
+ {
139
+ return $this->details;
140
+ }
141
+
142
+ /**
143
+ * Append Details to the list.
144
+ *
145
+ * @param \PayPal\Api\ErrorDetails $errorDetails
146
+ * @return $this
147
+ */
148
+ public function addDetail($errorDetails)
149
+ {
150
+ if (!$this->getDetails()) {
151
+ return $this->setDetails(array($errorDetails));
152
+ } else {
153
+ return $this->setDetails(
154
+ array_merge($this->getDetails(), array($errorDetails))
155
+ );
156
+ }
157
+ }
158
+
159
+ /**
160
+ * Remove Details from the list.
161
+ *
162
+ * @param \PayPal\Api\ErrorDetails $errorDetails
163
+ * @return $this
164
+ */
165
+ public function removeDetail($errorDetails)
166
+ {
167
+ return $this->setDetails(
168
+ array_diff($this->getDetails(), array($errorDetails))
169
+ );
170
+ }
171
+
172
+ /**
173
+ * response codes returned from a payment processor such as avs, cvv, etc. Only supported when the `payment_method` is set to `credit_card`.
174
+ *
175
+ * @deprecated Not publicly available
176
+ * @param \PayPal\Api\ProcessorResponse $processor_response
177
+ *
178
+ * @return $this
179
+ */
180
+ public function setProcessorResponse($processor_response)
181
+ {
182
+ $this->processor_response = $processor_response;
183
+ return $this;
184
+ }
185
+
186
+ /**
187
+ * response codes returned from a payment processor such as avs, cvv, etc. Only supported when the `payment_method` is set to `credit_card`.
188
+ *
189
+ * @deprecated Not publicly available
190
+ * @return \PayPal\Api\ProcessorResponse
191
+ */
192
+ public function getProcessorResponse()
193
+ {
194
+ return $this->processor_response;
195
+ }
196
+
197
+ /**
198
+ * Fraud filter details. Only supported when the `payment_method` is set to `credit_card`
199
+ *
200
+ * @deprecated Not publicly available
201
+ * @param \PayPal\Api\FmfDetails $fmf_details
202
+ *
203
+ * @return $this
204
+ */
205
+ public function setFmfDetails($fmf_details)
206
+ {
207
+ $this->fmf_details = $fmf_details;
208
+ return $this;
209
+ }
210
+
211
+ /**
212
+ * Fraud filter details. Only supported when the `payment_method` is set to `credit_card`
213
+ *
214
+ * @deprecated Not publicly available
215
+ * @return \PayPal\Api\FmfDetails
216
+ */
217
+ public function getFmfDetails()
218
+ {
219
+ return $this->fmf_details;
220
+ }
221
+
222
+ /**
223
+ * URI for detailed information related to this error for the developer.
224
+ *
225
+ * @param string $information_link
226
+ *
227
+ * @return $this
228
+ */
229
+ public function setInformationLink($information_link)
230
+ {
231
+ $this->information_link = $information_link;
232
+ return $this;
233
+ }
234
+
235
+ /**
236
+ * URI for detailed information related to this error for the developer.
237
+ *
238
+ * @return string
239
+ */
240
+ public function getInformationLink()
241
+ {
242
+ return $this->information_link;
243
+ }
244
+
245
+ /**
246
+ * PayPal internal identifier used for correlation purposes.
247
+ *
248
+ * @param string $debug_id
249
+ *
250
+ * @return $this
251
+ */
252
+ public function setDebugId($debug_id)
253
+ {
254
+ $this->debug_id = $debug_id;
255
+ return $this;
256
+ }
257
+
258
+ /**
259
+ * PayPal internal identifier used for correlation purposes.
260
+ *
261
+ * @return string
262
+ */
263
+ public function getDebugId()
264
+ {
265
+ return $this->debug_id;
266
+ }
267
+
268
+ /**
269
+ * Sets Links
270
+ *
271
+ * @param \PayPal\Api\Links[] $links
272
+ *
273
+ * @return $this
274
+ */
275
+ public function setLinks($links)
276
+ {
277
+ $this->links = $links;
278
+ return $this;
279
+ }
280
+
281
+ /**
282
+ * Gets Links
283
+ *
284
+ * @return \PayPal\Api\Links[]
285
+ */
286
+ public function getLinks()
287
+ {
288
+ return $this->links;
289
+ }
290
+
291
+ /**
292
+ * Append Links to the list.
293
+ *
294
+ * @param \PayPal\Api\Links $links
295
+ * @return $this
296
+ */
297
+ public function addLink($links)
298
+ {
299
+ if (!$this->getLinks()) {
300
+ return $this->setLinks(array($links));
301
+ } else {
302
+ return $this->setLinks(
303
+ array_merge($this->getLinks(), array($links))
304
+ );
305
+ }
306
+ }
307
+
308
+ /**
309
+ * Remove Links from the list.
310
+ *
311
+ * @param \PayPal\Api\Links $links
312
+ * @return $this
313
+ */
314
+ public function removeLink($links)
315
+ {
316
+ return $this->setLinks(
317
+ array_diff($this->getLinks(), array($links))
318
+ );
319
+ }
320
+
321
+ }
lib/PayPal/Api/ErrorDetails.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class ErrorDetails
9
+ *
10
+ * Details about a specific error.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string field
15
+ * @property string issue
16
+ */
17
+ class ErrorDetails extends PayPalModel
18
+ {
19
+ /**
20
+ * Name of the field that caused the error.
21
+ *
22
+ * @param string $field
23
+ *
24
+ * @return $this
25
+ */
26
+ public function setField($field)
27
+ {
28
+ $this->field = $field;
29
+ return $this;
30
+ }
31
+
32
+ /**
33
+ * Name of the field that caused the error.
34
+ *
35
+ * @return string
36
+ */
37
+ public function getField()
38
+ {
39
+ return $this->field;
40
+ }
41
+
42
+ /**
43
+ * Reason for the error.
44
+ *
45
+ * @param string $issue
46
+ *
47
+ * @return $this
48
+ */
49
+ public function setIssue($issue)
50
+ {
51
+ $this->issue = $issue;
52
+ return $this;
53
+ }
54
+
55
+ /**
56
+ * Reason for the error.
57
+ *
58
+ * @return string
59
+ */
60
+ public function getIssue()
61
+ {
62
+ return $this->issue;
63
+ }
64
+
65
+ /**
66
+ * Reference ID of the purchase_unit associated with this error
67
+ *
68
+ * @deprecated Not publicly available
69
+ * @param string $purchase_unit_reference_id
70
+ *
71
+ * @return $this
72
+ */
73
+ public function setPurchaseUnitReferenceId($purchase_unit_reference_id)
74
+ {
75
+ $this->purchase_unit_reference_id = $purchase_unit_reference_id;
76
+ return $this;
77
+ }
78
+
79
+ /**
80
+ * Reference ID of the purchase_unit associated with this error
81
+ *
82
+ * @deprecated Not publicly available
83
+ * @return string
84
+ */
85
+ public function getPurchaseUnitReferenceId()
86
+ {
87
+ return $this->purchase_unit_reference_id;
88
+ }
89
+
90
+ /**
91
+ * PayPal internal error code.
92
+ *
93
+ * @deprecated Not publicly available
94
+ * @param string $code
95
+ *
96
+ * @return $this
97
+ */
98
+ public function setCode($code)
99
+ {
100
+ $this->code = $code;
101
+ return $this;
102
+ }
103
+
104
+ /**
105
+ * PayPal internal error code.
106
+ *
107
+ * @deprecated Not publicly available
108
+ * @return string
109
+ */
110
+ public function getCode()
111
+ {
112
+ return $this->code;
113
+ }
114
+
115
+ }
lib/PayPal/Api/ExtendedBankAccount.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ /**
6
+ * Class ExtendedBankAccount
7
+ *
8
+ * A resource representing a bank account that can be used to fund a payment including support for SEPA.
9
+ *
10
+ * @package PayPal\Api
11
+ *
12
+ */
13
+ class ExtendedBankAccount extends BankAccount
14
+ {
15
+ /**
16
+ * Identifier of the direct debit mandate to validate. Currently supported only for EU bank accounts(SEPA).
17
+ *
18
+ * @deprecated Not publicly available
19
+ * @param string $mandate_reference_number
20
+ *
21
+ * @return $this
22
+ */
23
+ public function setMandateReferenceNumber($mandate_reference_number)
24
+ {
25
+ $this->mandate_reference_number = $mandate_reference_number;
26
+ return $this;
27
+ }
28
+
29
+ /**
30
+ * Identifier of the direct debit mandate to validate. Currently supported only for EU bank accounts(SEPA).
31
+ *
32
+ * @deprecated Not publicly available
33
+ * @return string
34
+ */
35
+ public function getMandateReferenceNumber()
36
+ {
37
+ return $this->mandate_reference_number;
38
+ }
39
+
40
+ }
lib/PayPal/Api/ExternalFunding.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class ExternalFunding
9
+ *
10
+ * A resource representing an external funding object.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string reference_id
15
+ * @property string code
16
+ * @property string funding_account_id
17
+ * @property string display_text
18
+ * @property \PayPal\Api\Amount amount
19
+ */
20
+ class ExternalFunding extends PayPalModel
21
+ {
22
+ /**
23
+ * Unique identifier for the external funding
24
+ *
25
+ * @param string $reference_id
26
+ *
27
+ * @return $this
28
+ */
29
+ public function setReferenceId($reference_id)
30
+ {
31
+ $this->reference_id = $reference_id;
32
+ return $this;
33
+ }
34
+
35
+ /**
36
+ * Unique identifier for the external funding
37
+ *
38
+ * @return string
39
+ */
40
+ public function getReferenceId()
41
+ {
42
+ return $this->reference_id;
43
+ }
44
+
45
+ /**
46
+ * Generic identifier for the external funding
47
+ *
48
+ * @param string $code
49
+ *
50
+ * @return $this
51
+ */
52
+ public function setCode($code)
53
+ {
54
+ $this->code = $code;
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * Generic identifier for the external funding
60
+ *
61
+ * @return string
62
+ */
63
+ public function getCode()
64
+ {
65
+ return $this->code;
66
+ }
67
+
68
+ /**
69
+ * Encrypted PayPal Account identifier for the funding account
70
+ *
71
+ * @param string $funding_account_id
72
+ *
73
+ * @return $this
74
+ */
75
+ public function setFundingAccountId($funding_account_id)
76
+ {
77
+ $this->funding_account_id = $funding_account_id;
78
+ return $this;
79
+ }
80
+
81
+ /**
82
+ * Encrypted PayPal Account identifier for the funding account
83
+ *
84
+ * @return string
85
+ */
86
+ public function getFundingAccountId()
87
+ {
88
+ return $this->funding_account_id;
89
+ }
90
+
91
+ /**
92
+ * Description of the external funding being applied
93
+ *
94
+ * @param string $display_text
95
+ *
96
+ * @return $this
97
+ */
98
+ public function setDisplayText($display_text)
99
+ {
100
+ $this->display_text = $display_text;
101
+ return $this;
102
+ }
103
+
104
+ /**
105
+ * Description of the external funding being applied
106
+ *
107
+ * @return string
108
+ */
109
+ public function getDisplayText()
110
+ {
111
+ return $this->display_text;
112
+ }
113
+
114
+ /**
115
+ * Amount being funded by the external funding account
116
+ *
117
+ * @param \PayPal\Api\Amount $amount
118
+ *
119
+ * @return $this
120
+ */
121
+ public function setAmount($amount)
122
+ {
123
+ $this->amount = $amount;
124
+ return $this;
125
+ }
126
+
127
+ /**
128
+ * Amount being funded by the external funding account
129
+ *
130
+ * @return \PayPal\Api\Amount
131
+ */
132
+ public function getAmount()
133
+ {
134
+ return $this->amount;
135
+ }
136
+
137
+ }
lib/PayPal/Api/FlowConfig.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+ use PayPal\Validation\UrlValidator;
7
+
8
+ /**
9
+ * Class FlowConfig
10
+ *
11
+ * Parameters for flow configuration.
12
+ *
13
+ * @package PayPal\Api
14
+ *
15
+ * @property string landing_page_type
16
+ * @property string bank_txn_pending_url
17
+ */
18
+ class FlowConfig extends PayPalModel
19
+ {
20
+ /**
21
+ * Type of PayPal page to be displayed when a user lands on the PayPal site for checkout. Allowed values: `Billing` or `Login`. When set to `Billing`, the Non-PayPal account landing page is used. When set to `Login`, the PayPal account login landing page is used.
22
+ *
23
+ *
24
+ * @param string $landing_page_type
25
+ *
26
+ * @return $this
27
+ */
28
+ public function setLandingPageType($landing_page_type)
29
+ {
30
+ $this->landing_page_type = $landing_page_type;
31
+ return $this;
32
+ }
33
+
34
+ /**
35
+ * Type of PayPal page to be displayed when a user lands on the PayPal site for checkout. Allowed values: `Billing` or `Login`. When set to `Billing`, the Non-PayPal account landing page is used. When set to `Login`, the PayPal account login landing page is used.
36
+ *
37
+ * @return string
38
+ */
39
+ public function getLandingPageType()
40
+ {
41
+ return $this->landing_page_type;
42
+ }
43
+
44
+ /**
45
+ * The URL on the merchant site for transferring to after a bank transfer payment.
46
+ *
47
+ *
48
+ * @param string $bank_txn_pending_url
49
+ * @throws \InvalidArgumentException
50
+ * @return $this
51
+ */
52
+ public function setBankTxnPendingUrl($bank_txn_pending_url)
53
+ {
54
+ UrlValidator::validate($bank_txn_pending_url, "BankTxnPendingUrl");
55
+ $this->bank_txn_pending_url = $bank_txn_pending_url;
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * The URL on the merchant site for transferring to after a bank transfer payment.
61
+ *
62
+ * @return string
63
+ */
64
+ public function getBankTxnPendingUrl()
65
+ {
66
+ return $this->bank_txn_pending_url;
67
+ }
68
+
69
+ }
lib/PayPal/Api/FmfDetails.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class FmfDetails
9
+ *
10
+ * Details of Fraud Management Filter (FMF).
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string filter_type
15
+ * @property string filter_id
16
+ * @property string name
17
+ * @property string description
18
+ */
19
+ class FmfDetails extends PayPalModel
20
+ {
21
+ /**
22
+ * Type of filter.
23
+ * Valid Values: ["ACCEPT", "PENDING", "DENY", "REPORT"]
24
+ *
25
+ * @param string $filter_type
26
+ *
27
+ * @return $this
28
+ */
29
+ public function setFilterType($filter_type)
30
+ {
31
+ $this->filter_type = $filter_type;
32
+ return $this;
33
+ }
34
+
35
+ /**
36
+ * Type of filter.
37
+ *
38
+ * @return string
39
+ */
40
+ public function getFilterType()
41
+ {
42
+ return $this->filter_type;
43
+ }
44
+
45
+ /**
46
+ * Filter Identifier.
47
+ * Valid Values: ["AVS_NO_MATCH", "AVS_PARTIAL_MATCH", "AVS_UNAVAILABLE_OR_UNSUPPORTED", "CARD_SECURITY_CODE_MISMATCH", "MAXIMUM_TRANSACTION_AMOUNT", "UNCONFIRMED_ADDRESS", "COUNTRY_MONITOR", "LARGE_ORDER_NUMBER", "BILLING_OR_SHIPPING_ADDRESS_MISMATCH", "RISKY_ZIP_CODE", "SUSPECTED_FREIGHT_FORWARDER_CHECK", "TOTAL_PURCHASE_PRICE_MINIMUM", "IP_ADDRESS_VELOCITY", "RISKY_EMAIL_ADDRESS_DOMAIN_CHECK", "RISKY_BANK_IDENTIFICATION_NUMBER_CHECK", "RISKY_IP_ADDRESS_RANGE", "PAYPAL_FRAUD_MODEL"]
48
+ *
49
+ * @param string $filter_id
50
+ *
51
+ * @return $this
52
+ */
53
+ public function setFilterId($filter_id)
54
+ {
55
+ $this->filter_id = $filter_id;
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * Filter Identifier.
61
+ *
62
+ * @return string
63
+ */
64
+ public function getFilterId()
65
+ {
66
+ return $this->filter_id;
67
+ }
68
+
69
+ /**
70
+ * Name of the filter
71
+ *
72
+ * @param string $name
73
+ *
74
+ * @return $this
75
+ */
76
+ public function setName($name)
77
+ {
78
+ $this->name = $name;
79
+ return $this;
80
+ }
81
+
82
+ /**
83
+ * Name of the filter
84
+ *
85
+ * @return string
86
+ */
87
+ public function getName()
88
+ {
89
+ return $this->name;
90
+ }
91
+
92
+ /**
93
+ * Description of the filter.
94
+ *
95
+ * @param string $description
96
+ *
97
+ * @return $this
98
+ */
99
+ public function setDescription($description)
100
+ {
101
+ $this->description = $description;
102
+ return $this;
103
+ }
104
+
105
+ /**
106
+ * Description of the filter.
107
+ *
108
+ * @return string
109
+ */
110
+ public function getDescription()
111
+ {
112
+ return $this->description;
113
+ }
114
+
115
+ }
lib/PayPal/Api/FundingDetail.php ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class FundingDetail
9
+ *
10
+ * Additional detail of the funding.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string clearing_time
15
+ * @property string payment_hold_date
16
+ * @property string payment_debit_date
17
+ * @property string processing_type
18
+ */
19
+ class FundingDetail extends PayPalModel
20
+ {
21
+ /**
22
+ * Expected clearing time
23
+ *
24
+ * @param string $clearing_time
25
+ *
26
+ * @return $this
27
+ */
28
+ public function setClearingTime($clearing_time)
29
+ {
30
+ $this->clearing_time = $clearing_time;
31
+ return $this;
32
+ }
33
+
34
+ /**
35
+ * Expected clearing time
36
+ *
37
+ * @return string
38
+ */
39
+ public function getClearingTime()
40
+ {
41
+ return $this->clearing_time;
42
+ }
43
+
44
+ /**
45
+ * [DEPRECATED] Hold-off duration of the payment. payment_debit_date should be used instead.
46
+ *
47
+ * @param string $payment_hold_date
48
+ *
49
+ * @return $this
50
+ */
51
+ public function setPaymentHoldDate($payment_hold_date)
52
+ {
53
+ $this->payment_hold_date = $payment_hold_date;
54
+ return $this;
55
+ }
56
+
57
+ /**
58
+ * @deprecated [DEPRECATED] Hold-off duration of the payment. payment_debit_date should be used instead.
59
+ *
60
+ * @return string
61
+ */
62
+ public function getPaymentHoldDate()
63
+ {
64
+ return $this->payment_hold_date;
65
+ }
66
+
67
+ /**
68
+ * Date when funds will be debited from the payer's account
69
+ *
70
+ * @param string $payment_debit_date
71
+ *
72
+ * @return $this
73
+ */
74
+ public function setPaymentDebitDate($payment_debit_date)
75
+ {
76
+ $this->payment_debit_date = $payment_debit_date;
77
+ return $this;
78
+ }
79
+
80
+ /**
81
+ * Date when funds will be debited from the payer's account
82
+ *
83
+ * @return string
84
+ */
85
+ public function getPaymentDebitDate()
86
+ {
87
+ return $this->payment_debit_date;
88
+ }
89
+
90
+ /**
91
+ * Processing type of the payment card
92
+ * Valid Values: ["PINLESS_DEBIT"]
93
+ *
94
+ * @param string $processing_type
95
+ *
96
+ * @return $this
97
+ */
98
+ public function setProcessingType($processing_type)
99
+ {
100
+ $this->processing_type = $processing_type;
101
+ return $this;
102
+ }
103
+
104
+ /**
105
+ * Processing type of the payment card
106
+ *
107
+ * @return string
108
+ */
109
+ public function getProcessingType()
110
+ {
111
+ return $this->processing_type;
112
+ }
113
+
114
+ }
lib/PayPal/Api/FundingInstrument.php ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class FundingInstrument
9
+ *
10
+ * A resource representing a Payer's funding instrument. An instance of this schema is valid if and only if it is valid against exactly one of these supported properties
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property \PayPal\Api\CreditCard credit_card
15
+ * @property \PayPal\Api\CreditCardToken credit_card_token
16
+ * @property \PayPal\Api\Billing billing
17
+ */
18
+ class FundingInstrument extends PayPalModel
19
+ {
20
+ /**
21
+ * Credit Card instrument.
22
+ *
23
+ * @param \PayPal\Api\CreditCard $credit_card
24
+ *
25
+ * @return $this
26
+ */
27
+ public function setCreditCard($credit_card)
28
+ {
29
+ $this->credit_card = $credit_card;
30
+ return $this;
31
+ }
32
+
33
+ /**
34
+ * Credit Card instrument.
35
+ *
36
+ * @return \PayPal\Api\CreditCard
37
+ */
38
+ public function getCreditCard()
39
+ {
40
+ return $this->credit_card;
41
+ }
42
+
43
+ /**
44
+ * PayPal vaulted credit Card instrument.
45
+ *
46
+ * @param \PayPal\Api\CreditCardToken $credit_card_token
47
+ *
48
+ * @return $this
49
+ */
50
+ public function setCreditCardToken($credit_card_token)
51
+ {
52
+ $this->credit_card_token = $credit_card_token;
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * PayPal vaulted credit Card instrument.
58
+ *
59
+ * @return \PayPal\Api\CreditCardToken
60
+ */
61
+ public function getCreditCardToken()
62
+ {
63
+ return $this->credit_card_token;
64
+ }
65
+
66
+ /**
67
+ * Payment Card information.
68
+ *
69
+ * @deprecated Not publicly available
70
+ * @param \PayPal\Api\PaymentCard $payment_card
71
+ *
72
+ * @return $this
73
+ */
74
+ public function setPaymentCard($payment_card)
75
+ {
76
+ $this->payment_card = $payment_card;
77
+ return $this;
78
+ }
79
+
80
+ /**
81
+ * Payment Card information.
82
+ *
83
+ * @deprecated Not publicly available
84
+ * @return \PayPal\Api\PaymentCard
85
+ */
86
+ public function getPaymentCard()
87
+ {
88
+ return $this->payment_card;
89
+ }
90
+
91
+ /**
92
+ * Bank Account information.
93
+ *
94
+ * @deprecated Not publicly available
95
+ * @param \PayPal\Api\ExtendedBankAccount $bank_account
96
+ *
97
+ * @return $this
98
+ */
99
+ public function setBankAccount($bank_account)
100
+ {
101
+ $this->bank_account = $bank_account;
102
+ return $this;
103
+ }
104
+
105
+ /**
106
+ * Bank Account information.
107
+ *
108
+ * @deprecated Not publicly available
109
+ * @return \PayPal\Api\ExtendedBankAccount
110
+ */
111
+ public function getBankAccount()
112
+ {
113
+ return $this->bank_account;
114
+ }
115
+
116
+ /**
117
+ * Vaulted bank account instrument.
118
+ *
119
+ * @deprecated Not publicly available
120
+ * @param \PayPal\Api\BankToken $bank_account_token
121
+ *
122
+ * @return $this
123
+ */
124
+ public function setBankAccountToken($bank_account_token)
125
+ {
126
+ $this->bank_account_token = $bank_account_token;
127
+ return $this;
128
+ }
129
+
130
+ /**
131
+ * Vaulted bank account instrument.
132
+ *
133
+ * @deprecated Not publicly available
134
+ * @return \PayPal\Api\BankToken
135
+ */
136
+ public function getBankAccountToken()
137
+ {
138
+ return $this->bank_account_token;
139
+ }
140
+
141
+ /**
142
+ * PayPal credit funding instrument.
143
+ *
144
+ * @deprecated Not publicly available
145
+ * @param \PayPal\Api\Credit $credit
146
+ *
147
+ * @return $this
148
+ */
149
+ public function setCredit($credit)
150
+ {
151
+ $this->credit = $credit;
152
+ return $this;
153
+ }
154
+
155
+ /**
156
+ * PayPal credit funding instrument.
157
+ *
158
+ * @deprecated Not publicly available
159
+ * @return \PayPal\Api\Credit
160
+ */
161
+ public function getCredit()
162
+ {
163
+ return $this->credit;
164
+ }
165
+
166
+ /**
167
+ * Incentive funding instrument.
168
+ *
169
+ * @deprecated Not publicly available
170
+ * @param \PayPal\Api\Incentive $incentive
171
+ *
172
+ * @return $this
173
+ */
174
+ public function setIncentive($incentive)
175
+ {
176
+ $this->incentive = $incentive;
177
+ return $this;
178
+ }
179
+
180
+ /**
181
+ * Incentive funding instrument.
182
+ *
183
+ * @deprecated Not publicly available
184
+ * @return \PayPal\Api\Incentive
185
+ */
186
+ public function getIncentive()
187
+ {
188
+ return $this->incentive;
189
+ }
190
+
191
+ /**
192
+ * External funding instrument.
193
+ *
194
+ * @deprecated Not publicly available
195
+ * @param \PayPal\Api\ExternalFunding $external_funding
196
+ *
197
+ * @return $this
198
+ */
199
+ public function setExternalFunding($external_funding)
200
+ {
201
+ $this->external_funding = $external_funding;
202
+ return $this;
203
+ }
204
+
205
+ /**
206
+ * External funding instrument.
207
+ *
208
+ * @deprecated Not publicly available
209
+ * @return \PayPal\Api\ExternalFunding
210
+ */
211
+ public function getExternalFunding()
212
+ {
213
+ return $this->external_funding;
214
+ }
215
+
216
+ /**
217
+ * Carrier account token instrument.
218
+ *
219
+ * @deprecated Not publicly available
220
+ * @param \PayPal\Api\CarrierAccountToken $carrier_account_token
221
+ *
222
+ * @return $this
223
+ */
224
+ public function setCarrierAccountToken($carrier_account_token)
225
+ {
226
+ $this->carrier_account_token = $carrier_account_token;
227
+ return $this;
228
+ }
229
+
230
+ /**
231
+ * Carrier account token instrument.
232
+ *
233
+ * @deprecated Not publicly available
234
+ * @return \PayPal\Api\CarrierAccountToken
235
+ */
236
+ public function getCarrierAccountToken()
237
+ {
238
+ return $this->carrier_account_token;
239
+ }
240
+
241
+ /**
242
+ * Carrier account instrument
243
+ *
244
+ * @deprecated Not publicly available
245
+ * @param \PayPal\Api\CarrierAccount $carrier_account
246
+ *
247
+ * @return $this
248
+ */
249
+ public function setCarrierAccount($carrier_account)
250
+ {
251
+ $this->carrier_account = $carrier_account;
252
+ return $this;
253
+ }
254
+
255
+ /**
256
+ * Carrier account instrument
257
+ *
258
+ * @deprecated Not publicly available
259
+ * @return \PayPal\Api\CarrierAccount
260
+ */
261
+ public function getCarrierAccount()
262
+ {
263
+ return $this->carrier_account;
264
+ }
265
+
266
+ /**
267
+ * Private Label Card funding instrument. These are store cards provided by merchants to drive business with value to customer with convenience and rewards.
268
+ *
269
+ * @deprecated Not publicly available
270
+ * @param \PayPal\Api\PrivateLabelCard $private_label_card
271
+ *
272
+ * @return $this
273
+ */
274
+ public function setPrivateLabelCard($private_label_card)
275
+ {
276
+ $this->private_label_card = $private_label_card;
277
+ return $this;
278
+ }
279
+
280
+ /**
281
+ * Private Label Card funding instrument. These are store cards provided by merchants to drive business with value to customer with convenience and rewards.
282
+ *
283
+ * @deprecated Not publicly available
284
+ * @return \PayPal\Api\PrivateLabelCard
285
+ */
286
+ public function getPrivateLabelCard()
287
+ {
288
+ return $this->private_label_card;
289
+ }
290
+
291
+ /**
292
+ * Billing instrument that references pre-approval information for the payment
293
+ *
294
+ * @param \PayPal\Api\Billing $billing
295
+ *
296
+ * @return $this
297
+ */
298
+ public function setBilling($billing)
299
+ {
300
+ $this->billing = $billing;
301
+ return $this;
302
+ }
303
+
304
+ /**
305
+ * Billing instrument that references pre-approval information for the payment
306
+ *
307
+ * @return \PayPal\Api\Billing
308
+ */
309
+ public function getBilling()
310
+ {
311
+ return $this->billing;
312
+ }
313
+
314
+ /**
315
+ * Alternate Payment information - Mostly regional payment providers. For e.g iDEAL in Netherlands
316
+ *
317
+ * @deprecated Not publicly available
318
+ * @param \PayPal\Api\AlternatePayment $alternate_payment
319
+ *
320
+ * @return $this
321
+ */
322
+ public function setAlternatePayment($alternate_payment)
323
+ {
324
+ $this->alternate_payment = $alternate_payment;
325
+ return $this;
326
+ }
327
+
328
+ /**
329
+ * Alternate Payment information - Mostly regional payment providers. For e.g iDEAL in Netherlands
330
+ *
331
+ * @deprecated Not publicly available
332
+ * @return \PayPal\Api\AlternatePayment
333
+ */
334
+ public function getAlternatePayment()
335
+ {
336
+ return $this->alternate_payment;
337
+ }
338
+
339
+ }
lib/PayPal/Api/FundingOption.php ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class FundingOption
9
+ *
10
+ * specifies the funding option details.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string id
15
+ * @property \PayPal\Api\FundingSource[] funding_sources
16
+ * @property \PayPal\Api\FundingInstrument backup_funding_instrument
17
+ * @property \PayPal\Api\CurrencyConversion currency_conversion
18
+ * @property \PayPal\Api\InstallmentInfo installment_info
19
+ * @property \PayPal\Api\Links[] links
20
+ */
21
+ class FundingOption extends PayPalModel
22
+ {
23
+ /**
24
+ * id of the funding option.
25
+ *
26
+ * @param string $id
27
+ *
28
+ * @return $this
29
+ */
30
+ public function setId($id)
31
+ {
32
+ $this->id = $id;
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * id of the funding option.
38
+ *
39
+ * @return string
40
+ */
41
+ public function getId()
42
+ {
43
+ return $this->id;
44
+ }
45
+
46
+ /**
47
+ * List of funding sources that contributes to a payment.
48
+ *
49
+ * @param \PayPal\Api\FundingSource[] $funding_sources
50
+ *
51
+ * @return $this
52
+ */
53
+ public function setFundingSources($funding_sources)
54
+ {
55
+ $this->funding_sources = $funding_sources;
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * List of funding sources that contributes to a payment.
61
+ *
62
+ * @return \PayPal\Api\FundingSource[]
63
+ */
64
+ public function getFundingSources()
65
+ {
66
+ return $this->funding_sources;
67
+ }
68
+
69
+ /**
70
+ * Append FundingSources to the list.
71
+ *
72
+ * @param \PayPal\Api\FundingSource $fundingSource
73
+ * @return $this
74
+ */
75
+ public function addFundingSource($fundingSource)
76
+ {
77
+ if (!$this->getFundingSources()) {
78
+ return $this->setFundingSources(array($fundingSource));
79
+ } else {
80
+ return $this->setFundingSources(
81
+ array_merge($this->getFundingSources(), array($fundingSource))
82
+ );
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Remove FundingSources from the list.
88
+ *
89
+ * @param \PayPal\Api\FundingSource $fundingSource
90
+ * @return $this
91
+ */
92
+ public function removeFundingSource($fundingSource)
93
+ {
94
+ return $this->setFundingSources(
95
+ array_diff($this->getFundingSources(), array($fundingSource))
96
+ );
97
+ }
98
+
99
+ /**
100
+ * Backup funding instrument which will be used for payment if primary fails.
101
+ *
102
+ * @param \PayPal\Api\FundingInstrument $backup_funding_instrument
103
+ *
104
+ * @return $this
105
+ */
106
+ public function setBackupFundingInstrument($backup_funding_instrument)
107
+ {
108
+ $this->backup_funding_instrument = $backup_funding_instrument;
109
+ return $this;
110
+ }
111
+
112
+ /**
113
+ * Backup funding instrument which will be used for payment if primary fails.
114
+ *
115
+ * @return \PayPal\Api\FundingInstrument
116
+ */
117
+ public function getBackupFundingInstrument()
118
+ {
119
+ return $this->backup_funding_instrument;
120
+ }
121
+
122
+ /**
123
+ * Currency conversion applicable to this funding option.
124
+ *
125
+ * @param \PayPal\Api\CurrencyConversion $currency_conversion
126
+ *
127
+ * @return $this
128
+ */
129
+ public function setCurrencyConversion($currency_conversion)
130
+ {
131
+ $this->currency_conversion = $currency_conversion;
132
+ return $this;
133
+ }
134
+
135
+ /**
136
+ * Currency conversion applicable to this funding option.
137
+ *
138
+ * @return \PayPal\Api\CurrencyConversion
139
+ */
140
+ public function getCurrencyConversion()
141
+ {
142
+ return $this->currency_conversion;
143
+ }
144
+
145
+ /**
146
+ * Installment options available for a funding option.
147
+ *
148
+ * @param \PayPal\Api\InstallmentInfo $installment_info
149
+ *
150
+ * @return $this
151
+ */
152
+ public function setInstallmentInfo($installment_info)
153
+ {
154
+ $this->installment_info = $installment_info;
155
+ return $this;
156
+ }
157
+
158
+ /**
159
+ * Installment options available for a funding option.
160
+ *
161
+ * @return \PayPal\Api\InstallmentInfo
162
+ */
163
+ public function getInstallmentInfo()
164
+ {
165
+ return $this->installment_info;
166
+ }
167
+
168
+ /**
169
+ * Sets Links
170
+ *
171
+ * @param \PayPal\Api\Links[] $links
172
+ *
173
+ * @return $this
174
+ */
175
+ public function setLinks($links)
176
+ {
177
+ $this->links = $links;
178
+ return $this;
179
+ }
180
+
181
+ /**
182
+ * Gets Links
183
+ *
184
+ * @return \PayPal\Api\Links[]
185
+ */
186
+ public function getLinks()
187
+ {
188
+ return $this->links;
189
+ }
190
+
191
+ /**
192
+ * Append Links to the list.
193
+ *
194
+ * @param \PayPal\Api\Links $links
195
+ * @return $this
196
+ */
197
+ public function addLink($links)
198
+ {
199
+ if (!$this->getLinks()) {
200
+ return $this->setLinks(array($links));
201
+ } else {
202
+ return $this->setLinks(
203
+ array_merge($this->getLinks(), array($links))
204
+ );
205
+ }
206
+ }
207
+
208
+ /**
209
+ * Remove Links from the list.
210
+ *
211
+ * @param \PayPal\Api\Links $links
212
+ * @return $this
213
+ */
214
+ public function removeLink($links)
215
+ {
216
+ return $this->setLinks(
217
+ array_diff($this->getLinks(), array($links))
218
+ );
219
+ }
220
+
221
+ }
lib/PayPal/Api/FundingSource.php ADDED
@@ -0,0 +1,289 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class FundingSource
9
+ *
10
+ * specifies the funding source details.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string funding_mode
15
+ * @property string funding_instrument_type
16
+ * @property string soft_descriptor
17
+ * @property \PayPal\Api\Currency amount
18
+ * @property \PayPal\Api\Currency negative_balance_amount
19
+ * @property string legal_text
20
+ * @property \PayPal\Api\FundingDetail funding_detail
21
+ * @property string additional_text
22
+ * @property \PayPal\Api\FundingInstrument extends
23
+ * @property \PayPal\Api\Links[] links
24
+ */
25
+ class FundingSource extends PayPalModel
26
+ {
27
+ /**
28
+ * specifies funding mode of the instrument
29
+ * Valid Values: ["INSTANT_TRANSFER", "MANUAL_BANK_TRANSFER", "DELAYED_TRANSFER", "ECHECK"]
30
+ *
31
+ * @param string $funding_mode
32
+ *
33
+ * @return $this
34
+ */
35
+ public function setFundingMode($funding_mode)
36
+ {
37
+ $this->funding_mode = $funding_mode;
38
+ return $this;
39
+ }
40
+
41
+ /**
42
+ * specifies funding mode of the instrument
43
+ *
44
+ * @return string
45
+ */
46
+ public function getFundingMode()
47
+ {
48
+ return $this->funding_mode;
49
+ }
50
+
51
+ /**
52
+ * Instrument type for this funding source
53
+ * Valid Values: ["BALANCE", "PAYMENT_CARD", "BANK_ACCOUNT", "CREDIT", "INCENTIVE"]
54
+ *
55
+ * @param string $funding_instrument_type
56
+ *
57
+ * @return $this
58
+ */
59
+ public function setFundingInstrumentType($funding_instrument_type)
60
+ {
61
+ $this->funding_instrument_type = $funding_instrument_type;
62
+ return $this;
63
+ }
64
+
65
+ /**
66
+ * Instrument type for this funding source
67
+ *
68
+ * @return string
69
+ */
70
+ public function getFundingInstrumentType()
71
+ {
72
+ return $this->funding_instrument_type;
73
+ }
74
+
75
+ /**
76
+ * Soft descriptor used when charging this funding source.
77
+ *
78
+ * @param string $soft_descriptor
79
+ *
80
+ * @return $this
81
+ */
82
+ public function setSoftDescriptor($soft_descriptor)
83
+ {
84
+ $this->soft_descriptor = $soft_descriptor;
85
+ return $this;
86
+ }
87
+
88
+ /**
89
+ * Soft descriptor used when charging this funding source.
90
+ *
91
+ * @return string
92
+ */
93
+ public function getSoftDescriptor()
94
+ {
95
+ return $this->soft_descriptor;
96
+ }
97
+
98
+ /**
99
+ * Total anticipated amount of money to be pulled from instrument.
100
+ *
101
+ * @param \PayPal\Api\Currency $amount
102
+ *
103
+ * @return $this
104
+ */
105
+ public function setAmount($amount)
106
+ {
107
+ $this->amount = $amount;
108
+ return $this;
109
+ }
110
+
111
+ /**
112
+ * Total anticipated amount of money to be pulled from instrument.
113
+ *
114
+ * @return \PayPal\Api\Currency
115
+ */
116
+ public function getAmount()
117
+ {
118
+ return $this->amount;
119
+ }
120
+
121
+ /**
122
+ * Additional amount to be pulled from the instrument to recover a negative balance on the buyer
123
+ *
124
+ * @param \PayPal\Api\Currency $amount
125
+ *
126
+ * @return $this
127
+ */
128
+ public function setNegativeBalanceAmount($amount)
129
+ {
130
+ $this->amount = $amount;
131
+ return $this;
132
+ }
133
+
134
+ /**
135
+ * Additional amount to be pulled from the instrument to recover a negative balance on the buyer
136
+ *
137
+ * @return \PayPal\Api\Currency
138
+ */
139
+ public function getNegativeBalanceAmount()
140
+ {
141
+ return $this->amount;
142
+ }
143
+
144
+ /**
145
+ * Localized legal text relevant to funding source.
146
+ *
147
+ * @param string $legal_text
148
+ *
149
+ * @return $this
150
+ */
151
+ public function setLegalText($legal_text)
152
+ {
153
+ $this->legal_text = $legal_text;
154
+ return $this;
155
+ }
156
+
157
+ /**
158
+ * Localized legal text relevant to funding source.
159
+ *
160
+ * @return string
161
+ */
162
+ public function getLegalText()
163
+ {
164
+ return $this->legal_text;
165
+ }
166
+
167
+ /**
168
+ * Additional detail of the funding.
169
+ *
170
+ * @param \PayPal\Api\FundingDetail $funding_detail
171
+ *
172
+ * @return $this
173
+ */
174
+ public function setFundingDetail($funding_detail)
175
+ {
176
+ $this->funding_detail = $funding_detail;
177
+ return $this;
178
+ }
179
+
180
+ /**
181
+ * Additional detail of the funding.
182
+ *
183
+ * @return \PayPal\Api\FundingDetail
184
+ */
185
+ public function getFundingDetail()
186
+ {
187
+ return $this->funding_detail;
188
+ }
189
+
190
+ /**
191
+ * Additional text relevant to funding source.
192
+ *
193
+ * @param string $additional_text
194
+ *
195
+ * @return $this
196
+ */
197
+ public function setAdditionalText($additional_text)
198
+ {
199
+ $this->additional_text = $additional_text;
200
+ return $this;
201
+ }
202
+
203
+ /**
204
+ * Additional text relevant to funding source.
205
+ *
206
+ * @return string
207
+ */
208
+ public function getAdditionalText()
209
+ {
210
+ return $this->additional_text;
211
+ }
212
+
213
+ /**
214
+ * Sets Extends
215
+ *
216
+ * @param \PayPal\Api\FundingInstrument $extends
217
+ *
218
+ * @return $this
219
+ */
220
+ public function setExtends($extends)
221
+ {
222
+ $this->extends = $extends;
223
+ return $this;
224
+ }
225
+
226
+ /**
227
+ * Gets Extends
228
+ *
229
+ * @return \PayPal\Api\FundingInstrument
230
+ */
231
+ public function getExtends()
232
+ {
233
+ return $this->extends;
234
+ }
235
+
236
+ /**
237
+ * Sets Links
238
+ *
239
+ * @param \PayPal\Api\Links[] $links
240
+ *
241
+ * @return $this
242
+ */
243
+ public function setLinks($links)
244
+ {
245
+ $this->links = $links;
246
+ return $this;
247
+ }
248
+
249
+ /**
250
+ * Gets Links
251
+ *
252
+ * @return \PayPal\Api\Links[]
253
+ */
254
+ public function getLinks()
255
+ {
256
+ return $this->links;
257
+ }
258
+
259
+ /**
260
+ * Append Links to the list.
261
+ *
262
+ * @param \PayPal\Api\Links $links
263
+ * @return $this
264
+ */
265
+ public function addLink($links)
266
+ {
267
+ if (!$this->getLinks()) {
268
+ return $this->setLinks(array($links));
269
+ } else {
270
+ return $this->setLinks(
271
+ array_merge($this->getLinks(), array($links))
272
+ );
273
+ }
274
+ }
275
+
276
+ /**
277
+ * Remove Links from the list.
278
+ *
279
+ * @param \PayPal\Api\Links $links
280
+ * @return $this
281
+ */
282
+ public function removeLink($links)
283
+ {
284
+ return $this->setLinks(
285
+ array_diff($this->getLinks(), array($links))
286
+ );
287
+ }
288
+
289
+ }
lib/PayPal/Api/FuturePayment.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Rest\ApiContext;
6
+ use PayPal\Transport\PayPalRestCall;
7
+
8
+ /**
9
+ * Class FuturePayment
10
+ *
11
+ * @package PayPal\Api
12
+ */
13
+ class FuturePayment extends Payment
14
+ {
15
+
16
+ /**
17
+ * Extends the Payment object to create future payments
18
+ *
19
+ * @param null $apiContext
20
+ * @param string|null $clientMetadataId
21
+ * @return $this
22
+ */
23
+ public function create($apiContext = null, $clientMetadataId = null)
24
+ {
25
+ if ($apiContext == null) {
26
+ $apiContext = new ApiContext(self::$credential);
27
+ }
28
+ $headers = array();
29
+ if ($clientMetadataId != null) {
30
+ $headers = array(
31
+ 'PAYPAL-CLIENT-METADATA-ID' => $clientMetadataId
32
+ );
33
+ }
34
+ $payLoad = $this->toJSON();
35
+ $call = new PayPalRestCall($apiContext);
36
+ $json = $call->execute(
37
+ array('PayPal\Handler\RestHandler'),
38
+ "/v1/payments/payment",
39
+ "POST",
40
+ $payLoad,
41
+ $headers
42
+ );
43
+ $this->fromJson($json);
44
+
45
+ return $this;
46
+
47
+ }
48
+
49
+ /**
50
+ * Get a Refresh Token from Authorization Code
51
+ *
52
+ * @param $authorizationCode
53
+ * @param ApiContext $apiContext
54
+ * @return string|null refresh token
55
+ */
56
+ public static function getRefreshToken($authorizationCode, $apiContext = null)
57
+ {
58
+ $apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential);
59
+ $credential = $apiContext->getCredential();
60
+ return $credential->getRefreshToken($apiContext->getConfig(), $authorizationCode);
61
+ }
62
+
63
+ /**
64
+ * Updates Access Token using long lived refresh token
65
+ *
66
+ * @param string|null $refreshToken
67
+ * @param ApiContext $apiContext
68
+ * @return void
69
+ */
70
+ public function updateAccessToken($refreshToken, $apiContext)
71
+ {
72
+ $apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential);
73
+ $apiContext->getCredential()->updateAccessToken($apiContext->getConfig(), $refreshToken);
74
+ }
75
+ }
lib/PayPal/Api/HyperSchema.php ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class HyperSchema
9
+ *
10
+ *
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property \PayPal\Api\Links[] links
15
+ * @property string fragmentResolution
16
+ * @property bool readonly
17
+ * @property string contentEncoding
18
+ * @property string pathStart
19
+ * @property string mediaType
20
+ */
21
+ class HyperSchema extends PayPalModel
22
+ {
23
+ /**
24
+ * Sets Links
25
+ *
26
+ * @param \PayPal\Api\Links[] $links
27
+ *
28
+ * @return $this
29
+ */
30
+ public function setLinks($links)
31
+ {
32
+ $this->links = $links;
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * Gets Links
38
+ *
39
+ * @return \PayPal\Api\Links[]
40
+ */
41
+ public function getLinks()
42
+ {
43
+ return $this->links;
44
+ }
45
+
46
+ /**
47
+ * Append Links to the list.
48
+ *
49
+ * @param \PayPal\Api\Links $links
50
+ * @return $this
51
+ */
52
+ public function addLink($links)
53
+ {
54
+ if (!$this->getLinks()) {
55
+ return $this->setLinks(array($links));
56
+ } else {
57
+ return $this->setLinks(
58
+ array_merge($this->getLinks(), array($links))
59
+ );
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Remove Links from the list.
65
+ *
66
+ * @param \PayPal\Api\Links $links
67
+ * @return $this
68
+ */
69
+ public function removeLink($links)
70
+ {
71
+ return $this->setLinks(
72
+ array_diff($this->getLinks(), array($links))
73
+ );
74
+ }
75
+
76
+ /**
77
+ * Sets FragmentResolution
78
+ *
79
+ * @param string $fragmentResolution
80
+ *
81
+ * @return $this
82
+ */
83
+ public function setFragmentResolution($fragmentResolution)
84
+ {
85
+ $this->fragmentResolution = $fragmentResolution;
86
+ return $this;
87
+ }
88
+
89
+ /**
90
+ * Gets FragmentResolution
91
+ *
92
+ * @return string
93
+ */
94
+ public function getFragmentResolution()
95
+ {
96
+ return $this->fragmentResolution;
97
+ }
98
+
99
+ /**
100
+ * Sets Readonly
101
+ *
102
+ * @param bool $readonly
103
+ *
104
+ * @return $this
105
+ */
106
+ public function setReadonly($readonly)
107
+ {
108
+ $this->readonly = $readonly;
109
+ return $this;
110
+ }
111
+
112
+ /**
113
+ * Gets Readonly
114
+ *
115
+ * @return bool
116
+ */
117
+ public function getReadonly()
118
+ {
119
+ return $this->readonly;
120
+ }
121
+
122
+ /**
123
+ * Sets ContentEncoding
124
+ *
125
+ * @param string $contentEncoding
126
+ *
127
+ * @return $this
128
+ */
129
+ public function setContentEncoding($contentEncoding)
130
+ {
131
+ $this->contentEncoding = $contentEncoding;
132
+ return $this;
133
+ }
134
+
135
+ /**
136
+ * Gets ContentEncoding
137
+ *
138
+ * @return string
139
+ */
140
+ public function getContentEncoding()
141
+ {
142
+ return $this->contentEncoding;
143
+ }
144
+
145
+ /**
146
+ * Sets PathStart
147
+ *
148
+ * @param string $pathStart
149
+ *
150
+ * @return $this
151
+ */
152
+ public function setPathStart($pathStart)
153
+ {
154
+ $this->pathStart = $pathStart;
155
+ return $this;
156
+ }
157
+
158
+ /**
159
+ * Gets PathStart
160
+ *
161
+ * @return string
162
+ */
163
+ public function getPathStart()
164
+ {
165
+ return $this->pathStart;
166
+ }
167
+
168
+ /**
169
+ * Sets MediaType
170
+ *
171
+ * @param string $mediaType
172
+ *
173
+ * @return $this
174
+ */
175
+ public function setMediaType($mediaType)
176
+ {
177
+ $this->mediaType = $mediaType;
178
+ return $this;
179
+ }
180
+
181
+ /**
182
+ * Gets MediaType
183
+ *
184
+ * @return string
185
+ */
186
+ public function getMediaType()
187
+ {
188
+ return $this->mediaType;
189
+ }
190
+
191
+ }
lib/PayPal/Api/Image.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class Image
9
+ *
10
+ * @package PayPal\Api
11
+ *
12
+ * @property string image
13
+ */
14
+ class Image extends PayPalModel
15
+ {
16
+ /**
17
+ * List of invoices belonging to a merchant.
18
+ *
19
+ * @param string $imageBase64String
20
+ *
21
+ * @return $this
22
+ */
23
+ public function setImage($imageBase64String)
24
+ {
25
+ $this->image = $imageBase64String;
26
+ return $this;
27
+ }
28
+
29
+ /**
30
+ * Get Image as Base-64 encoded String
31
+ *
32
+ * @return string
33
+ */
34
+ public function getImage()
35
+ {
36
+ return $this->image;
37
+ }
38
+
39
+ /**
40
+ * Stores the Image to file
41
+ *
42
+ * @param string $name File Name
43
+ * @return string File name
44
+ */
45
+ public function saveToFile($name = null)
46
+ {
47
+ // Self Generate File Location
48
+ if (!$name) {
49
+ $name = uniqid() . '.png';
50
+ }
51
+ // Save to File
52
+ file_put_contents($name, base64_decode($this->getImage()));
53
+ return $name;
54
+ }
55
+
56
+ }
lib/PayPal/Api/Incentive.php ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+ use PayPal\Validation\UrlValidator;
7
+
8
+ /**
9
+ * Class Incentive
10
+ *
11
+ * A resource representing a incentive.
12
+ *
13
+ * @package PayPal\Api
14
+ *
15
+ * @property string id
16
+ * @property string code
17
+ * @property string name
18
+ * @property string description
19
+ * @property \PayPal\Api\Currency minimum_purchase_amount
20
+ * @property string logo_image_url
21
+ * @property string expiry_date
22
+ * @property string type
23
+ * @property string terms
24
+ */
25
+ class Incentive extends PayPalModel
26
+ {
27
+ /**
28
+ * Identifier of the instrument in PayPal Wallet
29
+ *
30
+ * @param string $id
31
+ *
32
+ * @return $this
33
+ */
34
+ public function setId($id)
35
+ {
36
+ $this->id = $id;
37
+ return $this;
38
+ }
39
+
40
+ /**
41
+ * Identifier of the instrument in PayPal Wallet
42
+ *
43
+ * @return string
44
+ */
45
+ public function getId()
46
+ {
47
+ return $this->id;
48
+ }
49
+
50
+ /**
51
+ * Code that identifies the incentive.
52
+ *
53
+ * @param string $code
54
+ *
55
+ * @return $this
56
+ */
57
+ public function setCode($code)
58
+ {
59
+ $this->code = $code;
60
+ return $this;
61
+ }
62
+
63
+ /**
64
+ * Code that identifies the incentive.
65
+ *
66
+ * @return string
67
+ */
68
+ public function getCode()
69
+ {
70
+ return $this->code;
71
+ }
72
+
73
+ /**
74
+ * Name of the incentive.
75
+ *
76
+ * @param string $name
77
+ *
78
+ * @return $this
79
+ */
80
+ public function setName($name)
81
+ {
82
+ $this->name = $name;
83
+ return $this;
84
+ }
85
+
86
+ /**
87
+ * Name of the incentive.
88
+ *
89
+ * @return string
90
+ */
91
+ public function getName()
92
+ {
93
+ return $this->name;
94
+ }
95
+
96
+ /**
97
+ * Description of the incentive.
98
+ *
99
+ * @param string $description
100
+ *
101
+ * @return $this
102
+ */
103
+ public function setDescription($description)
104
+ {
105
+ $this->description = $description;
106
+ return $this;
107
+ }
108
+
109
+ /**
110
+ * Description of the incentive.
111
+ *
112
+ * @return string
113
+ */
114
+ public function getDescription()
115
+ {
116
+ return $this->description;
117
+ }
118
+
119
+ /**
120
+ * Indicates incentive is applicable for this minimum purchase amount.
121
+ *
122
+ * @param \PayPal\Api\Currency $minimum_purchase_amount
123
+ *
124
+ * @return $this
125
+ */
126
+ public function setMinimumPurchaseAmount($minimum_purchase_amount)
127
+ {
128
+ $this->minimum_purchase_amount = $minimum_purchase_amount;
129
+ return $this;
130
+ }
131
+
132
+ /**
133
+ * Indicates incentive is applicable for this minimum purchase amount.
134
+ *
135
+ * @return \PayPal\Api\Currency
136
+ */
137
+ public function getMinimumPurchaseAmount()
138
+ {
139
+ return $this->minimum_purchase_amount;
140
+ }
141
+
142
+ /**
143
+ * Logo image url for the incentive.
144
+ *
145
+ * @param string $logo_image_url
146
+ * @throws \InvalidArgumentException
147
+ * @return $this
148
+ */
149
+ public function setLogoImageUrl($logo_image_url)
150
+ {
151
+ UrlValidator::validate($logo_image_url, "LogoImageUrl");
152
+ $this->logo_image_url = $logo_image_url;
153
+ return $this;
154
+ }
155
+
156
+ /**
157
+ * Logo image url for the incentive.
158
+ *
159
+ * @return string
160
+ */
161
+ public function getLogoImageUrl()
162
+ {
163
+ return $this->logo_image_url;
164
+ }
165
+
166
+ /**
167
+ * expiry date of the incentive.
168
+ *
169
+ * @param string $expiry_date
170
+ *
171
+ * @return $this
172
+ */
173
+ public function setExpiryDate($expiry_date)
174
+ {
175
+ $this->expiry_date = $expiry_date;
176
+ return $this;
177
+ }
178
+
179
+ /**
180
+ * expiry date of the incentive.
181
+ *
182
+ * @return string
183
+ */
184
+ public function getExpiryDate()
185
+ {
186
+ return $this->expiry_date;
187
+ }
188
+
189
+ /**
190
+ * Specifies type of incentive
191
+ * Valid Values: ["COUPON", "GIFT_CARD", "MERCHANT_SPECIFIC_BALANCE", "VOUCHER"]
192
+ *
193
+ * @param string $type
194
+ *
195
+ * @return $this
196
+ */
197
+ public function setType($type)
198
+ {
199
+ $this->type = $type;
200
+ return $this;
201
+ }
202
+
203
+ /**
204
+ * Specifies type of incentive
205
+ *
206
+ * @return string
207
+ */
208
+ public function getType()
209
+ {
210
+ return $this->type;
211
+ }
212
+
213
+ /**
214
+ * URI to the associated terms
215
+ *
216
+ * @param string $terms
217
+ *
218
+ * @return $this
219
+ */
220
+ public function setTerms($terms)
221
+ {
222
+ $this->terms = $terms;
223
+ return $this;
224
+ }
225
+
226
+ /**
227
+ * URI to the associated terms
228
+ *
229
+ * @return string
230
+ */
231
+ public function getTerms()
232
+ {
233
+ return $this->terms;
234
+ }
235
+
236
+ }
lib/PayPal/Api/InputFields.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class InputFields
9
+ *
10
+ * Parameters for input fields customization.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property bool allow_note
15
+ * @property int no_shipping
16
+ * @property int address_override
17
+ */
18
+ class InputFields extends PayPalModel
19
+ {
20
+ /**
21
+ * Enables the buyer to enter a note to the merchant on the PayPal page during checkout.
22
+ *
23
+ *
24
+ * @param bool $allow_note
25
+ *
26
+ * @return $this
27
+ */
28
+ public function setAllowNote($allow_note)
29
+ {
30
+ $this->allow_note = $allow_note;
31
+ return $this;
32
+ }
33
+
34
+ /**
35
+ * Enables the buyer to enter a note to the merchant on the PayPal page during checkout.
36
+ *
37
+ * @return bool
38
+ */
39
+ public function getAllowNote()
40
+ {
41
+ return $this->allow_note;
42
+ }
43
+
44
+ /**
45
+ * Determines whether or not PayPal displays shipping address fields on the experience pages. Allowed values: `0`, `1`, or `2`. When set to `0`, PayPal displays the shipping address on the PayPal pages. When set to `1`, PayPal does not display shipping address fields whatsoever. When set to `2`, if you do not pass the shipping address, PayPal obtains it from the buyer's account profile. For digital goods, this field is required, and you must set it to `1`.
46
+ *
47
+ *
48
+ * @param int $no_shipping
49
+ *
50
+ * @return $this
51
+ */
52
+ public function setNoShipping($no_shipping)
53
+ {
54
+ $this->no_shipping = $no_shipping;
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * Determines whether or not PayPal displays shipping address fields on the experience pages. Allowed values: `0`, `1`, or `2`. When set to `0`, PayPal displays the shipping address on the PayPal pages. When set to `1`, PayPal does not display shipping address fields whatsoever. When set to `2`, if you do not pass the shipping address, PayPal obtains it from the buyer's account profile. For digital goods, this field is required, and you must set it to `1`.
60
+ *
61
+ * @return int
62
+ */
63
+ public function getNoShipping()
64
+ {
65
+ return $this->no_shipping;
66
+ }
67
+
68
+ /**
69
+ * Determines whether or not the PayPal pages should display the shipping address and not the shipping address on file with PayPal for this buyer. Displaying the PayPal street address on file does not allow the buyer to edit that address. Allowed values: `0` or `1`. When set to `0`, the PayPal pages should not display the shipping address. When set to `1`, the PayPal pages should display the shipping address.
70
+ *
71
+ *
72
+ * @param int $address_override
73
+ *
74
+ * @return $this
75
+ */
76
+ public function setAddressOverride($address_override)
77
+ {
78
+ $this->address_override = $address_override;
79
+ return $this;
80
+ }
81
+
82
+ /**
83
+ * Determines whether or not the PayPal pages should display the shipping address and not the shipping address on file with PayPal for this buyer. Displaying the PayPal street address on file does not allow the buyer to edit that address. Allowed values: `0` or `1`. When set to `0`, the PayPal pages should not display the shipping address. When set to `1`, the PayPal pages should display the shipping address.
84
+ *
85
+ * @return int
86
+ */
87
+ public function getAddressOverride()
88
+ {
89
+ return $this->address_override;
90
+ }
91
+
92
+ }
lib/PayPal/Api/InstallmentInfo.php ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class InstallmentInfo
9
+ *
10
+ * A resource representing installment information available for a transaction
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string installment_id
15
+ * @property string network
16
+ * @property string issuer
17
+ * @property \PayPal\Api\InstallmentOption[] installment_options
18
+ */
19
+ class InstallmentInfo extends PayPalModel
20
+ {
21
+ /**
22
+ * Installment id.
23
+ *
24
+ * @param string $installment_id
25
+ *
26
+ * @return $this
27
+ */
28
+ public function setInstallmentId($installment_id)
29
+ {
30
+ $this->installment_id = $installment_id;
31
+ return $this;
32
+ }
33
+
34
+ /**
35
+ * Installment id.
36
+ *
37
+ * @return string
38
+ */
39
+ public function getInstallmentId()
40
+ {
41
+ return $this->installment_id;
42
+ }
43
+
44
+ /**
45
+ * Credit card network.
46
+ * Valid Values: ["VISA", "MASTERCARD"]
47
+ *
48
+ * @param string $network
49
+ *
50
+ * @return $this
51
+ */
52
+ public function setNetwork($network)
53
+ {
54
+ $this->network = $network;
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * Credit card network.
60
+ *
61
+ * @return string
62
+ */
63
+ public function getNetwork()
64
+ {
65
+ return $this->network;
66
+ }
67
+
68
+ /**
69
+ * Credit card issuer.
70
+ *
71
+ * @param string $issuer
72
+ *
73
+ * @return $this
74
+ */
75
+ public function setIssuer($issuer)
76
+ {
77
+ $this->issuer = $issuer;
78
+ return $this;
79
+ }
80
+
81
+ /**
82
+ * Credit card issuer.
83
+ *
84
+ * @return string
85
+ */
86
+ public function getIssuer()
87
+ {
88
+ return $this->issuer;
89
+ }
90
+
91
+ /**
92
+ * List of available installment options and the cost associated with each one.
93
+ *
94
+ * @param \PayPal\Api\InstallmentOption[] $installment_options
95
+ *
96
+ * @return $this
97
+ */
98
+ public function setInstallmentOptions($installment_options)
99
+ {
100
+ $this->installment_options = $installment_options;
101
+ return $this;
102
+ }
103
+
104
+ /**
105
+ * List of available installment options and the cost associated with each one.
106
+ *
107
+ * @return \PayPal\Api\InstallmentOption[]
108
+ */
109
+ public function getInstallmentOptions()
110
+ {
111
+ return $this->installment_options;
112
+ }
113
+
114
+ /**
115
+ * Append InstallmentOptions to the list.
116
+ *
117
+ * @param \PayPal\Api\InstallmentOption $installmentOption
118
+ * @return $this
119
+ */
120
+ public function addInstallmentOption($installmentOption)
121
+ {
122
+ if (!$this->getInstallmentOptions()) {
123
+ return $this->setInstallmentOptions(array($installmentOption));
124
+ } else {
125
+ return $this->setInstallmentOptions(
126
+ array_merge($this->getInstallmentOptions(), array($installmentOption))
127
+ );
128
+ }
129
+ }
130
+
131
+ /**
132
+ * Remove InstallmentOptions from the list.
133
+ *
134
+ * @param \PayPal\Api\InstallmentOption $installmentOption
135
+ * @return $this
136
+ */
137
+ public function removeInstallmentOption($installmentOption)
138
+ {
139
+ return $this->setInstallmentOptions(
140
+ array_diff($this->getInstallmentOptions(), array($installmentOption))
141
+ );
142
+ }
143
+
144
+ }
lib/PayPal/Api/InstallmentOption.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class InstallmentOption
9
+ *
10
+ * A resource describing an installment
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property int term
15
+ * @property \PayPal\Api\Currency monthly_payment
16
+ * @property \PayPal\Api\Currency discount_amount
17
+ * @property string discount_percentage
18
+ */
19
+ class InstallmentOption extends PayPalModel
20
+ {
21
+ /**
22
+ * Number of installments
23
+ *
24
+ * @param int $term
25
+ *
26
+ * @return $this
27
+ */
28
+ public function setTerm($term)
29
+ {
30
+ $this->term = $term;
31
+ return $this;
32
+ }
33
+
34
+ /**
35
+ * Number of installments
36
+ *
37
+ * @return int
38
+ */
39
+ public function getTerm()
40
+ {
41
+ return $this->term;
42
+ }
43
+
44
+ /**
45
+ * Monthly payment
46
+ *
47
+ * @param \PayPal\Api\Currency $monthly_payment
48
+ *
49
+ * @return $this
50
+ */
51
+ public function setMonthlyPayment($monthly_payment)
52
+ {
53
+ $this->monthly_payment = $monthly_payment;
54
+ return $this;
55
+ }
56
+
57
+ /**
58
+ * Monthly payment
59
+ *
60
+ * @return \PayPal\Api\Currency
61
+ */
62
+ public function getMonthlyPayment()
63
+ {
64
+ return $this->monthly_payment;
65
+ }
66
+
67
+ /**
68
+ * Discount amount applied to the payment, if any
69
+ *
70
+ * @param \PayPal\Api\Currency $discount_amount
71
+ *
72
+ * @return $this
73
+ */
74
+ public function setDiscountAmount($discount_amount)
75
+ {
76
+ $this->discount_amount = $discount_amount;
77
+ return $this;
78
+ }
79
+
80
+ /**
81
+ * Discount amount applied to the payment, if any
82
+ *
83
+ * @return \PayPal\Api\Currency
84
+ */
85
+ public function getDiscountAmount()
86
+ {
87
+ return $this->discount_amount;
88
+ }
89
+
90
+ /**
91
+ * Discount percentage applied to the payment, if any
92
+ *
93
+ * @param string $discount_percentage
94
+ *
95
+ * @return $this
96
+ */
97
+ public function setDiscountPercentage($discount_percentage)
98
+ {
99
+ $this->discount_percentage = $discount_percentage;
100
+ return $this;
101
+ }
102
+
103
+ /**
104
+ * Discount percentage applied to the payment, if any
105
+ *
106
+ * @return string
107
+ */
108
+ public function getDiscountPercentage()
109
+ {
110
+ return $this->discount_percentage;
111
+ }
112
+
113
+ }
lib/PayPal/Api/Invoice.php ADDED
@@ -0,0 +1,1020 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalResourceModel;
6
+ use PayPal\Rest\ApiContext;
7
+ use PayPal\Transport\PayPalRestCall;
8
+ use PayPal\Validation\ArgumentValidator;
9
+ use PayPal\Validation\UrlValidator;
10
+
11
+ /**
12
+ * Class Invoice
13
+ *
14
+ * Detailed invoice information.
15
+ *
16
+ * @package PayPal\Api
17
+ *
18
+ * @property string id
19
+ * @property string number
20
+ * @property string uri
21
+ * @property string status
22
+ * @property \PayPal\Api\MerchantInfo merchant_info
23
+ * @property \PayPal\Api\BillingInfo[] billing_info
24
+ * @property \PayPal\Api\ShippingInfo shipping_info
25
+ * @property \PayPal\Api\InvoiceItem[] items
26
+ * @property string invoice_date
27
+ * @property \PayPal\Api\PaymentTerm payment_term
28
+ * @property \PayPal\Api\Cost discount
29
+ * @property \PayPal\Api\ShippingCost shipping_cost
30
+ * @property \PayPal\Api\CustomAmount custom
31
+ * @property bool tax_calculated_after_discount
32
+ * @property bool tax_inclusive
33
+ * @property string terms
34
+ * @property string note
35
+ * @property string merchant_memo
36
+ * @property string logo_url
37
+ * @property \PayPal\Api\Currency total_amount
38
+ * @property \PayPal\Api\PaymentDetail[] payments
39
+ * @property \PayPal\Api\RefundDetail[] refunds
40
+ * @property \PayPal\Api\Metadata metadata
41
+ * @property string additional_data
42
+ */
43
+ class Invoice extends PayPalResourceModel
44
+ {
45
+ /**
46
+ * Unique invoice resource identifier.
47
+ *
48
+ * @param string $id
49
+ *
50
+ * @return $this
51
+ */
52
+ public function setId($id)
53
+ {
54
+ $this->id = $id;
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * Unique invoice resource identifier.
60
+ *
61
+ * @return string
62
+ */
63
+ public function getId()
64
+ {
65
+ return $this->id;
66
+ }
67
+
68
+ /**
69
+ * Unique number that appears on the invoice. If left blank will be auto-incremented from the last number. 25 characters max.
70
+ *
71
+ * @param string $number
72
+ *
73
+ * @return $this
74
+ */
75
+ public function setNumber($number)
76
+ {
77
+ $this->number = $number;
78
+ return $this;
79
+ }
80
+
81
+ /**
82
+ * Unique number that appears on the invoice. If left blank will be auto-incremented from the last number. 25 characters max.
83
+ *
84
+ * @return string
85
+ */
86
+ public function getNumber()
87
+ {
88
+ return $this->number;
89
+ }
90
+
91
+ /**
92
+ * URI of the invoice resource.
93
+ *
94
+ * @param string $uri
95
+ *
96
+ * @return $this
97
+ */
98
+ public function setUri($uri)
99
+ {
100
+ $this->uri = $uri;
101
+ return $this;
102
+ }
103
+
104
+ /**
105
+ * URI of the invoice resource.
106
+ *
107
+ * @return string
108
+ */
109
+ public function getUri()
110
+ {
111
+ return $this->uri;
112
+ }
113
+
114
+ /**
115
+ * Status of the invoice.
116
+ * Valid Values: ["DRAFT", "SENT", "PAID", "MARKED_AS_PAID", "CANCELLED", "REFUNDED", "PARTIALLY_REFUNDED", "MARKED_AS_REFUNDED"]
117
+ *
118
+ * @param string $status
119
+ *
120
+ * @return $this
121
+ */
122
+ public function setStatus($status)
123
+ {
124
+ $this->status = $status;
125
+ return $this;
126
+ }
127
+
128
+ /**
129
+ * Status of the invoice.
130
+ *
131
+ * @return string
132
+ */
133
+ public function getStatus()
134
+ {
135
+ return $this->status;
136
+ }
137
+
138
+ /**
139
+ * Information about the merchant who is sending the invoice.
140
+ *
141
+ * @param \PayPal\Api\MerchantInfo $merchant_info
142
+ *
143
+ * @return $this
144
+ */
145
+ public function setMerchantInfo($merchant_info)
146
+ {
147
+ $this->merchant_info = $merchant_info;
148
+ return $this;
149
+ }
150
+
151
+ /**
152
+ * Information about the merchant who is sending the invoice.
153
+ *
154
+ * @return \PayPal\Api\MerchantInfo
155
+ */
156
+ public function getMerchantInfo()
157
+ {
158
+ return $this->merchant_info;
159
+ }
160
+
161
+ /**
162
+ * Email address of invoice recipient (required) and optional billing information. (Note: We currently only allow one recipient).
163
+ *
164
+ * @param \PayPal\Api\BillingInfo[] $billing_info
165
+ *
166
+ * @return $this
167
+ */
168
+ public function setBillingInfo($billing_info)
169
+ {
170
+ $this->billing_info = $billing_info;
171
+ return $this;
172
+ }
173
+
174
+ /**
175
+ * Email address of invoice recipient (required) and optional billing information. (Note: We currently only allow one recipient).
176
+ *
177
+ * @return \PayPal\Api\BillingInfo[]
178
+ */
179
+ public function getBillingInfo()
180
+ {
181
+ return $this->billing_info;
182
+ }
183
+
184
+ /**
185
+ * Append BillingInfo to the list.
186
+ *
187
+ * @param \PayPal\Api\BillingInfo $billingInfo
188
+ * @return $this
189
+ */
190
+ public function addBillingInfo($billingInfo)
191
+ {
192
+ if (!$this->getBillingInfo()) {
193
+ return $this->setBillingInfo(array($billingInfo));
194
+ } else {
195
+ return $this->setBillingInfo(
196
+ array_merge($this->getBillingInfo(), array($billingInfo))
197
+ );
198
+ }
199
+ }
200
+
201
+ /**
202
+ * Remove BillingInfo from the list.
203
+ *
204
+ * @param \PayPal\Api\BillingInfo $billingInfo
205
+ * @return $this
206
+ */
207
+ public function removeBillingInfo($billingInfo)
208
+ {
209
+ return $this->setBillingInfo(
210
+ array_diff($this->getBillingInfo(), array($billingInfo))
211
+ );
212
+ }
213
+
214
+ /**
215
+ * Shipping information for entities to whom items are being shipped.
216
+ *
217
+ * @param \PayPal\Api\ShippingInfo $shipping_info
218
+ *
219
+ * @return $this
220
+ */
221
+ public function setShippingInfo($shipping_info)
222
+ {
223
+ $this->shipping_info = $shipping_info;
224
+ return $this;
225
+ }
226
+
227
+ /**
228
+ * Shipping information for entities to whom items are being shipped.
229
+ *
230
+ * @return \PayPal\Api\ShippingInfo
231
+ */
232
+ public function getShippingInfo()
233
+ {
234
+ return $this->shipping_info;
235
+ }
236
+
237
+ /**
238
+ * List of items included in the invoice. 100 items max per invoice.
239
+ *
240
+ * @param \PayPal\Api\InvoiceItem[] $items
241
+ *
242
+ * @return $this
243
+ */
244
+ public function setItems($items)
245
+ {
246
+ $this->items = $items;
247
+ return $this;
248
+ }
249
+
250
+ /**
251
+ * List of items included in the invoice. 100 items max per invoice.
252
+ *
253
+ * @return \PayPal\Api\InvoiceItem[]
254
+ */
255
+ public function getItems()
256
+ {
257
+ return $this->items;
258
+ }
259
+
260
+ /**
261
+ * Append Items to the list.
262
+ *
263
+ * @param \PayPal\Api\InvoiceItem $invoiceItem
264
+ * @return $this
265
+ */
266
+ public function addItem($invoiceItem)
267
+ {
268
+ if (!$this->getItems()) {
269
+ return $this->setItems(array($invoiceItem));
270
+ } else {
271
+ return $this->setItems(
272
+ array_merge($this->getItems(), array($invoiceItem))
273
+ );
274
+ }
275
+ }
276
+
277
+ /**
278
+ * Remove Items from the list.
279
+ *
280
+ * @param \PayPal\Api\InvoiceItem $invoiceItem
281
+ * @return $this
282
+ */
283
+ public function removeItem($invoiceItem)
284
+ {
285
+ return $this->setItems(
286
+ array_diff($this->getItems(), array($invoiceItem))
287
+ );
288
+ }
289
+
290
+ /**
291
+ * Date on which the invoice was enabled. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
292
+ *
293
+ * @param string $invoice_date
294
+ *
295
+ * @return $this
296
+ */
297
+ public function setInvoiceDate($invoice_date)
298
+ {
299
+ $this->invoice_date = $invoice_date;
300
+ return $this;
301
+ }
302
+
303
+ /**
304
+ * Date on which the invoice was enabled. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
305
+ *
306
+ * @return string
307
+ */
308
+ public function getInvoiceDate()
309
+ {
310
+ return $this->invoice_date;
311
+ }
312
+
313
+ /**
314
+ * Optional field to pass payment deadline for the invoice. Either term_type or due_date can be passed, but not both.
315
+ *
316
+ * @param \PayPal\Api\PaymentTerm $payment_term
317
+ *
318
+ * @return $this
319
+ */
320
+ public function setPaymentTerm($payment_term)
321
+ {
322
+ $this->payment_term = $payment_term;
323
+ return $this;
324
+ }
325
+
326
+ /**
327
+ * Optional field to pass payment deadline for the invoice. Either term_type or due_date can be passed, but not both.
328
+ *
329
+ * @return \PayPal\Api\PaymentTerm
330
+ */
331
+ public function getPaymentTerm()
332
+ {
333
+ return $this->payment_term;
334
+ }
335
+
336
+ /**
337
+ * Invoice level discount in percent or amount.
338
+ *
339
+ * @param \PayPal\Api\Cost $discount
340
+ *
341
+ * @return $this
342
+ */
343
+ public function setDiscount($discount)
344
+ {
345
+ $this->discount = $discount;
346
+ return $this;
347
+ }
348
+
349
+ /**
350
+ * Invoice level discount in percent or amount.
351
+ *
352
+ * @return \PayPal\Api\Cost
353
+ */
354
+ public function getDiscount()
355
+ {
356
+ return $this->discount;
357
+ }
358
+
359
+ /**
360
+ * Shipping cost in percent or amount.
361
+ *
362
+ * @param \PayPal\Api\ShippingCost $shipping_cost
363
+ *
364
+ * @return $this
365
+ */
366
+ public function setShippingCost($shipping_cost)
367
+ {
368
+ $this->shipping_cost = $shipping_cost;
369
+ return $this;
370
+ }
371
+
372
+ /**
373
+ * Shipping cost in percent or amount.
374
+ *
375
+ * @return \PayPal\Api\ShippingCost
376
+ */
377
+ public function getShippingCost()
378
+ {
379
+ return $this->shipping_cost;
380
+ }
381
+
382
+ /**
383
+ * Custom amount applied on an invoice. If a label is included then the amount cannot be empty.
384
+ *
385
+ * @param \PayPal\Api\CustomAmount $custom
386
+ *
387
+ * @return $this
388
+ */
389
+ public function setCustom($custom)
390
+ {
391
+ $this->custom = $custom;
392
+ return $this;
393
+ }
394
+
395
+ /**
396
+ * Custom amount applied on an invoice. If a label is included then the amount cannot be empty.
397
+ *
398
+ * @return \PayPal\Api\CustomAmount
399
+ */
400
+ public function getCustom()
401
+ {
402
+ return $this->custom;
403
+ }
404
+
405
+ /**
406
+ * Indicates whether tax is calculated before or after a discount. If false (the default), the tax is calculated before a discount. If true, the tax is calculated after a discount.
407
+ *
408
+ * @param bool $tax_calculated_after_discount
409
+ *
410
+ * @return $this
411
+ */
412
+ public function setTaxCalculatedAfterDiscount($tax_calculated_after_discount)
413
+ {
414
+ $this->tax_calculated_after_discount = $tax_calculated_after_discount;
415
+ return $this;
416
+ }
417
+
418
+ /**
419
+ * Indicates whether tax is calculated before or after a discount. If false (the default), the tax is calculated before a discount. If true, the tax is calculated after a discount.
420
+ *
421
+ * @return bool
422
+ */
423
+ public function getTaxCalculatedAfterDiscount()
424
+ {
425
+ return $this->tax_calculated_after_discount;
426
+ }
427
+
428
+ /**
429
+ * A flag indicating whether the unit price includes tax. Default is false
430
+ *
431
+ * @param bool $tax_inclusive
432
+ *
433
+ * @return $this
434
+ */
435
+ public function setTaxInclusive($tax_inclusive)
436
+ {
437
+ $this->tax_inclusive = $tax_inclusive;
438
+ return $this;
439
+ }
440
+
441
+ /**
442
+ * A flag indicating whether the unit price includes tax. Default is false
443
+ *
444
+ * @return bool
445
+ */
446
+ public function getTaxInclusive()
447
+ {
448
+ return $this->tax_inclusive;
449
+ }
450
+
451
+ /**
452
+ * General terms of the invoice. 4000 characters max.
453
+ *
454
+ * @param string $terms
455
+ *
456
+ * @return $this
457
+ */
458
+ public function setTerms($terms)
459
+ {
460
+ $this->terms = $terms;
461
+ return $this;
462
+ }
463
+
464
+ /**
465
+ * General terms of the invoice. 4000 characters max.
466
+ *
467
+ * @return string
468
+ */
469
+ public function getTerms()
470
+ {
471
+ return $this->terms;
472
+ }
473
+
474
+ /**
475
+ * Note to the payer. 4000 characters max.
476
+ *
477
+ * @param string $note
478
+ *
479
+ * @return $this
480
+ */
481
+ public function setNote($note)
482
+ {
483
+ $this->note = $note;
484
+ return $this;
485
+ }
486
+
487
+ /**
488
+ * Note to the payer. 4000 characters max.
489
+ *
490
+ * @return string
491
+ */
492
+ public function getNote()
493
+ {
494
+ return $this->note;
495
+ }
496
+
497
+ /**
498
+ * Bookkeeping memo that is private to the merchant. 150 characters max.
499
+ *
500
+ * @param string $merchant_memo
501
+ *
502
+ * @return $this
503
+ */
504
+ public function setMerchantMemo($merchant_memo)
505
+ {
506
+ $this->merchant_memo = $merchant_memo;
507
+ return $this;
508
+ }
509
+
510
+ /**
511
+ * Bookkeeping memo that is private to the merchant. 150 characters max.
512
+ *
513
+ * @return string
514
+ */
515
+ public function getMerchantMemo()
516
+ {
517
+ return $this->merchant_memo;
518
+ }
519
+
520
+ /**
521
+ * Full URL of an external image to use as the logo. 4000 characters max.
522
+ *
523
+ * @param string $logo_url
524
+ * @throws \InvalidArgumentException
525
+ * @return $this
526
+ */
527
+ public function setLogoUrl($logo_url)
528
+ {
529
+ UrlValidator::validate($logo_url, "LogoUrl");
530
+ $this->logo_url = $logo_url;
531
+ return $this;
532
+ }
533
+
534
+ /**
535
+ * Full URL of an external image to use as the logo. 4000 characters max.
536
+ *
537
+ * @return string
538
+ */
539
+ public function getLogoUrl()
540
+ {
541
+ return $this->logo_url;
542
+ }
543
+
544
+ /**
545
+ * The total amount of the invoice.
546
+ *
547
+ * @param \PayPal\Api\Currency $total_amount
548
+ *
549
+ * @return $this
550
+ */
551
+ public function setTotalAmount($total_amount)
552
+ {
553
+ $this->total_amount = $total_amount;
554
+ return $this;
555
+ }
556
+
557
+ /**
558
+ * The total amount of the invoice.
559
+ *
560
+ * @return \PayPal\Api\Currency
561
+ */
562
+ public function getTotalAmount()
563
+ {
564
+ return $this->total_amount;
565
+ }
566
+
567
+ /**
568
+ * List of payment details for the invoice.
569
+ *
570
+ * @param \PayPal\Api\PaymentDetail[] $payments
571
+ *
572
+ * @return $this
573
+ */
574
+ public function setPayments($payments)
575
+ {
576
+ $this->payments = $payments;
577
+ return $this;
578
+ }
579
+
580
+ /**
581
+ * List of payment details for the invoice.
582
+ *
583
+ * @return \PayPal\Api\PaymentDetail[]
584
+ */
585
+ public function getPayments()
586
+ {
587
+ return $this->payments;
588
+ }
589
+
590
+ /**
591
+ * Append PaymentDetails to the list.
592
+ *
593
+ * @param \PayPal\Api\PaymentDetail $paymentDetail
594
+ * @return $this
595
+ */
596
+ public function addPaymentDetail($paymentDetail)
597
+ {
598
+ if (!$this->getPayments()) {
599
+ return $this->setPayments(array($paymentDetail));
600
+ } else {
601
+ return $this->setPayments(
602
+ array_merge($this->getPayments(), array($paymentDetail))
603
+ );
604
+ }
605
+ }
606
+
607
+ /**
608
+ * Remove PaymentDetails from the list.
609
+ *
610
+ * @param \PayPal\Api\PaymentDetail $paymentDetail
611
+ * @return $this
612
+ */
613
+ public function removePaymentDetail($paymentDetail)
614
+ {
615
+ return $this->setPayments(
616
+ array_diff($this->getPayments(), array($paymentDetail))
617
+ );
618
+ }
619
+
620
+ /**
621
+ * List of refund details for the invoice.
622
+ *
623
+ * @param \PayPal\Api\RefundDetail[] $refunds
624
+ *
625
+ * @return $this
626
+ */
627
+ public function setRefunds($refunds)
628
+ {
629
+ $this->refunds = $refunds;
630
+ return $this;
631
+ }
632
+
633
+ /**
634
+ * List of refund details for the invoice.
635
+ *
636
+ * @return \PayPal\Api\RefundDetail[]
637
+ */
638
+ public function getRefunds()
639
+ {
640
+ return $this->refunds;
641
+ }
642
+
643
+ /**
644
+ * Append RefundDetails to the list.
645
+ *
646
+ * @param \PayPal\Api\RefundDetail $refundDetail
647
+ * @return $this
648
+ */
649
+ public function addRefundDetail($refundDetail)
650
+ {
651
+ if (!$this->getRefunds()) {
652
+ return $this->setRefunds(array($refundDetail));
653
+ } else {
654
+ return $this->setRefunds(
655
+ array_merge($this->getRefunds(), array($refundDetail))
656
+ );
657
+ }
658
+ }
659
+
660
+ /**
661
+ * Remove RefundDetails from the list.
662
+ *
663
+ * @param \PayPal\Api\RefundDetail $refundDetail
664
+ * @return $this
665
+ */
666
+ public function removeRefundDetail($refundDetail)
667
+ {
668
+ return $this->setRefunds(
669
+ array_diff($this->getRefunds(), array($refundDetail))
670
+ );
671
+ }
672
+
673
+ /**
674
+ * Audit information for the invoice.
675
+ *
676
+ * @param \PayPal\Api\Metadata $metadata
677
+ *
678
+ * @return $this
679
+ */
680
+ public function setMetadata($metadata)
681
+ {
682
+ $this->metadata = $metadata;
683
+ return $this;
684
+ }
685
+
686
+ /**
687
+ * Audit information for the invoice.
688
+ *
689
+ * @return \PayPal\Api\Metadata
690
+ */
691
+ public function getMetadata()
692
+ {
693
+ return $this->metadata;
694
+ }
695
+
696
+ /**
697
+ * Any miscellaneous invoice data. 4000 characters max.
698
+ *
699
+ * @param string $additional_data
700
+ *
701
+ * @return $this
702
+ */
703
+ public function setAdditionalData($additional_data)
704
+ {
705
+ $this->additional_data = $additional_data;
706
+ return $this;
707
+ }
708
+
709
+ /**
710
+ * Any miscellaneous invoice data. 4000 characters max.
711
+ *
712
+ * @return string
713
+ */
714
+ public function getAdditionalData()
715
+ {
716
+ return $this->additional_data;
717
+ }
718
+
719
+ /**
720
+ * Create a new invoice by passing the details for the invoice, including the merchant_info, to the request URI.
721
+ *
722
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
723
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
724
+ * @return Invoice
725
+ */
726
+ public function create($apiContext = null, $restCall = null)
727
+ {
728
+ $payLoad = $this->toJSON();
729
+ $json = self::executeCall(
730
+ "/v1/invoicing/invoices",
731
+ "POST",
732
+ $payLoad,
733
+ null,
734
+ $apiContext,
735
+ $restCall
736
+ );
737
+ $this->fromJson($json);
738
+ return $this;
739
+ }
740
+
741
+ /**
742
+ * Search for a specific invoice or invoices by passing a search object that specifies your search criteria to the request URI.
743
+ *
744
+ * @param Search $search
745
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
746
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
747
+ * @return InvoiceSearchResponse
748
+ */
749
+ public static function search($search, $apiContext = null, $restCall = null)
750
+ {
751
+ ArgumentValidator::validate($search, 'search');
752
+ $payLoad = $search->toJSON();
753
+ $json = self::executeCall(
754
+ "/v1/invoicing/search",
755
+ "POST",
756
+ $payLoad,
757
+ null,
758
+ $apiContext,
759
+ $restCall
760
+ );
761
+ $ret = new InvoiceSearchResponse();
762
+ $ret->fromJson($json);
763
+ return $ret;
764
+ }
765
+
766
+ /**
767
+ * Send a specific invoice to its intended recipient by passing the invoice ID to the request URI. Optionally, you can specify whether to send the merchant an invoice update notification by using the notify_merchant query parameter. By default, notify_merchant is true.
768
+ *
769
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
770
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
771
+ * @return bool
772
+ */
773
+ public function send($apiContext = null, $restCall = null)
774
+ {
775
+ ArgumentValidator::validate($this->getId(), "Id");
776
+ $payLoad = "";
777
+ self::executeCall(
778
+ "/v1/invoicing/invoices/{$this->getId()}/send",
779
+ "POST",
780
+ $payLoad,
781
+ null,
782
+ $apiContext,
783
+ $restCall
784
+ );
785
+ return true;
786
+ }
787
+
788
+ /**
789
+ * Send a reminder about a specific invoice to its intended recipient by providing the ID of the invoice in the request URI. In addition, pass a notification object that specifies the subject of the reminder and other details in the request JSON.
790
+ *
791
+ * @param Notification $notification
792
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
793
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
794
+ * @return bool
795
+ */
796
+ public function remind($notification, $apiContext = null, $restCall = null)
797
+ {
798
+ ArgumentValidator::validate($this->getId(), "Id");
799
+ ArgumentValidator::validate($notification, 'notification');
800
+ $payLoad = $notification->toJSON();
801
+ self::executeCall(
802
+ "/v1/invoicing/invoices/{$this->getId()}/remind",
803
+ "POST",
804
+ $payLoad,
805
+ null,
806
+ $apiContext,
807
+ $restCall
808
+ );
809
+ return true;
810
+ }
811
+
812
+ /**
813
+ * Cancel an invoice by passing the invoice ID to the request URI.
814
+ *
815
+ * @param CancelNotification $cancelNotification
816
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
817
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
818
+ * @return bool
819
+ */
820
+ public function cancel($cancelNotification, $apiContext = null, $restCall = null)
821
+ {
822
+ ArgumentValidator::validate($this->getId(), "Id");
823
+ ArgumentValidator::validate($cancelNotification, 'cancelNotification');
824
+ $payLoad = $cancelNotification->toJSON();
825
+ self::executeCall(
826
+ "/v1/invoicing/invoices/{$this->getId()}/cancel",
827
+ "POST",
828
+ $payLoad,
829
+ null,
830
+ $apiContext,
831
+ $restCall
832
+ );
833
+ return true;
834
+ }
835
+
836
+ /**
837
+ * Mark the status of an invoice as paid by passing the invoice ID to the request URI. In addition, pass a payment detail object that specifies the payment method and other details in the request JSON.
838
+ *
839
+ * @param PaymentDetail $paymentDetail
840
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
841
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
842
+ * @return bool
843
+ */
844
+ public function recordPayment($paymentDetail, $apiContext = null, $restCall = null)
845
+ {
846
+ ArgumentValidator::validate($this->getId(), "Id");
847
+ ArgumentValidator::validate($paymentDetail, 'paymentDetail');
848
+ $payLoad = $paymentDetail->toJSON();
849
+ self::executeCall(
850
+ "/v1/invoicing/invoices/{$this->getId()}/record-payment",
851
+ "POST",
852
+ $payLoad,
853
+ null,
854
+ $apiContext,
855
+ $restCall
856
+ );
857
+ return true;
858
+ }
859
+
860
+ /**
861
+ * Mark the status of an invoice as refunded by passing the invoice ID to the request URI. In addition, pass a refund-detail object that specifies the type of refund and other details in the request JSON.
862
+ *
863
+ * @param RefundDetail $refundDetail
864
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
865
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
866
+ * @return bool
867
+ */
868
+ public function recordRefund($refundDetail, $apiContext = null, $restCall = null)
869
+ {
870
+ ArgumentValidator::validate($this->getId(), "Id");
871
+ ArgumentValidator::validate($refundDetail, 'refundDetail');
872
+ $payLoad = $refundDetail->toJSON();
873
+ self::executeCall(
874
+ "/v1/invoicing/invoices/{$this->getId()}/record-refund",
875
+ "POST",
876
+ $payLoad,
877
+ null,
878
+ $apiContext,
879
+ $restCall
880
+ );
881
+ return true;
882
+ }
883
+
884
+ /**
885
+ * Retrieve the details for a particular invoice by passing the invoice ID to the request URI.
886
+ *
887
+ * @param string $invoiceId
888
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
889
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
890
+ * @return Invoice
891
+ */
892
+ public static function get($invoiceId, $apiContext = null, $restCall = null)
893
+ {
894
+ ArgumentValidator::validate($invoiceId, 'invoiceId');
895
+ $payLoad = "";
896
+ $json = self::executeCall(
897
+ "/v1/invoicing/invoices/$invoiceId",
898
+ "GET",
899
+ $payLoad,
900
+ null,
901
+ $apiContext,
902
+ $restCall
903
+ );
904
+ $ret = new Invoice();
905
+ $ret->fromJson($json);
906
+ return $ret;
907
+ }
908
+
909
+ /**
910
+ * List some or all invoices for a merchant according to optional query string parameters specified.
911
+ *
912
+ * @param array $params
913
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
914
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
915
+ * @return InvoiceSearchResponse
916
+ */
917
+ public static function getAll($params = array(), $apiContext = null, $restCall = null)
918
+ {
919
+ ArgumentValidator::validate($params, 'params');
920
+
921
+ $allowedParams = array(
922
+ 'page' => 1,
923
+ 'page_size' => 1,
924
+ 'total_count_required' => 1
925
+ );
926
+
927
+ $payLoad = "";
928
+ $json = self::executeCall(
929
+ "/v1/invoicing/invoices/?" . http_build_query(array_intersect_key($params, $allowedParams)),
930
+ "GET",
931
+ $payLoad,
932
+ null,
933
+ $apiContext,
934
+ $restCall
935
+ );
936
+ $ret = new InvoiceSearchResponse();
937
+ $ret->fromJson($json);
938
+ return $ret;
939
+ }
940
+
941
+ /**
942
+ * Fully update an invoice by passing the invoice ID to the request URI. In addition, pass a complete invoice object in the request JSON. Partial updates are not supported.
943
+ *
944
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
945
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
946
+ * @return Invoice
947
+ */
948
+ public function update($apiContext = null, $restCall = null)
949
+ {
950
+ ArgumentValidator::validate($this->getId(), "Id");
951
+ $payLoad = $this->toJSON();
952
+ $json = self::executeCall(
953
+ "/v1/invoicing/invoices/{$this->getId()}",
954
+ "PUT",
955
+ $payLoad,
956
+ null,
957
+ $apiContext,
958
+ $restCall
959
+ );
960
+ $this->fromJson($json);
961
+ return $this;
962
+ }
963
+
964
+ /**
965
+ * Delete a particular invoice by passing the invoice ID to the request URI.
966
+ *
967
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
968
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
969
+ * @return bool
970
+ */
971
+ public function delete($apiContext = null, $restCall = null)
972
+ {
973
+ ArgumentValidator::validate($this->getId(), "Id");
974
+ $payLoad = "";
975
+ self::executeCall(
976
+ "/v1/invoicing/invoices/{$this->getId()}",
977
+ "DELETE",
978
+ $payLoad,
979
+ null,
980
+ $apiContext,
981
+ $restCall
982
+ );
983
+ return true;
984
+ }
985
+
986
+ /**
987
+ * Generate a QR code for an invoice by passing the invoice ID to the request URI. The request generates a QR code that is 500 pixels in width and height. You can change the dimensions of the returned code by specifying optional query parameters.
988
+ *
989
+ * @param array $params
990
+ * @param string $invoiceId
991
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
992
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
993
+ * @return Image
994
+ */
995
+ public static function qrCode($invoiceId, $params = array(), $apiContext = null, $restCall = null)
996
+ {
997
+ ArgumentValidator::validate($invoiceId, 'invoiceId');
998
+ ArgumentValidator::validate($params, 'params');
999
+
1000
+ $allowedParams = array(
1001
+ 'width' => 1,
1002
+ 'height' => 1,
1003
+ 'action' => 1
1004
+ );
1005
+
1006
+ $payLoad = "";
1007
+ $json = self::executeCall(
1008
+ "/v1/invoicing/invoices/$invoiceId/qr-code?" . http_build_query(array_intersect_key($params, $allowedParams)),
1009
+ "GET",
1010
+ $payLoad,
1011
+ null,
1012
+ $apiContext,
1013
+ $restCall
1014
+ );
1015
+ $ret = new Image();
1016
+ $ret->fromJson($json);
1017
+ return $ret;
1018
+ }
1019
+
1020
+ }
lib/PayPal/Api/InvoiceAddress.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ /**
6
+ * Class InvoiceAddress
7
+ *
8
+ * Base Address object used as billing address in a payment or extended for Shipping Address.
9
+ *
10
+ * @package PayPal\Api
11
+ *
12
+ * @property \PayPal\Api\Phone phone
13
+ */
14
+ class InvoiceAddress extends BaseAddress
15
+ {
16
+ /**
17
+ * Phone number in E.123 format.
18
+ *
19
+ * @param \PayPal\Api\Phone $phone
20
+ *
21
+ * @return $this
22
+ */
23
+ public function setPhone($phone)
24
+ {
25
+ $this->phone = $phone;
26
+ return $this;
27
+ }
28
+
29
+ /**
30
+ * Phone number in E.123 format.
31
+ *
32
+ * @return \PayPal\Api\Phone
33
+ */
34
+ public function getPhone()
35
+ {
36
+ return $this->phone;
37
+ }
38
+
39
+ }
lib/PayPal/Api/InvoiceItem.php ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+ use PayPal\Converter\FormatConverter;
7
+ use PayPal\Validation\NumericValidator;
8
+
9
+ /**
10
+ * Class InvoiceItem
11
+ *
12
+ * Information about a single line item.
13
+ *
14
+ * @package PayPal\Api
15
+ *
16
+ * @property string name
17
+ * @property string description
18
+ * @property \PayPal\Api\number quantity
19
+ * @property \PayPal\Api\Currency unit_price
20
+ * @property \PayPal\Api\Tax tax
21
+ * @property string date
22
+ * @property \PayPal\Api\Cost discount
23
+ */
24
+ class InvoiceItem extends PayPalModel
25
+ {
26
+ /**
27
+ * Name of the item. 60 characters max.
28
+ *
29
+ * @param string $name
30
+ *
31
+ * @return $this
32
+ */
33
+ public function setName($name)
34
+ {
35
+ $this->name = $name;
36
+ return $this;
37
+ }
38
+
39
+ /**
40
+ * Name of the item. 60 characters max.
41
+ *
42
+ * @return string
43
+ */
44
+ public function getName()
45
+ {
46
+ return $this->name;
47
+ }
48
+
49
+ /**
50
+ * Description of the item. 1000 characters max.
51
+ *
52
+ * @param string $description
53
+ *
54
+ * @return $this
55
+ */
56
+ public function setDescription($description)
57
+ {
58
+ $this->description = $description;
59
+ return $this;
60
+ }
61
+
62
+ /**
63
+ * Description of the item. 1000 characters max.
64
+ *
65
+ * @return string
66
+ */
67
+ public function getDescription()
68
+ {
69
+ return $this->description;
70
+ }
71
+
72
+ /**
73
+ * Quantity of the item. Range of 0 to 9999.999.
74
+ *
75
+ * @param string|double $quantity
76
+ *
77
+ * @return $this
78
+ */
79
+ public function setQuantity($quantity)
80
+ {
81
+ NumericValidator::validate($quantity, "Percent");
82
+ $quantity = FormatConverter::formatToPrice($quantity);
83
+ $this->quantity = $quantity;
84
+ return $this;
85
+ }
86
+
87
+ /**
88
+ * Quantity of the item. Range of 0 to 9999.999.
89
+ *
90
+ * @return string
91
+ */
92
+ public function getQuantity()
93
+ {
94
+ return $this->quantity;
95
+ }
96
+
97
+ /**
98
+ * Unit price of the item. Range of -999999.99 to 999999.99.
99
+ *
100
+ * @param \PayPal\Api\Currency $unit_price
101
+ *
102
+ * @return $this
103
+ */
104
+ public function setUnitPrice($unit_price)
105
+ {
106
+ $this->unit_price = $unit_price;
107
+ return $this;
108
+ }
109
+
110
+ /**
111
+ * Unit price of the item. Range of -999999.99 to 999999.99.
112
+ *
113
+ * @return \PayPal\Api\Currency
114
+ */
115
+ public function getUnitPrice()
116
+ {
117
+ return $this->unit_price;
118
+ }
119
+
120
+ /**
121
+ * Tax associated with the item.
122
+ *
123
+ * @param \PayPal\Api\Tax $tax
124
+ *
125
+ * @return $this
126
+ */
127
+ public function setTax($tax)
128
+ {
129
+ $this->tax = $tax;
130
+ return $this;
131
+ }
132
+
133
+ /**
134
+ * Tax associated with the item.
135
+ *
136
+ * @return \PayPal\Api\Tax
137
+ */
138
+ public function getTax()
139
+ {
140
+ return $this->tax;
141
+ }
142
+
143
+ /**
144
+ * Date on which the item or service was provided. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
145
+ *
146
+ * @param string $date
147
+ *
148
+ * @return $this
149
+ */
150
+ public function setDate($date)
151
+ {
152
+ $this->date = $date;
153
+ return $this;
154
+ }
155
+
156
+ /**
157
+ * Date on which the item or service was provided. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
158
+ *
159
+ * @return string
160
+ */
161
+ public function getDate()
162
+ {
163
+ return $this->date;
164
+ }
165
+
166
+ /**
167
+ * Item discount in percent or amount.
168
+ *
169
+ * @param \PayPal\Api\Cost $discount
170
+ *
171
+ * @return $this
172
+ */
173
+ public function setDiscount($discount)
174
+ {
175
+ $this->discount = $discount;
176
+ return $this;
177
+ }
178
+
179
+ /**
180
+ * Item discount in percent or amount.
181
+ *
182
+ * @return \PayPal\Api\Cost
183
+ */
184
+ public function getDiscount()
185
+ {
186
+ return $this->discount;
187
+ }
188
+
189
+ }
lib/PayPal/Api/InvoiceSearchResponse.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class InvoiceSearchResponse
9
+ *
10
+ *
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property int total_count
15
+ * @property \PayPal\Api\Invoice[] invoices
16
+ */
17
+ class InvoiceSearchResponse extends PayPalModel
18
+ {
19
+ /**
20
+ * Total number of invoices.
21
+ *
22
+ * @param int $total_count
23
+ *
24
+ * @return $this
25
+ */
26
+ public function setTotalCount($total_count)
27
+ {
28
+ $this->total_count = $total_count;
29
+ return $this;
30
+ }
31
+
32
+ /**
33
+ * Total number of invoices.
34
+ *
35
+ * @return int
36
+ */
37
+ public function getTotalCount()
38
+ {
39
+ return $this->total_count;
40
+ }
41
+
42
+ /**
43
+ * List of invoices belonging to a merchant.
44
+ *
45
+ * @param \PayPal\Api\Invoice[] $invoices
46
+ *
47
+ * @return $this
48
+ */
49
+ public function setInvoices($invoices)
50
+ {
51
+ $this->invoices = $invoices;
52
+ return $this;
53
+ }
54
+
55
+ /**
56
+ * List of invoices belonging to a merchant.
57
+ *
58
+ * @return \PayPal\Api\Invoice[]
59
+ */
60
+ public function getInvoices()
61
+ {
62
+ return $this->invoices;
63
+ }
64
+
65
+ /**
66
+ * Append Invoices to the list.
67
+ *
68
+ * @param \PayPal\Api\Invoice $invoice
69
+ * @return $this
70
+ */
71
+ public function addInvoice($invoice)
72
+ {
73
+ if (!$this->getInvoices()) {
74
+ return $this->setInvoices(array($invoice));
75
+ } else {
76
+ return $this->setInvoices(
77
+ array_merge($this->getInvoices(), array($invoice))
78
+ );
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Remove Invoices from the list.
84
+ *
85
+ * @param \PayPal\Api\Invoice $invoice
86
+ * @return $this
87
+ */
88
+ public function removeInvoice($invoice)
89
+ {
90
+ return $this->setInvoices(
91
+ array_diff($this->getInvoices(), array($invoice))
92
+ );
93
+ }
94
+
95
+ }
lib/PayPal/Api/Item.php ADDED
@@ -0,0 +1,456 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+ use PayPal\Converter\FormatConverter;
7
+ use PayPal\Validation\NumericValidator;
8
+ use PayPal\Validation\UrlValidator;
9
+
10
+ /**
11
+ * Class Item
12
+ *
13
+ * Item details.
14
+ *
15
+ * @package PayPal\Api
16
+ *
17
+ * @property string sku
18
+ * @property string name
19
+ * @property string description
20
+ * @property string quantity
21
+ * @property string price
22
+ * @property string currency
23
+ * @property string tax
24
+ * @property string url
25
+ * @property string category
26
+ */
27
+ class Item extends PayPalModel
28
+ {
29
+ /**
30
+ * Stock keeping unit corresponding (SKU) to item.
31
+ *
32
+ * @param string $sku
33
+ *
34
+ * @return $this
35
+ */
36
+ public function setSku($sku)
37
+ {
38
+ $this->sku = $sku;
39
+ return $this;
40
+ }
41
+
42
+ /**
43
+ * Stock keeping unit corresponding (SKU) to item.
44
+ *
45
+ * @return string
46
+ */
47
+ public function getSku()
48
+ {
49
+ return $this->sku;
50
+ }
51
+
52
+ /**
53
+ * Item name. 127 characters max.
54
+ *
55
+ * @param string $name
56
+ *
57
+ * @return $this
58
+ */
59
+ public function setName($name)
60
+ {
61
+ $this->name = $name;
62
+ return $this;
63
+ }
64
+
65
+ /**
66
+ * Item name. 127 characters max.
67
+ *
68
+ * @return string
69
+ */
70
+ public function getName()
71
+ {
72
+ return $this->name;
73
+ }
74
+
75
+ /**
76
+ * Description of the item. Only supported when the `payment_method` is set to `paypal`.
77
+ *
78
+ * @param string $description
79
+ *
80
+ * @return $this
81
+ */
82
+ public function setDescription($description)
83
+ {
84
+ $this->description = $description;
85
+ return $this;
86
+ }
87
+
88
+ /**
89
+ * Description of the item. Only supported when the `payment_method` is set to `paypal`.
90
+ *
91
+ * @return string
92
+ */
93
+ public function getDescription()
94
+ {
95
+ return $this->description;
96
+ }
97
+
98
+ /**
99
+ * Number of a particular item. 10 characters max.
100
+ *
101
+ * @param string $quantity
102
+ *
103
+ * @return $this
104
+ */
105
+ public function setQuantity($quantity)
106
+ {
107
+ $this->quantity = $quantity;
108
+ return $this;
109
+ }
110
+
111
+ /**
112
+ * Number of a particular item. 10 characters max.
113
+ *
114
+ * @return string
115
+ */
116
+ public function getQuantity()
117
+ {
118
+ return $this->quantity;
119
+ }
120
+
121
+ /**
122
+ * Item cost. 10 characters max.
123
+ *
124
+ * @param string|double $price
125
+ *
126
+ * @return $this
127
+ */
128
+ public function setPrice($price)
129
+ {
130
+ NumericValidator::validate($price, "Price");
131
+ $price = FormatConverter::formatToPrice($price, $this->getCurrency());
132
+ $this->price = $price;
133
+ return $this;
134
+ }
135
+
136
+ /**
137
+ * Item cost. 10 characters max.
138
+ *
139
+ * @return string
140
+ */
141
+ public function getPrice()
142
+ {
143
+ return $this->price;
144
+ }
145
+
146
+ /**
147
+ * 3-letter [currency code](https://developer.paypal.com/docs/integration/direct/rest_api_payment_country_currency_support/).
148
+ *
149
+ * @param string $currency
150
+ *
151
+ * @return $this
152
+ */
153
+ public function setCurrency($currency)
154
+ {
155
+ $this->currency = $currency;
156
+ return $this;
157
+ }
158
+
159
+ /**
160
+ * 3-letter [currency code](https://developer.paypal.com/docs/integration/direct/rest_api_payment_country_currency_support/).
161
+ *
162
+ * @return string
163
+ */
164
+ public function getCurrency()
165
+ {
166
+ return $this->currency;
167
+ }
168
+
169
+ /**
170
+ * Tax of the item. Only supported when the `payment_method` is set to `paypal`.
171
+ *
172
+ * @param string|double $tax
173
+ *
174
+ * @return $this
175
+ */
176
+ public function setTax($tax)
177
+ {
178
+ NumericValidator::validate($tax, "Tax");
179
+ $tax = FormatConverter::formatToPrice($tax, $this->getCurrency());
180
+ $this->tax = $tax;
181
+ return $this;
182
+ }
183
+
184
+ /**
185
+ * Tax of the item. Only supported when the `payment_method` is set to `paypal`.
186
+ *
187
+ * @return string
188
+ */
189
+ public function getTax()
190
+ {
191
+ return $this->tax;
192
+ }
193
+
194
+ /**
195
+ * URL linking to item information. Available to payer in transaction history.
196
+ *
197
+ * @param string $url
198
+ * @throws \InvalidArgumentException
199
+ * @return $this
200
+ */
201
+ public function setUrl($url)
202
+ {
203
+ UrlValidator::validate($url, "Url");
204
+ $this->url = $url;
205
+ return $this;
206
+ }
207
+
208
+ /**
209
+ * URL linking to item information. Available to payer in transaction history.
210
+ *
211
+ * @return string
212
+ */
213
+ public function getUrl()
214
+ {
215
+ return $this->url;
216
+ }
217
+
218
+ /**
219
+ * Category type of the item.
220
+ * Valid Values: ["DIGITAL", "PHYSICAL"]
221
+ *
222
+ * @param string $category
223
+ *
224
+ * @return $this
225
+ */
226
+ public function setCategory($category)
227
+ {
228
+ $this->category = $category;
229
+ return $this;
230
+ }
231
+
232
+ /**
233
+ * Category type of the item.
234
+ *
235
+ * @return string
236
+ */
237
+ public function getCategory()
238
+ {
239
+ return $this->category;
240
+ }
241
+
242
+ /**
243
+ * Weight of the item.
244
+ *
245
+ * @deprecated Not publicly available
246
+ * @param \PayPal\Api\Measurement $weight
247
+ *
248
+ * @return $this
249
+ */
250
+ public function setWeight($weight)
251
+ {
252
+ $this->weight = $weight;
253
+ return $this;
254
+ }
255
+
256
+ /**
257
+ * Weight of the item.
258
+ *
259
+ * @deprecated Not publicly available
260
+ * @return \PayPal\Api\Measurement
261
+ */
262
+ public function getWeight()
263
+ {
264
+ return $this->weight;
265
+ }
266
+
267
+ /**
268
+ * Length of the item.
269
+ *
270
+ * @deprecated Not publicly available
271
+ * @param \PayPal\Api\Measurement $length
272
+ *
273
+ * @return $this
274
+ */
275
+ public function setLength($length)
276
+ {
277
+ $this->length = $length;
278
+ return $this;
279
+ }
280
+
281
+ /**
282
+ * Length of the item.
283
+ *
284
+ * @deprecated Not publicly available
285
+ * @return \PayPal\Api\Measurement
286
+ */
287
+ public function getLength()
288
+ {
289
+ return $this->length;
290
+ }
291
+
292
+ /**
293
+ * Height of the item.
294
+ *
295
+ * @deprecated Not publicly available
296
+ * @param \PayPal\Api\Measurement $height
297
+ *
298
+ * @return $this
299
+ */
300
+ public function setHeight($height)
301
+ {
302
+ $this->height = $height;
303
+ return $this;
304
+ }
305
+
306
+ /**
307
+ * Height of the item.
308
+ *
309
+ * @deprecated Not publicly available
310
+ * @return \PayPal\Api\Measurement
311
+ */
312
+ public function getHeight()
313
+ {
314
+ return $this->height;
315
+ }
316
+
317
+ /**
318
+ * Width of the item.
319
+ *
320
+ * @deprecated Not publicly available
321
+ * @param \PayPal\Api\Measurement $width
322
+ *
323
+ * @return $this
324
+ */
325
+ public function setWidth($width)
326
+ {
327
+ $this->width = $width;
328
+ return $this;
329
+ }
330
+
331
+ /**
332
+ * Width of the item.
333
+ *
334
+ * @deprecated Not publicly available
335
+ * @return \PayPal\Api\Measurement
336
+ */
337
+ public function getWidth()
338
+ {
339
+ return $this->width;
340
+ }
341
+
342
+ /**
343
+ * Set of optional data used for PayPal risk determination.
344
+ *
345
+ * @deprecated Not publicly available
346
+ * @param \PayPal\Api\NameValuePair[] $supplementary_data
347
+ *
348
+ * @return $this
349
+ */
350
+ public function setSupplementaryData($supplementary_data)
351
+ {
352
+ $this->supplementary_data = $supplementary_data;
353
+ return $this;
354
+ }
355
+
356
+ /**
357
+ * Set of optional data used for PayPal risk determination.
358
+ *
359
+ * @deprecated Not publicly available
360
+ * @return \PayPal\Api\NameValuePair[]
361
+ */
362
+ public function getSupplementaryData()
363
+ {
364
+ return $this->supplementary_data;
365
+ }
366
+
367
+ /**
368
+ * Append SupplementaryData to the list.
369
+ *
370
+ * @deprecated Not publicly available
371
+ * @param \PayPal\Api\NameValuePair $nameValuePair
372
+ * @return $this
373
+ */
374
+ public function addSupplementaryData($nameValuePair)
375
+ {
376
+ if (!$this->getSupplementaryData()) {
377
+ return $this->setSupplementaryData(array($nameValuePair));
378
+ } else {
379
+ return $this->setSupplementaryData(
380
+ array_merge($this->getSupplementaryData(), array($nameValuePair))
381
+ );
382
+ }
383
+ }
384
+
385
+ /**
386
+ * Remove SupplementaryData from the list.
387
+ *
388
+ * @deprecated Not publicly available
389
+ * @param \PayPal\Api\NameValuePair $nameValuePair
390
+ * @return $this
391
+ */
392
+ public function removeSupplementaryData($nameValuePair)
393
+ {
394
+ return $this->setSupplementaryData(
395
+ array_diff($this->getSupplementaryData(), array($nameValuePair))
396
+ );
397
+ }
398
+
399
+ /**
400
+ * Set of optional data used for PayPal post-transaction notifications.
401
+ *
402
+ * @deprecated Not publicly available
403
+ * @param \PayPal\Api\NameValuePair[] $postback_data
404
+ *
405
+ * @return $this
406
+ */
407
+ public function setPostbackData($postback_data)
408
+ {
409
+ $this->postback_data = $postback_data;
410
+ return $this;
411
+ }
412
+
413
+ /**
414
+ * Set of optional data used for PayPal post-transaction notifications.
415
+ *
416
+ * @deprecated Not publicly available
417
+ * @return \PayPal\Api\NameValuePair[]
418
+ */
419
+ public function getPostbackData()
420
+ {
421
+ return $this->postback_data;
422
+ }
423
+
424
+ /**
425
+ * Append PostbackData to the list.
426
+ *
427
+ * @deprecated Not publicly available
428
+ * @param \PayPal\Api\NameValuePair $nameValuePair
429
+ * @return $this
430
+ */
431
+ public function addPostbackData($nameValuePair)
432
+ {
433
+ if (!$this->getPostbackData()) {
434
+ return $this->setPostbackData(array($nameValuePair));
435
+ } else {
436
+ return $this->setPostbackData(
437
+ array_merge($this->getPostbackData(), array($nameValuePair))
438
+ );
439
+ }
440
+ }
441
+
442
+ /**
443
+ * Remove PostbackData from the list.
444
+ *
445
+ * @deprecated Not publicly available
446
+ * @param \PayPal\Api\NameValuePair $nameValuePair
447
+ * @return $this
448
+ */
449
+ public function removePostbackData($nameValuePair)
450
+ {
451
+ return $this->setPostbackData(
452
+ array_diff($this->getPostbackData(), array($nameValuePair))
453
+ );
454
+ }
455
+
456
+ }
lib/PayPal/Api/ItemList.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class ItemList
9
+ *
10
+ * Items and related shipping address within a transaction.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property \PayPal\Api\Item[] items
15
+ * @property \PayPal\Api\ShippingAddress shipping_address
16
+ * @property string shipping_method
17
+ * @property string shipping_phone_number
18
+ */
19
+ class ItemList extends PayPalModel
20
+ {
21
+ /**
22
+ * List of items.
23
+ *
24
+ * @param \PayPal\Api\Item[] $items
25
+ *
26
+ * @return $this
27
+ */
28
+ public function setItems($items)
29
+ {
30
+ $this->items = $items;
31
+ return $this;
32
+ }
33
+
34
+ /**
35
+ * List of items.
36
+ *
37
+ * @return \PayPal\Api\Item[]
38
+ */
39
+ public function getItems()
40
+ {
41
+ return $this->items;
42
+ }
43
+
44
+ /**
45
+ * Append Items to the list.
46
+ *
47
+ * @param \PayPal\Api\Item $item
48
+ * @return $this
49
+ */
50
+ public function addItem($item)
51
+ {
52
+ if (!$this->getItems()) {
53
+ return $this->setItems(array($item));
54
+ } else {
55
+ return $this->setItems(
56
+ array_merge($this->getItems(), array($item))
57
+ );
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Remove Items from the list.
63
+ *
64
+ * @param \PayPal\Api\Item $item
65
+ * @return $this
66
+ */
67
+ public function removeItem($item)
68
+ {
69
+ return $this->setItems(
70
+ array_diff($this->getItems(), array($item))
71
+ );
72
+ }
73
+
74
+ /**
75
+ * Shipping address, if different than the payer address.
76
+ *
77
+ * @param \PayPal\Api\ShippingAddress $shipping_address
78
+ *
79
+ * @return $this
80
+ */
81
+ public function setShippingAddress($shipping_address)
82
+ {
83
+ $this->shipping_address = $shipping_address;
84
+ return $this;
85
+ }
86
+
87
+ /**
88
+ * Shipping address, if different than the payer address.
89
+ *
90
+ * @return \PayPal\Api\ShippingAddress
91
+ */
92
+ public function getShippingAddress()
93
+ {
94
+ return $this->shipping_address;
95
+ }
96
+
97
+ /**
98
+ * Shipping method used for this payment like USPSParcel etc.
99
+ *
100
+ * @param string $shipping_method
101
+ *
102
+ * @return $this
103
+ */
104
+ public function setShippingMethod($shipping_method)
105
+ {
106
+ $this->shipping_method = $shipping_method;
107
+ return $this;
108
+ }
109
+
110
+ /**
111
+ * Shipping method used for this payment like USPSParcel etc.
112
+ *
113
+ * @return string
114
+ */
115
+ public function getShippingMethod()
116
+ {
117
+ return $this->shipping_method;
118
+ }
119
+
120
+ /**
121
+ * Allows merchant's to share payer’s contact number with PayPal for the current payment. Final contact number of payer associated with the transaction might be same as shipping_phone_number or different based on Payer’s action on PayPal. The phone number must be represented in its canonical international format, as defined by the E.164 numbering plan
122
+ *
123
+ * @param string $shipping_phone_number
124
+ *
125
+ * @return $this
126
+ */
127
+ public function setShippingPhoneNumber($shipping_phone_number)
128
+ {
129
+ $this->shipping_phone_number = $shipping_phone_number;
130
+ return $this;
131
+ }
132
+
133
+ /**
134
+ * Allows merchant's to share payer’s contact number with PayPal for the current payment. Final contact number of payer associated with the transaction might be same as shipping_phone_number or different based on Payer’s action on PayPal. The phone number must be represented in its canonical international format, as defined by the E.164 numbering plan
135
+ *
136
+ * @return string
137
+ */
138
+ public function getShippingPhoneNumber()
139
+ {
140
+ return $this->shipping_phone_number;
141
+ }
142
+
143
+ }
lib/PayPal/Api/Links.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class Links
9
+ *
10
+ *
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string href
15
+ * @property string rel
16
+ * @property \PayPal\Api\HyperSchema targetSchema
17
+ * @property string method
18
+ * @property string enctype
19
+ * @property \PayPal\Api\HyperSchema schema
20
+ */
21
+ class Links extends PayPalModel
22
+ {
23
+ /**
24
+ * Sets Href
25
+ *
26
+ * @param string $href
27
+ *
28
+ * @return $this
29
+ */
30
+ public function setHref($href)
31
+ {
32
+ $this->href = $href;
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * Gets Href
38
+ *
39
+ * @return string
40
+ */
41
+ public function getHref()
42
+ {
43
+ return $this->href;
44
+ }
45
+
46
+ /**
47
+ * Sets Rel
48
+ *
49
+ * @param string $rel
50
+ *
51
+ * @return $this
52
+ */
53
+ public function setRel($rel)
54
+ {
55
+ $this->rel = $rel;
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * Gets Rel
61
+ *
62
+ * @return string
63
+ */
64
+ public function getRel()
65
+ {
66
+ return $this->rel;
67
+ }
68
+
69
+ /**
70
+ * Sets TargetSchema
71
+ *
72
+ * @param \PayPal\Api\HyperSchema $targetSchema
73
+ *
74
+ * @return $this
75
+ */
76
+ public function setTargetSchema($targetSchema)
77
+ {
78
+ $this->targetSchema = $targetSchema;
79
+ return $this;
80
+ }
81
+
82
+ /**
83
+ * Gets TargetSchema
84
+ *
85
+ * @return \PayPal\Api\HyperSchema
86
+ */
87
+ public function getTargetSchema()
88
+ {
89
+ return $this->targetSchema;
90
+ }
91
+
92
+ /**
93
+ * Sets Method
94
+ *
95
+ * @param string $method
96
+ *
97
+ * @return $this
98
+ */
99
+ public function setMethod($method)
100
+ {
101
+ $this->method = $method;
102
+ return $this;
103
+ }
104
+
105
+ /**
106
+ * Gets Method
107
+ *
108
+ * @return string
109
+ */
110
+ public function getMethod()
111
+ {
112
+ return $this->method;
113
+ }
114
+
115
+ /**
116
+ * Sets Enctype
117
+ *
118
+ * @param string $enctype
119
+ *
120
+ * @return $this
121
+ */
122
+ public function setEnctype($enctype)
123
+ {
124
+ $this->enctype = $enctype;
125
+ return $this;
126
+ }
127
+
128
+ /**
129
+ * Gets Enctype
130
+ *
131
+ * @return string
132
+ */
133
+ public function getEnctype()
134
+ {
135
+ return $this->enctype;
136
+ }
137
+
138
+ /**
139
+ * Sets Schema
140
+ *
141
+ * @param \PayPal\Api\HyperSchema $schema
142
+ *
143
+ * @return $this
144
+ */
145
+ public function setSchema($schema)
146
+ {
147
+ $this->schema = $schema;
148
+ return $this;
149
+ }
150
+
151
+ /**
152
+ * Gets Schema
153
+ *
154
+ * @return \PayPal\Api\HyperSchema
155
+ */
156
+ public function getSchema()
157
+ {
158
+ return $this->schema;
159
+ }
160
+
161
+ }
lib/PayPal/Api/Measurement.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class Measurement
9
+ *
10
+ * Measurement to represent item dimensions like length, width, height and weight etc.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string value
15
+ * @property string unit
16
+ */
17
+ class Measurement extends PayPalModel
18
+ {
19
+ /**
20
+ * Value this measurement represents.
21
+ *
22
+ * @param string $value
23
+ *
24
+ * @return $this
25
+ */
26
+ public function setValue($value)
27
+ {
28
+ $this->value = $value;
29
+ return $this;
30
+ }
31
+
32
+ /**
33
+ * Value this measurement represents.
34
+ *
35
+ * @return string
36
+ */
37
+ public function getValue()
38
+ {
39
+ return $this->value;
40
+ }
41
+
42
+ /**
43
+ * Unit in which the value is represented.
44
+ *
45
+ * @param string $unit
46
+ *
47
+ * @return $this
48
+ */
49
+ public function setUnit($unit)
50
+ {
51
+ $this->unit = $unit;
52
+ return $this;
53
+ }
54
+
55
+ /**
56
+ * Unit in which the value is represented.
57
+ *
58
+ * @return string
59
+ */
60
+ public function getUnit()
61
+ {
62
+ return $this->unit;
63
+ }
64
+
65
+ }
lib/PayPal/Api/MerchantInfo.php ADDED
@@ -0,0 +1,257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class MerchantInfo
9
+ *
10
+ * Business information of the merchant that will appear on the invoice.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string email
15
+ * @property string first_name
16
+ * @property string last_name
17
+ * @property \PayPal\Api\InvoiceAddress address
18
+ * @property string business_name
19
+ * @property \PayPal\Api\Phone phone
20
+ * @property \PayPal\Api\Phone fax
21
+ * @property string website
22
+ * @property string tax_id
23
+ * @property string additional_info
24
+ */
25
+ class MerchantInfo extends PayPalModel
26
+ {
27
+ /**
28
+ * Email address of the merchant. 260 characters max.
29
+ *
30
+ * @param string $email
31
+ *
32
+ * @return $this
33
+ */
34
+ public function setEmail($email)
35
+ {
36
+ $this->email = $email;
37
+ return $this;
38
+ }
39
+
40
+ /**
41
+ * Email address of the merchant. 260 characters max.
42
+ *
43
+ * @return string
44
+ */
45
+ public function getEmail()
46
+ {
47
+ return $this->email;
48
+ }
49
+
50
+ /**
51
+ * First name of the merchant. 30 characters max.
52
+ *
53
+ * @param string $first_name
54
+ *
55
+ * @return $this
56
+ */
57
+ public function setFirstName($first_name)
58
+ {
59
+ $this->first_name = $first_name;
60
+ return $this;
61
+ }
62
+
63
+ /**
64
+ * First name of the merchant. 30 characters max.
65
+ *
66
+ * @return string
67
+ */
68
+ public function getFirstName()
69
+ {
70
+ return $this->first_name;
71
+ }
72
+
73
+ /**
74
+ * Last name of the merchant. 30 characters max.
75
+ *
76
+ * @param string $last_name
77
+ *
78
+ * @return $this
79
+ */
80
+ public function setLastName($last_name)
81
+ {
82
+ $this->last_name = $last_name;
83
+ return $this;
84
+ }
85
+
86
+ /**
87
+ * Last name of the merchant. 30 characters max.
88
+ *
89
+ * @return string
90
+ */
91
+ public function getLastName()
92
+ {
93
+ return $this->last_name;
94
+ }
95
+
96
+ /**
97
+ * Address of the merchant.
98
+ *
99
+ * @param \PayPal\Api\InvoiceAddress $address
100
+ *
101
+ * @return $this
102
+ */
103
+ public function setAddress($address)
104
+ {
105
+ $this->address = $address;
106
+ return $this;
107
+ }
108
+
109
+ /**
110
+ * Address of the merchant.
111
+ *
112
+ * @return \PayPal\Api\InvoiceAddress
113
+ */
114
+ public function getAddress()
115
+ {
116
+ return $this->address;
117
+ }
118
+
119
+ /**
120
+ * Company business name of the merchant. 100 characters max.
121
+ *
122
+ * @param string $business_name
123
+ *
124
+ * @return $this
125
+ */
126
+ public function setBusinessName($business_name)
127
+ {
128
+ $this->business_name = $business_name;
129
+ return $this;
130
+ }
131
+
132
+ /**
133
+ * Company business name of the merchant. 100 characters max.
134
+ *
135
+ * @return string
136
+ */
137
+ public function getBusinessName()
138
+ {
139
+ return $this->business_name;
140
+ }
141
+
142
+ /**
143
+ * Phone number of the merchant.
144
+ *
145
+ * @param \PayPal\Api\Phone $phone
146
+ *
147
+ * @return $this
148
+ */
149
+ public function setPhone($phone)
150
+ {
151
+ $this->phone = $phone;
152
+ return $this;
153
+ }
154
+
155
+ /**
156
+ * Phone number of the merchant.
157
+ *
158
+ * @return \PayPal\Api\Phone
159
+ */
160
+ public function getPhone()
161
+ {
162
+ return $this->phone;
163
+ }
164
+
165
+ /**
166
+ * Fax number of the merchant.
167
+ *
168
+ * @param \PayPal\Api\Phone $fax
169
+ *
170
+ * @return $this
171
+ */
172
+ public function setFax($fax)
173
+ {
174
+ $this->fax = $fax;
175
+ return $this;
176
+ }
177
+
178
+ /**
179
+ * Fax number of the merchant.
180
+ *
181
+ * @return \PayPal\Api\Phone
182
+ */
183
+ public function getFax()
184
+ {
185
+ return $this->fax;
186
+ }
187
+
188
+ /**
189
+ * Website of the merchant. 2048 characters max.
190
+ *
191
+ * @param string $website
192
+ *
193
+ * @return $this
194
+ */
195
+ public function setWebsite($website)
196
+ {
197
+ $this->website = $website;
198
+ return $this;
199
+ }
200
+
201
+ /**
202
+ * Website of the merchant. 2048 characters max.
203
+ *
204
+ * @return string
205
+ */
206
+ public function getWebsite()
207
+ {
208
+ return $this->website;
209
+ }
210
+
211
+ /**
212
+ * Tax ID of the merchant. 100 characters max.
213
+ *
214
+ * @param string $tax_id
215
+ *
216
+ * @return $this
217
+ */
218
+ public function setTaxId($tax_id)
219
+ {
220
+ $this->tax_id = $tax_id;
221
+ return $this;
222
+ }
223
+
224
+ /**
225
+ * Tax ID of the merchant. 100 characters max.
226
+ *
227
+ * @return string
228
+ */
229
+ public function getTaxId()
230
+ {
231
+ return $this->tax_id;
232
+ }
233
+
234
+ /**
235
+ * Option to display additional information such as business hours. 40 characters max.
236
+ *
237
+ * @param string $additional_info
238
+ *
239
+ * @return $this
240
+ */
241
+ public function setAdditionalInfo($additional_info)
242
+ {
243
+ $this->additional_info = $additional_info;
244
+ return $this;
245
+ }
246
+
247
+ /**
248
+ * Option to display additional information such as business hours. 40 characters max.
249
+ *
250
+ * @return string
251
+ */
252
+ public function getAdditionalInfo()
253
+ {
254
+ return $this->additional_info;
255
+ }
256
+
257
+ }
lib/PayPal/Api/MerchantPreferences.php ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+ use PayPal\Validation\UrlValidator;
7
+
8
+ /**
9
+ * Class MerchantPreferences
10
+ *
11
+ * Resource representing merchant preferences like max failed attempts, set up fee and others for a plan.
12
+ *
13
+ * @package PayPal\Api
14
+ *
15
+ * @property string id
16
+ * @property \PayPal\Api\Currency setup_fee
17
+ * @property string cancel_url
18
+ * @property string return_url
19
+ * @property string notify_url
20
+ * @property string max_fail_attempts
21
+ * @property string auto_bill_amount
22
+ * @property string initial_fail_amount_action
23
+ * @property string accepted_payment_type
24
+ * @property string char_set
25
+ */
26
+ class MerchantPreferences extends PayPalModel
27
+ {
28
+ /**
29
+ * Identifier of the merchant_preferences. 128 characters max.
30
+ *
31
+ * @param string $id
32
+ *
33
+ * @return $this
34
+ */
35
+ public function setId($id)
36
+ {
37
+ $this->id = $id;
38
+ return $this;
39
+ }
40
+
41
+ /**
42
+ * Identifier of the merchant_preferences. 128 characters max.
43
+ *
44
+ * @return string
45
+ */
46
+ public function getId()
47
+ {
48
+ return $this->id;
49
+ }
50
+
51
+ /**
52
+ * Setup fee amount. Default is 0.
53
+ *
54
+ * @param \PayPal\Api\Currency $setup_fee
55
+ *
56
+ * @return $this
57
+ */
58
+ public function setSetupFee($setup_fee)
59
+ {
60
+ $this->setup_fee = $setup_fee;
61
+ return $this;
62
+ }
63
+
64
+ /**
65
+ * Setup fee amount. Default is 0.
66
+ *
67
+ * @return \PayPal\Api\Currency
68
+ */
69
+ public function getSetupFee()
70
+ {
71
+ return $this->setup_fee;
72
+ }
73
+
74
+ /**
75
+ * Redirect URL on cancellation of agreement request. 1000 characters max.
76
+ *
77
+ * @param string $cancel_url
78
+ * @throws \InvalidArgumentException
79
+ * @return $this
80
+ */
81
+ public function setCancelUrl($cancel_url)
82
+ {
83
+ UrlValidator::validate($cancel_url, "CancelUrl");
84
+ $this->cancel_url = $cancel_url;
85
+ return $this;
86
+ }
87
+
88
+ /**
89
+ * Redirect URL on cancellation of agreement request. 1000 characters max.
90
+ *
91
+ * @return string
92
+ */
93
+ public function getCancelUrl()
94
+ {
95
+ return $this->cancel_url;
96
+ }
97
+
98
+ /**
99
+ * Redirect URL on creation of agreement request. 1000 characters max.
100
+ *
101
+ * @param string $return_url
102
+ * @throws \InvalidArgumentException
103
+ * @return $this
104
+ */
105
+ public function setReturnUrl($return_url)
106
+ {
107
+ UrlValidator::validate($return_url, "ReturnUrl");
108
+ $this->return_url = $return_url;
109
+ return $this;
110
+ }
111
+
112
+ /**
113
+ * Redirect URL on creation of agreement request. 1000 characters max.
114
+ *
115
+ * @return string
116
+ */
117
+ public function getReturnUrl()
118
+ {
119
+ return $this->return_url;
120
+ }
121
+
122
+ /**
123
+ * Notify URL on agreement creation. 1000 characters max.
124
+ *
125
+ * @param string $notify_url
126
+ * @throws \InvalidArgumentException
127
+ * @return $this
128
+ */
129
+ public function setNotifyUrl($notify_url)
130
+ {
131
+ UrlValidator::validate($notify_url, "NotifyUrl");
132
+ $this->notify_url = $notify_url;
133
+ return $this;
134
+ }
135
+
136
+ /**
137
+ * Notify URL on agreement creation. 1000 characters max.
138
+ *
139
+ * @return string
140
+ */
141
+ public function getNotifyUrl()
142
+ {
143
+ return $this->notify_url;
144
+ }
145
+
146
+ /**
147
+ * Total number of failed attempts allowed. Default is 0, representing an infinite number of failed attempts.
148
+ *
149
+ * @param string $max_fail_attempts
150
+ *
151
+ * @return $this
152
+ */
153
+ public function setMaxFailAttempts($max_fail_attempts)
154
+ {
155
+ $this->max_fail_attempts = $max_fail_attempts;
156
+ return $this;
157
+ }
158
+
159
+ /**
160
+ * Total number of failed attempts allowed. Default is 0, representing an infinite number of failed attempts.
161
+ *
162
+ * @return string
163
+ */
164
+ public function getMaxFailAttempts()
165
+ {
166
+ return $this->max_fail_attempts;
167
+ }
168
+
169
+ /**
170
+ * Allow auto billing for the outstanding amount of the agreement in the next cycle. Allowed values: `YES`, `NO`. Default is `NO`.
171
+ *
172
+ * @param string $auto_bill_amount
173
+ *
174
+ * @return $this
175
+ */
176
+ public function setAutoBillAmount($auto_bill_amount)
177
+ {
178
+ $this->auto_bill_amount = $auto_bill_amount;
179
+ return $this;
180
+ }
181
+
182
+ /**
183
+ * Allow auto billing for the outstanding amount of the agreement in the next cycle. Allowed values: `YES`, `NO`. Default is `NO`.
184
+ *
185
+ * @return string
186
+ */
187
+ public function getAutoBillAmount()
188
+ {
189
+ return $this->auto_bill_amount;
190
+ }
191
+
192
+ /**
193
+ * Action to take if a failure occurs during initial payment. Allowed values: `CONTINUE`, `CANCEL`. Default is continue.
194
+ *
195
+ * @param string $initial_fail_amount_action
196
+ *
197
+ * @return $this
198
+ */
199
+ public function setInitialFailAmountAction($initial_fail_amount_action)
200
+ {
201
+ $this->initial_fail_amount_action = $initial_fail_amount_action;
202
+ return $this;
203
+ }
204
+
205
+ /**
206
+ * Action to take if a failure occurs during initial payment. Allowed values: `CONTINUE`, `CANCEL`. Default is continue.
207
+ *
208
+ * @return string
209
+ */
210
+ public function getInitialFailAmountAction()
211
+ {
212
+ return $this->initial_fail_amount_action;
213
+ }
214
+
215
+ /**
216
+ * Payment types that are accepted for this plan.
217
+ *
218
+ * @param string $accepted_payment_type
219
+ *
220
+ * @return $this
221
+ */
222
+ public function setAcceptedPaymentType($accepted_payment_type)
223
+ {
224
+ $this->accepted_payment_type = $accepted_payment_type;
225
+ return $this;
226
+ }
227
+
228
+ /**
229
+ * Payment types that are accepted for this plan.
230
+ *
231
+ * @return string
232
+ */
233
+ public function getAcceptedPaymentType()
234
+ {
235
+ return $this->accepted_payment_type;
236
+ }
237
+
238
+ /**
239
+ * char_set for this plan.
240
+ *
241
+ * @param string $char_set
242
+ *
243
+ * @return $this
244
+ */
245
+ public function setCharSet($char_set)
246
+ {
247
+ $this->char_set = $char_set;
248
+ return $this;
249
+ }
250
+
251
+ /**
252
+ * char_set for this plan.
253
+ *
254
+ * @return string
255
+ */
256
+ public function getCharSet()
257
+ {
258
+ return $this->char_set;
259
+ }
260
+
261
+ }
lib/PayPal/Api/Metadata.php ADDED
@@ -0,0 +1,259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+ use PayPal\Validation\UrlValidator;
7
+
8
+ /**
9
+ * Class Metadata
10
+ *
11
+ * Audit information of the resource.
12
+ *
13
+ * @package PayPal\Api
14
+ *
15
+ * @property string created_date
16
+ * @property string created_by
17
+ * @property string cancelled_date
18
+ * @property string cancelled_by
19
+ * @property string last_updated_date
20
+ * @property string last_updated_by
21
+ * @property string first_sent_date
22
+ * @property string last_sent_date
23
+ * @property string last_sent_by
24
+ * @property string payer_view_url
25
+ */
26
+ class Metadata extends PayPalModel
27
+ {
28
+ /**
29
+ * Date when the resource was created.
30
+ *
31
+ * @param string $created_date
32
+ *
33
+ * @return $this
34
+ */
35
+ public function setCreatedDate($created_date)
36
+ {
37
+ $this->created_date = $created_date;
38
+ return $this;
39
+ }
40
+
41
+ /**
42
+ * Date when the resource was created.
43
+ *
44
+ * @return string
45
+ */
46
+ public function getCreatedDate()
47
+ {
48
+ return $this->created_date;
49
+ }
50
+
51
+ /**
52
+ * Email address of the account that created the resource.
53
+ *
54
+ * @param string $created_by
55
+ *
56
+ * @return $this
57
+ */
58
+ public function setCreatedBy($created_by)
59
+ {
60
+ $this->created_by = $created_by;
61
+ return $this;
62
+ }
63
+
64
+ /**
65
+ * Email address of the account that created the resource.
66
+ *
67
+ * @return string
68
+ */
69
+ public function getCreatedBy()
70
+ {
71
+ return $this->created_by;
72
+ }
73
+
74
+ /**
75
+ * Date when the resource was cancelled.
76
+ *
77
+ * @param string $cancelled_date
78
+ *
79
+ * @return $this
80
+ */
81
+ public function setCancelledDate($cancelled_date)
82
+ {
83
+ $this->cancelled_date = $cancelled_date;
84
+ return $this;
85
+ }
86
+
87
+ /**
88
+ * Date when the resource was cancelled.
89
+ *
90
+ * @return string
91
+ */
92
+ public function getCancelledDate()
93
+ {
94
+ return $this->cancelled_date;
95
+ }
96
+
97
+ /**
98
+ * Actor who cancelled the resource.
99
+ *
100
+ * @param string $cancelled_by
101
+ *
102
+ * @return $this
103
+ */
104
+ public function setCancelledBy($cancelled_by)
105
+ {
106
+ $this->cancelled_by = $cancelled_by;
107
+ return $this;
108
+ }
109
+
110
+ /**
111
+ * Actor who cancelled the resource.
112
+ *
113
+ * @return string
114
+ */
115
+ public function getCancelledBy()
116
+ {
117
+ return $this->cancelled_by;
118
+ }
119
+
120
+ /**
121
+ * Date when the resource was last edited.
122
+ *
123
+ * @param string $last_updated_date
124
+ *
125
+ * @return $this
126
+ */
127
+ public function setLastUpdatedDate($last_updated_date)
128
+ {
129
+ $this->last_updated_date = $last_updated_date;
130
+ return $this;
131
+ }
132
+
133
+ /**
134
+ * Date when the resource was last edited.
135
+ *
136
+ * @return string
137
+ */
138
+ public function getLastUpdatedDate()
139
+ {
140
+ return $this->last_updated_date;
141
+ }
142
+
143
+ /**
144
+ * Email address of the account that last edited the resource.
145
+ *
146
+ * @param string $last_updated_by
147
+ *
148
+ * @return $this
149
+ */
150
+ public function setLastUpdatedBy($last_updated_by)
151
+ {
152
+ $this->last_updated_by = $last_updated_by;
153
+ return $this;
154
+ }
155
+
156
+ /**
157
+ * Email address of the account that last edited the resource.
158
+ *
159
+ * @return string
160
+ */
161
+ public function getLastUpdatedBy()
162
+ {
163
+ return $this->last_updated_by;
164
+ }
165
+
166
+ /**
167
+ * Date when the resource was first sent.
168
+ *
169
+ * @param string $first_sent_date
170
+ *
171
+ * @return $this
172
+ */
173
+ public function setFirstSentDate($first_sent_date)
174
+ {
175
+ $this->first_sent_date = $first_sent_date;
176
+ return $this;
177
+ }
178
+
179
+ /**
180
+ * Date when the resource was first sent.
181
+ *
182
+ * @return string
183
+ */
184
+ public function getFirstSentDate()
185
+ {
186
+ return $this->first_sent_date;
187
+ }
188
+
189
+ /**
190
+ * Date when the resource was last sent.
191
+ *
192
+ * @param string $last_sent_date
193
+ *
194
+ * @return $this
195
+ */
196
+ public function setLastSentDate($last_sent_date)
197
+ {
198
+ $this->last_sent_date = $last_sent_date;
199
+ return $this;
200
+ }
201
+
202
+ /**
203
+ * Date when the resource was last sent.
204
+ *
205
+ * @return string
206
+ */
207
+ public function getLastSentDate()
208
+ {
209
+ return $this->last_sent_date;
210
+ }
211
+
212
+ /**
213
+ * Email address of the account that last sent the resource.
214
+ *
215
+ * @param string $last_sent_by
216
+ *
217
+ * @return $this
218
+ */
219
+ public function setLastSentBy($last_sent_by)
220
+ {
221
+ $this->last_sent_by = $last_sent_by;
222
+ return $this;
223
+ }
224
+
225
+ /**
226
+ * Email address of the account that last sent the resource.
227
+ *
228
+ * @return string
229
+ */
230
+ public function getLastSentBy()
231
+ {
232
+ return $this->last_sent_by;
233
+ }
234
+
235
+ /**
236
+ * URL representing the payer's view of the invoice.
237
+ *
238
+ * @param string $payer_view_url
239
+ * @throws \InvalidArgumentException
240
+ * @return $this
241
+ */
242
+ public function setPayerViewUrl($payer_view_url)
243
+ {
244
+ UrlValidator::validate($payer_view_url, "PayerViewUrl");
245
+ $this->payer_view_url = $payer_view_url;
246
+ return $this;
247
+ }
248
+
249
+ /**
250
+ * URL representing the payer's view of the invoice.
251
+ *
252
+ * @return string
253
+ */
254
+ public function getPayerViewUrl()
255
+ {
256
+ return $this->payer_view_url;
257
+ }
258
+
259
+ }
lib/PayPal/Api/NameValuePair.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class NameValuePair
9
+ *
10
+ * Used to define a type for name-value pairs. The use of name value pairs in an API should be limited and approved by architecture.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string name
15
+ * @property string value
16
+ */
17
+ class NameValuePair extends PayPalModel
18
+ {
19
+ /**
20
+ * Key for the name value pair. The value name types should be correlated
21
+ *
22
+ * @param string $name
23
+ *
24
+ * @return $this
25
+ */
26
+ public function setName($name)
27
+ {
28
+ $this->name = $name;
29
+ return $this;
30
+ }
31
+
32
+ /**
33
+ * Key for the name value pair. The value name types should be correlated
34
+ *
35
+ * @return string
36
+ */
37
+ public function getName()
38
+ {
39
+ return $this->name;
40
+ }
41
+
42
+ /**
43
+ * Value for the name value pair.
44
+ *
45
+ * @param string $value
46
+ *
47
+ * @return $this
48
+ */
49
+ public function setValue($value)
50
+ {
51
+ $this->value = $value;
52
+ return $this;
53
+ }
54
+
55
+ /**
56
+ * Value for the name value pair.
57
+ *
58
+ * @return string
59
+ */
60
+ public function getValue()
61
+ {
62
+ return $this->value;
63
+ }
64
+
65
+ }
lib/PayPal/Api/Notification.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class Notification
9
+ *
10
+ * Email/SMS notification.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string subject
15
+ * @property string note
16
+ * @property bool send_to_merchant
17
+ */
18
+ class Notification extends PayPalModel
19
+ {
20
+ /**
21
+ * Subject of the notification.
22
+ *
23
+ * @param string $subject
24
+ *
25
+ * @return $this
26
+ */
27
+ public function setSubject($subject)
28
+ {
29
+ $this->subject = $subject;
30
+ return $this;
31
+ }
32
+
33
+ /**
34
+ * Subject of the notification.
35
+ *
36
+ * @return string
37
+ */
38
+ public function getSubject()
39
+ {
40
+ return $this->subject;
41
+ }
42
+
43
+ /**
44
+ * Note to the payer.
45
+ *
46
+ * @param string $note
47
+ *
48
+ * @return $this
49
+ */
50
+ public function setNote($note)
51
+ {
52
+ $this->note = $note;
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * Note to the payer.
58
+ *
59
+ * @return string
60
+ */
61
+ public function getNote()
62
+ {
63
+ return $this->note;
64
+ }
65
+
66
+ /**
67
+ * A flag indicating whether a copy of the email has to be sent to the merchant.
68
+ *
69
+ * @param bool $send_to_merchant
70
+ *
71
+ * @return $this
72
+ */
73
+ public function setSendToMerchant($send_to_merchant)
74
+ {
75
+ $this->send_to_merchant = $send_to_merchant;
76
+ return $this;
77
+ }
78
+
79
+ /**
80
+ * A flag indicating whether a copy of the email has to be sent to the merchant.
81
+ *
82
+ * @return bool
83
+ */
84
+ public function getSendToMerchant()
85
+ {
86
+ return $this->send_to_merchant;
87
+ }
88
+
89
+ }
lib/PayPal/Api/OpenIdAddress.php ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class OpenIdAddress
9
+ *
10
+ * End-User's preferred address.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string street_address
15
+ * @property string locality
16
+ * @property string region
17
+ * @property string postal_code
18
+ * @property string country
19
+ */
20
+ class OpenIdAddress extends PayPalModel
21
+ {
22
+ /**
23
+ * Full street address component, which may include house number, street name.
24
+ *
25
+ * @param string $street_address
26
+ * @return self
27
+ */
28
+ public function setStreetAddress($street_address)
29
+ {
30
+ $this->street_address = $street_address;
31
+ return $this;
32
+ }
33
+
34
+ /**
35
+ * Full street address component, which may include house number, street name.
36
+ *
37
+ * @return string
38
+ */
39
+ public function getStreetAddress()
40
+ {
41
+ return $this->street_address;
42
+ }
43
+
44
+ /**
45
+ * City or locality component.
46
+ *
47
+ * @param string $locality
48
+ * @return self
49
+ */
50
+ public function setLocality($locality)
51
+ {
52
+ $this->locality = $locality;
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * City or locality component.
58
+ *
59
+ * @return string
60
+ */
61
+ public function getLocality()
62
+ {
63
+ return $this->locality;
64
+ }
65
+
66
+ /**
67
+ * State, province, prefecture or region component.
68
+ *
69
+ * @param string $region
70
+ * @return self
71
+ */
72
+ public function setRegion($region)
73
+ {
74
+ $this->region = $region;
75
+ return $this;
76
+ }
77
+
78
+ /**
79
+ * State, province, prefecture or region component.
80
+ *
81
+ * @return string
82
+ */
83
+ public function getRegion()
84
+ {
85
+ return $this->region;
86
+ }
87
+
88
+ /**
89
+ * Zip code or postal code component.
90
+ *
91
+ * @param string $postal_code
92
+ * @return self
93
+ */
94
+ public function setPostalCode($postal_code)
95
+ {
96
+ $this->postal_code = $postal_code;
97
+ return $this;
98
+ }
99
+
100
+ /**
101
+ * Zip code or postal code component.
102
+ *
103
+ * @return string
104
+ */
105
+ public function getPostalCode()
106
+ {
107
+ return $this->postal_code;
108
+ }
109
+
110
+ /**
111
+ * Country name component.
112
+ *
113
+ * @param string $country
114
+ * @return self
115
+ */
116
+ public function setCountry($country)
117
+ {
118
+ $this->country = $country;
119
+ return $this;
120
+ }
121
+
122
+ /**
123
+ * Country name component.
124
+ *
125
+ * @return string
126
+ */
127
+ public function getCountry()
128
+ {
129
+ return $this->country;
130
+ }
131
+
132
+
133
+ }
lib/PayPal/Api/OpenIdError.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PayPal\Api;
3
+
4
+ use PayPal\Common\PayPalModel;
5
+
6
+ /**
7
+ * Class OpenIdError
8
+ *
9
+ * Error resource
10
+ *
11
+ * @property string error
12
+ * @property string error_description
13
+ * @property string error_uri
14
+ */
15
+ class OpenIdError extends PayPalModel
16
+ {
17
+
18
+ /**
19
+ * A single ASCII error code from the following enum.
20
+ *
21
+ * @param string $error
22
+ * @return self
23
+ */
24
+ public function setError($error)
25
+ {
26
+ $this->error = $error;
27
+ return $this;
28
+ }
29
+
30
+ /**
31
+ * A single ASCII error code from the following enum.
32
+ *
33
+ * @return string
34
+ */
35
+ public function getError()
36
+ {
37
+ return $this->error;
38
+ }
39
+
40
+ /**
41
+ * A resource ID that indicates the starting resource in the returned results.
42
+ *
43
+ * @param string $error_description
44
+ * @return self
45
+ */
46
+ public function setErrorDescription($error_description)
47
+ {
48
+ $this->error_description = $error_description;
49
+ return $this;
50
+ }
51
+
52
+ /**
53
+ * A resource ID that indicates the starting resource in the returned results.
54
+ *
55
+ * @return string
56
+ */
57
+ public function getErrorDescription()
58
+ {
59
+ return $this->error_description;
60
+ }
61
+
62
+ /**
63
+ * A URI identifying a human-readable web page with information about the error, used to provide the client developer with additional information about the error.
64
+ *
65
+ * @param string $error_uri
66
+ * @return self
67
+ */
68
+ public function setErrorUri($error_uri)
69
+ {
70
+ $this->error_uri = $error_uri;
71
+ return $this;
72
+ }
73
+
74
+ /**
75
+ * A URI identifying a human-readable web page with information about the error, used to provide the client developer with additional information about the error.
76
+ *
77
+ * @return string
78
+ */
79
+ public function getErrorUri()
80
+ {
81
+ return $this->error_uri;
82
+ }
83
+
84
+
85
+ }
lib/PayPal/Api/OpenIdSession.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PayPal\Api;
3
+
4
+
5
+ use PayPal\Core\PayPalConstants;
6
+ use PayPal\Rest\ApiContext;
7
+
8
+ class OpenIdSession
9
+ {
10
+
11
+ /**
12
+ * Returns the PayPal URL to which the user must be redirected to
13
+ * start the authentication / authorization process.
14
+ *
15
+ * @param string $redirectUri Uri on merchant website to where
16
+ * the user must be redirected to post paypal login
17
+ * @param array $scope The access privilges that you are requesting for
18
+ * from the user. Pass empty array for all scopes.
19
+ * @param string $clientId client id from developer portal
20
+ * See https://developer.paypal.com/webapps/developer/docs/integration/direct/log-in-with-paypal/detailed/#attributes for more
21
+ * @param null $nonce
22
+ * @param null $state
23
+ * @param ApiContext $apiContext Optional API Context
24
+ * @return string Authorization URL
25
+ */
26
+ public static function getAuthorizationUrl($redirectUri, $scope, $clientId, $nonce = null, $state = null, $apiContext = null)
27
+ {
28
+ $apiContext = $apiContext ? $apiContext : new ApiContext();
29
+ $config = $apiContext->getConfig();
30
+
31
+ if ($apiContext->get($clientId)) {
32
+ $clientId = $apiContext->get($clientId);
33
+ }
34
+
35
+ $clientId = $clientId ? $clientId : $apiContext->getCredential()->getClientId();
36
+
37
+ $scope = count($scope) != 0 ? $scope : array('openid', 'profile', 'address', 'email', 'phone',
38
+ 'https://uri.paypal.com/services/paypalattributes', 'https://uri.paypal.com/services/expresscheckout');
39
+ if (!in_array('openid', $scope)) {
40
+ $scope[] = 'openid';
41
+ }
42
+
43
+ $params = array(
44
+ 'client_id' => $clientId,
45
+ 'response_type' => 'code',
46
+ 'scope' => implode(" ", $scope),
47
+ 'redirect_uri' => $redirectUri
48
+ );
49
+
50
+ if ($nonce) {
51
+ $params['nonce'] = $nonce;
52
+ }
53
+ if ($state) {
54
+ $params['state'] = $state;
55
+ }
56
+ return sprintf("%s/v1/authorize?%s", self::getBaseUrl($config), http_build_query($params));
57
+ }
58
+
59
+
60
+ /**
61
+ * Returns the URL to which the user must be redirected to
62
+ * logout from the OpenID provider (i.e. PayPal)
63
+ *
64
+ * @param string $redirectUri Uri on merchant website to where
65
+ * the user must be redirected to post logout
66
+ * @param string $idToken id_token from the TokenInfo object
67
+ * @param ApiContext $apiContext Optional API Context
68
+ * @return string logout URL
69
+ */
70
+ public static function getLogoutUrl($redirectUri, $idToken, $apiContext = null)
71
+ {
72
+
73
+ if (is_null($apiContext)) {
74
+ $apiContext = new ApiContext();
75
+ }
76
+ $config = $apiContext->getConfig();
77
+
78
+ $params = array(
79
+ 'id_token' => $idToken,
80
+ 'redirect_uri' => $redirectUri,
81
+ 'logout' => 'true'
82
+ );
83
+ return sprintf("%s/v1/endsession?%s", self::getBaseUrl($config), http_build_query($params));
84
+ }
85
+
86
+ /**
87
+ * Gets the base URL for the Redirect URI
88
+ *
89
+ * @param $config
90
+ * @return null|string
91
+ */
92
+ private static function getBaseUrl($config)
93
+ {
94
+
95
+ if (array_key_exists('openid.RedirectUri', $config)) {
96
+ return $config['openid.RedirectUri'];
97
+ } else if (array_key_exists('mode', $config)) {
98
+ switch (strtoupper($config['mode'])) {
99
+ case 'SANDBOX':
100
+ return PayPalConstants::OPENID_REDIRECT_SANDBOX_URL;
101
+ case 'LIVE':
102
+ return PayPalConstants::OPENID_REDIRECT_LIVE_URL;
103
+ }
104
+ }
105
+ return null;
106
+ }
107
+ }
lib/PayPal/Api/OpenIdTokeninfo.php ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PayPal\Api;
3
+
4
+ use PayPal\Common\PayPalResourceModel;
5
+ use PayPal\Rest\ApiContext;
6
+ use PayPal\Transport\PayPalRestCall;
7
+
8
+ /**
9
+ * Class OpenIdTokeninfo
10
+ *
11
+ * Token grant resource
12
+ *
13
+ * @property string scope
14
+ * @property string access_token
15
+ * @property string refresh_token
16
+ * @property string token_type
17
+ * @property string id_token
18
+ * @property int expires_in
19
+ */
20
+ class OpenIdTokeninfo extends PayPalResourceModel
21
+ {
22
+
23
+ /**
24
+ * OPTIONAL, if identical to the scope requested by the client; otherwise, REQUIRED.
25
+ *
26
+ * @param string $scope
27
+ * @return self
28
+ */
29
+ public function setScope($scope)
30
+ {
31
+ $this->scope = $scope;
32
+ return $this;
33
+ }
34
+
35
+ /**
36
+ * OPTIONAL, if identical to the scope requested by the client; otherwise, REQUIRED.
37
+ *
38
+ * @return string
39
+ */
40
+ public function getScope()
41
+ {
42
+ return $this->scope;
43
+ }
44
+
45
+ /**
46
+ * The access token issued by the authorization server.
47
+ *
48
+ * @param string $access_token
49
+ * @return self
50
+ */
51
+ public function setAccessToken($access_token)
52
+ {
53
+ $this->access_token = $access_token;
54
+ return $this;
55
+ }
56
+
57
+ /**
58
+ * The access token issued by the authorization server.
59
+ *
60
+ * @return string
61
+ */
62
+ public function getAccessToken()
63
+ {
64
+ return $this->access_token;
65
+ }
66
+
67
+ /**
68
+ * The refresh token, which can be used to obtain new access tokens using the same authorization grant as described in OAuth2.0 RFC6749 in Section 6.
69
+ *
70
+ * @param string $refresh_token
71
+ * @return self
72
+ */
73
+ public function setRefreshToken($refresh_token)
74
+ {
75
+ $this->refresh_token = $refresh_token;
76
+ return $this;
77
+ }
78
+
79
+ /**
80
+ * The refresh token, which can be used to obtain new access tokens using the same authorization grant as described in OAuth2.0 RFC6749 in Section 6.
81
+ *
82
+ * @return string
83
+ */
84
+ public function getRefreshToken()
85
+ {
86
+ return $this->refresh_token;
87
+ }
88
+
89
+ /**
90
+ * The type of the token issued as described in OAuth2.0 RFC6749 (Section 7.1). Value is case insensitive.
91
+ *
92
+ * @param string $token_type
93
+ * @return self
94
+ */
95
+ public function setTokenType($token_type)
96
+ {
97
+ $this->token_type = $token_type;
98
+ return $this;
99
+ }
100
+
101
+ /**
102
+ * The type of the token issued as described in OAuth2.0 RFC6749 (Section 7.1). Value is case insensitive.
103
+ *
104
+ * @return string
105
+ */
106
+ public function getTokenType()
107
+ {
108
+ return $this->token_type;
109
+ }
110
+
111
+ /**
112
+ * The id_token is a session token assertion that denotes the user's authentication status
113
+ *
114
+ * @param string $id_token
115
+ * @return self
116
+ */
117
+ public function setIdToken($id_token)
118
+ {
119
+ $this->id_token = $id_token;
120
+ return $this;
121
+ }
122
+
123
+ /**
124
+ * The id_token is a session token assertion that denotes the user's authentication status
125
+ *
126
+ * @return string
127
+ */
128
+ public function getIdToken()
129
+ {
130
+ return $this->id_token;
131
+ }
132
+
133
+ /**
134
+ * The lifetime in seconds of the access token.
135
+ *
136
+ * @param integer $expires_in
137
+ * @return self
138
+ */
139
+ public function setExpiresIn($expires_in)
140
+ {
141
+ $this->expires_in = $expires_in;
142
+ return $this;
143
+ }
144
+
145
+ /**
146
+ * The lifetime in seconds of the access token.
147
+ *
148
+ * @return integer
149
+ */
150
+ public function getExpiresIn()
151
+ {
152
+ return $this->expires_in;
153
+ }
154
+
155
+
156
+ /**
157
+ * Creates an Access Token from an Authorization Code.
158
+ *
159
+ * @path /v1/identity/openidconnect/tokenservice
160
+ * @method POST
161
+ * @param array $params (allowed values are client_id, client_secret, grant_type, code and redirect_uri)
162
+ * (required) client_id from developer portal
163
+ * (required) client_secret from developer portal
164
+ * (required) code is Authorization code previously received from the authorization server
165
+ * (required) redirect_uri Redirection endpoint that must match the one provided during the
166
+ * authorization request that ended in receiving the authorization code.
167
+ * (optional) grant_type is the Token grant type. Defaults to authorization_code
168
+ * @param string $clientId
169
+ * @param string $clientSecret
170
+ * @param ApiContext $apiContext Optional API Context
171
+ * @param PayPalRestCall $restCall
172
+ * @return OpenIdTokeninfo
173
+ */
174
+ public static function createFromAuthorizationCode($params, $clientId = null, $clientSecret = null, $apiContext = null, $restCall = null)
175
+ {
176
+ static $allowedParams = array('grant_type' => 1, 'code' => 1, 'redirect_uri' => 1);
177
+
178
+ if (!array_key_exists('grant_type', $params)) {
179
+ $params['grant_type'] = 'authorization_code';
180
+ }
181
+ $apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential);
182
+
183
+ if (sizeof($apiContext->get($clientId)) > 0) {
184
+ $clientId = $apiContext->get($clientId);
185
+ }
186
+
187
+ if (sizeof($apiContext->get($clientSecret)) > 0) {
188
+ $clientSecret = $apiContext->get($clientSecret);
189
+ }
190
+
191
+ $clientId = $clientId ? $clientId : $apiContext->getCredential()->getClientId();
192
+ $clientSecret = $clientSecret ? $clientSecret : $apiContext->getCredential()->getClientSecret();
193
+
194
+ $json = self::executeCall(
195
+ "/v1/identity/openidconnect/tokenservice",
196
+ "POST",
197
+ http_build_query(array_intersect_key($params, $allowedParams)),
198
+ array(
199
+ 'Content-Type' => 'application/x-www-form-urlencoded',
200
+ 'Authorization' => 'Basic ' . base64_encode($clientId . ":" . $clientSecret)
201
+ ),
202
+ $apiContext,
203
+ $restCall
204
+ );
205
+ $token = new OpenIdTokeninfo();
206
+ $token->fromJson($json);
207
+ return $token;
208
+ }
209
+
210
+ /**
211
+ * Creates an Access Token from an Refresh Token.
212
+ *
213
+ * @path /v1/identity/openidconnect/tokenservice
214
+ * @method POST
215
+ * @param array $params (allowed values are grant_type and scope)
216
+ * (required) client_id from developer portal
217
+ * (required) client_secret from developer portal
218
+ * (optional) refresh_token refresh token. If one is not passed, refresh token from the current object is used.
219
+ * (optional) grant_type is the Token grant type. Defaults to refresh_token
220
+ * (optional) scope is an array that either the same or a subset of the scope passed to the authorization request
221
+ * @param APIContext $apiContext Optional API Context
222
+ * @return OpenIdTokeninfo
223
+ */
224
+ public function createFromRefreshToken($params, $apiContext = null)
225
+ {
226
+ static $allowedParams = array('grant_type' => 1, 'refresh_token' => 1, 'scope' => 1);
227
+ $apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential);
228
+
229
+ if (!array_key_exists('grant_type', $params)) {
230
+ $params['grant_type'] = 'refresh_token';
231
+ }
232
+ if (!array_key_exists('refresh_token', $params)) {
233
+ $params['refresh_token'] = $this->getRefreshToken();
234
+ }
235
+
236
+ $clientId = isset($params['client_id']) ? $params['client_id'] : $apiContext->getCredential()->getClientId();
237
+ $clientSecret = isset($params['client_secret']) ? $params['client_secret'] : $apiContext->getCredential()->getClientSecret();
238
+
239
+ $json = self::executeCall(
240
+ "/v1/identity/openidconnect/tokenservice",
241
+ "POST",
242
+ http_build_query(array_intersect_key($params, $allowedParams)),
243
+ array(
244
+ 'Content-Type' => 'application/x-www-form-urlencoded',
245
+ 'Authorization' => 'Basic ' . base64_encode($clientId . ":" . $clientSecret)
246
+ ),
247
+ $apiContext
248
+ );
249
+
250
+ $this->fromJson($json);
251
+ return $this;
252
+ }
253
+ }
lib/PayPal/Api/OpenIdUserinfo.php ADDED
@@ -0,0 +1,538 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PayPal\Api;
3
+
4
+ use PayPal\Common\PayPalResourceModel;
5
+ use PayPal\Rest\ApiContext;
6
+
7
+ /**
8
+ * Class OpenIdUserinfo
9
+ *
10
+ * OpenIdConnect UserInfo Resource
11
+ *
12
+ * @property string user_id
13
+ * @property string sub
14
+ * @property mixed name
15
+ * @property string given_name
16
+ * @property string family_name
17
+ * @property string middle_name
18
+ * @property string picture
19
+ * @property string email
20
+ * @property bool email_verified
21
+ * @property string gender
22
+ * @property string birthday
23
+ * @property string zoneinfo
24
+ * @property string locale
25
+ * @property string language
26
+ * @property bool verified
27
+ * @property string phone_number
28
+ * @property OpenIdAddress address
29
+ * @property mixed verified_account
30
+ * @property mixed account_type
31
+ * @property string age_range
32
+ * @property string payer_id
33
+ */
34
+ class OpenIdUserinfo extends PayPalResourceModel
35
+ {
36
+
37
+ /**
38
+ * Subject - Identifier for the End-User at the Issuer.
39
+ *
40
+ * @param string $user_id
41
+ * @return self
42
+ */
43
+ public function setUserId($user_id)
44
+ {
45
+ $this->user_id = $user_id;
46
+ return $this;
47
+ }
48
+
49
+ /**
50
+ * Subject - Identifier for the End-User at the Issuer.
51
+ *
52
+ * @return string
53
+ */
54
+ public function getUserId()
55
+ {
56
+ return $this->user_id;
57
+ }
58
+
59
+ /**
60
+ * Subject - Identifier for the End-User at the Issuer.
61
+ *
62
+ * @param string $sub
63
+ * @return self
64
+ */
65
+ public function setSub($sub)
66
+ {
67
+ $this->sub = $sub;
68
+ return $this;
69
+ }
70
+
71
+ /**
72
+ * Subject - Identifier for the End-User at the Issuer.
73
+ *
74
+ * @return string
75
+ */
76
+ public function getSub()
77
+ {
78
+ return $this->sub;
79
+ }
80
+
81
+ /**
82
+ * End-User's full name in displayable form including all name parts, possibly including titles and suffixes, ordered according to the End-User's locale and preferences.
83
+ *
84
+ * @param string $name
85
+ * @return self
86
+ */
87
+ public function setName($name)
88
+ {
89
+ $this->name = $name;
90
+ return $this;
91
+ }
92
+
93
+ /**
94
+ * End-User's full name in displayable form including all name parts, possibly including titles and suffixes, ordered according to the End-User's locale and preferences.
95
+ *
96
+ * @return string
97
+ */
98
+ public function getName()
99
+ {
100
+ return $this->name;
101
+ }
102
+
103
+ /**
104
+ * Given name(s) or first name(s) of the End-User
105
+ *
106
+ * @param string $given_name
107
+ * @return self
108
+ */
109
+ public function setGivenName($given_name)
110
+ {
111
+ $this->given_name = $given_name;
112
+ return $this;
113
+ }
114
+
115
+ /**
116
+ * Given name(s) or first name(s) of the End-User
117
+ *
118
+ * @return string
119
+ */
120
+ public function getGivenName()
121
+ {
122
+ return $this->given_name;
123
+ }
124
+
125
+ /**
126
+ * Surname(s) or last name(s) of the End-User.
127
+ *
128
+ * @param string $family_name
129
+ * @return self
130
+ */
131
+ public function setFamilyName($family_name)
132
+ {
133
+ $this->family_name = $family_name;
134
+ return $this;
135
+ }
136
+
137
+ /**
138
+ * Surname(s) or last name(s) of the End-User.
139
+ *
140
+ * @return string
141
+ */
142
+ public function getFamilyName()
143
+ {
144
+ return $this->family_name;
145
+ }
146
+
147
+ /**
148
+ * Middle name(s) of the End-User.
149
+ *
150
+ * @param string $middle_name
151
+ * @return self
152
+ */
153
+ public function setMiddleName($middle_name)
154
+ {
155
+ $this->middle_name = $middle_name;
156
+ return $this;
157
+ }
158
+
159
+ /**
160
+ * Middle name(s) of the End-User.
161
+ *
162
+ * @return string
163
+ */
164
+ public function getMiddleName()
165
+ {
166
+ return $this->middle_name;
167
+ }
168
+
169
+ /**
170
+ * URL of the End-User's profile picture.
171
+ *
172
+ * @param string $picture
173
+ * @return self
174
+ */
175
+ public function setPicture($picture)
176
+ {
177
+ $this->picture = $picture;
178
+ return $this;
179
+ }
180
+
181
+ /**
182
+ * URL of the End-User's profile picture.
183
+ *
184
+ * @return string
185
+ */
186
+ public function getPicture()
187
+ {
188
+ return $this->picture;
189
+ }
190
+
191
+ /**
192
+ * End-User's preferred e-mail address.
193
+ *
194
+ * @param string $email
195
+ * @return self
196
+ */
197
+ public function setEmail($email)
198
+ {
199
+ $this->email = $email;
200
+ return $this;
201
+ }
202
+
203
+ /**
204
+ * End-User's preferred e-mail address.
205
+ *
206
+ * @return string
207
+ */
208
+ public function getEmail()
209
+ {
210
+ return $this->email;
211
+ }
212
+
213
+ /**
214
+ * True if the End-User's e-mail address has been verified; otherwise false.
215
+ *
216
+ * @param boolean $email_verified
217
+ * @return self
218
+ */
219
+ public function setEmailVerified($email_verified)
220
+ {
221
+ $this->email_verified = $email_verified;
222
+ return $this;
223
+ }
224
+
225
+ /**
226
+ * True if the End-User's e-mail address has been verified; otherwise false.
227
+ *
228
+ * @return boolean
229
+ */
230
+ public function getEmailVerified()
231
+ {
232
+ return $this->email_verified;
233
+ }
234
+
235
+ /**
236
+ * End-User's gender.
237
+ *
238
+ * @param string $gender
239
+ * @return self
240
+ */
241
+ public function setGender($gender)
242
+ {
243
+ $this->gender = $gender;
244
+ return $this;
245
+ }
246
+
247
+ /**
248
+ * End-User's gender.
249
+ *
250
+ * @return string
251
+ */
252
+ public function getGender()
253
+ {
254
+ return $this->gender;
255
+ }
256
+
257
+ /**
258
+ * End-User's birthday, represented as an YYYY-MM-DD format. They year MAY be 0000, indicating it is omited. To represent only the year, YYYY format would be used.
259
+ *
260
+ * @param string $birthday
261
+ * @return self
262
+ */
263
+ public function setBirthday($birthday)
264
+ {
265
+ $this->birthday = $birthday;
266
+ return $this;
267
+ }
268
+
269
+ /**
270
+ * End-User's birthday, represented as an YYYY-MM-DD format. They year MAY be 0000, indicating it is omited. To represent only the year, YYYY format would be used.
271
+ *
272
+ * @return string
273
+ */
274
+ public function getBirthday()
275
+ {
276
+ return $this->birthday;
277
+ }
278
+
279
+ /**
280
+ * Time zone database representing the End-User's time zone
281
+ *
282
+ * @param string $zoneinfo
283
+ * @return self
284
+ */
285
+ public function setZoneinfo($zoneinfo)
286
+ {
287
+ $this->zoneinfo = $zoneinfo;
288
+ return $this;
289
+ }
290
+
291
+ /**
292
+ * Time zone database representing the End-User's time zone
293
+ *
294
+ * @return string
295
+ */
296
+ public function getZoneinfo()
297
+ {
298
+ return $this->zoneinfo;
299
+ }
300
+
301
+ /**
302
+ * End-User's locale.
303
+ *
304
+ * @param string $locale
305
+ * @return self
306
+ */
307
+ public function setLocale($locale)
308
+ {
309
+ $this->locale = $locale;
310
+ return $this;
311
+ }
312
+
313
+ /**
314
+ * End-User's locale.
315
+ *
316
+ * @return string
317
+ */
318
+ public function getLocale()
319
+ {
320
+ return $this->locale;
321
+ }
322
+
323
+ /**
324
+ * End-User's language.
325
+ *
326
+ * @param string $language
327
+ * @return self
328
+ */
329
+ public function setLanguage($language)
330
+ {
331
+ $this->language = $language;
332
+ return $this;
333
+ }
334
+
335
+ /**
336
+ * End-User's language.
337
+ *
338
+ * @return string
339
+ */
340
+ public function getLanguage()
341
+ {
342
+ return $this->language;
343
+ }
344
+
345
+ /**
346
+ * End-User's verified status.
347
+ *
348
+ * @param boolean $verified
349
+ * @return self
350
+ */
351
+ public function setVerified($verified)
352
+ {
353
+ $this->verified = $verified;
354
+ return $this;
355
+ }
356
+
357
+ /**
358
+ * End-User's verified status.
359
+ *
360
+ * @return boolean
361
+ */
362
+ public function getVerified()
363
+ {
364
+ return $this->verified;
365
+ }
366
+
367
+ /**
368
+ * End-User's preferred telephone number.
369
+ *
370
+ * @param string $phone_number
371
+ * @return self
372
+ */
373
+ public function setPhoneNumber($phone_number)
374
+ {
375
+ $this->phone_number = $phone_number;
376
+ return $this;
377
+ }
378
+
379
+ /**
380
+ * End-User's preferred telephone number.
381
+ *
382
+ * @return string
383
+ */
384
+ public function getPhoneNumber()
385
+ {
386
+ return $this->phone_number;
387
+ }
388
+
389
+ /**
390
+ * End-User's preferred address.
391
+ *
392
+ * @param \PayPal\Api\OpenIdAddress $address
393
+ * @return self
394
+ */
395
+ public function setAddress($address)
396
+ {
397
+ $this->address = $address;
398
+ return $this;
399
+ }
400
+
401
+ /**
402
+ * End-User's preferred address.
403
+ *
404
+ * @return \PayPal\Api\OpenIdAddress
405
+ */
406
+ public function getAddress()
407
+ {
408
+ return $this->address;
409
+ }
410
+
411
+ /**
412
+ * Verified account status.
413
+ *
414
+ * @param boolean $verified_account
415
+ * @return self
416
+ */
417
+ public function setVerifiedAccount($verified_account)
418
+ {
419
+ $this->verified_account = $verified_account;
420
+ return $this;
421
+ }
422
+
423
+ /**
424
+ * Verified account status.
425
+ *
426
+ * @return boolean
427
+ */
428
+ public function getVerifiedAccount()
429
+ {
430
+ return $this->verified_account;
431
+ }
432
+
433
+ /**
434
+ * Account type.
435
+ *
436
+ * @param string $account_type
437
+ * @return self
438
+ */
439
+ public function setAccountType($account_type)
440
+ {
441
+ $this->account_type = $account_type;
442
+ return $this;
443
+ }
444
+
445
+ /**
446
+ * Account type.
447
+ *
448
+ * @return string
449
+ */
450
+ public function getAccountType()
451
+ {
452
+ return $this->account_type;
453
+ }
454
+
455
+ /**
456
+ * Account holder age range.
457
+ *
458
+ * @param string $age_range
459
+ * @return self
460
+ */
461
+ public function setAgeRange($age_range)
462
+ {
463
+ $this->age_range = $age_range;
464
+ return $this;
465
+ }
466
+
467
+ /**
468
+ * Account holder age range.
469
+ *
470
+ * @return string
471
+ */
472
+ public function getAgeRange()
473
+ {
474
+ return $this->age_range;
475
+ }
476
+
477
+ /**
478
+ * Account payer identifier.
479
+ *
480
+ * @param string $payer_id
481
+ * @return self
482
+ */
483
+ public function setPayerId($payer_id)
484
+ {
485
+ $this->payer_id = $payer_id;
486
+ return $this;
487
+ }
488
+
489
+ /**
490
+ * Account payer identifier.
491
+ *
492
+ * @return string
493
+ */
494
+ public function getPayerId()
495
+ {
496
+ return $this->payer_id;
497
+ }
498
+
499
+
500
+ /**
501
+ * returns user details
502
+ *
503
+ * @path /v1/identity/openidconnect/userinfo
504
+ * @method GET
505
+ * @param array $params (allowed values are access_token)
506
+ * access_token - access token from the createFromAuthorizationCode / createFromRefreshToken calls
507
+ * @param ApiContext $apiContext Optional API Context
508
+ * @return OpenIdUserinfo
509
+ */
510
+ public static function getUserinfo($params, $apiContext = null)
511
+ {
512
+ static $allowedParams = array('schema' => 1);
513
+
514
+ $params = is_array($params) ? $params : array();
515
+
516
+ if (!array_key_exists('schema', $params)) {
517
+ $params['schema'] = 'openid';
518
+ }
519
+ $requestUrl = "/v1/identity/openidconnect/userinfo?"
520
+ . http_build_query(array_intersect_key($params, $allowedParams));
521
+
522
+ $json = self::executeCall(
523
+ $requestUrl,
524
+ "GET",
525
+ "",
526
+ array(
527
+ 'Authorization' => "Bearer " . $params['access_token'],
528
+ 'Content-Type' => 'x-www-form-urlencoded'
529
+ ),
530
+ $apiContext
531
+ );
532
+
533
+ $ret = new OpenIdUserinfo();
534
+ $ret->fromJson($json);
535
+
536
+ return $ret;
537
+ }
538
+ }
lib/PayPal/Api/Order.php ADDED
@@ -0,0 +1,438 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalResourceModel;
6
+ use PayPal\Rest\ApiContext;
7
+ use PayPal\Validation\ArgumentValidator;
8
+
9
+ /**
10
+ * Class Order
11
+ *
12
+ * An order transaction.
13
+ *
14
+ * @package PayPal\Api
15
+ *
16
+ * @property string id
17
+ * @property string purchase_unit_reference_id
18
+ * @property \PayPal\Api\Amount amount
19
+ * @property string payment_mode
20
+ * @property string state
21
+ * @property string reason_code
22
+ * @property string pending_reason
23
+ * @property string protection_eligibility
24
+ * @property string protection_eligibility_type
25
+ * @property string parent_payment
26
+ * @property \PayPal\Api\FmfDetails fmf_details
27
+ * @property string create_time
28
+ * @property string update_time
29
+ * @property \PayPal\Api\Links[] links
30
+ */
31
+ class Order extends PayPalResourceModel
32
+ {
33
+ /**
34
+ * Identifier of the order transaction.
35
+ *
36
+ * @param string $id
37
+ *
38
+ * @return $this
39
+ */
40
+ public function setId($id)
41
+ {
42
+ $this->id = $id;
43
+ return $this;
44
+ }
45
+
46
+ /**
47
+ * Identifier of the order transaction.
48
+ *
49
+ * @return string
50
+ */
51
+ public function getId()
52
+ {
53
+ return $this->id;
54
+ }
55
+
56
+ /**
57
+ * Identifier to the purchase unit associated with this object. Obsolete. Use one in cart_base.
58
+ *
59
+ * @param string $purchase_unit_reference_id
60
+ *
61
+ * @return $this
62
+ */
63
+ public function setPurchaseUnitReferenceId($purchase_unit_reference_id)
64
+ {
65
+ $this->purchase_unit_reference_id = $purchase_unit_reference_id;
66
+ return $this;
67
+ }
68
+
69
+ /**
70
+ * Identifier to the purchase unit associated with this object. Obsolete. Use one in cart_base.
71
+ *
72
+ * @return string
73
+ */
74
+ public function getPurchaseUnitReferenceId()
75
+ {
76
+ return $this->purchase_unit_reference_id;
77
+ }
78
+
79
+ /**
80
+ * Amount being collected.
81
+ *
82
+ * @param \PayPal\Api\Amount $amount
83
+ *
84
+ * @return $this
85
+ */
86
+ public function setAmount($amount)
87
+ {
88
+ $this->amount = $amount;
89
+ return $this;
90
+ }
91
+
92
+ /**
93
+ * Amount being collected.
94
+ *
95
+ * @return \PayPal\Api\Amount
96
+ */
97
+ public function getAmount()
98
+ {
99
+ return $this->amount;
100
+ }
101
+
102
+ /**
103
+ * specifies payment mode of the transaction
104
+ * Valid Values: ["INSTANT_TRANSFER", "MANUAL_BANK_TRANSFER", "DELAYED_TRANSFER", "ECHECK"]
105
+ *
106
+ * @param string $payment_mode
107
+ *
108
+ * @return $this
109
+ */
110
+ public function setPaymentMode($payment_mode)
111
+ {
112
+ $this->payment_mode = $payment_mode;
113
+ return $this;
114
+ }
115
+
116
+ /**
117
+ * specifies payment mode of the transaction
118
+ *
119
+ * @return string
120
+ */
121
+ public function getPaymentMode()
122
+ {
123
+ return $this->payment_mode;
124
+ }
125
+
126
+ /**
127
+ * State of the order transaction.
128
+ * Valid Values: ["pending", "completed", "refunded", "partially_refunded", "voided"]
129
+ *
130
+ * @param string $state
131
+ *
132
+ * @return $this
133
+ */
134
+ public function setState($state)
135
+ {
136
+ $this->state = $state;
137
+ return $this;
138
+ }
139
+
140
+ /**
141
+ * State of the order transaction.
142
+ *
143
+ * @return string
144
+ */
145
+ public function getState()
146
+ {
147
+ return $this->state;
148
+ }
149
+
150
+ /**
151
+ * Reason code for the transaction state being Pending or Reversed. Only supported when the `payment_method` is set to `paypal`.
152
+ * Valid Values: ["PAYER_SHIPPING_UNCONFIRMED", "MULTI_CURRENCY", "RISK_REVIEW", "REGULATORY_REVIEW", "VERIFICATION_REQUIRED", "ORDER", "OTHER"]
153
+ *
154
+ * @param string $reason_code
155
+ *
156
+ * @return $this
157
+ */
158
+ public function setReasonCode($reason_code)
159
+ {
160
+ $this->reason_code = $reason_code;
161
+ return $this;
162
+ }
163
+
164
+ /**
165
+ * Reason code for the transaction state being Pending or Reversed. Only supported when the `payment_method` is set to `paypal`.
166
+ *
167
+ * @return string
168
+ */
169
+ public function getReasonCode()
170
+ {
171
+ return $this->reason_code;
172
+ }
173
+
174
+ /**
175
+ * [DEPRECATED] Reason the transaction is in pending state. Use reason_code field above instead.
176
+ * Valid Values: ["payer_shipping_unconfirmed", "multi_currency", "risk_review", "regulatory_review", "verification_required", "order", "other"]
177
+ *
178
+ * @param string $pending_reason
179
+ *
180
+ * @return $this
181
+ */
182
+ public function setPendingReason($pending_reason)
183
+ {
184
+ $this->pending_reason = $pending_reason;
185
+ return $this;
186
+ }
187
+
188
+ /**
189
+ * @deprecated [DEPRECATED] Reason the transaction is in pending state. Use reason_code field above instead.
190
+ *
191
+ * @return string
192
+ */
193
+ public function getPendingReason()
194
+ {
195
+ return $this->pending_reason;
196
+ }
197
+
198
+ /**
199
+ * The level of seller protection in force for the transaction.
200
+ * Valid Values: ["ELIGIBLE", "PARTIALLY_ELIGIBLE", "INELIGIBLE"]
201
+ *
202
+ * @param string $protection_eligibility
203
+ *
204
+ * @return $this
205
+ */
206
+ public function setProtectionEligibility($protection_eligibility)
207
+ {
208
+ $this->protection_eligibility = $protection_eligibility;
209
+ return $this;
210
+ }
211
+
212
+ /**
213
+ * The level of seller protection in force for the transaction.
214
+ *
215
+ * @return string
216
+ */
217
+ public function getProtectionEligibility()
218
+ {
219
+ return $this->protection_eligibility;
220
+ }
221
+
222
+ /**
223
+ * The kind of seller protection in force for the transaction. This property is returned only when the `protection_eligibility` property is set to `ELIGIBLE`or `PARTIALLY_ELIGIBLE`. Only supported when the `payment_method` is set to `paypal`. Allowed values:<br> `ITEM_NOT_RECEIVED_ELIGIBLE`- Sellers are protected against claims for items not received.<br> `UNAUTHORIZED_PAYMENT_ELIGIBLE`- Sellers are protected against claims for unauthorized payments.<br> One or both of the allowed values can be returned.
224
+ * Valid Values: ["ITEM_NOT_RECEIVED_ELIGIBLE", "UNAUTHORIZED_PAYMENT_ELIGIBLE", "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE"]
225
+ *
226
+ * @param string $protection_eligibility_type
227
+ *
228
+ * @return $this
229
+ */
230
+ public function setProtectionEligibilityType($protection_eligibility_type)
231
+ {
232
+ $this->protection_eligibility_type = $protection_eligibility_type;
233
+ return $this;
234
+ }
235
+
236
+ /**
237
+ * The kind of seller protection in force for the transaction. This property is returned only when the `protection_eligibility` property is set to `ELIGIBLE`or `PARTIALLY_ELIGIBLE`. Only supported when the `payment_method` is set to `paypal`. Allowed values:<br> `ITEM_NOT_RECEIVED_ELIGIBLE`- Sellers are protected against claims for items not received.<br> `UNAUTHORIZED_PAYMENT_ELIGIBLE`- Sellers are protected against claims for unauthorized payments.<br> One or both of the allowed values can be returned.
238
+ *
239
+ * @return string
240
+ */
241
+ public function getProtectionEligibilityType()
242
+ {
243
+ return $this->protection_eligibility_type;
244
+ }
245
+
246
+ /**
247
+ * ID of the Payment resource that this transaction is based on.
248
+ *
249
+ * @param string $parent_payment
250
+ *
251
+ * @return $this
252
+ */
253
+ public function setParentPayment($parent_payment)
254
+ {
255
+ $this->parent_payment = $parent_payment;
256
+ return $this;
257
+ }
258
+
259
+ /**
260
+ * ID of the Payment resource that this transaction is based on.
261
+ *
262
+ * @return string
263
+ */
264
+ public function getParentPayment()
265
+ {
266
+ return $this->parent_payment;
267
+ }
268
+
269
+ /**
270
+ * Fraud Management Filter (FMF) details applied for the payment that could result in accept/deny/pending action.
271
+ *
272
+ * @param \PayPal\Api\FmfDetails $fmf_details
273
+ *
274
+ * @return $this
275
+ */
276
+ public function setFmfDetails($fmf_details)
277
+ {
278
+ $this->fmf_details = $fmf_details;
279
+ return $this;
280
+ }
281
+
282
+ /**
283
+ * Fraud Management Filter (FMF) details applied for the payment that could result in accept/deny/pending action.
284
+ *
285
+ * @return \PayPal\Api\FmfDetails
286
+ */
287
+ public function getFmfDetails()
288
+ {
289
+ return $this->fmf_details;
290
+ }
291
+
292
+ /**
293
+ * Time the resource was created in UTC ISO8601 format.
294
+ *
295
+ * @param string $create_time
296
+ *
297
+ * @return $this
298
+ */
299
+ public function setCreateTime($create_time)
300
+ {
301
+ $this->create_time = $create_time;
302
+ return $this;
303
+ }
304
+
305
+ /**
306
+ * Time the resource was created in UTC ISO8601 format.
307
+ *
308
+ * @return string
309
+ */
310
+ public function getCreateTime()
311
+ {
312
+ return $this->create_time;
313
+ }
314
+
315
+ /**
316
+ * Time the resource was last updated in UTC ISO8601 format.
317
+ *
318
+ * @param string $update_time
319
+ *
320
+ * @return $this
321
+ */
322
+ public function setUpdateTime($update_time)
323
+ {
324
+ $this->update_time = $update_time;
325
+ return $this;
326
+ }
327
+
328
+ /**
329
+ * Time the resource was last updated in UTC ISO8601 format.
330
+ *
331
+ * @return string
332
+ */
333
+ public function getUpdateTime()
334
+ {
335
+ return $this->update_time;
336
+ }
337
+
338
+ /**
339
+ * Retrieve details about an order by passing the order_id in the request URI.
340
+ *
341
+ * @param string $orderId
342
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
343
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
344
+ * @return Order
345
+ */
346
+ public static function get($orderId, $apiContext = null, $restCall = null)
347
+ {
348
+ ArgumentValidator::validate($orderId, 'orderId');
349
+ $payLoad = "";
350
+ $json = self::executeCall(
351
+ "/v1/payments/orders/$orderId",
352
+ "GET",
353
+ $payLoad,
354
+ null,
355
+ $apiContext,
356
+ $restCall
357
+ );
358
+ $ret = new Order();
359
+ $ret->fromJson($json);
360
+ return $ret;
361
+ }
362
+
363
+ /**
364
+ * Capture a payment. 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.
365
+ *
366
+ * @param Capture $capture
367
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
368
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
369
+ * @return Capture
370
+ */
371
+ public function capture($capture, $apiContext = null, $restCall = null)
372
+ {
373
+ ArgumentValidator::validate($this->getId(), "Id");
374
+ ArgumentValidator::validate($capture, 'capture');
375
+ $payLoad = $capture->toJSON();
376
+ $json = self::executeCall(
377
+ "/v1/payments/orders/{$this->getId()}/capture",
378
+ "POST",
379
+ $payLoad,
380
+ null,
381
+ $apiContext,
382
+ $restCall
383
+ );
384
+ $ret = new Capture();
385
+ $ret->fromJson($json);
386
+ return $ret;
387
+ }
388
+
389
+ /**
390
+ * 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.
391
+ *
392
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
393
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
394
+ * @return Order
395
+ */
396
+ public function void($apiContext = null, $restCall = null)
397
+ {
398
+ ArgumentValidator::validate($this->getId(), "Id");
399
+ $payLoad = "";
400
+ $json = self::executeCall(
401
+ "/v1/payments/orders/{$this->getId()}/do-void",
402
+ "POST",
403
+ $payLoad,
404
+ null,
405
+ $apiContext,
406
+ $restCall
407
+ );
408
+ $this->fromJson($json);
409
+ return $this;
410
+ }
411
+
412
+ /**
413
+ * 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.
414
+ *
415
+ * @param Authorization $authorization Authorization Object with Amount value to be authorized
416
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
417
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
418
+ * @return Authorization
419
+ */
420
+ public function authorize($authorization, $apiContext = null, $restCall = null)
421
+ {
422
+ ArgumentValidator::validate($this->getId(), "Id");
423
+ ArgumentValidator::validate($authorization, 'Authorization');
424
+ $payLoad = $authorization->toJSON();
425
+ $json = self::executeCall(
426
+ "/v1/payments/orders/{$this->getId()}/authorize",
427
+ "POST",
428
+ $payLoad,
429
+ null,
430
+ $apiContext,
431
+ $restCall
432
+ );
433
+ $ret = new Authorization();
434
+ $ret->fromJson($json);
435
+ return $ret;
436
+ }
437
+
438
+ }
lib/PayPal/Api/OverrideChargeModel.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class OverrideChargeModel
9
+ *
10
+ * A resource representing an override_charge_model to be used during creation of the agreement.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string charge_id
15
+ * @property \PayPal\Api\Currency amount
16
+ */
17
+ class OverrideChargeModel extends PayPalModel
18
+ {
19
+ /**
20
+ * ID of charge model.
21
+ *
22
+ * @param string $charge_id
23
+ *
24
+ * @return $this
25
+ */
26
+ public function setChargeId($charge_id)
27
+ {
28
+ $this->charge_id = $charge_id;
29
+ return $this;
30
+ }
31
+
32
+ /**
33
+ * ID of charge model.
34
+ *
35
+ * @return string
36
+ */
37
+ public function getChargeId()
38
+ {
39
+ return $this->charge_id;
40
+ }
41
+
42
+ /**
43
+ * Updated Amount to be associated with this charge model.
44
+ *
45
+ * @param \PayPal\Api\Currency $amount
46
+ *
47
+ * @return $this
48
+ */
49
+ public function setAmount($amount)
50
+ {
51
+ $this->amount = $amount;
52
+ return $this;
53
+ }
54
+
55
+ /**
56
+ * Updated Amount to be associated with this charge model.
57
+ *
58
+ * @return \PayPal\Api\Currency
59
+ */
60
+ public function getAmount()
61
+ {
62
+ return $this->amount;
63
+ }
64
+
65
+ }
lib/PayPal/Api/Patch.php ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class Patch
9
+ *
10
+ * A JSON patch object used for applying partial updates to resources.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string op
15
+ * @property string path
16
+ * @property mixed value
17
+ * @property string from
18
+ */
19
+ class Patch extends PayPalModel
20
+ {
21
+ /**
22
+ * The operation to perform.
23
+ * Valid Values: ["add", "remove", "replace", "move", "copy", "test"]
24
+ *
25
+ * @param string $op
26
+ *
27
+ * @return $this
28
+ */
29
+ public function setOp($op)
30
+ {
31
+ $this->op = $op;
32
+ return $this;
33
+ }
34
+
35
+ /**
36
+ * The operation to perform.
37
+ *
38
+ * @return string
39
+ */
40
+ public function getOp()
41
+ {
42
+ return $this->op;
43
+ }
44
+
45
+ /**
46
+ * String containing a JSON Pointer value that references a location within the target document where the operation is performed.
47
+ *
48
+ * @param string $path
49
+ *
50
+ * @return $this
51
+ */
52
+ public function setPath($path)
53
+ {
54
+ $this->path = $path;
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * String containing a JSON Pointer value that references a location within the target document where the operation is performed.
60
+ *
61
+ * @return string
62
+ */
63
+ public function getPath()
64
+ {
65
+ return $this->path;
66
+ }
67
+
68
+ /**
69
+ * New value to apply based on the operation.
70
+ *
71
+ * @param mixed $value
72
+ *
73
+ * @return $this
74
+ */
75
+ public function setValue($value)
76
+ {
77
+ $this->value = $value;
78
+ return $this;
79
+ }
80
+
81
+ /**
82
+ * New value to apply based on the operation.
83
+ *
84
+ * @return mixed
85
+ */
86
+ public function getValue()
87
+ {
88
+ return $this->value;
89
+ }
90
+
91
+ /**
92
+ * A string containing a JSON Pointer value that references the location in the target document to move the value from.
93
+ *
94
+ * @param string $from
95
+ *
96
+ * @return $this
97
+ */
98
+ public function setFrom($from)
99
+ {
100
+ $this->from = $from;
101
+ return $this;
102
+ }
103
+
104
+ /**
105
+ * A string containing a JSON Pointer value that references the location in the target document to move the value from.
106
+ *
107
+ * @return string
108
+ */
109
+ public function getFrom()
110
+ {
111
+ return $this->from;
112
+ }
113
+
114
+ }
lib/PayPal/Api/PatchRequest.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class PatchRequest
9
+ *
10
+ * Request object used for a JSON Patch.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property \PayPal\Api\Patch[] patches
15
+ */
16
+ class PatchRequest extends PayPalModel
17
+ {
18
+ /**
19
+ * Placeholder for holding array of patch objects
20
+ *
21
+ * @param \PayPal\Api\Patch[] $patches
22
+ *
23
+ * @return $this
24
+ */
25
+ public function setPatches($patches)
26
+ {
27
+ $this->patches = $patches;
28
+ return $this;
29
+ }
30
+
31
+ /**
32
+ * Placeholder for holding array of patch objects
33
+ *
34
+ * @return \PayPal\Api\Patch[]
35
+ */
36
+ public function getPatches()
37
+ {
38
+ return $this->patches;
39
+ }
40
+
41
+ /**
42
+ * Append Patches to the list.
43
+ *
44
+ * @param \PayPal\Api\Patch $patch
45
+ * @return $this
46
+ */
47
+ public function addPatch($patch)
48
+ {
49
+ if (!$this->getPatches()) {
50
+ return $this->setPatches(array($patch));
51
+ } else {
52
+ return $this->setPatches(
53
+ array_merge($this->getPatches(), array($patch))
54
+ );
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Remove Patches from the list.
60
+ *
61
+ * @param \PayPal\Api\Patch $patch
62
+ * @return $this
63
+ */
64
+ public function removePatch($patch)
65
+ {
66
+ return $this->setPatches(
67
+ array_diff($this->getPatches(), array($patch))
68
+ );
69
+ }
70
+
71
+ /**
72
+ * As PatchRequest holds the array of Patch object, we would override the json conversion to return
73
+ * a json representation of array of Patch objects.
74
+ *
75
+ * @param int $options
76
+ * @return mixed|string
77
+ */
78
+ public function toJSON($options = 0)
79
+ {
80
+ $json = array();
81
+ foreach ($this->getPatches() as $patch) {
82
+ $json[] = $patch->toArray();
83
+ }
84
+ return str_replace('\\/', '/', json_encode($json, $options));
85
+ }
86
+ }
lib/PayPal/Api/Payee.php ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class Payee
9
+ *
10
+ * A resource representing a Payee who receives the funds and fulfills the order.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string email
15
+ * @property string merchant_id
16
+ */
17
+ class Payee extends PayPalModel
18
+ {
19
+ /**
20
+ * Email Address associated with the Payee's PayPal Account. If the provided email address is not associated with any PayPal Account, the payee can only receiver PayPal Wallet Payments. Direct Credit Card Payments will be denied due to card compliance requirements.
21
+ *
22
+ * @param string $email
23
+ *
24
+ * @return $this
25
+ */
26
+ public function setEmail($email)
27
+ {
28
+ $this->email = $email;
29
+ return $this;
30
+ }
31
+
32
+ /**
33
+ * Email Address associated with the Payee's PayPal Account. If the provided email address is not associated with any PayPal Account, the payee can only receiver PayPal Wallet Payments. Direct Credit Card Payments will be denied due to card compliance requirements.
34
+ *
35
+ * @return string
36
+ */
37
+ public function getEmail()
38
+ {
39
+ return $this->email;
40
+ }
41
+
42
+ /**
43
+ * Encrypted PayPal account identifier for the Payee.
44
+ *
45
+ * @param string $merchant_id
46
+ *
47
+ * @return $this
48
+ */
49
+ public function setMerchantId($merchant_id)
50
+ {
51
+ $this->merchant_id = $merchant_id;
52
+ return $this;
53
+ }
54
+
55
+ /**
56
+ * Encrypted PayPal account identifier for the Payee.
57
+ *
58
+ * @return string
59
+ */
60
+ public function getMerchantId()
61
+ {
62
+ return $this->merchant_id;
63
+ }
64
+
65
+ /**
66
+ * First Name of the Payee.
67
+ *
68
+ * @deprecated Not publicly available
69
+ * @param string $first_name
70
+ *
71
+ * @return $this
72
+ */
73
+ public function setFirstName($first_name)
74
+ {
75
+ $this->first_name = $first_name;
76
+ return $this;
77
+ }
78
+
79
+ /**
80
+ * First Name of the Payee.
81
+ *
82
+ * @deprecated Not publicly available
83
+ * @return string
84
+ */
85
+ public function getFirstName()
86
+ {
87
+ return $this->first_name;
88
+ }
89
+
90
+ /**
91
+ * Last Name of the Payee.
92
+ *
93
+ * @deprecated Not publicly available
94
+ * @param string $last_name
95
+ *
96
+ * @return $this
97
+ */
98
+ public function setLastName($last_name)
99
+ {
100
+ $this->last_name = $last_name;
101
+ return $this;
102
+ }
103
+
104
+ /**
105
+ * Last Name of the Payee.
106
+ *
107
+ * @deprecated Not publicly available
108
+ * @return string
109
+ */
110
+ public function getLastName()
111
+ {
112
+ return $this->last_name;
113
+ }
114
+
115
+ /**
116
+ * Unencrypted PayPal account Number of the Payee
117
+ *
118
+ * @deprecated Not publicly available
119
+ * @param string $account_number
120
+ *
121
+ * @return $this
122
+ */
123
+ public function setAccountNumber($account_number)
124
+ {
125
+ $this->account_number = $account_number;
126
+ return $this;
127
+ }
128
+
129
+ /**
130
+ * Unencrypted PayPal account Number of the Payee
131
+ *
132
+ * @deprecated Not publicly available
133
+ * @return string
134
+ */
135
+ public function getAccountNumber()
136
+ {
137
+ return $this->account_number;
138
+ }
139
+
140
+ /**
141
+ * Information related to the Payer. In case of PayPal Wallet payment, this information will be filled in by PayPal after the user approves the payment using their PayPal Wallet.
142
+ *
143
+ * @deprecated Not publicly available
144
+ * @param \PayPal\Api\Phone $phone
145
+ *
146
+ * @return $this
147
+ */
148
+ public function setPhone($phone)
149
+ {
150
+ $this->phone = $phone;
151
+ return $this;
152
+ }
153
+
154
+ /**
155
+ * Information related to the Payer. In case of PayPal Wallet payment, this information will be filled in by PayPal after the user approves the payment using their PayPal Wallet.
156
+ *
157
+ * @deprecated Not publicly available
158
+ * @return \PayPal\Api\Phone
159
+ */
160
+ public function getPhone()
161
+ {
162
+ return $this->phone;
163
+ }
164
+
165
+ }
lib/PayPal/Api/Payer.php ADDED
@@ -0,0 +1,270 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class Payer
9
+ *
10
+ * A resource representing a Payer that funds a payment.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string payment_method
15
+ * @property string status
16
+ * @property \PayPal\Api\FundingInstrument[] funding_instruments
17
+ * @property string funding_option_id
18
+ * @property \PayPal\Api\PayerInfo payer_info
19
+ */
20
+ class Payer extends PayPalModel
21
+ {
22
+ /**
23
+ * Payment method being used - PayPal Wallet payment, Bank Direct Debit or Direct Credit card.
24
+ * Valid Values: ["credit_card", "bank", "paypal", "pay_upon_invoice", "carrier", "alternate_payment"]
25
+ *
26
+ * @param string $payment_method
27
+ *
28
+ * @return $this
29
+ */
30
+ public function setPaymentMethod($payment_method)
31
+ {
32
+ $this->payment_method = $payment_method;
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * Payment method being used - PayPal Wallet payment, Bank Direct Debit or Direct Credit card.
38
+ *
39
+ * @return string
40
+ */
41
+ public function getPaymentMethod()
42
+ {
43
+ return $this->payment_method;
44
+ }
45
+
46
+ /**
47
+ * Status of payer's PayPal Account.
48
+ * Valid Values: ["VERIFIED", "UNVERIFIED"]
49
+ *
50
+ * @param string $status
51
+ *
52
+ * @return $this
53
+ */
54
+ public function setStatus($status)
55
+ {
56
+ $this->status = $status;
57
+ return $this;
58
+ }
59
+
60
+ /**
61
+ * Status of payer's PayPal Account.
62
+ *
63
+ * @return string
64
+ */
65
+ public function getStatus()
66
+ {
67
+ return $this->status;
68
+ }
69
+
70
+ /**
71
+ * Type of account relationship payer has with PayPal.
72
+ * Valid Values: ["BUSINESS", "PERSONAL", "PREMIER"]
73
+ *
74
+ * @deprecated Not publicly available
75
+ * @param string $account_type
76
+ *
77
+ * @return $this
78
+ */
79
+ public function setAccountType($account_type)
80
+ {
81
+ $this->account_type = $account_type;
82
+ return $this;
83
+ }
84
+
85
+ /**
86
+ * Type of account relationship payer has with PayPal.
87
+ *
88
+ * @deprecated Not publicly available
89
+ * @return string
90
+ */
91
+ public function getAccountType()
92
+ {
93
+ return $this->account_type;
94
+ }
95
+
96
+ /**
97
+ * Duration since the payer established account relationship with PayPal in days.
98
+ *
99
+ * @deprecated Not publicly available
100
+ * @param string $account_age
101
+ *
102
+ * @return $this
103
+ */
104
+ public function setAccountAge($account_age)
105
+ {
106
+ $this->account_age = $account_age;
107
+ return $this;
108
+ }
109
+
110
+ /**
111
+ * Duration since the payer established account relationship with PayPal in days.
112
+ *
113
+ * @deprecated Not publicly available
114
+ * @return string
115
+ */
116
+ public function getAccountAge()
117
+ {
118
+ return $this->account_age;
119
+ }
120
+
121
+ /**
122
+ * List of funding instruments to fund the payment. 'OneOf' funding_instruments,funding_option_id to be used to identify the specifics of payment method passed.
123
+ *
124
+ * @param \PayPal\Api\FundingInstrument[] $funding_instruments
125
+ *
126
+ * @return $this
127
+ */
128
+ public function setFundingInstruments($funding_instruments)
129
+ {
130
+ $this->funding_instruments = $funding_instruments;
131
+ return $this;
132
+ }
133
+
134
+ /**
135
+ * List of funding instruments to fund the payment. 'OneOf' funding_instruments,funding_option_id to be used to identify the specifics of payment method passed.
136
+ *
137
+ * @return \PayPal\Api\FundingInstrument[]
138
+ */
139
+ public function getFundingInstruments()
140
+ {
141
+ return $this->funding_instruments;
142
+ }
143
+
144
+ /**
145
+ * Append FundingInstruments to the list.
146
+ *
147
+ * @param \PayPal\Api\FundingInstrument $fundingInstrument
148
+ * @return $this
149
+ */
150
+ public function addFundingInstrument($fundingInstrument)
151
+ {
152
+ if (!$this->getFundingInstruments()) {
153
+ return $this->setFundingInstruments(array($fundingInstrument));
154
+ } else {
155
+ return $this->setFundingInstruments(
156
+ array_merge($this->getFundingInstruments(), array($fundingInstrument))
157
+ );
158
+ }
159
+ }
160
+
161
+ /**
162
+ * Remove FundingInstruments from the list.
163
+ *
164
+ * @param \PayPal\Api\FundingInstrument $fundingInstrument
165
+ * @return $this
166
+ */
167
+ public function removeFundingInstrument($fundingInstrument)
168
+ {
169
+ return $this->setFundingInstruments(
170
+ array_diff($this->getFundingInstruments(), array($fundingInstrument))
171
+ );
172
+ }
173
+
174
+ /**
175
+ * Id of user selected funding option for the payment.'OneOf' funding_instruments,funding_option_id to be used to identify the specifics of payment method passed.
176
+ *
177
+ * @param string $funding_option_id
178
+ *
179
+ * @return $this
180
+ */
181
+ public function setFundingOptionId($funding_option_id)
182
+ {
183
+ $this->funding_option_id = $funding_option_id;
184
+ return $this;
185
+ }
186
+
187
+ /**
188
+ * Id of user selected funding option for the payment.'OneOf' funding_instruments,funding_option_id to be used to identify the specifics of payment method passed.
189
+ *
190
+ * @return string
191
+ */
192
+ public function getFundingOptionId()
193
+ {
194
+ return $this->funding_option_id;
195
+ }
196
+
197
+ /**
198
+ * Default funding option available for the payment
199
+ *
200
+ * @deprecated Not publicly available
201
+ * @param \PayPal\Api\FundingOption $funding_option
202
+ *
203
+ * @return $this
204
+ */
205
+ public function setFundingOption($funding_option)
206
+ {
207
+ $this->funding_option = $funding_option;
208
+ return $this;
209
+ }
210
+
211
+ /**
212
+ * Default funding option available for the payment
213
+ *
214
+ * @deprecated Not publicly available
215
+ * @return \PayPal\Api\FundingOption
216
+ */
217
+ public function getFundingOption()
218
+ {
219
+ return $this->funding_option;
220
+ }
221
+
222
+ /**
223
+ * Funding option related to default funding option.
224
+ *
225
+ * @deprecated Not publicly available
226
+ * @param \PayPal\Api\FundingOption $related_funding_option
227
+ *
228
+ * @return $this
229
+ */
230
+ public function setRelatedFundingOption($related_funding_option)
231
+ {
232
+ $this->related_funding_option = $related_funding_option;
233
+ return $this;
234
+ }
235
+
236
+ /**
237
+ * Funding option related to default funding option.
238
+ *
239
+ * @deprecated Not publicly available
240
+ * @return \PayPal\Api\FundingOption
241
+ */
242
+ public function getRelatedFundingOption()
243
+ {
244
+ return $this->related_funding_option;
245
+ }
246
+
247
+ /**
248
+ * Information related to the Payer.
249
+ *
250
+ * @param \PayPal\Api\PayerInfo $payer_info
251
+ *
252
+ * @return $this
253
+ */
254
+ public function setPayerInfo($payer_info)
255
+ {
256
+ $this->payer_info = $payer_info;
257
+ return $this;
258
+ }
259
+
260
+ /**
261
+ * Information related to the Payer.
262
+ *
263
+ * @return \PayPal\Api\PayerInfo
264
+ */
265
+ public function getPayerInfo()
266
+ {
267
+ return $this->payer_info;
268
+ }
269
+
270
+ }
lib/PayPal/Api/PayerInfo.php ADDED
@@ -0,0 +1,428 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class PayerInfo
9
+ *
10
+ * A resource representing a information about Payer.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string email
15
+ * @property string external_remember_me_id
16
+ * @property string salutation
17
+ * @property string first_name
18
+ * @property string middle_name
19
+ * @property string last_name
20
+ * @property string suffix
21
+ * @property string payer_id
22
+ * @property string phone
23
+ * @property string phone_type
24
+ * @property string birth_date
25
+ * @property string tax_id
26
+ * @property string tax_id_type
27
+ * @property string country_code
28
+ * @property \PayPal\Api\Address billing_address
29
+ * @property \PayPal\Api\ShippingAddress shipping_address
30
+ */
31
+ class PayerInfo extends PayPalModel
32
+ {
33
+ /**
34
+ * Email address representing the payer. 127 characters max.
35
+ *
36
+ * @param string $email
37
+ *
38
+ * @return $this
39
+ */
40
+ public function setEmail($email)
41
+ {
42
+ $this->email = $email;
43
+ return $this;
44
+ }
45
+
46
+ /**
47
+ * Email address representing the payer. 127 characters max.
48
+ *
49
+ * @return string
50
+ */
51
+ public function getEmail()
52
+ {
53
+ return $this->email;
54
+ }
55
+
56
+ /**
57
+ * External Remember Me id representing the payer
58
+ *
59
+ * @param string $external_remember_me_id
60
+ *
61
+ * @return $this
62
+ */
63
+ public function setExternalRememberMeId($external_remember_me_id)
64
+ {
65
+ $this->external_remember_me_id = $external_remember_me_id;
66
+ return $this;
67
+ }
68
+
69
+ /**
70
+ * External Remember Me id representing the payer
71
+ *
72
+ * @return string
73
+ */
74
+ public function getExternalRememberMeId()
75
+ {
76
+ return $this->external_remember_me_id;
77
+ }
78
+
79
+ /**
80
+ * Account Number representing the Payer
81
+ *
82
+ * @deprecated Not publicly available
83
+ * @param string $account_number
84
+ *
85
+ * @return $this
86
+ */
87
+ public function setAccountNumber($account_number)
88
+ {
89
+ $this->account_number = $account_number;
90
+ return $this;
91
+ }
92
+
93
+ /**
94
+ * Account Number representing the Payer
95
+ *
96
+ * @deprecated Not publicly available
97
+ * @return string
98
+ */
99
+ public function getAccountNumber()
100
+ {
101
+ return $this->account_number;
102
+ }
103
+
104
+ /**
105
+ * Salutation of the payer.
106
+ *
107
+ * @param string $salutation
108
+ *
109
+ * @return $this
110
+ */
111
+ public function setSalutation($salutation)
112
+ {
113
+ $this->salutation = $salutation;
114
+ return $this;
115
+ }
116
+
117
+ /**
118
+ * Salutation of the payer.
119
+ *
120
+ * @return string
121
+ */
122
+ public function getSalutation()
123
+ {
124
+ return $this->salutation;
125
+ }
126
+
127
+ /**
128
+ * First name of the payer.
129
+ *
130
+ * @param string $first_name
131
+ *
132
+ * @return $this
133
+ */
134
+ public function setFirstName($first_name)
135
+ {
136
+ $this->first_name = $first_name;
137
+ return $this;
138
+ }
139
+
140
+ /**
141
+ * First name of the payer.
142
+ *
143
+ * @return string
144
+ */
145
+ public function getFirstName()
146
+ {
147
+ return $this->first_name;
148
+ }
149
+
150
+ /**
151
+ * Middle name of the payer.
152
+ *
153
+ * @param string $middle_name
154
+ *
155
+ * @return $this
156
+ */
157
+ public function setMiddleName($middle_name)
158
+ {
159
+ $this->middle_name = $middle_name;
160
+ return $this;
161
+ }
162
+
163
+ /**
164
+ * Middle name of the payer.
165
+ *
166
+ * @return string
167
+ */
168
+ public function getMiddleName()
169
+ {
170
+ return $this->middle_name;
171
+ }
172
+
173
+ /**
174
+ * Last name of the payer.
175
+ *
176
+ * @param string $last_name
177
+ *
178
+ * @return $this
179
+ */
180
+ public function setLastName($last_name)
181
+ {
182
+ $this->last_name = $last_name;
183
+ return $this;
184
+ }
185
+
186
+ /**
187
+ * Last name of the payer.
188
+ *
189
+ * @return string
190
+ */
191
+ public function getLastName()
192
+ {
193
+ return $this->last_name;
194
+ }
195
+
196
+ /**
197
+ * Suffix of the payer.
198
+ *
199
+ * @param string $suffix
200
+ *
201
+ * @return $this
202
+ */
203
+ public function setSuffix($suffix)
204
+ {
205
+ $this->suffix = $suffix;
206
+ return $this;
207
+ }
208
+
209
+ /**
210
+ * Suffix of the payer.
211
+ *
212
+ * @return string
213
+ */
214
+ public function getSuffix()
215
+ {
216
+ return $this->suffix;
217
+ }
218
+
219
+ /**
220
+ * PayPal assigned encrypted Payer ID.
221
+ *
222
+ * @param string $payer_id
223
+ *
224
+ * @return $this
225
+ */
226
+ public function setPayerId($payer_id)
227
+ {
228
+ $this->payer_id = $payer_id;
229
+ return $this;
230
+ }
231
+
232
+ /**
233
+ * PayPal assigned encrypted Payer ID.
234
+ *
235
+ * @return string
236
+ */
237
+ public function getPayerId()
238
+ {
239
+ return $this->payer_id;
240
+ }
241
+
242
+ /**
243
+ * Phone number representing the payer. 20 characters max.
244
+ *
245
+ * @param string $phone
246
+ *
247
+ * @return $this
248
+ */
249
+ public function setPhone($phone)
250
+ {
251
+ $this->phone = $phone;
252
+ return $this;
253
+ }
254
+
255
+ /**
256
+ * Phone number representing the payer. 20 characters max.
257
+ *
258
+ * @return string
259
+ */
260
+ public function getPhone()
261
+ {
262
+ return $this->phone;
263
+ }
264
+
265
+ /**
266
+ * Phone type
267
+ * Valid Values: ["HOME", "WORK", "MOBILE", "OTHER"]
268
+ *
269
+ * @param string $phone_type
270
+ *
271
+ * @return $this
272
+ */
273
+ public function setPhoneType($phone_type)
274
+ {
275
+ $this->phone_type = $phone_type;
276
+ return $this;
277
+ }
278
+
279
+ /**
280
+ * Phone type
281
+ *
282
+ * @return string
283
+ */
284
+ public function getPhoneType()
285
+ {
286
+ return $this->phone_type;
287
+ }
288
+
289
+ /**
290
+ * Birth date of the Payer in ISO8601 format (yyyy-mm-dd).
291
+ *
292
+ * @param string $birth_date
293
+ *
294
+ * @return $this
295
+ */
296
+ public function setBirthDate($birth_date)
297
+ {
298
+ $this->birth_date = $birth_date;
299
+ return $this;
300
+ }
301
+
302
+ /**
303
+ * Birth date of the Payer in ISO8601 format (yyyy-mm-dd).
304
+ *
305
+ * @return string
306
+ */
307
+ public function getBirthDate()
308
+ {
309
+ return $this->birth_date;
310
+ }
311
+
312
+ /**
313
+ * Payer’s tax ID. Only supported when the `payment_method` is set to `paypal`.
314
+ *
315
+ * @param string $tax_id
316
+ *
317
+ * @return $this
318
+ */
319
+ public function setTaxId($tax_id)
320
+ {
321
+ $this->tax_id = $tax_id;
322
+ return $this;
323
+ }
324
+
325
+ /**
326
+ * Payer’s tax ID. Only supported when the `payment_method` is set to `paypal`.
327
+ *
328
+ * @return string
329
+ */
330
+ public function getTaxId()
331
+ {
332
+ return $this->tax_id;
333
+ }
334
+
335
+ /**
336
+ * Payer’s tax ID type. Allowed values: `BR_CPF` or `BR_CNPJ`. Only supported when the `payment_method` is set to `paypal`.
337
+ * Valid Values: ["BR_CPF", "BR_CNPJ"]
338
+ *
339
+ * @param string $tax_id_type
340
+ *
341
+ * @return $this
342
+ */
343
+ public function setTaxIdType($tax_id_type)
344
+ {
345
+ $this->tax_id_type = $tax_id_type;
346
+ return $this;
347
+ }
348
+
349
+ /**
350
+ * Payer’s tax ID type. Allowed values: `BR_CPF` or `BR_CNPJ`. Only supported when the `payment_method` is set to `paypal`.
351
+ *
352
+ * @return string
353
+ */
354
+ public function getTaxIdType()
355
+ {
356
+ return $this->tax_id_type;
357
+ }
358
+
359
+ /**
360
+ * Two-letter registered country code of the payer to identify the buyer country.
361
+ *
362
+ * @param string $country_code
363
+ *
364
+ * @return $this
365
+ */
366
+ public function setCountryCode($country_code)
367
+ {
368
+ $this->country_code = $country_code;
369
+ return $this;
370
+ }
371
+
372
+ /**
373
+ * Two-letter registered country code of the payer to identify the buyer country.
374
+ *
375
+ * @return string
376
+ */
377
+ public function getCountryCode()
378
+ {
379
+ return $this->country_code;
380
+ }
381
+
382
+ /**
383
+ * Billing address of the Payer.
384
+ *
385
+ * @param \PayPal\Api\Address $billing_address
386
+ *
387
+ * @return $this
388
+ */
389
+ public function setBillingAddress($billing_address)
390
+ {
391
+ $this->billing_address = $billing_address;
392
+ return $this;
393
+ }
394
+
395
+ /**
396
+ * Billing address of the Payer.
397
+ *
398
+ * @return \PayPal\Api\Address
399
+ */
400
+ public function getBillingAddress()
401
+ {
402
+ return $this->billing_address;
403
+ }
404
+
405
+ /**
406
+ * Shipping address of payer PayPal account.
407
+ *
408
+ * @param \PayPal\Api\ShippingAddress $shipping_address
409
+ *
410
+ * @return $this
411
+ */
412
+ public function setShippingAddress($shipping_address)
413
+ {
414
+ $this->shipping_address = $shipping_address;
415
+ return $this;
416
+ }
417
+
418
+ /**
419
+ * Shipping address of payer PayPal account.
420
+ *
421
+ * @return \PayPal\Api\ShippingAddress
422
+ */
423
+ public function getShippingAddress()
424
+ {
425
+ return $this->shipping_address;
426
+ }
427
+
428
+ }
lib/PayPal/Api/Payment.php ADDED
@@ -0,0 +1,693 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalResourceModel;
6
+ use PayPal\Core\PayPalConstants;
7
+ use PayPal\Rest\ApiContext;
8
+ use PayPal\Transport\PayPalRestCall;
9
+ use PayPal\Validation\ArgumentValidator;
10
+
11
+ /**
12
+ * Class Payment
13
+ *
14
+ * Lets you create, process and manage payments.
15
+ *
16
+ * @package PayPal\Api
17
+ *
18
+ * @property string id
19
+ * @property string intent
20
+ * @property \PayPal\Api\Payer payer
21
+ * @property \PayPal\Api\PotentialPayerInfo potential_payer_info
22
+ * @property \PayPal\Api\Payee payee
23
+ * @property \PayPal\Api\Transaction[] transactions
24
+ * @property string[] billing_agreement_tokens
25
+ * @property \PayPal\Api\PaymentInstruction payment_instruction
26
+ * @property string state
27
+ * @property string experience_profile_id
28
+ * @property string note_to_payer
29
+ * @property \PayPal\Api\RedirectUrls redirect_urls
30
+ * @property string failure_reason
31
+ * @property string create_time
32
+ * @property string update_time
33
+ * @property \PayPal\Api\Links[] links
34
+ */
35
+ class Payment extends PayPalResourceModel
36
+ {
37
+ /**
38
+ * ID of the created payment, the 'transaction ID'
39
+ *
40
+ * @param string $id
41
+ *
42
+ * @return $this
43
+ */
44
+ public function setId($id)
45
+ {
46
+ $this->id = $id;
47
+ return $this;
48
+ }
49
+
50
+ /**
51
+ * ID of the created payment, the 'transaction ID'
52
+ *
53
+ * @return string
54
+ */
55
+ public function getId()
56
+ {
57
+ return $this->id;
58
+ }
59
+
60
+ /**
61
+ * Payment intent.
62
+ * Valid Values: ["sale", "authorize", "order"]
63
+ *
64
+ * @param string $intent
65
+ *
66
+ * @return $this
67
+ */
68
+ public function setIntent($intent)
69
+ {
70
+ $this->intent = $intent;
71
+ return $this;
72
+ }
73
+
74
+ /**
75
+ * Payment intent.
76
+ *
77
+ * @return string
78
+ */
79
+ public function getIntent()
80
+ {
81
+ return $this->intent;
82
+ }
83
+
84
+ /**
85
+ * Source of the funds for this payment represented by a PayPal account or a direct credit card.
86
+ *
87
+ * @param \PayPal\Api\Payer $payer
88
+ *
89
+ * @return $this
90
+ */
91
+ public function setPayer($payer)
92
+ {
93
+ $this->payer = $payer;
94
+ return $this;
95
+ }
96
+
97
+ /**
98
+ * Source of the funds for this payment represented by a PayPal account or a direct credit card.
99
+ *
100
+ * @return \PayPal\Api\Payer
101
+ */
102
+ public function getPayer()
103
+ {
104
+ return $this->payer;
105
+ }
106
+
107
+ /**
108
+ * Information that the merchant knows about the payer. This information is not definitive and only serves as a hint to the UI or any pre-processing logic.
109
+ *
110
+ * @param \PayPal\Api\PotentialPayerInfo $potential_payer_info
111
+ *
112
+ * @return $this
113
+ */
114
+ public function setPotentialPayerInfo($potential_payer_info)
115
+ {
116
+ $this->potential_payer_info = $potential_payer_info;
117
+ return $this;
118
+ }
119
+
120
+ /**
121
+ * Information that the merchant knows about the payer. This information is not definitive and only serves as a hint to the UI or any pre-processing logic.
122
+ *
123
+ * @return \PayPal\Api\PotentialPayerInfo
124
+ */
125
+ public function getPotentialPayerInfo()
126
+ {
127
+ return $this->potential_payer_info;
128
+ }
129
+
130
+ /**
131
+ * Receiver of funds for this payment. **Readonly for PayPal external REST payments.**
132
+ *
133
+ * @param \PayPal\Api\Payee $payee
134
+ *
135
+ * @return $this
136
+ */
137
+ public function setPayee($payee)
138
+ {
139
+ $this->payee = $payee;
140
+ return $this;
141
+ }
142
+
143
+ /**
144
+ * Receiver of funds for this payment. **Readonly for PayPal external REST payments.**
145
+ *
146
+ * @return \PayPal\Api\Payee
147
+ */
148
+ public function getPayee()
149
+ {
150
+ return $this->payee;
151
+ }
152
+
153
+ /**
154
+ * ID of the cart to execute the payment.
155
+ *
156
+ * @deprecated Not publicly available
157
+ * @param string $cart
158
+ *
159
+ * @return $this
160
+ */
161
+ public function setCart($cart)
162
+ {
163
+ $this->cart = $cart;
164
+ return $this;
165
+ }
166
+
167
+ /**
168
+ * ID of the cart to execute the payment.
169
+ *
170
+ * @deprecated Not publicly available
171
+ * @return string
172
+ */
173
+ public function getCart()
174
+ {
175
+ return $this->cart;
176
+ }
177
+
178
+ /**
179
+ * Transactional details including the amount and item details.
180
+ *
181
+ * @param \PayPal\Api\Transaction[] $transactions
182
+ *
183
+ * @return $this
184
+ */
185
+ public function setTransactions($transactions)
186
+ {
187
+ $this->transactions = $transactions;
188
+ return $this;
189
+ }
190
+
191
+ /**
192
+ * Transactional details including the amount and item details.
193
+ *
194
+ * @return \PayPal\Api\Transaction[]
195
+ */
196
+ public function getTransactions()
197
+ {
198
+ return $this->transactions;
199
+ }
200
+
201
+ /**
202
+ * Append Transactions to the list.
203
+ *
204
+ * @param \PayPal\Api\Transaction $transaction
205
+ * @return $this
206
+ */
207
+ public function addTransaction($transaction)
208
+ {
209
+ if (!$this->getTransactions()) {
210
+ return $this->setTransactions(array($transaction));
211
+ } else {
212
+ return $this->setTransactions(
213
+ array_merge($this->getTransactions(), array($transaction))
214
+ );
215
+ }
216
+ }
217
+
218
+ /**
219
+ * Remove Transactions from the list.
220
+ *
221
+ * @param \PayPal\Api\Transaction $transaction
222
+ * @return $this
223
+ */
224
+ public function removeTransaction($transaction)
225
+ {
226
+ return $this->setTransactions(
227
+ array_diff($this->getTransactions(), array($transaction))
228
+ );
229
+ }
230
+
231
+ /**
232
+ * Applicable for advanced payments like multi seller payment (MSP) to support partial failures
233
+ *
234
+ * @deprecated Not publicly available
235
+ * @param \PayPal\Api\Error[] $failed_transactions
236
+ *
237
+ * @return $this
238
+ */
239
+ public function setFailedTransactions($failed_transactions)
240
+ {
241
+ $this->failed_transactions = $failed_transactions;
242
+ return $this;
243
+ }
244
+
245
+ /**
246
+ * Applicable for advanced payments like multi seller payment (MSP) to support partial failures
247
+ *
248
+ * @deprecated Not publicly available
249
+ * @return \PayPal\Api\Error[]
250
+ */
251
+ public function getFailedTransactions()
252
+ {
253
+ return $this->failed_transactions;
254
+ }
255
+
256
+ /**
257
+ * Append FailedTransactions to the list.
258
+ *
259
+ * @deprecated Not publicly available
260
+ * @param \PayPal\Api\Error $error
261
+ * @return $this
262
+ */
263
+ public function addFailedTransaction($error)
264
+ {
265
+ if (!$this->getFailedTransactions()) {
266
+ return $this->setFailedTransactions(array($error));
267
+ } else {
268
+ return $this->setFailedTransactions(
269
+ array_merge($this->getFailedTransactions(), array($error))
270
+ );
271
+ }
272
+ }
273
+
274
+ /**
275
+ * Remove FailedTransactions from the list.
276
+ *
277
+ * @deprecated Not publicly available
278
+ * @param \PayPal\Api\Error $error
279
+ * @return $this
280
+ */
281
+ public function removeFailedTransaction($error)
282
+ {
283
+ return $this->setFailedTransactions(
284
+ array_diff($this->getFailedTransactions(), array($error))
285
+ );
286
+ }
287
+
288
+ /**
289
+ * Collection of PayPal generated billing agreement tokens.
290
+ *
291
+ * @param string[] $billing_agreement_tokens
292
+ *
293
+ * @return $this
294
+ */
295
+ public function setBillingAgreementTokens($billing_agreement_tokens)
296
+ {
297
+ $this->billing_agreement_tokens = $billing_agreement_tokens;
298
+ return $this;
299
+ }
300
+
301
+ /**
302
+ * Collection of PayPal generated billing agreement tokens.
303
+ *
304
+ * @return string[]
305
+ */
306
+ public function getBillingAgreementTokens()
307
+ {
308
+ return $this->billing_agreement_tokens;
309
+ }
310
+
311
+ /**
312
+ * Append BillingAgreementTokens to the list.
313
+ *
314
+ * @param string $billingAgreementToken
315
+ * @return $this
316
+ */
317
+ public function addBillingAgreementToken($billingAgreementToken)
318
+ {
319
+ if (!$this->getBillingAgreementTokens()) {
320
+ return $this->setBillingAgreementTokens(array($billingAgreementToken));
321
+ } else {
322
+ return $this->setBillingAgreementTokens(
323
+ array_merge($this->getBillingAgreementTokens(), array($billingAgreementToken))
324
+ );
325
+ }
326
+ }
327
+
328
+ /**
329
+ * Remove BillingAgreementTokens from the list.
330
+ *
331
+ * @param string $billingAgreementToken
332
+ * @return $this
333
+ */
334
+ public function removeBillingAgreementToken($billingAgreementToken)
335
+ {
336
+ return $this->setBillingAgreementTokens(
337
+ array_diff($this->getBillingAgreementTokens(), array($billingAgreementToken))
338
+ );
339
+ }
340
+
341
+ /**
342
+ * Credit financing offered to payer on PayPal side. Returned in payment after payer opts-in
343
+ *
344
+ * @deprecated Not publicly available
345
+ * @param \PayPal\Api\CreditFinancingOffered $credit_financing_offered
346
+ *
347
+ * @return $this
348
+ */
349
+ public function setCreditFinancingOffered($credit_financing_offered)
350
+ {
351
+ $this->credit_financing_offered = $credit_financing_offered;
352
+ return $this;
353
+ }
354
+
355
+ /**
356
+ * Credit financing offered to payer on PayPal side. Returned in payment after payer opts-in
357
+ *
358
+ * @deprecated Not publicly available
359
+ * @return \PayPal\Api\CreditFinancingOffered
360
+ */
361
+ public function getCreditFinancingOffered()
362
+ {
363
+ return $this->credit_financing_offered;
364
+ }
365
+
366
+ /**
367
+ * Instructions for the payer to complete this payment.
368
+ *
369
+ * @param \PayPal\Api\PaymentInstruction $payment_instruction
370
+ *
371
+ * @return $this
372
+ */
373
+ public function setPaymentInstruction($payment_instruction)
374
+ {
375
+ $this->payment_instruction = $payment_instruction;
376
+ return $this;
377
+ }
378
+
379
+ /**
380
+ * Instructions for the payer to complete this payment.
381
+ *
382
+ * @return \PayPal\Api\PaymentInstruction
383
+ */
384
+ public function getPaymentInstruction()
385
+ {
386
+ return $this->payment_instruction;
387
+ }
388
+
389
+ /**
390
+ * Payment state.
391
+ * Valid Values: ["created", "approved", "failed", "partially_completed", "in_progress"]
392
+ *
393
+ * @param string $state
394
+ *
395
+ * @return $this
396
+ */
397
+ public function setState($state)
398
+ {
399
+ $this->state = $state;
400
+ return $this;
401
+ }
402
+
403
+ /**
404
+ * Payment state.
405
+ *
406
+ * @return string
407
+ */
408
+ public function getState()
409
+ {
410
+ return $this->state;
411
+ }
412
+
413
+ /**
414
+ * PayPal generated identifier for the merchant's payment experience profile. Refer to [this](https://developer.paypal.com/webapps/developer/docs/api/#payment-experience) link to create experience profile ID.
415
+ *
416
+ * @param string $experience_profile_id
417
+ *
418
+ * @return $this
419
+ */
420
+ public function setExperienceProfileId($experience_profile_id)
421
+ {
422
+ $this->experience_profile_id = $experience_profile_id;
423
+ return $this;
424
+ }
425
+
426
+ /**
427
+ * PayPal generated identifier for the merchant's payment experience profile. Refer to [this](https://developer.paypal.com/webapps/developer/docs/api/#payment-experience) link to create experience profile ID.
428
+ *
429
+ * @return string
430
+ */
431
+ public function getExperienceProfileId()
432
+ {
433
+ return $this->experience_profile_id;
434
+ }
435
+
436
+ /**
437
+ * free-form field for the use of clients to pass in a message to the payer
438
+ *
439
+ * @param string $note_to_payer
440
+ *
441
+ * @return $this
442
+ */
443
+ public function setNoteToPayer($note_to_payer)
444
+ {
445
+ $this->note_to_payer = $note_to_payer;
446
+ return $this;
447
+ }
448
+
449
+ /**
450
+ * free-form field for the use of clients to pass in a message to the payer
451
+ *
452
+ * @return string
453
+ */
454
+ public function getNoteToPayer()
455
+ {
456
+ return $this->note_to_payer;
457
+ }
458
+
459
+ /**
460
+ * Set of redirect URLs you provide only for PayPal-based payments.
461
+ *
462
+ * @param \PayPal\Api\RedirectUrls $redirect_urls
463
+ *
464
+ * @return $this
465
+ */
466
+ public function setRedirectUrls($redirect_urls)
467
+ {
468
+ $this->redirect_urls = $redirect_urls;
469
+ return $this;
470
+ }
471
+
472
+ /**
473
+ * Set of redirect URLs you provide only for PayPal-based payments.
474
+ *
475
+ * @return \PayPal\Api\RedirectUrls
476
+ */
477
+ public function getRedirectUrls()
478
+ {
479
+ return $this->redirect_urls;
480
+ }
481
+
482
+ /**
483
+ * Failure reason code returned when the payment failed for some valid reasons.
484
+ * Valid Values: ["UNABLE_TO_COMPLETE_TRANSACTION", "INVALID_PAYMENT_METHOD", "PAYER_CANNOT_PAY", "CANNOT_PAY_THIS_PAYEE", "REDIRECT_REQUIRED", "PAYEE_FILTER_RESTRICTIONS"]
485
+ *
486
+ * @param string $failure_reason
487
+ *
488
+ * @return $this
489
+ */
490
+ public function setFailureReason($failure_reason)
491
+ {
492
+ $this->failure_reason = $failure_reason;
493
+ return $this;
494
+ }
495
+
496
+ /**
497
+ * Failure reason code returned when the payment failed for some valid reasons.
498
+ *
499
+ * @return string
500
+ */
501
+ public function getFailureReason()
502
+ {
503
+ return $this->failure_reason;
504
+ }
505
+
506
+ /**
507
+ * Payment creation time as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6).
508
+ *
509
+ * @param string $create_time
510
+ *
511
+ * @return $this
512
+ */
513
+ public function setCreateTime($create_time)
514
+ {
515
+ $this->create_time = $create_time;
516
+ return $this;
517
+ }
518
+
519
+ /**
520
+ * Payment creation time as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6).
521
+ *
522
+ * @return string
523
+ */
524
+ public function getCreateTime()
525
+ {
526
+ return $this->create_time;
527
+ }
528
+
529
+ /**
530
+ * Payment update time as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6).
531
+ *
532
+ * @param string $update_time
533
+ *
534
+ * @return $this
535
+ */
536
+ public function setUpdateTime($update_time)
537
+ {
538
+ $this->update_time = $update_time;
539
+ return $this;
540
+ }
541
+
542
+ /**
543
+ * Payment update time as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6).
544
+ *
545
+ * @return string
546
+ */
547
+ public function getUpdateTime()
548
+ {
549
+ return $this->update_time;
550
+ }
551
+
552
+ /**
553
+ * Get Approval Link
554
+ *
555
+ * @return null|string
556
+ */
557
+ public function getApprovalLink()
558
+ {
559
+ return $this->getLink(PayPalConstants::APPROVAL_URL);
560
+ }
561
+
562
+ /**
563
+ * Create and process a payment by passing a payment object that includes the intent, payer, and transactions in the body of the request JSON. For PayPal payments, include redirect URLs in the payment object.
564
+ *
565
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
566
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
567
+ * @return Payment
568
+ */
569
+ public function create($apiContext = null, $restCall = null)
570
+ {
571
+ $payLoad = $this->toJSON();
572
+ $json = self::executeCall(
573
+ "/v1/payments/payment",
574
+ "POST",
575
+ $payLoad,
576
+ null,
577
+ $apiContext,
578
+ $restCall
579
+ );
580
+ $this->fromJson($json);
581
+ return $this;
582
+ }
583
+
584
+ /**
585
+ * Look up a particular payment resource by passing the payment_id in the request URI.
586
+ *
587
+ * @param string $paymentId
588
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
589
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
590
+ * @return Payment
591
+ */
592
+ public static function get($paymentId, $apiContext = null, $restCall = null)
593
+ {
594
+ ArgumentValidator::validate($paymentId, 'paymentId');
595
+ $payLoad = "";
596
+ $json = self::executeCall(
597
+ "/v1/payments/payment/$paymentId",
598
+ "GET",
599
+ $payLoad,
600
+ null,
601
+ $apiContext,
602
+ $restCall
603
+ );
604
+ $ret = new Payment();
605
+ $ret->fromJson($json);
606
+ return $ret;
607
+ }
608
+
609
+ /**
610
+ * Use this call to partially update the payment resource for the given identifier. Allowed objects are amount, shipping_address, invoice_id and custom. Please note that it is not possible to use patch after execute has been called.
611
+ *
612
+ * @param PatchRequest $patchRequest
613
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
614
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
615
+ * @return boolean
616
+ */
617
+ public function update($patchRequest, $apiContext = null, $restCall = null)
618
+ {
619
+ ArgumentValidator::validate($this->getId(), "Id");
620
+ ArgumentValidator::validate($patchRequest, 'patchRequest');
621
+ $payLoad = $patchRequest->toJSON();
622
+ self::executeCall(
623
+ "/v1/payments/payment/{$this->getId()}",
624
+ "PATCH",
625
+ $payLoad,
626
+ null,
627
+ $apiContext,
628
+ $restCall
629
+ );
630
+ return true;
631
+ }
632
+
633
+ /**
634
+ * Execute (complete) a PayPal payment that has been approved by the payer. Optionally update selective payment information when executing the payment.
635
+ *
636
+ * @param PaymentExecution $paymentExecution
637
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
638
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
639
+ * @return Payment
640
+ */
641
+ public function execute($paymentExecution, $apiContext = null, $restCall = null)
642
+ {
643
+ ArgumentValidator::validate($this->getId(), "Id");
644
+ ArgumentValidator::validate($paymentExecution, 'paymentExecution');
645
+ $payLoad = $paymentExecution->toJSON();
646
+ $json = self::executeCall(
647
+ "/v1/payments/payment/{$this->getId()}/execute",
648
+ "POST",
649
+ $payLoad,
650
+ null,
651
+ $apiContext,
652
+ $restCall
653
+ );
654
+ $this->fromJson($json);
655
+ return $this;
656
+ }
657
+
658
+ /**
659
+ * List payments in any state (created, approved, failed, etc.). Payments returned are the payments made to the merchant issuing the request.
660
+ *
661
+ * @param array $params
662
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
663
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
664
+ * @return PaymentHistory
665
+ */
666
+ public static function all($params, $apiContext = null, $restCall = null)
667
+ {
668
+ ArgumentValidator::validate($params, 'params');
669
+ $payLoad = "";
670
+ $allowedParams = array(
671
+ 'count' => 1,
672
+ 'start_id' => 1,
673
+ 'start_index' => 1,
674
+ 'start_time' => 1,
675
+ 'end_time' => 1,
676
+ 'payee_id' => 1,
677
+ 'sort_by' => 1,
678
+ 'sort_order' => 1,
679
+ );
680
+ $json = self::executeCall(
681
+ "/v1/payments/payment?" . http_build_query(array_intersect_key($params, $allowedParams)),
682
+ "GET",
683
+ $payLoad,
684
+ null,
685
+ $apiContext,
686
+ $restCall
687
+ );
688
+ $ret = new PaymentHistory();
689
+ $ret->fromJson($json);
690
+ return $ret;
691
+ }
692
+
693
+ }
lib/PayPal/Api/PaymentCard.php ADDED
@@ -0,0 +1,457 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class PaymentCard
9
+ *
10
+ * A resource representing a payment card that can be used to fund a payment.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string id
15
+ * @property string number
16
+ * @property string type
17
+ * @property string expire_month
18
+ * @property string expire_year
19
+ * @property string start_month
20
+ * @property string start_year
21
+ * @property string cvv2
22
+ * @property string first_name
23
+ * @property string last_name
24
+ * @property string billing_country
25
+ * @property \PayPal\Api\Address billing_address
26
+ * @property string external_customer_id
27
+ * @property string status
28
+ * @property string valid_until
29
+ * @property string issue_number
30
+ * @property \PayPal\Api\Links[] links
31
+ */
32
+ class PaymentCard extends PayPalModel
33
+ {
34
+ /**
35
+ * ID of the credit card being saved for later use.
36
+ *
37
+ * @param string $id
38
+ *
39
+ * @return $this
40
+ */
41
+ public function setId($id)
42
+ {
43
+ $this->id = $id;
44
+ return $this;
45
+ }
46
+
47
+ /**
48
+ * ID of the credit card being saved for later use.
49
+ *
50
+ * @return string
51
+ */
52
+ public function getId()
53
+ {
54
+ return $this->id;
55
+ }
56
+
57
+ /**
58
+ * Card number.
59
+ *
60
+ * @param string $number
61
+ *
62
+ * @return $this
63
+ */
64
+ public function setNumber($number)
65
+ {
66
+ $this->number = $number;
67
+ return $this;
68
+ }
69
+
70
+ /**
71
+ * Card number.
72
+ *
73
+ * @return string
74
+ */
75
+ public function getNumber()
76
+ {
77
+ return $this->number;
78
+ }
79
+
80
+ /**
81
+ * Type of the Card.
82
+ * Valid Values: ["VISA", "AMEX", "SOLO", "JCB", "STAR", "DELTA", "DISCOVER", "SWITCH", "MAESTRO", "CB_NATIONALE", "CONFINOGA", "COFIDIS", "ELECTRON", "CETELEM", "CHINA_UNION_PAY", "MASTERCARD"]
83
+ *
84
+ * @param string $type
85
+ *
86
+ * @return $this
87
+ */
88
+ public function setType($type)
89
+ {
90
+ $this->type = $type;
91
+ return $this;
92
+ }
93
+
94
+ /**
95
+ * Type of the Card.
96
+ *
97
+ * @return string
98
+ */
99
+ public function getType()
100
+ {
101
+ return $this->type;
102
+ }
103
+
104
+ /**
105
+ * 2 digit card expiry month.
106
+ *
107
+ * @param string $expire_month
108
+ *
109
+ * @return $this
110
+ */
111
+ public function setExpireMonth($expire_month)
112
+ {
113
+ $this->expire_month = $expire_month;
114
+ return $this;
115
+ }
116
+
117
+ /**
118
+ * 2 digit card expiry month.
119
+ *
120
+ * @return string
121
+ */
122
+ public function getExpireMonth()
123
+ {
124
+ return $this->expire_month;
125
+ }
126
+
127
+ /**
128
+ * 4 digit card expiry year
129
+ *
130
+ * @param string $expire_year
131
+ *
132
+ * @return $this
133
+ */
134
+ public function setExpireYear($expire_year)
135
+ {
136
+ $this->expire_year = $expire_year;
137
+ return $this;
138
+ }
139
+
140
+ /**
141
+ * 4 digit card expiry year
142
+ *
143
+ * @return string
144
+ */
145
+ public function getExpireYear()
146
+ {
147
+ return $this->expire_year;
148
+ }
149
+
150
+ /**
151
+ * 2 digit card start month. Needed for UK Maestro Card.
152
+ *
153
+ * @param string $start_month
154
+ *
155
+ * @return $this
156
+ */
157
+ public function setStartMonth($start_month)
158
+ {
159
+ $this->start_month = $start_month;
160
+ return $this;
161
+ }
162
+
163
+ /**
164
+ * 2 digit card start month. Needed for UK Maestro Card.
165
+ *
166
+ * @return string
167
+ */
168
+ public function getStartMonth()
169
+ {
170
+ return $this->start_month;
171
+ }
172
+
173
+ /**
174
+ * 4 digit card start year. Needed for UK Maestro Card.
175
+ *
176
+ * @param string $start_year
177
+ *
178
+ * @return $this
179
+ */
180
+ public function setStartYear($start_year)
181
+ {
182
+ $this->start_year = $start_year;
183
+ return $this;
184
+ }
185
+
186
+ /**
187
+ * 4 digit card start year. Needed for UK Maestro Card.
188
+ *
189
+ * @return string
190
+ */
191
+ public function getStartYear()
192
+ {
193
+ return $this->start_year;
194
+ }
195
+
196
+ /**
197
+ * Card validation code. Only supported when making a Payment but not when saving a payment card for future use.
198
+ *
199
+ * @param string $cvv2
200
+ *
201
+ * @return $this
202
+ */
203
+ public function setCvv2($cvv2)
204
+ {
205
+ $this->cvv2 = $cvv2;
206
+ return $this;
207
+ }
208
+
209
+ /**
210
+ * Card validation code. Only supported when making a Payment but not when saving a payment card for future use.
211
+ *
212
+ * @return string
213
+ */
214
+ public function getCvv2()
215
+ {
216
+ return $this->cvv2;
217
+ }
218
+
219
+ /**
220
+ * Card holder's first name.
221
+ *
222
+ * @param string $first_name
223
+ *
224
+ * @return $this
225
+ */
226
+ public function setFirstName($first_name)
227
+ {
228
+ $this->first_name = $first_name;
229
+ return $this;
230
+ }
231
+
232
+ /**
233
+ * Card holder's first name.
234
+ *
235
+ * @return string
236
+ */
237
+ public function getFirstName()
238
+ {
239
+ return $this->first_name;
240
+ }
241
+
242
+ /**
243
+ * Card holder's last name.
244
+ *
245
+ * @param string $last_name
246
+ *
247
+ * @return $this
248
+ */
249
+ public function setLastName($last_name)
250
+ {
251
+ $this->last_name = $last_name;
252
+ return $this;
253
+ }
254
+
255
+ /**
256
+ * Card holder's last name.
257
+ *
258
+ * @return string
259
+ */
260
+ public function getLastName()
261
+ {
262
+ return $this->last_name;
263
+ }
264
+
265
+ /**
266
+ * 2 letter country code
267
+ *
268
+ * @param string $billing_country
269
+ *
270
+ * @return $this
271
+ */
272
+ public function setBillingCountry($billing_country)
273
+ {
274
+ $this->billing_country = $billing_country;
275
+ return $this;
276
+ }
277
+
278
+ /**
279
+ * 2 letter country code
280
+ *
281
+ * @return string
282
+ */
283
+ public function getBillingCountry()
284
+ {
285
+ return $this->billing_country;
286
+ }
287
+
288
+ /**
289
+ * Billing Address associated with this card.
290
+ *
291
+ * @param \PayPal\Api\Address $billing_address
292
+ *
293
+ * @return $this
294
+ */
295
+ public function setBillingAddress($billing_address)
296
+ {
297
+ $this->billing_address = $billing_address;
298
+ return $this;
299
+ }
300
+
301
+ /**
302
+ * Billing Address associated with this card.
303
+ *
304
+ * @return \PayPal\Api\Address
305
+ */
306
+ public function getBillingAddress()
307
+ {
308
+ return $this->billing_address;
309
+ }
310
+
311
+ /**
312
+ * A unique identifier of the customer to whom this card account belongs to. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault.
313
+ *
314
+ * @param string $external_customer_id
315
+ *
316
+ * @return $this
317
+ */
318
+ public function setExternalCustomerId($external_customer_id)
319
+ {
320
+ $this->external_customer_id = $external_customer_id;
321
+ return $this;
322
+ }
323
+
324
+ /**
325
+ * A unique identifier of the customer to whom this card account belongs to. Generated and provided by the facilitator. This is required when creating or using a stored funding instrument in vault.
326
+ *
327
+ * @return string
328
+ */
329
+ public function getExternalCustomerId()
330
+ {
331
+ return $this->external_customer_id;
332
+ }
333
+
334
+ /**
335
+ * State of the funding instrument.
336
+ * Valid Values: ["EXPIRED", "ACTIVE"]
337
+ *
338
+ * @param string $status
339
+ *
340
+ * @return $this
341
+ */
342
+ public function setStatus($status)
343
+ {
344
+ $this->status = $status;
345
+ return $this;
346
+ }
347
+
348
+ /**
349
+ * State of the funding instrument.
350
+ *
351
+ * @return string
352
+ */
353
+ public function getStatus()
354
+ {
355
+ return $this->status;
356
+ }
357
+
358
+ /**
359
+ * Date/Time until this resource can be used fund a payment.
360
+ *
361
+ * @param string $valid_until
362
+ *
363
+ * @return $this
364
+ */
365
+ public function setValidUntil($valid_until)
366
+ {
367
+ $this->valid_until = $valid_until;
368
+ return $this;
369
+ }
370
+
371
+ /**
372
+ * Date/Time until this resource can be used fund a payment.
373
+ *
374
+ * @return string
375
+ */
376
+ public function getValidUntil()
377
+ {
378
+ return $this->valid_until;
379
+ }
380
+
381
+ /**
382
+ * 1-2 digit card issue number. Needed for UK Maestro Card.
383
+ *
384
+ * @param string $issue_number
385
+ *
386
+ * @return $this
387
+ */
388
+ public function setIssueNumber($issue_number)
389
+ {
390
+ $this->issue_number = $issue_number;
391
+ return $this;
392
+ }
393
+
394
+ /**
395
+ * 1-2 digit card issue number. Needed for UK Maestro Card.
396
+ *
397
+ * @return string
398
+ */
399
+ public function getIssueNumber()
400
+ {
401
+ return $this->issue_number;
402
+ }
403
+
404
+ /**
405
+ * Sets Links
406
+ *
407
+ * @param \PayPal\Api\Links[] $links
408
+ *
409
+ * @return $this
410
+ */
411
+ public function setLinks($links)
412
+ {
413
+ $this->links = $links;
414
+ return $this;
415
+ }
416
+
417
+ /**
418
+ * Gets Links
419
+ *
420
+ * @return \PayPal\Api\Links[]
421
+ */
422
+ public function getLinks()
423
+ {
424
+ return $this->links;
425
+ }
426
+
427
+ /**
428
+ * Append Links to the list.
429
+ *
430
+ * @param \PayPal\Api\Links $links
431
+ * @return $this
432
+ */
433
+ public function addLink($links)
434
+ {
435
+ if (!$this->getLinks()) {
436
+ return $this->setLinks(array($links));
437
+ } else {
438
+ return $this->setLinks(
439
+ array_merge($this->getLinks(), array($links))
440
+ );
441
+ }
442
+ }
443
+
444
+ /**
445
+ * Remove Links from the list.
446
+ *
447
+ * @param \PayPal\Api\Links $links
448
+ * @return $this
449
+ */
450
+ public function removeLink($links)
451
+ {
452
+ return $this->setLinks(
453
+ array_diff($this->getLinks(), array($links))
454
+ );
455
+ }
456
+
457
+ }
lib/PayPal/Api/PaymentCardToken.php ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class PaymentCardToken
9
+ *
10
+ * A resource representing a payment card that can be used to fund a payment.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string payment_card_id
15
+ * @property string external_customer_id
16
+ * @property string last4
17
+ * @property string type
18
+ * @property int expire_month
19
+ * @property int expire_year
20
+ */
21
+ class PaymentCardToken extends PayPalModel
22
+ {
23
+ /**
24
+ * ID of a previously saved Payment Card resource.
25
+ *
26
+ * @param string $payment_card_id
27
+ *
28
+ * @return $this
29
+ */
30
+ public function setPaymentCardId($payment_card_id)
31
+ {
32
+ $this->payment_card_id = $payment_card_id;
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * ID of a previously saved Payment Card resource.
38
+ *
39
+ * @return string
40
+ */
41
+ public function getPaymentCardId()
42
+ {
43
+ return $this->payment_card_id;
44
+ }
45
+
46
+ /**
47
+ * The unique identifier of the payer used when saving this payment card.
48
+ *
49
+ * @param string $external_customer_id
50
+ *
51
+ * @return $this
52
+ */
53
+ public function setExternalCustomerId($external_customer_id)
54
+ {
55
+ $this->external_customer_id = $external_customer_id;
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * The unique identifier of the payer used when saving this payment card.
61
+ *
62
+ * @return string
63
+ */
64
+ public function getExternalCustomerId()
65
+ {
66
+ return $this->external_customer_id;
67
+ }
68
+
69
+ /**
70
+ * Last 4 digits of the card number from the saved card.
71
+ *
72
+ * @param string $last4
73
+ *
74
+ * @return $this
75
+ */
76
+ public function setLast4($last4)
77
+ {
78
+ $this->last4 = $last4;
79
+ return $this;
80
+ }
81
+
82
+ /**
83
+ * Last 4 digits of the card number from the saved card.
84
+ *
85
+ * @return string
86
+ */
87
+ public function getLast4()
88
+ {
89
+ return $this->last4;
90
+ }
91
+
92
+ /**
93
+ * Type of the Card.
94
+ * Valid Values: ["VISA", "AMEX", "SOLO", "JCB", "STAR", "DELTA", "DISCOVER", "SWITCH", "MAESTRO", "CB_NATIONALE", "CONFINOGA", "COFIDIS", "ELECTRON", "CETELEM", "CHINA_UNION_PAY", "MASTERCARD"]
95
+ *
96
+ * @param string $type
97
+ *
98
+ * @return $this
99
+ */
100
+ public function setType($type)
101
+ {
102
+ $this->type = $type;
103
+ return $this;
104
+ }
105
+
106
+ /**
107
+ * Type of the Card.
108
+ *
109
+ * @return string
110
+ */
111
+ public function getType()
112
+ {
113
+ return $this->type;
114
+ }
115
+
116
+ /**
117
+ * Expiry month from the saved card with value 1 - 12.
118
+ *
119
+ * @param int $expire_month
120
+ *
121
+ * @return $this
122
+ */
123
+ public function setExpireMonth($expire_month)
124
+ {
125
+ $this->expire_month = $expire_month;
126
+ return $this;
127
+ }
128
+
129
+ /**
130
+ * Expiry month from the saved card with value 1 - 12.
131
+ *
132
+ * @return int
133
+ */
134
+ public function getExpireMonth()
135
+ {
136
+ return $this->expire_month;
137
+ }
138
+
139
+ /**
140
+ * Four digit expiry year from the saved card, represented as YYYY format.
141
+ *
142
+ * @param int $expire_year
143
+ *
144
+ * @return $this
145
+ */
146
+ public function setExpireYear($expire_year)
147
+ {
148
+ $this->expire_year = $expire_year;
149
+ return $this;
150
+ }
151
+
152
+ /**
153
+ * Four digit expiry year from the saved card, represented as YYYY format.
154
+ *
155
+ * @return int
156
+ */
157
+ public function getExpireYear()
158
+ {
159
+ return $this->expire_year;
160
+ }
161
+
162
+ }
lib/PayPal/Api/PaymentDefinition.php ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class PaymentDefinition
9
+ *
10
+ * Resource representing payment definition scheduling information.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string id
15
+ * @property string name
16
+ * @property string type
17
+ * @property string frequency_interval
18
+ * @property string frequency
19
+ * @property string cycles
20
+ * @property \PayPal\Api\Currency amount
21
+ * @property \PayPal\Api\ChargeModel[] charge_models
22
+ */
23
+ class PaymentDefinition extends PayPalModel
24
+ {
25
+ /**
26
+ * Identifier of the payment_definition. 128 characters max.
27
+ *
28
+ * @param string $id
29
+ *
30
+ * @return $this
31
+ */
32
+ public function setId($id)
33
+ {
34
+ $this->id = $id;
35
+ return $this;
36
+ }
37
+
38
+ /**
39
+ * Identifier of the payment_definition. 128 characters max.
40
+ *
41
+ * @return string
42
+ */
43
+ public function getId()
44
+ {
45
+ return $this->id;
46
+ }
47
+
48
+ /**
49
+ * Name of the payment definition. 128 characters max.
50
+ *
51
+ * @param string $name
52
+ *
53
+ * @return $this
54
+ */
55
+ public function setName($name)
56
+ {
57
+ $this->name = $name;
58
+ return $this;
59
+ }
60
+
61
+ /**
62
+ * Name of the payment definition. 128 characters max.
63
+ *
64
+ * @return string
65
+ */
66
+ public function getName()
67
+ {
68
+ return $this->name;
69
+ }
70
+
71
+ /**
72
+ * Type of the payment definition. Allowed values: `TRIAL`, `REGULAR`.
73
+ *
74
+ * @param string $type
75
+ *
76
+ * @return $this
77
+ */
78
+ public function setType($type)
79
+ {
80
+ $this->type = $type;
81
+ return $this;
82
+ }
83
+
84
+ /**
85
+ * Type of the payment definition. Allowed values: `TRIAL`, `REGULAR`.
86
+ *
87
+ * @return string
88
+ */
89
+ public function getType()
90
+ {
91
+ return $this->type;
92
+ }
93
+
94
+ /**
95
+ * How frequently the customer should be charged.
96
+ *
97
+ * @param string $frequency_interval
98
+ *
99
+ * @return $this
100
+ */
101
+ public function setFrequencyInterval($frequency_interval)
102
+ {
103
+ $this->frequency_interval = $frequency_interval;
104
+ return $this;
105
+ }
106
+
107
+ /**
108
+ * How frequently the customer should be charged.
109
+ *
110
+ * @return string
111
+ */
112
+ public function getFrequencyInterval()
113
+ {
114
+ return $this->frequency_interval;
115
+ }
116
+
117
+ /**
118
+ * Frequency of the payment definition offered. Allowed values: `WEEK`, `DAY`, `YEAR`, `MONTH`.
119
+ *
120
+ * @param string $frequency
121
+ *
122
+ * @return $this
123
+ */
124
+ public function setFrequency($frequency)
125
+ {
126
+ $this->frequency = $frequency;
127
+ return $this;
128
+ }
129
+
130
+ /**
131
+ * Frequency of the payment definition offered. Allowed values: `WEEK`, `DAY`, `YEAR`, `MONTH`.
132
+ *
133
+ * @return string
134
+ */
135
+ public function getFrequency()
136
+ {
137
+ return $this->frequency;
138
+ }
139
+
140
+ /**
141
+ * Number of cycles in this payment definition.
142
+ *
143
+ * @param string $cycles
144
+ *
145
+ * @return $this
146
+ */
147
+ public function setCycles($cycles)
148
+ {
149
+ $this->cycles = $cycles;
150
+ return $this;
151
+ }
152
+
153
+ /**
154
+ * Number of cycles in this payment definition.
155
+ *
156
+ * @return string
157
+ */
158
+ public function getCycles()
159
+ {
160
+ return $this->cycles;
161
+ }
162
+
163
+ /**
164
+ * Amount that will be charged at the end of each cycle for this payment definition.
165
+ *
166
+ * @param \PayPal\Api\Currency $amount
167
+ *
168
+ * @return $this
169
+ */
170
+ public function setAmount($amount)
171
+ {
172
+ $this->amount = $amount;
173
+ return $this;
174
+ }
175
+
176
+ /**
177
+ * Amount that will be charged at the end of each cycle for this payment definition.
178
+ *
179
+ * @return \PayPal\Api\Currency
180
+ */
181
+ public function getAmount()
182
+ {
183
+ return $this->amount;
184
+ }
185
+
186
+ /**
187
+ * Array of charge_models for this payment definition.
188
+ *
189
+ * @param \PayPal\Api\ChargeModel[] $charge_models
190
+ *
191
+ * @return $this
192
+ */
193
+ public function setChargeModels($charge_models)
194
+ {
195
+ $this->charge_models = $charge_models;
196
+ return $this;
197
+ }
198
+
199
+ /**
200
+ * Array of charge_models for this payment definition.
201
+ *
202
+ * @return \PayPal\Api\ChargeModel[]
203
+ */
204
+ public function getChargeModels()
205
+ {
206
+ return $this->charge_models;
207
+ }
208
+
209
+ /**
210
+ * Append ChargeModels to the list.
211
+ *
212
+ * @param \PayPal\Api\ChargeModel $chargeModel
213
+ * @return $this
214
+ */
215
+ public function addChargeModel($chargeModel)
216
+ {
217
+ if (!$this->getChargeModels()) {
218
+ return $this->setChargeModels(array($chargeModel));
219
+ } else {
220
+ return $this->setChargeModels(
221
+ array_merge($this->getChargeModels(), array($chargeModel))
222
+ );
223
+ }
224
+ }
225
+
226
+ /**
227
+ * Remove ChargeModels from the list.
228
+ *
229
+ * @param \PayPal\Api\ChargeModel $chargeModel
230
+ * @return $this
231
+ */
232
+ public function removeChargeModel($chargeModel)
233
+ {
234
+ return $this->setChargeModels(
235
+ array_diff($this->getChargeModels(), array($chargeModel))
236
+ );
237
+ }
238
+
239
+ }
lib/PayPal/Api/PaymentDetail.php ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class PaymentDetail
9
+ *
10
+ * Invoicing payment information.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string type
15
+ * @property string transaction_id
16
+ * @property string transaction_type
17
+ * @property string date
18
+ * @property string method
19
+ * @property string note
20
+ */
21
+ class PaymentDetail extends PayPalModel
22
+ {
23
+ /**
24
+ * PayPal payment detail indicating whether payment was made in an invoicing flow via PayPal or externally. In the case of the mark-as-paid API, payment type is EXTERNAL and this is what is now supported. The PAYPAL value is provided for backward compatibility.
25
+ * Valid Values: ["PAYPAL", "EXTERNAL"]
26
+ *
27
+ * @param string $type
28
+ *
29
+ * @return $this
30
+ */
31
+ public function setType($type)
32
+ {
33
+ $this->type = $type;
34
+ return $this;
35
+ }
36
+
37
+ /**
38
+ * PayPal payment detail indicating whether payment was made in an invoicing flow via PayPal or externally. In the case of the mark-as-paid API, payment type is EXTERNAL and this is what is now supported. The PAYPAL value is provided for backward compatibility.
39
+ *
40
+ * @return string
41
+ */
42
+ public function getType()
43
+ {
44
+ return $this->type;
45
+ }
46
+
47
+ /**
48
+ * PayPal payment transaction id. Mandatory field in case the type value is PAYPAL.
49
+ *
50
+ * @param string $transaction_id
51
+ *
52
+ * @return $this
53
+ */
54
+ public function setTransactionId($transaction_id)
55
+ {
56
+ $this->transaction_id = $transaction_id;
57
+ return $this;
58
+ }
59
+
60
+ /**
61
+ * PayPal payment transaction id. Mandatory field in case the type value is PAYPAL.
62
+ *
63
+ * @return string
64
+ */
65
+ public function getTransactionId()
66
+ {
67
+ return $this->transaction_id;
68
+ }
69
+
70
+ /**
71
+ * Type of the transaction.
72
+ * Valid Values: ["SALE", "AUTHORIZATION", "CAPTURE"]
73
+ *
74
+ * @param string $transaction_type
75
+ *
76
+ * @return $this
77
+ */
78
+ public function setTransactionType($transaction_type)
79
+ {
80
+ $this->transaction_type = $transaction_type;
81
+ return $this;
82
+ }
83
+
84
+ /**
85
+ * Type of the transaction.
86
+ *
87
+ * @return string
88
+ */
89
+ public function getTransactionType()
90
+ {
91
+ return $this->transaction_type;
92
+ }
93
+
94
+ /**
95
+ * Date when the invoice was paid. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
96
+ *
97
+ * @param string $date
98
+ *
99
+ * @return $this
100
+ */
101
+ public function setDate($date)
102
+ {
103
+ $this->date = $date;
104
+ return $this;
105
+ }
106
+
107
+ /**
108
+ * Date when the invoice was paid. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
109
+ *
110
+ * @return string
111
+ */
112
+ public function getDate()
113
+ {
114
+ return $this->date;
115
+ }
116
+
117
+ /**
118
+ * Payment mode or method. This field is mandatory if the value of the type field is EXTERNAL.
119
+ * Valid Values: ["BANK_TRANSFER", "CASH", "CHECK", "CREDIT_CARD", "DEBIT_CARD", "PAYPAL", "WIRE_TRANSFER", "OTHER"]
120
+ *
121
+ * @param string $method
122
+ *
123
+ * @return $this
124
+ */
125
+ public function setMethod($method)
126
+ {
127
+ $this->method = $method;
128
+ return $this;
129
+ }
130
+
131
+ /**
132
+ * Payment mode or method. This field is mandatory if the value of the type field is EXTERNAL.
133
+ *
134
+ * @return string
135
+ */
136
+ public function getMethod()
137
+ {
138
+ return $this->method;
139
+ }
140
+
141
+ /**
142
+ * Optional note associated with the payment.
143
+ *
144
+ * @param string $note
145
+ *
146
+ * @return $this
147
+ */
148
+ public function setNote($note)
149
+ {
150
+ $this->note = $note;
151
+ return $this;
152
+ }
153
+
154
+ /**
155
+ * Optional note associated with the payment.
156
+ *
157
+ * @return string
158
+ */
159
+ public function getNote()
160
+ {
161
+ return $this->note;
162
+ }
163
+
164
+ }
lib/PayPal/Api/PaymentExecution.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class PaymentExecution
9
+ *
10
+ * Let's you execute a PayPal Account based Payment resource with the payer_id obtained from web approval url.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string payer_id
15
+ * @property string carrier_account_id
16
+ * @property \PayPal\Api\Transaction[] transactions
17
+ */
18
+ class PaymentExecution extends PayPalModel
19
+ {
20
+ /**
21
+ * The ID of the Payer, passed in the `return_url` by PayPal.
22
+ *
23
+ * @param string $payer_id
24
+ *
25
+ * @return $this
26
+ */
27
+ public function setPayerId($payer_id)
28
+ {
29
+ $this->payer_id = $payer_id;
30
+ return $this;
31
+ }
32
+
33
+ /**
34
+ * The ID of the Payer, passed in the `return_url` by PayPal.
35
+ *
36
+ * @return string
37
+ */
38
+ public function getPayerId()
39
+ {
40
+ return $this->payer_id;
41
+ }
42
+
43
+ /**
44
+ * Carrier account id for a carrier billing payment. For a carrier billing payment, payer_id is not applicable.
45
+ *
46
+ * @param string $carrier_account_id
47
+ *
48
+ * @return $this
49
+ */
50
+ public function setCarrierAccountId($carrier_account_id)
51
+ {
52
+ $this->carrier_account_id = $carrier_account_id;
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * Carrier account id for a carrier billing payment. For a carrier billing payment, payer_id is not applicable.
58
+ *
59
+ * @return string
60
+ */
61
+ public function getCarrierAccountId()
62
+ {
63
+ return $this->carrier_account_id;
64
+ }
65
+
66
+ /**
67
+ * Transactional details including the amount and item details.
68
+ *
69
+ * @param \PayPal\Api\Transaction[] $transactions
70
+ *
71
+ * @return $this
72
+ */
73
+ public function setTransactions($transactions)
74
+ {
75
+ $this->transactions = $transactions;
76
+ return $this;
77
+ }
78
+
79
+ /**
80
+ * Transactional details including the amount and item details.
81
+ *
82
+ * @return \PayPal\Api\Transaction[]
83
+ */
84
+ public function getTransactions()
85
+ {
86
+ return $this->transactions;
87
+ }
88
+
89
+ /**
90
+ * Append Transactions to the list.
91
+ *
92
+ * @param \PayPal\Api\Transaction $transaction
93
+ * @return $this
94
+ */
95
+ public function addTransaction($transaction)
96
+ {
97
+ if (!$this->getTransactions()) {
98
+ return $this->setTransactions(array($transaction));
99
+ } else {
100
+ return $this->setTransactions(
101
+ array_merge($this->getTransactions(), array($transaction))
102
+ );
103
+ }
104
+ }
105
+
106
+ /**
107
+ * Remove Transactions from the list.
108
+ *
109
+ * @param \PayPal\Api\Transaction $transaction
110
+ * @return $this
111
+ */
112
+ public function removeTransaction($transaction)
113
+ {
114
+ return $this->setTransactions(
115
+ array_diff($this->getTransactions(), array($transaction))
116
+ );
117
+ }
118
+
119
+ }
lib/PayPal/Api/PaymentHistory.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class PaymentHistory
9
+ *
10
+ * List of Payments made by the seller.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property \PayPal\Api\Payment[] payments
15
+ * @property int count
16
+ * @property string next_id
17
+ */
18
+ class PaymentHistory extends PayPalModel
19
+ {
20
+ /**
21
+ * A list of Payment resources
22
+ *
23
+ * @param \PayPal\Api\Payment[] $payments
24
+ *
25
+ * @return $this
26
+ */
27
+ public function setPayments($payments)
28
+ {
29
+ $this->payments = $payments;
30
+ return $this;
31
+ }
32
+
33
+ /**
34
+ * A list of Payment resources
35
+ *
36
+ * @return \PayPal\Api\Payment[]
37
+ */
38
+ public function getPayments()
39
+ {
40
+ return $this->payments;
41
+ }
42
+
43
+ /**
44
+ * Append Payments to the list.
45
+ *
46
+ * @param \PayPal\Api\Payment $payment
47
+ * @return $this
48
+ */
49
+ public function addPayment($payment)
50
+ {
51
+ if (!$this->getPayments()) {
52
+ return $this->setPayments(array($payment));
53
+ } else {
54
+ return $this->setPayments(
55
+ array_merge($this->getPayments(), array($payment))
56
+ );
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Remove Payments from the list.
62
+ *
63
+ * @param \PayPal\Api\Payment $payment
64
+ * @return $this
65
+ */
66
+ public function removePayment($payment)
67
+ {
68
+ return $this->setPayments(
69
+ array_diff($this->getPayments(), array($payment))
70
+ );
71
+ }
72
+
73
+ /**
74
+ * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items.
75
+ *
76
+ * @param int $count
77
+ *
78
+ * @return $this
79
+ */
80
+ public function setCount($count)
81
+ {
82
+ $this->count = $count;
83
+ return $this;
84
+ }
85
+
86
+ /**
87
+ * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items.
88
+ *
89
+ * @return int
90
+ */
91
+ public function getCount()
92
+ {
93
+ return $this->count;
94
+ }
95
+
96
+ /**
97
+ * Identifier of the next element to get the next range of results.
98
+ *
99
+ * @param string $next_id
100
+ *
101
+ * @return $this
102
+ */
103
+ public function setNextId($next_id)
104
+ {
105
+ $this->next_id = $next_id;
106
+ return $this;
107
+ }
108
+
109
+ /**
110
+ * Identifier of the next element to get the next range of results.
111
+ *
112
+ * @return string
113
+ */
114
+ public function getNextId()
115
+ {
116
+ return $this->next_id;
117
+ }
118
+
119
+ }
lib/PayPal/Api/PaymentInstruction.php ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalResourceModel;
6
+ use PayPal\Rest\ApiContext;
7
+ use PayPal\Validation\ArgumentValidator;
8
+
9
+ /**
10
+ * Class PaymentInstruction
11
+ *
12
+ * Contain details of how and when the payment should be made to PayPal in cases of manual bank transfer.
13
+ *
14
+ * @package PayPal\Api
15
+ *
16
+ * @property string reference_number
17
+ * @property string instruction_type
18
+ * @property \PayPal\Api\RecipientBankingInstruction recipient_banking_instruction
19
+ * @property \PayPal\Api\Currency amount
20
+ * @property string payment_due_date
21
+ * @property string note
22
+ * @property \PayPal\Api\Links[] links
23
+ */
24
+ class PaymentInstruction extends PayPalResourceModel
25
+ {
26
+ /**
27
+ * ID of payment instruction
28
+ *
29
+ * @param string $reference_number
30
+ *
31
+ * @return $this
32
+ */
33
+ public function setReferenceNumber($reference_number)
34
+ {
35
+ $this->reference_number = $reference_number;
36
+ return $this;
37
+ }
38
+
39
+ /**
40
+ * ID of payment instruction
41
+ *
42
+ * @return string
43
+ */
44
+ public function getReferenceNumber()
45
+ {
46
+ return $this->reference_number;
47
+ }
48
+
49
+ /**
50
+ * Type of payment instruction
51
+ * Valid Values: ["MANUAL_BANK_TRANSFER", "PAY_UPON_INVOICE"]
52
+ *
53
+ * @param string $instruction_type
54
+ *
55
+ * @return $this
56
+ */
57
+ public function setInstructionType($instruction_type)
58
+ {
59
+ $this->instruction_type = $instruction_type;
60
+ return $this;
61
+ }
62
+
63
+ /**
64
+ * Type of payment instruction
65
+ *
66
+ * @return string
67
+ */
68
+ public function getInstructionType()
69
+ {
70
+ return $this->instruction_type;
71
+ }
72
+
73
+ /**
74
+ * Recipient bank Details.
75
+ *
76
+ * @param \PayPal\Api\RecipientBankingInstruction $recipient_banking_instruction
77
+ *
78
+ * @return $this
79
+ */
80
+ public function setRecipientBankingInstruction($recipient_banking_instruction)
81
+ {
82
+ $this->recipient_banking_instruction = $recipient_banking_instruction;
83
+ return $this;
84
+ }
85
+
86
+ /**
87
+ * Recipient bank Details.
88
+ *
89
+ * @return \PayPal\Api\RecipientBankingInstruction
90
+ */
91
+ public function getRecipientBankingInstruction()
92
+ {
93
+ return $this->recipient_banking_instruction;
94
+ }
95
+
96
+ /**
97
+ * Amount to be transferred
98
+ *
99
+ * @param \PayPal\Api\Currency $amount
100
+ *
101
+ * @return $this
102
+ */
103
+ public function setAmount($amount)
104
+ {
105
+ $this->amount = $amount;
106
+ return $this;
107
+ }
108
+
109
+ /**
110
+ * Amount to be transferred
111
+ *
112
+ * @return \PayPal\Api\Currency
113
+ */
114
+ public function getAmount()
115
+ {
116
+ return $this->amount;
117
+ }
118
+
119
+ /**
120
+ * Date by which payment should be received
121
+ *
122
+ * @param string $payment_due_date
123
+ *
124
+ * @return $this
125
+ */
126
+ public function setPaymentDueDate($payment_due_date)
127
+ {
128
+ $this->payment_due_date = $payment_due_date;
129
+ return $this;
130
+ }
131
+
132
+ /**
133
+ * Date by which payment should be received
134
+ *
135
+ * @return string
136
+ */
137
+ public function getPaymentDueDate()
138
+ {
139
+ return $this->payment_due_date;
140
+ }
141
+
142
+ /**
143
+ * Additional text regarding payment handling
144
+ *
145
+ * @param string $note
146
+ *
147
+ * @return $this
148
+ */
149
+ public function setNote($note)
150
+ {
151
+ $this->note = $note;
152
+ return $this;
153
+ }
154
+
155
+ /**
156
+ * Additional text regarding payment handling
157
+ *
158
+ * @return string
159
+ */
160
+ public function getNote()
161
+ {
162
+ return $this->note;
163
+ }
164
+
165
+ /**
166
+ * Retrieve a payment instruction by passing the payment_id in the request URI. Use this request if you are implementing a solution that includes delayed payment like Pay Upon Invoice (PUI).
167
+ *
168
+ * @param string $paymentId
169
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
170
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
171
+ * @return PaymentInstruction
172
+ */
173
+ public static function get($paymentId, $apiContext = null, $restCall = null)
174
+ {
175
+ ArgumentValidator::validate($paymentId, 'paymentId');
176
+ $payLoad = "";
177
+ $json = self::executeCall(
178
+ "/v1/payments/payment/$paymentId/payment-instruction",
179
+ "GET",
180
+ $payLoad,
181
+ null,
182
+ $apiContext,
183
+ $restCall
184
+ );
185
+ $ret = new PaymentInstruction();
186
+ $ret->fromJson($json);
187
+ return $ret;
188
+ }
189
+
190
+ }
lib/PayPal/Api/PaymentOptions.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class PaymentOptions
9
+ *
10
+ * Payment options requested for this purchase unit
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string allowed_payment_method
15
+ */
16
+ class PaymentOptions extends PayPalModel
17
+ {
18
+ /**
19
+ * Optional payment method type. If specified, the transaction will go through for only instant payment. Only for use with the paypal payment_method, not relevant for the credit_card payment_method.
20
+ * Valid Values: ["UNRESTRICTED", "INSTANT_FUNDING_SOURCE", "IMMEDIATE_PAY"]
21
+ *
22
+ * @param string $allowed_payment_method
23
+ *
24
+ * @return $this
25
+ */
26
+ public function setAllowedPaymentMethod($allowed_payment_method)
27
+ {
28
+ $this->allowed_payment_method = $allowed_payment_method;
29
+ return $this;
30
+ }
31
+
32
+ /**
33
+ * Optional payment method type. If specified, the transaction will go through for only instant payment. Only for use with the paypal payment_method, not relevant for the credit_card payment_method.
34
+ *
35
+ * @return string
36
+ */
37
+ public function getAllowedPaymentMethod()
38
+ {
39
+ return $this->allowed_payment_method;
40
+ }
41
+
42
+ /**
43
+ * Indicator if this payment request is a recurring payment. Only supported when the `payment_method` is set to `credit_card`
44
+ *
45
+ * @deprecated Not publicly available
46
+ * @param bool $recurring_flag
47
+ *
48
+ * @return $this
49
+ */
50
+ public function setRecurringFlag($recurring_flag)
51
+ {
52
+ $this->recurring_flag = $recurring_flag;
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * Indicator if this payment request is a recurring payment. Only supported when the `payment_method` is set to `credit_card`
58
+ *
59
+ * @deprecated Not publicly available
60
+ * @return bool
61
+ */
62
+ public function getRecurringFlag()
63
+ {
64
+ return $this->recurring_flag;
65
+ }
66
+
67
+ /**
68
+ * Indicator if fraud management filters (fmf) should be skipped for this transaction. Only supported when the `payment_method` is set to `credit_card`
69
+ *
70
+ * @deprecated Not publicly available
71
+ * @param bool $skip_fmf
72
+ *
73
+ * @return $this
74
+ */
75
+ public function setSkipFmf($skip_fmf)
76
+ {
77
+ $this->skip_fmf = $skip_fmf;
78
+ return $this;
79
+ }
80
+
81
+ /**
82
+ * Indicator if fraud management filters (fmf) should be skipped for this transaction. Only supported when the `payment_method` is set to `credit_card`
83
+ *
84
+ * @deprecated Not publicly available
85
+ * @return bool
86
+ */
87
+ public function getSkipFmf()
88
+ {
89
+ return $this->skip_fmf;
90
+ }
91
+
92
+ }
lib/PayPal/Api/PaymentTerm.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class PaymentTerm
9
+ *
10
+ * Payment term of the invoice. If term_type is present, due_date must not be present and vice versa.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string term_type
15
+ * @property string due_date
16
+ */
17
+ class PaymentTerm extends PayPalModel
18
+ {
19
+ /**
20
+ * Terms by which the invoice payment is due.
21
+ * Valid Values: ["DUE_ON_RECEIPT", "NET_10", "NET_15", "NET_30", "NET_45"]
22
+ *
23
+ * @param string $term_type
24
+ *
25
+ * @return $this
26
+ */
27
+ public function setTermType($term_type)
28
+ {
29
+ $this->term_type = $term_type;
30
+ return $this;
31
+ }
32
+
33
+ /**
34
+ * Terms by which the invoice payment is due.
35
+ *
36
+ * @return string
37
+ */
38
+ public function getTermType()
39
+ {
40
+ return $this->term_type;
41
+ }
42
+
43
+ /**
44
+ * Date on which invoice payment is due. It must be always a future date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
45
+ *
46
+ * @param string $due_date
47
+ *
48
+ * @return $this
49
+ */
50
+ public function setDueDate($due_date)
51
+ {
52
+ $this->due_date = $due_date;
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * Date on which invoice payment is due. It must be always a future date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
58
+ *
59
+ * @return string
60
+ */
61
+ public function getDueDate()
62
+ {
63
+ return $this->due_date;
64
+ }
65
+
66
+ }
lib/PayPal/Api/Payout.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalResourceModel;
6
+ use PayPal\Rest\ApiContext;
7
+ use PayPal\Transport\PayPalRestCall;
8
+ use PayPal\Validation\ArgumentValidator;
9
+
10
+ /**
11
+ * Class Payout
12
+ *
13
+ * This object represents a set of payouts that includes status data for the payouts. This object enables you to create a payout using a POST request.
14
+ *
15
+ * @package PayPal\Api
16
+ *
17
+ * @property \PayPal\Api\PayoutSenderBatchHeader sender_batch_header
18
+ * @property \PayPal\Api\PayoutItem[] items
19
+ * @property \PayPal\Api\Links[] links
20
+ */
21
+ class Payout extends PayPalResourceModel
22
+ {
23
+ /**
24
+ * The original batch header as provided by the payment sender.
25
+ *
26
+ * @param \PayPal\Api\PayoutSenderBatchHeader $sender_batch_header
27
+ *
28
+ * @return $this
29
+ */
30
+ public function setSenderBatchHeader($sender_batch_header)
31
+ {
32
+ $this->sender_batch_header = $sender_batch_header;
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * The original batch header as provided by the payment sender.
38
+ *
39
+ * @return \PayPal\Api\PayoutSenderBatchHeader
40
+ */
41
+ public function getSenderBatchHeader()
42
+ {
43
+ return $this->sender_batch_header;
44
+ }
45
+
46
+ /**
47
+ * An array of payout items (that is, a set of individual payouts).
48
+ *
49
+ * @param \PayPal\Api\PayoutItem[] $items
50
+ *
51
+ * @return $this
52
+ */
53
+ public function setItems($items)
54
+ {
55
+ $this->items = $items;
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * An array of payout items (that is, a set of individual payouts).
61
+ *
62
+ * @return \PayPal\Api\PayoutItem[]
63
+ */
64
+ public function getItems()
65
+ {
66
+ return $this->items;
67
+ }
68
+
69
+ /**
70
+ * Append Items to the list.
71
+ *
72
+ * @param \PayPal\Api\PayoutItem $payoutItem
73
+ * @return $this
74
+ */
75
+ public function addItem($payoutItem)
76
+ {
77
+ if (!$this->getItems()) {
78
+ return $this->setItems(array($payoutItem));
79
+ } else {
80
+ return $this->setItems(
81
+ array_merge($this->getItems(), array($payoutItem))
82
+ );
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Remove Items from the list.
88
+ *
89
+ * @param \PayPal\Api\PayoutItem $payoutItem
90
+ * @return $this
91
+ */
92
+ public function removeItem($payoutItem)
93
+ {
94
+ return $this->setItems(
95
+ array_diff($this->getItems(), array($payoutItem))
96
+ );
97
+ }
98
+
99
+ /**
100
+ * Create a payout batch resource by passing a sender_batch_header and an items array to the request URI. The sender_batch_header contains payout parameters that describe the handling of a batch resource while the items array conatins payout items.
101
+ *
102
+ * @param array $params
103
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
104
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
105
+ * @return PayoutBatch
106
+ */
107
+ public function create($params = array(), $apiContext = null, $restCall = null)
108
+ {
109
+ $params = $params ? $params : array();
110
+ ArgumentValidator::validate($params, 'params');
111
+ $payLoad = $this->toJSON();
112
+ $allowedParams = array(
113
+ 'sync_mode' => 1,
114
+ );
115
+ $json = self::executeCall(
116
+ "/v1/payments/payouts" . "?" . http_build_query(array_intersect_key($params, $allowedParams)),
117
+ "POST",
118
+ $payLoad,
119
+ null,
120
+ $apiContext,
121
+ $restCall
122
+ );
123
+ $ret = new PayoutBatch();
124
+ $ret->fromJson($json);
125
+ return $ret;
126
+ }
127
+
128
+ /**
129
+ * You can submit a payout with a synchronous API call, which immediately returns the results of a PayPal payment.
130
+ *
131
+ * @param ApiContext $apiContext
132
+ * @param PayPalRestCall $restCall
133
+ * @return PayoutBatch
134
+ */
135
+ public function createSynchronous($apiContext = null, $restCall = null)
136
+ {
137
+ $params = array('sync_mode' => 'true');
138
+ return $this->create($params, $apiContext, $restCall);
139
+ }
140
+
141
+ /**
142
+ * Obtain the status of a specific batch resource by passing the payout batch ID to the request URI. You can issue this call multiple times to get the current status.
143
+ *
144
+ * @param string $payoutBatchId
145
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
146
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
147
+ * @return PayoutBatch
148
+ */
149
+ public static function get($payoutBatchId, $apiContext = null, $restCall = null)
150
+ {
151
+ ArgumentValidator::validate($payoutBatchId, 'payoutBatchId');
152
+ $payLoad = "";
153
+ $json = self::executeCall(
154
+ "/v1/payments/payouts/$payoutBatchId",
155
+ "GET",
156
+ $payLoad,
157
+ null,
158
+ $apiContext,
159
+ $restCall
160
+ );
161
+ $ret = new PayoutBatch();
162
+ $ret->fromJson($json);
163
+ return $ret;
164
+ }
165
+
166
+ }
lib/PayPal/Api/PayoutBatch.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class PayoutBatch
9
+ *
10
+ * The batch status as generated by PayPal.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property \PayPal\Api\PayoutBatchHeader batch_header
15
+ * @property \PayPal\Api\PayoutItemDetails[] items
16
+ * @property \PayPal\Api\Links[] links
17
+ */
18
+ class PayoutBatch extends PayPalModel
19
+ {
20
+ /**
21
+ * A batch header that includes the generated batch status.
22
+ *
23
+ * @param \PayPal\Api\PayoutBatchHeader $batch_header
24
+ *
25
+ * @return $this
26
+ */
27
+ public function setBatchHeader($batch_header)
28
+ {
29
+ $this->batch_header = $batch_header;
30
+ return $this;
31
+ }
32
+
33
+ /**
34
+ * A batch header that includes the generated batch status.
35
+ *
36
+ * @return \PayPal\Api\PayoutBatchHeader
37
+ */
38
+ public function getBatchHeader()
39
+ {
40
+ return $this->batch_header;
41
+ }
42
+
43
+ /**
44
+ * Array of the items in a batch payout.
45
+ *
46
+ * @param \PayPal\Api\PayoutItemDetails[] $items
47
+ *
48
+ * @return $this
49
+ */
50
+ public function setItems($items)
51
+ {
52
+ $this->items = $items;
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * Array of the items in a batch payout.
58
+ *
59
+ * @return \PayPal\Api\PayoutItemDetails[]
60
+ */
61
+ public function getItems()
62
+ {
63
+ return $this->items;
64
+ }
65
+
66
+ /**
67
+ * Append Items to the list.
68
+ *
69
+ * @param \PayPal\Api\PayoutItemDetails $payoutItemDetails
70
+ * @return $this
71
+ */
72
+ public function addItem($payoutItemDetails)
73
+ {
74
+ if (!$this->getItems()) {
75
+ return $this->setItems(array($payoutItemDetails));
76
+ } else {
77
+ return $this->setItems(
78
+ array_merge($this->getItems(), array($payoutItemDetails))
79
+ );
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Remove Items from the list.
85
+ *
86
+ * @param \PayPal\Api\PayoutItemDetails $payoutItemDetails
87
+ * @return $this
88
+ */
89
+ public function removeItem($payoutItemDetails)
90
+ {
91
+ return $this->setItems(
92
+ array_diff($this->getItems(), array($payoutItemDetails))
93
+ );
94
+ }
95
+
96
+
97
+ /**
98
+ * Sets Links
99
+ *
100
+ * @param \PayPal\Api\Links[] $links
101
+ *
102
+ * @return $this
103
+ */
104
+ public function setLinks($links)
105
+ {
106
+ $this->links = $links;
107
+ return $this;
108
+ }
109
+
110
+ /**
111
+ * Gets Links
112
+ *
113
+ * @return \PayPal\Api\Links[]
114
+ */
115
+ public function getLinks()
116
+ {
117
+ return $this->links;
118
+ }
119
+
120
+ }
lib/PayPal/Api/PayoutBatchHeader.php ADDED
@@ -0,0 +1,263 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class PayoutBatchHeader
9
+ *
10
+ * This object enables you to get payout header information for an entire batch request. This object represents payout header data, and can be the response to a batch header request.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string payout_batch_id
15
+ * @property string batch_status
16
+ * @property string time_created
17
+ * @property string time_completed
18
+ * @property \PayPal\Api\PayoutSenderBatchHeader sender_batch_header
19
+ * @property \PayPal\Api\Currency amount
20
+ * @property \PayPal\Api\Currency fees
21
+ * @property \PayPal\Api\Error errors
22
+ * @property \PayPal\Api\Links[] links
23
+ */
24
+ class PayoutBatchHeader extends PayPalModel
25
+ {
26
+ /**
27
+ * An ID for the batch payout. Generated by PayPal. 30 characters max.
28
+ *
29
+ * @param string $payout_batch_id
30
+ *
31
+ * @return $this
32
+ */
33
+ public function setPayoutBatchId($payout_batch_id)
34
+ {
35
+ $this->payout_batch_id = $payout_batch_id;
36
+ return $this;
37
+ }
38
+
39
+ /**
40
+ * An ID for the batch payout. Generated by PayPal. 30 characters max.
41
+ *
42
+ * @return string
43
+ */
44
+ public function getPayoutBatchId()
45
+ {
46
+ return $this->payout_batch_id;
47
+ }
48
+
49
+ /**
50
+ * Generated batch status.
51
+ *
52
+ * @param string $batch_status
53
+ *
54
+ * @return $this
55
+ */
56
+ public function setBatchStatus($batch_status)
57
+ {
58
+ $this->batch_status = $batch_status;
59
+ return $this;
60
+ }
61
+
62
+ /**
63
+ * Generated batch status.
64
+ *
65
+ * @return string
66
+ */
67
+ public function getBatchStatus()
68
+ {
69
+ return $this->batch_status;
70
+ }
71
+
72
+ /**
73
+ * The time the batch entered processing.
74
+ *
75
+ * @param string $time_created
76
+ *
77
+ * @return $this
78
+ */
79
+ public function setTimeCreated($time_created)
80
+ {
81
+ $this->time_created = $time_created;
82
+ return $this;
83
+ }
84
+
85
+ /**
86
+ * The time the batch entered processing.
87
+ *
88
+ * @return string
89
+ */
90
+ public function getTimeCreated()
91
+ {
92
+ return $this->time_created;
93
+ }
94
+
95
+ /**
96
+ * The time that processing for the batch was completed.
97
+ *
98
+ * @param string $time_completed
99
+ *
100
+ * @return $this
101
+ */
102
+ public function setTimeCompleted($time_completed)
103
+ {
104
+ $this->time_completed = $time_completed;
105
+ return $this;
106
+ }
107
+
108
+ /**
109
+ * The time that processing for the batch was completed.
110
+ *
111
+ * @return string
112
+ */
113
+ public function getTimeCompleted()
114
+ {
115
+ return $this->time_completed;
116
+ }
117
+
118
+ /**
119
+ * The original batch header as provided by the payment sender.
120
+ *
121
+ * @param \PayPal\Api\PayoutSenderBatchHeader $sender_batch_header
122
+ *
123
+ * @return $this
124
+ */
125
+ public function setSenderBatchHeader($sender_batch_header)
126
+ {
127
+ $this->sender_batch_header = $sender_batch_header;
128
+ return $this;
129
+ }
130
+
131
+ /**
132
+ * The original batch header as provided by the payment sender.
133
+ *
134
+ * @return \PayPal\Api\PayoutSenderBatchHeader
135
+ */
136
+ public function getSenderBatchHeader()
137
+ {
138
+ return $this->sender_batch_header;
139
+ }
140
+
141
+ /**
142
+ * Total amount, in U.S. dollars, requested for the applicable payouts.
143
+ *
144
+ * @param \PayPal\Api\Currency $amount
145
+ *
146
+ * @return $this
147
+ */
148
+ public function setAmount($amount)
149
+ {
150
+ $this->amount = $amount;
151
+ return $this;
152
+ }
153
+
154
+ /**
155
+ * Total amount, in U.S. dollars, requested for the applicable payouts.
156
+ *
157
+ * @return \PayPal\Api\Currency
158
+ */
159
+ public function getAmount()
160
+ {
161
+ return $this->amount;
162
+ }
163
+
164
+ /**
165
+ * Total estimate in U.S. dollars for the applicable payouts fees.
166
+ *
167
+ * @param \PayPal\Api\Currency $fees
168
+ *
169
+ * @return $this
170
+ */
171
+ public function setFees($fees)
172
+ {
173
+ $this->fees = $fees;
174
+ return $this;
175
+ }
176
+
177
+ /**
178
+ * Total estimate in U.S. dollars for the applicable payouts fees.
179
+ *
180
+ * @return \PayPal\Api\Currency
181
+ */
182
+ public function getFees()
183
+ {
184
+ return $this->fees;
185
+ }
186
+
187
+ /**
188
+ * Sets Errors
189
+ *
190
+ * @param \PayPal\Api\Error $errors
191
+ *
192
+ * @return $this
193
+ */
194
+ public function setErrors($errors)
195
+ {
196
+ $this->errors = $errors;
197
+ return $this;
198
+ }
199
+
200
+ /**
201
+ * Gets Errors
202
+ *
203
+ * @return \PayPal\Api\Error
204
+ */
205
+ public function getErrors()
206
+ {
207
+ return $this->errors;
208
+ }
209
+
210
+ /**
211
+ * Sets Links
212
+ *
213
+ * @param \PayPal\Api\Links[] $links
214
+ *
215
+ * @return $this
216
+ */
217
+ public function setLinks($links)
218
+ {
219
+ $this->links = $links;
220
+ return $this;
221
+ }
222
+
223
+ /**
224
+ * Gets Links
225
+ *
226
+ * @return \PayPal\Api\Links[]
227
+ */
228
+ public function getLinks()
229
+ {
230
+ return $this->links;
231
+ }
232
+
233
+ /**
234
+ * Append Links to the list.
235
+ *
236
+ * @param \PayPal\Api\Links $links
237
+ * @return $this
238
+ */
239
+ public function addLink($links)
240
+ {
241
+ if (!$this->getLinks()) {
242
+ return $this->setLinks(array($links));
243
+ } else {
244
+ return $this->setLinks(
245
+ array_merge($this->getLinks(), array($links))
246
+ );
247
+ }
248
+ }
249
+
250
+ /**
251
+ * Remove Links from the list.
252
+ *
253
+ * @param \PayPal\Api\Links $links
254
+ * @return $this
255
+ */
256
+ public function removeLink($links)
257
+ {
258
+ return $this->setLinks(
259
+ array_diff($this->getLinks(), array($links))
260
+ );
261
+ }
262
+
263
+ }
lib/PayPal/Api/PayoutItem.php ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalResourceModel;
6
+ use PayPal\Rest\ApiContext;
7
+ use PayPal\Transport\PayPalRestCall;
8
+ use PayPal\Validation\ArgumentValidator;
9
+
10
+ /**
11
+ * Class PayoutItem
12
+ *
13
+ * Sender-created description of a payout to a single recipient.
14
+ *
15
+ * @package PayPal\Api
16
+ *
17
+ * @property string recipient_type
18
+ * @property \PayPal\Api\Currency amount
19
+ * @property string note
20
+ * @property string receiver
21
+ * @property string sender_item_id
22
+ */
23
+ class PayoutItem extends PayPalResourceModel
24
+ {
25
+ /**
26
+ * The type of identification for the payment receiver. If this field is provided, the payout items without a `recipient_type` will use the provided value. If this field is not provided, each payout item must include a value for the `recipient_type`.
27
+ *
28
+ * @param string $recipient_type
29
+ *
30
+ * @return $this
31
+ */
32
+ public function setRecipientType($recipient_type)
33
+ {
34
+ $this->recipient_type = $recipient_type;
35
+ return $this;
36
+ }
37
+
38
+ /**
39
+ * The type of identification for the payment receiver. If this field is provided, the payout items without a `recipient_type` will use the provided value. If this field is not provided, each payout item must include a value for the `recipient_type`.
40
+ *
41
+ * @return string
42
+ */
43
+ public function getRecipientType()
44
+ {
45
+ return $this->recipient_type;
46
+ }
47
+
48
+ /**
49
+ * The amount of money to pay a receiver.
50
+ *
51
+ * @param \PayPal\Api\Currency $amount
52
+ *
53
+ * @return $this
54
+ */
55
+ public function setAmount($amount)
56
+ {
57
+ $this->amount = $amount;
58
+ return $this;
59
+ }
60
+
61
+ /**
62
+ * The amount of money to pay a receiver.
63
+ *
64
+ * @return \PayPal\Api\Currency
65
+ */
66
+ public function getAmount()
67
+ {
68
+ return $this->amount;
69
+ }
70
+
71
+ /**
72
+ * Note for notifications. The note is provided by the payment sender. This note can be any string. 4000 characters max.
73
+ *
74
+ * @param string $note
75
+ *
76
+ * @return $this
77
+ */
78
+ public function setNote($note)
79
+ {
80
+ $this->note = $note;
81
+ return $this;
82
+ }
83
+
84
+ /**
85
+ * Note for notifications. The note is provided by the payment sender. This note can be any string. 4000 characters max.
86
+ *
87
+ * @return string
88
+ */
89
+ public function getNote()
90
+ {
91
+ return $this->note;
92
+ }
93
+
94
+ /**
95
+ * The receiver of the payment. In a call response, the format of this value corresponds to the `recipient_type` specified in the request. 127 characters max.
96
+ *
97
+ * @param string $receiver
98
+ *
99
+ * @return $this
100
+ */
101
+ public function setReceiver($receiver)
102
+ {
103
+ $this->receiver = $receiver;
104
+ return $this;
105
+ }
106
+
107
+ /**
108
+ * The receiver of the payment. In a call response, the format of this value corresponds to the `recipient_type` specified in the request. 127 characters max.
109
+ *
110
+ * @return string
111
+ */
112
+ public function getReceiver()
113
+ {
114
+ return $this->receiver;
115
+ }
116
+
117
+ /**
118
+ * A sender-specific ID number, used in an accounting system for tracking purposes. 30 characters max.
119
+ *
120
+ * @param string $sender_item_id
121
+ *
122
+ * @return $this
123
+ */
124
+ public function setSenderItemId($sender_item_id)
125
+ {
126
+ $this->sender_item_id = $sender_item_id;
127
+ return $this;
128
+ }
129
+
130
+ /**
131
+ * A sender-specific ID number, used in an accounting system for tracking purposes. 30 characters max.
132
+ *
133
+ * @return string
134
+ */
135
+ public function getSenderItemId()
136
+ {
137
+ return $this->sender_item_id;
138
+ }
139
+
140
+ /**
141
+ * Obtain the status of a payout item by passing the item ID to the request URI.
142
+ *
143
+ * @param string $payoutItemId
144
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
145
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
146
+ * @return PayoutItemDetails
147
+ */
148
+ public static function get($payoutItemId, $apiContext = null, $restCall = null)
149
+ {
150
+ ArgumentValidator::validate($payoutItemId, 'payoutItemId');
151
+ $payLoad = "";
152
+ $json = self::executeCall(
153
+ "/v1/payments/payouts-item/$payoutItemId",
154
+ "GET",
155
+ $payLoad,
156
+ null,
157
+ $apiContext,
158
+ $restCall
159
+ );
160
+ $ret = new PayoutItemDetails();
161
+ $ret->fromJson($json);
162
+ return $ret;
163
+ }
164
+
165
+ /**
166
+ * Cancels the unclaimed payment using the items id passed in the request URI. If an unclaimed item is not claimed within 30 days, the funds will be automatically returned to the sender. This call can be used to cancel the unclaimed item prior to the automatic 30-day return.
167
+ *
168
+ * @param string $payoutItemId
169
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
170
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
171
+ * @return PayoutItemDetails
172
+ */
173
+ public static function cancel($payoutItemId, $apiContext = null, $restCall = null)
174
+ {
175
+ ArgumentValidator::validate($payoutItemId, 'payoutItemId');
176
+ $payLoad = "";
177
+ $json = self::executeCall(
178
+ "/v1/payments/payouts-item/$payoutItemId/cancel",
179
+ "POST",
180
+ $payLoad,
181
+ null,
182
+ $apiContext,
183
+ $restCall
184
+ );
185
+ $ret = new PayoutItemDetails();
186
+ $ret->fromJson($json);
187
+ return $ret;
188
+ }
189
+
190
+ }
lib/PayPal/Api/PayoutItemDetails.php ADDED
@@ -0,0 +1,287 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class PayoutItemDetails
9
+ *
10
+ * This object contains status and other data for an individual payout of a batch.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string payout_item_id
15
+ * @property string transaction_id
16
+ * @property string transaction_status
17
+ * @property \PayPal\Api\Currency payout_item_fee
18
+ * @property string payout_batch_id
19
+ * @property string sender_batch_id
20
+ * @property \PayPal\Api\PayoutItem payout_item
21
+ * @property string time_processed
22
+ * @property \PayPal\Api\Error errors
23
+ * @property \PayPal\Api\Links[] links
24
+ */
25
+ class PayoutItemDetails extends PayPalModel
26
+ {
27
+ /**
28
+ * An ID for an individual payout. Provided by PayPal, such as in the case of getting the status of a batch request. 30 characters max.
29
+ *
30
+ * @param string $payout_item_id
31
+ *
32
+ * @return $this
33
+ */
34
+ public function setPayoutItemId($payout_item_id)
35
+ {
36
+ $this->payout_item_id = $payout_item_id;
37
+ return $this;
38
+ }
39
+
40
+ /**
41
+ * An ID for an individual payout. Provided by PayPal, such as in the case of getting the status of a batch request. 30 characters max.
42
+ *
43
+ * @return string
44
+ */
45
+ public function getPayoutItemId()
46
+ {
47
+ return $this->payout_item_id;
48
+ }
49
+
50
+ /**
51
+ * Generated ID for the transaction. 30 characters max.
52
+ *
53
+ * @param string $transaction_id
54
+ *
55
+ * @return $this
56
+ */
57
+ public function setTransactionId($transaction_id)
58
+ {
59
+ $this->transaction_id = $transaction_id;
60
+ return $this;
61
+ }
62
+
63
+ /**
64
+ * Generated ID for the transaction. 30 characters max.
65
+ *
66
+ * @return string
67
+ */
68
+ public function getTransactionId()
69
+ {
70
+ return $this->transaction_id;
71
+ }
72
+
73
+ /**
74
+ * Status of a transaction.
75
+ *
76
+ * @param string $transaction_status
77
+ *
78
+ * @return $this
79
+ */
80
+ public function setTransactionStatus($transaction_status)
81
+ {
82
+ $this->transaction_status = $transaction_status;
83
+ return $this;
84
+ }
85
+
86
+ /**
87
+ * Status of a transaction.
88
+ *
89
+ * @return string
90
+ */
91
+ public function getTransactionStatus()
92
+ {
93
+ return $this->transaction_status;
94
+ }
95
+
96
+ /**
97
+ * Amount of money in U.S. dollars for fees.
98
+ *
99
+ * @param \PayPal\Api\Currency $payout_item_fee
100
+ *
101
+ * @return $this
102
+ */
103
+ public function setPayoutItemFee($payout_item_fee)
104
+ {
105
+ $this->payout_item_fee = $payout_item_fee;
106
+ return $this;
107
+ }
108
+
109
+ /**
110
+ * Amount of money in U.S. dollars for fees.
111
+ *
112
+ * @return \PayPal\Api\Currency
113
+ */
114
+ public function getPayoutItemFee()
115
+ {
116
+ return $this->payout_item_fee;
117
+ }
118
+
119
+ /**
120
+ * An ID for the batch payout. Generated by PayPal. 30 characters max.
121
+ *
122
+ * @param string $payout_batch_id
123
+ *
124
+ * @return $this
125
+ */
126
+ public function setPayoutBatchId($payout_batch_id)
127
+ {
128
+ $this->payout_batch_id = $payout_batch_id;
129
+ return $this;
130
+ }
131
+
132
+ /**
133
+ * An ID for the batch payout. Generated by PayPal. 30 characters max.
134
+ *
135
+ * @return string
136
+ */
137
+ public function getPayoutBatchId()
138
+ {
139
+ return $this->payout_batch_id;
140
+ }
141
+
142
+ /**
143
+ * Sender-created ID for tracking the batch in an accounting system. 30 characters max.
144
+ *
145
+ * @param string $sender_batch_id
146
+ *
147
+ * @return $this
148
+ */
149
+ public function setSenderBatchId($sender_batch_id)
150
+ {
151
+ $this->sender_batch_id = $sender_batch_id;
152
+ return $this;
153
+ }
154
+
155
+ /**
156
+ * Sender-created ID for tracking the batch in an accounting system. 30 characters max.
157
+ *
158
+ * @return string
159
+ */
160
+ public function getSenderBatchId()
161
+ {
162
+ return $this->sender_batch_id;
163
+ }
164
+
165
+ /**
166
+ * The data for a payout item that the sender initially provided.
167
+ *
168
+ * @param \PayPal\Api\PayoutItem $payout_item
169
+ *
170
+ * @return $this
171
+ */
172
+ public function setPayoutItem($payout_item)
173
+ {
174
+ $this->payout_item = $payout_item;
175
+ return $this;
176
+ }
177
+
178
+ /**
179
+ * The data for a payout item that the sender initially provided.
180
+ *
181
+ * @return \PayPal\Api\PayoutItem
182
+ */
183
+ public function getPayoutItem()
184
+ {
185
+ return $this->payout_item;
186
+ }
187
+
188
+ /**
189
+ * Time of the last processing for this item.
190
+ *
191
+ * @param string $time_processed
192
+ *
193
+ * @return $this
194
+ */
195
+ public function setTimeProcessed($time_processed)
196
+ {
197
+ $this->time_processed = $time_processed;
198
+ return $this;
199
+ }
200
+
201
+ /**
202
+ * Time of the last processing for this item.
203
+ *
204
+ * @return string
205
+ */
206
+ public function getTimeProcessed()
207
+ {
208
+ return $this->time_processed;
209
+ }
210
+
211
+ /**
212
+ * Sets Error
213
+ *
214
+ * @param \PayPal\Api\Error $errors
215
+ *
216
+ * @return $this
217
+ */
218
+ public function setErrors($errors)
219
+ {
220
+ $this->errors = $errors;
221
+ return $this;
222
+ }
223
+
224
+ /**
225
+ * Gets Error
226
+ *
227
+ * @return \PayPal\Api\Error
228
+ */
229
+ public function getErrors()
230
+ {
231
+ return $this->errors;
232
+ }
233
+
234
+ /**
235
+ * Sets Links
236
+ *
237
+ * @param \PayPal\Api\Links[] $links
238
+ *
239
+ * @return $this
240
+ */
241
+ public function setLinks($links)
242
+ {
243
+ $this->links = $links;
244
+ return $this;
245
+ }
246
+
247
+ /**
248
+ * Gets Links
249
+ *
250
+ * @return \PayPal\Api\Links[]
251
+ */
252
+ public function getLinks()
253
+ {
254
+ return $this->links;
255
+ }
256
+
257
+ /**
258
+ * Append Links to the list.
259
+ *
260
+ * @param \PayPal\Api\Links $links
261
+ * @return $this
262
+ */
263
+ public function addLink($links)
264
+ {
265
+ if (!$this->getLinks()) {
266
+ return $this->setLinks(array($links));
267
+ } else {
268
+ return $this->setLinks(
269
+ array_merge($this->getLinks(), array($links))
270
+ );
271
+ }
272
+ }
273
+
274
+ /**
275
+ * Remove Links from the list.
276
+ *
277
+ * @param \PayPal\Api\Links $links
278
+ * @return $this
279
+ */
280
+ public function removeLink($links)
281
+ {
282
+ return $this->setLinks(
283
+ array_diff($this->getLinks(), array($links))
284
+ );
285
+ }
286
+
287
+ }
lib/PayPal/Api/PayoutSenderBatchHeader.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class PayoutSenderBatchHeader
9
+ *
10
+ * This object represents sender-provided data about a batch header. The data is provided in a POST request. All batch submissions must have a batch header.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string sender_batch_id
15
+ * @property string email_subject
16
+ * @property string recipient_type
17
+ */
18
+ class PayoutSenderBatchHeader extends PayPalModel
19
+ {
20
+ /**
21
+ * Sender-created ID for tracking the batch payout in an accounting system. 30 characters max.
22
+ *
23
+ * @param string $sender_batch_id
24
+ *
25
+ * @return $this
26
+ */
27
+ public function setSenderBatchId($sender_batch_id)
28
+ {
29
+ $this->sender_batch_id = $sender_batch_id;
30
+ return $this;
31
+ }
32
+
33
+ /**
34
+ * Sender-created ID for tracking the batch payout in an accounting system. 30 characters max.
35
+ *
36
+ * @return string
37
+ */
38
+ public function getSenderBatchId()
39
+ {
40
+ return $this->sender_batch_id;
41
+ }
42
+
43
+ /**
44
+ * The subject line text for the email that PayPal sends when a payout item is completed. (The subject line is the same for all recipients.) Maximum of 255 single-byte alphanumeric characters.
45
+ *
46
+ * @param string $email_subject
47
+ *
48
+ * @return $this
49
+ */
50
+ public function setEmailSubject($email_subject)
51
+ {
52
+ $this->email_subject = $email_subject;
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * The subject line text for the email that PayPal sends when a payout item is completed. (The subject line is the same for all recipients.) Maximum of 255 single-byte alphanumeric characters.
58
+ *
59
+ * @return string
60
+ */
61
+ public function getEmailSubject()
62
+ {
63
+ return $this->email_subject;
64
+ }
65
+
66
+ /**
67
+ * The type of ID for a payment receiver. If this field is provided, the payout items without a `recipient_type` will use the provided value. If this field is not provided, each payout item must include a value for the `recipient_type`.
68
+ *
69
+ * @param string $recipient_type
70
+ *
71
+ * @return $this
72
+ */
73
+ public function setRecipientType($recipient_type)
74
+ {
75
+ $this->recipient_type = $recipient_type;
76
+ return $this;
77
+ }
78
+
79
+ /**
80
+ * The type of ID for a payment receiver. If this field is provided, the payout items without a `recipient_type` will use the provided value. If this field is not provided, each payout item must include a value for the `recipient_type`.
81
+ *
82
+ * @return string
83
+ */
84
+ public function getRecipientType()
85
+ {
86
+ return $this->recipient_type;
87
+ }
88
+
89
+ }
lib/PayPal/Api/Phone.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class Phone
9
+ *
10
+ * Information related to the Payer. In case of PayPal Wallet payment, this information will be filled in by PayPal after the user approves the payment using their PayPal Wallet.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string country_code
15
+ * @property string national_number
16
+ * @property string extension
17
+ */
18
+ class Phone extends PayPalModel
19
+ {
20
+ /**
21
+ * Country code (from in E.164 format)
22
+ *
23
+ * @param string $country_code
24
+ *
25
+ * @return $this
26
+ */
27
+ public function setCountryCode($country_code)
28
+ {
29
+ $this->country_code = $country_code;
30
+ return $this;
31
+ }
32
+
33
+ /**
34
+ * Country code (from in E.164 format)
35
+ *
36
+ * @return string
37
+ */
38
+ public function getCountryCode()
39
+ {
40
+ return $this->country_code;
41
+ }
42
+
43
+ /**
44
+ * In-country phone number (from in E.164 format)
45
+ *
46
+ * @param string $national_number
47
+ *
48
+ * @return $this
49
+ */
50
+ public function setNationalNumber($national_number)
51
+ {
52
+ $this->national_number = $national_number;
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * In-country phone number (from in E.164 format)
58
+ *
59
+ * @return string
60
+ */
61
+ public function getNationalNumber()
62
+ {
63
+ return $this->national_number;
64
+ }
65
+
66
+ /**
67
+ * Phone extension
68
+ *
69
+ * @param string $extension
70
+ *
71
+ * @return $this
72
+ */
73
+ public function setExtension($extension)
74
+ {
75
+ $this->extension = $extension;
76
+ return $this;
77
+ }
78
+
79
+ /**
80
+ * Phone extension
81
+ *
82
+ * @return string
83
+ */
84
+ public function getExtension()
85
+ {
86
+ return $this->extension;
87
+ }
88
+
89
+ }
lib/PayPal/Api/Plan.php ADDED
@@ -0,0 +1,445 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+ use PayPal\Common\PayPalResourceModel;
7
+ use PayPal\Rest\ApiContext;
8
+ use PayPal\Transport\PayPalRestCall;
9
+ use PayPal\Validation\ArgumentValidator;
10
+
11
+ /**
12
+ * Class Plan
13
+ *
14
+ * Billing plan resource that will be used to create a billing agreement.
15
+ *
16
+ * @package PayPal\Api
17
+ *
18
+ * @property string id
19
+ * @property string name
20
+ * @property string description
21
+ * @property string type
22
+ * @property string state
23
+ * @property string create_time
24
+ * @property string update_time
25
+ * @property \PayPal\Api\PaymentDefinition[] payment_definitions
26
+ * @property \PayPal\Api\Terms[] terms
27
+ * @property \PayPal\Api\MerchantPreferences merchant_preferences
28
+ */
29
+ class Plan extends PayPalResourceModel
30
+ {
31
+ /**
32
+ * Identifier of the billing plan. 128 characters max.
33
+ *
34
+ * @param string $id
35
+ *
36
+ * @return $this
37
+ */
38
+ public function setId($id)
39
+ {
40
+ $this->id = $id;
41
+ return $this;
42
+ }
43
+
44
+ /**
45
+ * Identifier of the billing plan. 128 characters max.
46
+ *
47
+ * @return string
48
+ */
49
+ public function getId()
50
+ {
51
+ return $this->id;
52
+ }
53
+
54
+ /**
55
+ * Name of the billing plan. 128 characters max.
56
+ *
57
+ * @param string $name
58
+ *
59
+ * @return $this
60
+ */
61
+ public function setName($name)
62
+ {
63
+ $this->name = $name;
64
+ return $this;
65
+ }
66
+
67
+ /**
68
+ * Name of the billing plan. 128 characters max.
69
+ *
70
+ * @return string
71
+ */
72
+ public function getName()
73
+ {
74
+ return $this->name;
75
+ }
76
+
77
+ /**
78
+ * Description of the billing plan. 128 characters max.
79
+ *
80
+ * @param string $description
81
+ *
82
+ * @return $this
83
+ */
84
+ public function setDescription($description)
85
+ {
86
+ $this->description = $description;
87
+ return $this;
88
+ }
89
+
90
+ /**
91
+ * Description of the billing plan. 128 characters max.
92
+ *
93
+ * @return string
94
+ */
95
+ public function getDescription()
96
+ {
97
+ return $this->description;
98
+ }
99
+
100
+ /**
101
+ * Type of the billing plan. Allowed values: `FIXED`, `INFINITE`.
102
+ *
103
+ * @param string $type
104
+ *
105
+ * @return $this
106
+ */
107
+ public function setType($type)
108
+ {
109
+ $this->type = $type;
110
+ return $this;
111
+ }
112
+
113
+ /**
114
+ * Type of the billing plan. Allowed values: `FIXED`, `INFINITE`.
115
+ *
116
+ * @return string
117
+ */
118
+ public function getType()
119
+ {
120
+ return $this->type;
121
+ }
122
+
123
+ /**
124
+ * Status of the billing plan. Allowed values: `CREATED`, `ACTIVE`, `INACTIVE`, and `DELETED`.
125
+ *
126
+ * @param string $state
127
+ *
128
+ * @return $this
129
+ */
130
+ public function setState($state)
131
+ {
132
+ $this->state = $state;
133
+ return $this;
134
+ }
135
+
136
+ /**
137
+ * Status of the billing plan. Allowed values: `CREATED`, `ACTIVE`, `INACTIVE`, and `DELETED`.
138
+ *
139
+ * @return string
140
+ */
141
+ public function getState()
142
+ {
143
+ return $this->state;
144
+ }
145
+
146
+ /**
147
+ * Time when the billing plan was created. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
148
+ *
149
+ * @param string $create_time
150
+ *
151
+ * @return $this
152
+ */
153
+ public function setCreateTime($create_time)
154
+ {
155
+ $this->create_time = $create_time;
156
+ return $this;
157
+ }
158
+
159
+ /**
160
+ * Time when the billing plan was created. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
161
+ *
162
+ * @return string
163
+ */
164
+ public function getCreateTime()
165
+ {
166
+ return $this->create_time;
167
+ }
168
+
169
+ /**
170
+ * Time when this billing plan was updated. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
171
+ *
172
+ * @param string $update_time
173
+ *
174
+ * @return $this
175
+ */
176
+ public function setUpdateTime($update_time)
177
+ {
178
+ $this->update_time = $update_time;
179
+ return $this;
180
+ }
181
+
182
+ /**
183
+ * Time when this billing plan was updated. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
184
+ *
185
+ * @return string
186
+ */
187
+ public function getUpdateTime()
188
+ {
189
+ return $this->update_time;
190
+ }
191
+
192
+ /**
193
+ * Array of payment definitions for this billing plan.
194
+ *
195
+ * @param \PayPal\Api\PaymentDefinition[] $payment_definitions
196
+ *
197
+ * @return $this
198
+ */
199
+ public function setPaymentDefinitions($payment_definitions)
200
+ {
201
+ $this->payment_definitions = $payment_definitions;
202
+ return $this;
203
+ }
204
+
205
+ /**
206
+ * Array of payment definitions for this billing plan.
207
+ *
208
+ * @return \PayPal\Api\PaymentDefinition[]
209
+ */
210
+ public function getPaymentDefinitions()
211
+ {
212
+ return $this->payment_definitions;
213
+ }
214
+
215
+ /**
216
+ * Append PaymentDefinitions to the list.
217
+ *
218
+ * @param \PayPal\Api\PaymentDefinition $paymentDefinition
219
+ * @return $this
220
+ */
221
+ public function addPaymentDefinition($paymentDefinition)
222
+ {
223
+ if (!$this->getPaymentDefinitions()) {
224
+ return $this->setPaymentDefinitions(array($paymentDefinition));
225
+ } else {
226
+ return $this->setPaymentDefinitions(
227
+ array_merge($this->getPaymentDefinitions(), array($paymentDefinition))
228
+ );
229
+ }
230
+ }
231
+
232
+ /**
233
+ * Remove PaymentDefinitions from the list.
234
+ *
235
+ * @param \PayPal\Api\PaymentDefinition $paymentDefinition
236
+ * @return $this
237
+ */
238
+ public function removePaymentDefinition($paymentDefinition)
239
+ {
240
+ return $this->setPaymentDefinitions(
241
+ array_diff($this->getPaymentDefinitions(), array($paymentDefinition))
242
+ );
243
+ }
244
+
245
+ /**
246
+ * Array of terms for this billing plan.
247
+ *
248
+ * @param \PayPal\Api\Terms[] $terms
249
+ *
250
+ * @return $this
251
+ */
252
+ public function setTerms($terms)
253
+ {
254
+ $this->terms = $terms;
255
+ return $this;
256
+ }
257
+
258
+ /**
259
+ * Array of terms for this billing plan.
260
+ *
261
+ * @return \PayPal\Api\Terms[]
262
+ */
263
+ public function getTerms()
264
+ {
265
+ return $this->terms;
266
+ }
267
+
268
+ /**
269
+ * Append Terms to the list.
270
+ *
271
+ * @param \PayPal\Api\Terms $terms
272
+ * @return $this
273
+ */
274
+ public function addTerm($terms)
275
+ {
276
+ if (!$this->getTerms()) {
277
+ return $this->setTerms(array($terms));
278
+ } else {
279
+ return $this->setTerms(
280
+ array_merge($this->getTerms(), array($terms))
281
+ );
282
+ }
283
+ }
284
+
285
+ /**
286
+ * Remove Terms from the list.
287
+ *
288
+ * @param \PayPal\Api\Terms $terms
289
+ * @return $this
290
+ */
291
+ public function removeTerm($terms)
292
+ {
293
+ return $this->setTerms(
294
+ array_diff($this->getTerms(), array($terms))
295
+ );
296
+ }
297
+
298
+ /**
299
+ * Specific preferences such as: set up fee, max fail attempts, autobill amount, and others that are configured for this billing plan.
300
+ *
301
+ * @param \PayPal\Api\MerchantPreferences $merchant_preferences
302
+ *
303
+ * @return $this
304
+ */
305
+ public function setMerchantPreferences($merchant_preferences)
306
+ {
307
+ $this->merchant_preferences = $merchant_preferences;
308
+ return $this;
309
+ }
310
+
311
+ /**
312
+ * Specific preferences such as: set up fee, max fail attempts, autobill amount, and others that are configured for this billing plan.
313
+ *
314
+ * @return \PayPal\Api\MerchantPreferences
315
+ */
316
+ public function getMerchantPreferences()
317
+ {
318
+ return $this->merchant_preferences;
319
+ }
320
+
321
+ /**
322
+ * Retrieve the details for a particular billing plan by passing the billing plan ID to the request URI.
323
+ *
324
+ * @param string $planId
325
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
326
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
327
+ * @return Plan
328
+ */
329
+ public static function get($planId, $apiContext = null, $restCall = null)
330
+ {
331
+ ArgumentValidator::validate($planId, 'planId');
332
+ $payLoad = "";
333
+ $json = self::executeCall(
334
+ "/v1/payments/billing-plans/$planId",
335
+ "GET",
336
+ $payLoad,
337
+ null,
338
+ $apiContext,
339
+ $restCall
340
+ );
341
+ $ret = new Plan();
342
+ $ret->fromJson($json);
343
+ return $ret;
344
+ }
345
+
346
+ /**
347
+ * Create a new billing plan by passing the details for the plan, including the plan name, description, and type, to the request URI.
348
+ *
349
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
350
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
351
+ * @return Plan
352
+ */
353
+ public function create($apiContext = null, $restCall = null)
354
+ {
355
+ $payLoad = $this->toJSON();
356
+ $json = self::executeCall(
357
+ "/v1/payments/billing-plans/",
358
+ "POST",
359
+ $payLoad,
360
+ null,
361
+ $apiContext,
362
+ $restCall
363
+ );
364
+ $this->fromJson($json);
365
+ return $this;
366
+ }
367
+
368
+ /**
369
+ * Replace specific fields within a billing plan by passing the ID of the billing plan to the request URI. In addition, pass a patch object in the request JSON that specifies the operation to perform, field to update, and new value for each update.
370
+ *
371
+ * @param PatchRequest $patchRequest
372
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
373
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
374
+ * @return bool
375
+ */
376
+ public function update($patchRequest, $apiContext = null, $restCall = null)
377
+ {
378
+ ArgumentValidator::validate($this->getId(), "Id");
379
+ ArgumentValidator::validate($patchRequest, 'patchRequest');
380
+ $payLoad = $patchRequest->toJSON();
381
+ self::executeCall(
382
+ "/v1/payments/billing-plans/{$this->getId()}",
383
+ "PATCH",
384
+ $payLoad,
385
+ null,
386
+ $apiContext,
387
+ $restCall
388
+ );
389
+ return true;
390
+ }
391
+
392
+ /**
393
+ * Delete a billing plan by passing the ID of the billing plan to the request URI.
394
+ *
395
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
396
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
397
+ * @return bool
398
+ */
399
+ public function delete($apiContext = null, $restCall = null)
400
+ {
401
+ ArgumentValidator::validate($this->getId(), "Id");
402
+ $patchRequest = new PatchRequest();
403
+ $patch = new Patch();
404
+ $value = new PayPalModel('{
405
+ "state":"DELETED"
406
+ }');
407
+ $patch->setOp('replace')
408
+ ->setPath('/')
409
+ ->setValue($value);
410
+ $patchRequest->addPatch($patch);
411
+ return $this->update($patchRequest, $apiContext, $restCall);
412
+ }
413
+
414
+ /**
415
+ * List billing plans according to optional query string parameters specified.
416
+ *
417
+ * @param array $params
418
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
419
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
420
+ * @return PlanList
421
+ */
422
+ public static function all($params, $apiContext = null, $restCall = null)
423
+ {
424
+ ArgumentValidator::validate($params, 'params');
425
+ $payLoad = "";
426
+ $allowedParams = array(
427
+ 'page_size' => 1,
428
+ 'status' => 1,
429
+ 'page' => 1,
430
+ 'total_required' => 1
431
+ );
432
+ $json = self::executeCall(
433
+ "/v1/payments/billing-plans/" . "?" . http_build_query(array_intersect_key($params, $allowedParams)),
434
+ "GET",
435
+ $payLoad,
436
+ null,
437
+ $apiContext,
438
+ $restCall
439
+ );
440
+ $ret = new PlanList();
441
+ $ret->fromJson($json);
442
+ return $ret;
443
+ }
444
+
445
+ }
lib/PayPal/Api/PlanList.php ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class PlanList
9
+ *
10
+ * Resource representing a list of billing plans with basic information and get link.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property \PayPal\Api\Plan[] plans
15
+ * @property string total_items
16
+ * @property string total_pages
17
+ * @property \PayPal\Api\Links[] links
18
+ */
19
+ class PlanList extends PayPalModel
20
+ {
21
+ /**
22
+ * Array of billing plans.
23
+ *
24
+ * @param \PayPal\Api\Plan[] $plans
25
+ *
26
+ * @return $this
27
+ */
28
+ public function setPlans($plans)
29
+ {
30
+ $this->plans = $plans;
31
+ return $this;
32
+ }
33
+
34
+ /**
35
+ * Array of billing plans.
36
+ *
37
+ * @return \PayPal\Api\Plan[]
38
+ */
39
+ public function getPlans()
40
+ {
41
+ return $this->plans;
42
+ }
43
+
44
+ /**
45
+ * Append Plans to the list.
46
+ *
47
+ * @param \PayPal\Api\Plan $plan
48
+ * @return $this
49
+ */
50
+ public function addPlan($plan)
51
+ {
52
+ if (!$this->getPlans()) {
53
+ return $this->setPlans(array($plan));
54
+ } else {
55
+ return $this->setPlans(
56
+ array_merge($this->getPlans(), array($plan))
57
+ );
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Remove Plans from the list.
63
+ *
64
+ * @param \PayPal\Api\Plan $plan
65
+ * @return $this
66
+ */
67
+ public function removePlan($plan)
68
+ {
69
+ return $this->setPlans(
70
+ array_diff($this->getPlans(), array($plan))
71
+ );
72
+ }
73
+
74
+ /**
75
+ * Total number of items.
76
+ *
77
+ * @param string $total_items
78
+ *
79
+ * @return $this
80
+ */
81
+ public function setTotalItems($total_items)
82
+ {
83
+ $this->total_items = $total_items;
84
+ return $this;
85
+ }
86
+
87
+ /**
88
+ * Total number of items.
89
+ *
90
+ * @return string
91
+ */
92
+ public function getTotalItems()
93
+ {
94
+ return $this->total_items;
95
+ }
96
+
97
+ /**
98
+ * Total number of pages.
99
+ *
100
+ * @param string $total_pages
101
+ *
102
+ * @return $this
103
+ */
104
+ public function setTotalPages($total_pages)
105
+ {
106
+ $this->total_pages = $total_pages;
107
+ return $this;
108
+ }
109
+
110
+ /**
111
+ * Total number of pages.
112
+ *
113
+ * @return string
114
+ */
115
+ public function getTotalPages()
116
+ {
117
+ return $this->total_pages;
118
+ }
119
+
120
+ /**
121
+ * Sets Links
122
+ *
123
+ * @param \PayPal\Api\Links[] $links
124
+ *
125
+ * @return $this
126
+ */
127
+ public function setLinks($links)
128
+ {
129
+ $this->links = $links;
130
+ return $this;
131
+ }
132
+
133
+ /**
134
+ * Gets Links
135
+ *
136
+ * @return \PayPal\Api\Links[]
137
+ */
138
+ public function getLinks()
139
+ {
140
+ return $this->links;
141
+ }
142
+
143
+ /**
144
+ * Append Links to the list.
145
+ *
146
+ * @param \PayPal\Api\Links $links
147
+ * @return $this
148
+ */
149
+ public function addLink($links)
150
+ {
151
+ if (!$this->getLinks()) {
152
+ return $this->setLinks(array($links));
153
+ } else {
154
+ return $this->setLinks(
155
+ array_merge($this->getLinks(), array($links))
156
+ );
157
+ }
158
+ }
159
+
160
+ /**
161
+ * Remove Links from the list.
162
+ *
163
+ * @param \PayPal\Api\Links $links
164
+ * @return $this
165
+ */
166
+ public function removeLink($links)
167
+ {
168
+ return $this->setLinks(
169
+ array_diff($this->getLinks(), array($links))
170
+ );
171
+ }
172
+
173
+ }
lib/PayPal/Api/PotentialPayerInfo.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class PotentialPayerInfo
9
+ *
10
+ * A resource representing a information about a potential Payer.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string email
15
+ * @property string external_remember_me_id
16
+ * @property \PayPal\Api\Address billing_address
17
+ */
18
+ class PotentialPayerInfo extends PayPalModel
19
+ {
20
+ /**
21
+ * Email address representing the potential payer.
22
+ *
23
+ * @param string $email
24
+ *
25
+ * @return $this
26
+ */
27
+ public function setEmail($email)
28
+ {
29
+ $this->email = $email;
30
+ return $this;
31
+ }
32
+
33
+ /**
34
+ * Email address representing the potential payer.
35
+ *
36
+ * @return string
37
+ */
38
+ public function getEmail()
39
+ {
40
+ return $this->email;
41
+ }
42
+
43
+ /**
44
+ * ExternalRememberMe id representing the potential payer
45
+ *
46
+ * @param string $external_remember_me_id
47
+ *
48
+ * @return $this
49
+ */
50
+ public function setExternalRememberMeId($external_remember_me_id)
51
+ {
52
+ $this->external_remember_me_id = $external_remember_me_id;
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * ExternalRememberMe id representing the potential payer
58
+ *
59
+ * @return string
60
+ */
61
+ public function getExternalRememberMeId()
62
+ {
63
+ return $this->external_remember_me_id;
64
+ }
65
+
66
+ /**
67
+ * Account Number representing the potential payer
68
+ * @deprecated Not publicly available
69
+ * @param string $account_number
70
+ *
71
+ * @return $this
72
+ */
73
+ public function setAccountNumber($account_number)
74
+ {
75
+ $this->account_number = $account_number;
76
+ return $this;
77
+ }
78
+
79
+ /**
80
+ * Account Number representing the potential payer
81
+ * @deprecated Not publicly available
82
+ * @return string
83
+ */
84
+ public function getAccountNumber()
85
+ {
86
+ return $this->account_number;
87
+ }
88
+
89
+ /**
90
+ * Billing address of the potential payer.
91
+ *
92
+ * @param \PayPal\Api\Address $billing_address
93
+ *
94
+ * @return $this
95
+ */
96
+ public function setBillingAddress($billing_address)
97
+ {
98
+ $this->billing_address = $billing_address;
99
+ return $this;
100
+ }
101
+
102
+ /**
103
+ * Billing address of the potential payer.
104
+ *
105
+ * @return \PayPal\Api\Address
106
+ */
107
+ public function getBillingAddress()
108
+ {
109
+ return $this->billing_address;
110
+ }
111
+
112
+ }
lib/PayPal/Api/Presentation.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class Presentation
9
+ *
10
+ * Parameters for style and presentation.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string brand_name
15
+ * @property string logo_image
16
+ * @property string locale_code
17
+ */
18
+ class Presentation extends PayPalModel
19
+ {
20
+ /**
21
+ * A label that overrides the business name in the PayPal account on the PayPal pages.
22
+ *
23
+ *
24
+ * @param string $brand_name
25
+ *
26
+ * @return $this
27
+ */
28
+ public function setBrandName($brand_name)
29
+ {
30
+ $this->brand_name = $brand_name;
31
+ return $this;
32
+ }
33
+
34
+ /**
35
+ * A label that overrides the business name in the PayPal account on the PayPal pages.
36
+ *
37
+ * @return string
38
+ */
39
+ public function getBrandName()
40
+ {
41
+ return $this->brand_name;
42
+ }
43
+
44
+ /**
45
+ * A URL to logo image. Allowed vaues: `.gif`, `.jpg`, or `.png`.
46
+ *
47
+ *
48
+ * @param string $logo_image
49
+ *
50
+ * @return $this
51
+ */
52
+ public function setLogoImage($logo_image)
53
+ {
54
+ $this->logo_image = $logo_image;
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * A URL to logo image. Allowed vaues: `.gif`, `.jpg`, or `.png`.
60
+ *
61
+ * @return string
62
+ */
63
+ public function getLogoImage()
64
+ {
65
+ return $this->logo_image;
66
+ }
67
+
68
+ /**
69
+ * Locale of pages displayed by PayPal payment experience.
70
+ *
71
+ *
72
+ * @param string $locale_code
73
+ *
74
+ * @return $this
75
+ */
76
+ public function setLocaleCode($locale_code)
77
+ {
78
+ $this->locale_code = $locale_code;
79
+ return $this;
80
+ }
81
+
82
+ /**
83
+ * Locale of pages displayed by PayPal payment experience.
84
+ *
85
+ * @return string
86
+ */
87
+ public function getLocaleCode()
88
+ {
89
+ return $this->locale_code;
90
+ }
91
+
92
+ }
lib/PayPal/Api/PrivateLabelCard.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class PrivateLabelCard
9
+ *
10
+ * A resource representing a type of merchant branded payment card. To promote customer value (convenience and earning rewards) and retailer value (merchants drive business using the store cards), PayPal will support as payment method.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string id
15
+ * @property string card_number
16
+ * @property string issuer_id
17
+ * @property string issuer_name
18
+ * @property string image_key
19
+ */
20
+ class PrivateLabelCard extends PayPalModel
21
+ {
22
+ /**
23
+ * encrypted identifier of the private label card instrument.
24
+ *
25
+ * @param string $id
26
+ *
27
+ * @return $this
28
+ */
29
+ public function setId($id)
30
+ {
31
+ $this->id = $id;
32
+ return $this;
33
+ }
34
+
35
+ /**
36
+ * encrypted identifier of the private label card instrument.
37
+ *
38
+ * @return string
39
+ */
40
+ public function getId()
41
+ {
42
+ return $this->id;
43
+ }
44
+
45
+ /**
46
+ * last 4 digits of the card number.
47
+ *
48
+ * @param string $card_number
49
+ *
50
+ * @return $this
51
+ */
52
+ public function setCardNumber($card_number)
53
+ {
54
+ $this->card_number = $card_number;
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * last 4 digits of the card number.
60
+ *
61
+ * @return string
62
+ */
63
+ public function getCardNumber()
64
+ {
65
+ return $this->card_number;
66
+ }
67
+
68
+ /**
69
+ * Merchants providing private label store cards have associated issuer account. This value indicates encrypted account number of the associated issuer account.
70
+ *
71
+ * @param string $issuer_id
72
+ *
73
+ * @return $this
74
+ */
75
+ public function setIssuerId($issuer_id)
76
+ {
77
+ $this->issuer_id = $issuer_id;
78
+ return $this;
79
+ }
80
+
81
+ /**
82
+ * Merchants providing private label store cards have associated issuer account. This value indicates encrypted account number of the associated issuer account.
83
+ *
84
+ * @return string
85
+ */
86
+ public function getIssuerId()
87
+ {
88
+ return $this->issuer_id;
89
+ }
90
+
91
+ /**
92
+ * Merchants providing private label store cards have associated issuer account. This value indicates name on the issuer account.
93
+ *
94
+ * @param string $issuer_name
95
+ *
96
+ * @return $this
97
+ */
98
+ public function setIssuerName($issuer_name)
99
+ {
100
+ $this->issuer_name = $issuer_name;
101
+ return $this;
102
+ }
103
+
104
+ /**
105
+ * Merchants providing private label store cards have associated issuer account. This value indicates name on the issuer account.
106
+ *
107
+ * @return string
108
+ */
109
+ public function getIssuerName()
110
+ {
111
+ return $this->issuer_name;
112
+ }
113
+
114
+ /**
115
+ * This value indicates URL to access PLCC program logo image
116
+ *
117
+ * @param string $image_key
118
+ *
119
+ * @return $this
120
+ */
121
+ public function setImageKey($image_key)
122
+ {
123
+ $this->image_key = $image_key;
124
+ return $this;
125
+ }
126
+
127
+ /**
128
+ * This value indicates URL to access PLCC program logo image
129
+ *
130
+ * @return string
131
+ */
132
+ public function getImageKey()
133
+ {
134
+ return $this->image_key;
135
+ }
136
+
137
+ }
lib/PayPal/Api/ProcessorResponse.php ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class ProcessorResponse
9
+ *
10
+ * Collection of payment response related fields returned from a payment request
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string response_code
15
+ * @property string avs_code
16
+ * @property string cvv_code
17
+ * @property string advice_code
18
+ * @property string eci_submitted
19
+ * @property string vpas
20
+ */
21
+ class ProcessorResponse extends PayPalModel
22
+ {
23
+ /**
24
+ * Paypal normalized response code, generated from the processor's specific response code
25
+ *
26
+ * @param string $response_code
27
+ *
28
+ * @return $this
29
+ */
30
+ public function setResponseCode($response_code)
31
+ {
32
+ $this->response_code = $response_code;
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * Paypal normalized response code, generated from the processor's specific response code
38
+ *
39
+ * @return string
40
+ */
41
+ public function getResponseCode()
42
+ {
43
+ return $this->response_code;
44
+ }
45
+
46
+ /**
47
+ * Address Verification System response code. https://developer.paypal.com/webapps/developer/docs/classic/api/AVSResponseCodes/
48
+ *
49
+ * @param string $avs_code
50
+ *
51
+ * @return $this
52
+ */
53
+ public function setAvsCode($avs_code)
54
+ {
55
+ $this->avs_code = $avs_code;
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * Address Verification System response code. https://developer.paypal.com/webapps/developer/docs/classic/api/AVSResponseCodes/
61
+ *
62
+ * @return string
63
+ */
64
+ public function getAvsCode()
65
+ {
66
+ return $this->avs_code;
67
+ }
68
+
69
+ /**
70
+ * CVV System response code. https://developer.paypal.com/webapps/developer/docs/classic/api/AVSResponseCodes/
71
+ *
72
+ * @param string $cvv_code
73
+ *
74
+ * @return $this
75
+ */
76
+ public function setCvvCode($cvv_code)
77
+ {
78
+ $this->cvv_code = $cvv_code;
79
+ return $this;
80
+ }
81
+
82
+ /**
83
+ * CVV System response code. https://developer.paypal.com/webapps/developer/docs/classic/api/AVSResponseCodes/
84
+ *
85
+ * @return string
86
+ */
87
+ public function getCvvCode()
88
+ {
89
+ return $this->cvv_code;
90
+ }
91
+
92
+ /**
93
+ * Provides merchant advice on how to handle declines related to recurring payments
94
+ * Valid Values: ["01_NEW_ACCOUNT_INFORMATION", "02_TRY_AGAIN_LATER", "02_STOP_SPECIFIC_PAYMENT", "03_DO_NOT_TRY_AGAIN", "03_REVOKE_AUTHORIZATION_FOR_FUTURE_PAYMENT", "21_DO_NOT_TRY_AGAIN_CARD_HOLDER_CANCELLED_RECURRRING_CHARGE", "21_CANCEL_ALL_RECURRING_PAYMENTS"]
95
+ *
96
+ * @param string $advice_code
97
+ *
98
+ * @return $this
99
+ */
100
+ public function setAdviceCode($advice_code)
101
+ {
102
+ $this->advice_code = $advice_code;
103
+ return $this;
104
+ }
105
+
106
+ /**
107
+ * Provides merchant advice on how to handle declines related to recurring payments
108
+ *
109
+ * @return string
110
+ */
111
+ public function getAdviceCode()
112
+ {
113
+ return $this->advice_code;
114
+ }
115
+
116
+ /**
117
+ * Response back from the authorization. Provided by the processor
118
+ *
119
+ * @param string $eci_submitted
120
+ *
121
+ * @return $this
122
+ */
123
+ public function setEciSubmitted($eci_submitted)
124
+ {
125
+ $this->eci_submitted = $eci_submitted;
126
+ return $this;
127
+ }
128
+
129
+ /**
130
+ * Response back from the authorization. Provided by the processor
131
+ *
132
+ * @return string
133
+ */
134
+ public function getEciSubmitted()
135
+ {
136
+ return $this->eci_submitted;
137
+ }
138
+
139
+ /**
140
+ * Visa Payer Authentication Service status. Will be return from processor
141
+ *
142
+ * @param string $vpas
143
+ *
144
+ * @return $this
145
+ */
146
+ public function setVpas($vpas)
147
+ {
148
+ $this->vpas = $vpas;
149
+ return $this;
150
+ }
151
+
152
+ /**
153
+ * Visa Payer Authentication Service status. Will be return from processor
154
+ *
155
+ * @return string
156
+ */
157
+ public function getVpas()
158
+ {
159
+ return $this->vpas;
160
+ }
161
+
162
+ }
lib/PayPal/Api/RecipientBankingInstruction.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class RecipientBankingInstruction
9
+ *
10
+ * Recipient bank Details.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string bank_name
15
+ * @property string account_holder_name
16
+ * @property string account_number
17
+ * @property string routing_number
18
+ * @property string international_bank_account_number
19
+ * @property string bank_identifier_code
20
+ */
21
+ class RecipientBankingInstruction extends PayPalModel
22
+ {
23
+ /**
24
+ * Name of the financial institution.
25
+ *
26
+ * @param string $bank_name
27
+ *
28
+ * @return $this
29
+ */
30
+ public function setBankName($bank_name)
31
+ {
32
+ $this->bank_name = $bank_name;
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * Name of the financial institution.
38
+ *
39
+ * @return string
40
+ */
41
+ public function getBankName()
42
+ {
43
+ return $this->bank_name;
44
+ }
45
+
46
+ /**
47
+ * Name of the account holder
48
+ *
49
+ * @param string $account_holder_name
50
+ *
51
+ * @return $this
52
+ */
53
+ public function setAccountHolderName($account_holder_name)
54
+ {
55
+ $this->account_holder_name = $account_holder_name;
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * Name of the account holder
61
+ *
62
+ * @return string
63
+ */
64
+ public function getAccountHolderName()
65
+ {
66
+ return $this->account_holder_name;
67
+ }
68
+
69
+ /**
70
+ * bank account number
71
+ *
72
+ * @param string $account_number
73
+ *
74
+ * @return $this
75
+ */
76
+ public function setAccountNumber($account_number)
77
+ {
78
+ $this->account_number = $account_number;
79
+ return $this;
80
+ }
81
+
82
+ /**
83
+ * bank account number
84
+ *
85
+ * @return string
86
+ */
87
+ public function getAccountNumber()
88
+ {
89
+ return $this->account_number;
90
+ }
91
+
92
+ /**
93
+ * bank routing number
94
+ *
95
+ * @param string $routing_number
96
+ *
97
+ * @return $this
98
+ */
99
+ public function setRoutingNumber($routing_number)
100
+ {
101
+ $this->routing_number = $routing_number;
102
+ return $this;
103
+ }
104
+
105
+ /**
106
+ * bank routing number
107
+ *
108
+ * @return string
109
+ */
110
+ public function getRoutingNumber()
111
+ {
112
+ return $this->routing_number;
113
+ }
114
+
115
+ /**
116
+ * IBAN equivalent of the bank
117
+ *
118
+ * @param string $international_bank_account_number
119
+ *
120
+ * @return $this
121
+ */
122
+ public function setInternationalBankAccountNumber($international_bank_account_number)
123
+ {
124
+ $this->international_bank_account_number = $international_bank_account_number;
125
+ return $this;
126
+ }
127
+
128
+ /**
129
+ * IBAN equivalent of the bank
130
+ *
131
+ * @return string
132
+ */
133
+ public function getInternationalBankAccountNumber()
134
+ {
135
+ return $this->international_bank_account_number;
136
+ }
137
+
138
+ /**
139
+ * BIC identifier of the financial institution
140
+ *
141
+ * @param string $bank_identifier_code
142
+ *
143
+ * @return $this
144
+ */
145
+ public function setBankIdentifierCode($bank_identifier_code)
146
+ {
147
+ $this->bank_identifier_code = $bank_identifier_code;
148
+ return $this;
149
+ }
150
+
151
+ /**
152
+ * BIC identifier of the financial institution
153
+ *
154
+ * @return string
155
+ */
156
+ public function getBankIdentifierCode()
157
+ {
158
+ return $this->bank_identifier_code;
159
+ }
160
+
161
+ }
lib/PayPal/Api/RedirectUrls.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+ use PayPal\Validation\UrlValidator;
7
+
8
+ /**
9
+ * Class RedirectUrls
10
+ *
11
+ * Set of redirect URLs you provide only for PayPal-based payments.
12
+ *
13
+ * @package PayPal\Api
14
+ *
15
+ * @property string return_url
16
+ * @property string cancel_url
17
+ */
18
+ class RedirectUrls extends PayPalModel
19
+ {
20
+ /**
21
+ * Url where the payer would be redirected to after approving the payment. **Required for PayPal account payments.**
22
+ *
23
+ * @param string $return_url
24
+ * @throws \InvalidArgumentException
25
+ * @return $this
26
+ */
27
+ public function setReturnUrl($return_url)
28
+ {
29
+ UrlValidator::validate($return_url, "ReturnUrl");
30
+ $this->return_url = $return_url;
31
+ return $this;
32
+ }
33
+
34
+ /**
35
+ * Url where the payer would be redirected to after approving the payment. **Required for PayPal account payments.**
36
+ *
37
+ * @return string
38
+ */
39
+ public function getReturnUrl()
40
+ {
41
+ return $this->return_url;
42
+ }
43
+
44
+ /**
45
+ * Url where the payer would be redirected to after canceling the payment. **Required for PayPal account payments.**
46
+ *
47
+ * @param string $cancel_url
48
+ * @throws \InvalidArgumentException
49
+ * @return $this
50
+ */
51
+ public function setCancelUrl($cancel_url)
52
+ {
53
+ UrlValidator::validate($cancel_url, "CancelUrl");
54
+ $this->cancel_url = $cancel_url;
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * Url where the payer would be redirected to after canceling the payment. **Required for PayPal account payments.**
60
+ *
61
+ * @return string
62
+ */
63
+ public function getCancelUrl()
64
+ {
65
+ return $this->cancel_url;
66
+ }
67
+
68
+ }
lib/PayPal/Api/Refund.php ADDED
@@ -0,0 +1,286 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalResourceModel;
6
+ use PayPal\Rest\ApiContext;
7
+ use PayPal\Validation\ArgumentValidator;
8
+
9
+ /**
10
+ * Class Refund
11
+ *
12
+ * A refund transaction.
13
+ *
14
+ * @package PayPal\Api
15
+ *
16
+ * @property string id
17
+ * @property \PayPal\Api\Amount amount
18
+ * @property string state
19
+ * @property string reason
20
+ * @property string sale_id
21
+ * @property string capture_id
22
+ * @property string parent_payment
23
+ * @property string description
24
+ * @property string create_time
25
+ * @property string update_time
26
+ * @property \PayPal\Api\Links[] links
27
+ */
28
+ class Refund extends PayPalResourceModel
29
+ {
30
+ /**
31
+ * ID of the refund transaction. 17 characters max.
32
+ *
33
+ * @param string $id
34
+ *
35
+ * @return $this
36
+ */
37
+ public function setId($id)
38
+ {
39
+ $this->id = $id;
40
+ return $this;
41
+ }
42
+
43
+ /**
44
+ * ID of the refund transaction. 17 characters max.
45
+ *
46
+ * @return string
47
+ */
48
+ public function getId()
49
+ {
50
+ return $this->id;
51
+ }
52
+
53
+ /**
54
+ * Details including both refunded amount (to payer) and refunded fee (to payee). 10 characters max.
55
+ *
56
+ * @param \PayPal\Api\Amount $amount
57
+ *
58
+ * @return $this
59
+ */
60
+ public function setAmount($amount)
61
+ {
62
+ $this->amount = $amount;
63
+ return $this;
64
+ }
65
+
66
+ /**
67
+ * Details including both refunded amount (to payer) and refunded fee (to payee). 10 characters max.
68
+ *
69
+ * @return \PayPal\Api\Amount
70
+ */
71
+ public function getAmount()
72
+ {
73
+ return $this->amount;
74
+ }
75
+
76
+ /**
77
+ * State of the refund.
78
+ * Valid Values: ["pending", "completed", "failed"]
79
+ *
80
+ * @param string $state
81
+ *
82
+ * @return $this
83
+ */
84
+ public function setState($state)
85
+ {
86
+ $this->state = $state;
87
+ return $this;
88
+ }
89
+
90
+ /**
91
+ * State of the refund.
92
+ *
93
+ * @return string
94
+ */
95
+ public function getState()
96
+ {
97
+ return $this->state;
98
+ }
99
+
100
+ /**
101
+ * Reason description for the Sale transaction being refunded.
102
+ *
103
+ * @param string $reason
104
+ *
105
+ * @return $this
106
+ */
107
+ public function setReason($reason)
108
+ {
109
+ $this->reason = $reason;
110
+ return $this;
111
+ }
112
+
113
+ /**
114
+ * Reason description for the Sale transaction being refunded.
115
+ *
116
+ * @return string
117
+ */
118
+ public function getReason()
119
+ {
120
+ return $this->reason;
121
+ }
122
+
123
+ /**
124
+ * ID of the Sale transaction being refunded.
125
+ *
126
+ * @param string $sale_id
127
+ *
128
+ * @return $this
129
+ */
130
+ public function setSaleId($sale_id)
131
+ {
132
+ $this->sale_id = $sale_id;
133
+ return $this;
134
+ }
135
+
136
+ /**
137
+ * ID of the Sale transaction being refunded.
138
+ *
139
+ * @return string
140
+ */
141
+ public function getSaleId()
142
+ {
143
+ return $this->sale_id;
144
+ }
145
+
146
+ /**
147
+ * ID of the sale transaction being refunded.
148
+ *
149
+ * @param string $capture_id
150
+ *
151
+ * @return $this
152
+ */
153
+ public function setCaptureId($capture_id)
154
+ {
155
+ $this->capture_id = $capture_id;
156
+ return $this;
157
+ }
158
+
159
+ /**
160
+ * ID of the sale transaction being refunded.
161
+ *
162
+ * @return string
163
+ */
164
+ public function getCaptureId()
165
+ {
166
+ return $this->capture_id;
167
+ }
168
+
169
+ /**
170
+ * ID of the payment resource on which this transaction is based.
171
+ *
172
+ * @param string $parent_payment
173
+ *
174
+ * @return $this
175
+ */
176
+ public function setParentPayment($parent_payment)
177
+ {
178
+ $this->parent_payment = $parent_payment;
179
+ return $this;
180
+ }
181
+
182
+ /**
183
+ * ID of the payment resource on which this transaction is based.
184
+ *
185
+ * @return string
186
+ */
187
+ public function getParentPayment()
188
+ {
189
+ return $this->parent_payment;
190
+ }
191
+
192
+ /**
193
+ * Description of what is being refunded for.
194
+ *
195
+ * @param string $description
196
+ *
197
+ * @return $this
198
+ */
199
+ public function setDescription($description)
200
+ {
201
+ $this->description = $description;
202
+ return $this;
203
+ }
204
+
205
+ /**
206
+ * Description of what is being refunded for.
207
+ *
208
+ * @return string
209
+ */
210
+ public function getDescription()
211
+ {
212
+ return $this->description;
213
+ }
214
+
215
+ /**
216
+ * Time of refund as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6).
217
+ *
218
+ * @param string $create_time
219
+ *
220
+ * @return $this
221
+ */
222
+ public function setCreateTime($create_time)
223
+ {
224
+ $this->create_time = $create_time;
225
+ return $this;
226
+ }
227
+
228
+ /**
229
+ * Time of refund as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6).
230
+ *
231
+ * @return string
232
+ */
233
+ public function getCreateTime()
234
+ {
235
+ return $this->create_time;
236
+ }
237
+
238
+ /**
239
+ * Time that the resource was last updated.
240
+ *
241
+ * @param string $update_time
242
+ *
243
+ * @return $this
244
+ */
245
+ public function setUpdateTime($update_time)
246
+ {
247
+ $this->update_time = $update_time;
248
+ return $this;
249
+ }
250
+
251
+ /**
252
+ * Time that the resource was last updated.
253
+ *
254
+ * @return string
255
+ */
256
+ public function getUpdateTime()
257
+ {
258
+ return $this->update_time;
259
+ }
260
+
261
+ /**
262
+ * Retrieve details about a specific refund by passing the refund_id in the request URI.
263
+ *
264
+ * @param string $refundId
265
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
266
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
267
+ * @return Refund
268
+ */
269
+ public static function get($refundId, $apiContext = null, $restCall = null)
270
+ {
271
+ ArgumentValidator::validate($refundId, 'refundId');
272
+ $payLoad = "";
273
+ $json = self::executeCall(
274
+ "/v1/payments/refund/$refundId",
275
+ "GET",
276
+ $payLoad,
277
+ null,
278
+ $apiContext,
279
+ $restCall
280
+ );
281
+ $ret = new Refund();
282
+ $ret->fromJson($json);
283
+ return $ret;
284
+ }
285
+
286
+ }
lib/PayPal/Api/RefundDetail.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class RefundDetail
9
+ *
10
+ * Invoicing refund information.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string type
15
+ * @property string date
16
+ * @property string note
17
+ */
18
+ class RefundDetail extends PayPalModel
19
+ {
20
+ /**
21
+ * PayPal refund type indicating whether refund was done in invoicing flow via PayPal or externally. In the case of the mark-as-refunded API, refund type is EXTERNAL and this is what is now supported. The PAYPAL value is provided for backward compatibility.
22
+ * Valid Values: ["PAYPAL", "EXTERNAL"]
23
+ *
24
+ * @param string $type
25
+ *
26
+ * @return $this
27
+ */
28
+ public function setType($type)
29
+ {
30
+ $this->type = $type;
31
+ return $this;
32
+ }
33
+
34
+ /**
35
+ * PayPal refund type indicating whether refund was done in invoicing flow via PayPal or externally. In the case of the mark-as-refunded API, refund type is EXTERNAL and this is what is now supported. The PAYPAL value is provided for backward compatibility.
36
+ *
37
+ * @return string
38
+ */
39
+ public function getType()
40
+ {
41
+ return $this->type;
42
+ }
43
+
44
+ /**
45
+ * Date when the invoice was marked as refunded. If no date is specified, the current date and time is used as the default. In addition, the date must be after the invoice payment date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
46
+ *
47
+ * @param string $date
48
+ *
49
+ * @return $this
50
+ */
51
+ public function setDate($date)
52
+ {
53
+ $this->date = $date;
54
+ return $this;
55
+ }
56
+
57
+ /**
58
+ * Date when the invoice was marked as refunded. If no date is specified, the current date and time is used as the default. In addition, the date must be after the invoice payment date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
59
+ *
60
+ * @return string
61
+ */
62
+ public function getDate()
63
+ {
64
+ return $this->date;
65
+ }
66
+
67
+ /**
68
+ * Optional note associated with the refund.
69
+ *
70
+ * @param string $note
71
+ *
72
+ * @return $this
73
+ */
74
+ public function setNote($note)
75
+ {
76
+ $this->note = $note;
77
+ return $this;
78
+ }
79
+
80
+ /**
81
+ * Optional note associated with the refund.
82
+ *
83
+ * @return string
84
+ */
85
+ public function getNote()
86
+ {
87
+ return $this->note;
88
+ }
89
+
90
+ }
lib/PayPal/Api/RelatedResources.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class RelatedResources
9
+ *
10
+ * Each one representing a financial transaction (Sale, Authorization, Capture, Refund) related to the payment.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property \PayPal\Api\Sale sale
15
+ * @property \PayPal\Api\Authorization authorization
16
+ * @property \PayPal\Api\Order order
17
+ * @property \PayPal\Api\Capture capture
18
+ * @property \PayPal\Api\Refund refund
19
+ */
20
+ class RelatedResources extends PayPalModel
21
+ {
22
+ /**
23
+ * Sale transaction
24
+ *
25
+ * @param \PayPal\Api\Sale $sale
26
+ *
27
+ * @return $this
28
+ */
29
+ public function setSale($sale)
30
+ {
31
+ $this->sale = $sale;
32
+ return $this;
33
+ }
34
+
35
+ /**
36
+ * Sale transaction
37
+ *
38
+ * @return \PayPal\Api\Sale
39
+ */
40
+ public function getSale()
41
+ {
42
+ return $this->sale;
43
+ }
44
+
45
+ /**
46
+ * Authorization transaction
47
+ *
48
+ * @param \PayPal\Api\Authorization $authorization
49
+ *
50
+ * @return $this
51
+ */
52
+ public function setAuthorization($authorization)
53
+ {
54
+ $this->authorization = $authorization;
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * Authorization transaction
60
+ *
61
+ * @return \PayPal\Api\Authorization
62
+ */
63
+ public function getAuthorization()
64
+ {
65
+ return $this->authorization;
66
+ }
67
+
68
+ /**
69
+ * Order transaction
70
+ *
71
+ * @param \PayPal\Api\Order $order
72
+ *
73
+ * @return $this
74
+ */
75
+ public function setOrder($order)
76
+ {
77
+ $this->order = $order;
78
+ return $this;
79
+ }
80
+
81
+ /**
82
+ * Order transaction
83
+ *
84
+ * @return \PayPal\Api\Order
85
+ */
86
+ public function getOrder()
87
+ {
88
+ return $this->order;
89
+ }
90
+
91
+ /**
92
+ * Capture transaction
93
+ *
94
+ * @param \PayPal\Api\Capture $capture
95
+ *
96
+ * @return $this
97
+ */
98
+ public function setCapture($capture)
99
+ {
100
+ $this->capture = $capture;
101
+ return $this;
102
+ }
103
+
104
+ /**
105
+ * Capture transaction
106
+ *
107
+ * @return \PayPal\Api\Capture
108
+ */
109
+ public function getCapture()
110
+ {
111
+ return $this->capture;
112
+ }
113
+
114
+ /**
115
+ * Refund transaction
116
+ *
117
+ * @param \PayPal\Api\Refund $refund
118
+ *
119
+ * @return $this
120
+ */
121
+ public function setRefund($refund)
122
+ {
123
+ $this->refund = $refund;
124
+ return $this;
125
+ }
126
+
127
+ /**
128
+ * Refund transaction
129
+ *
130
+ * @return \PayPal\Api\Refund
131
+ */
132
+ public function getRefund()
133
+ {
134
+ return $this->refund;
135
+ }
136
+
137
+ }
lib/PayPal/Api/Sale.php ADDED
@@ -0,0 +1,611 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalResourceModel;
6
+ use PayPal\Rest\ApiContext;
7
+ use PayPal\Validation\ArgumentValidator;
8
+
9
+ /**
10
+ * Class Sale
11
+ *
12
+ * A sale transaction.
13
+ *
14
+ * @package PayPal\Api
15
+ *
16
+ * @property string id
17
+ * @property string purchase_unit_reference_id
18
+ * @property \PayPal\Api\Amount amount
19
+ * @property string payment_mode
20
+ * @property string state
21
+ * @property string reason_code
22
+ * @property string protection_eligibility
23
+ * @property string protection_eligibility_type
24
+ * @property string clearing_time
25
+ * @property string payment_hold_status
26
+ * @property string[] payment_hold_reasons
27
+ * @property \PayPal\Api\Currency transaction_fee
28
+ * @property \PayPal\Api\Currency receivable_amount
29
+ * @property string exchange_rate
30
+ * @property \PayPal\Api\FmfDetails fmf_details
31
+ * @property string receipt_id
32
+ * @property string parent_payment
33
+ * @property \PayPal\Api\ProcessorResponse processor_response
34
+ * @property string billing_agreement_id
35
+ * @property string create_time
36
+ * @property string update_time
37
+ * @property \PayPal\Api\Links[] links
38
+ */
39
+ class Sale extends PayPalResourceModel
40
+ {
41
+ /**
42
+ * ID of the sale transaction.
43
+ *
44
+ * @param string $id
45
+ *
46
+ * @return $this
47
+ */
48
+ public function setId($id)
49
+ {
50
+ $this->id = $id;
51
+ return $this;
52
+ }
53
+
54
+ /**
55
+ * ID of the sale transaction.
56
+ *
57
+ * @return string
58
+ */
59
+ public function getId()
60
+ {
61
+ return $this->id;
62
+ }
63
+
64
+ /**
65
+ * Identifier of the purchased unit associated with this object.
66
+ *
67
+ * @param string $purchase_unit_reference_id
68
+ *
69
+ * @return $this
70
+ */
71
+ public function setPurchaseUnitReferenceId($purchase_unit_reference_id)
72
+ {
73
+ $this->purchase_unit_reference_id = $purchase_unit_reference_id;
74
+ return $this;
75
+ }
76
+
77
+ /**
78
+ * Identifier of the purchased unit associated with this object.
79
+ *
80
+ * @return string
81
+ */
82
+ public function getPurchaseUnitReferenceId()
83
+ {
84
+ return $this->purchase_unit_reference_id;
85
+ }
86
+
87
+ /**
88
+ * Amount being collected.
89
+ *
90
+ * @param \PayPal\Api\Amount $amount
91
+ *
92
+ * @return $this
93
+ */
94
+ public function setAmount($amount)
95
+ {
96
+ $this->amount = $amount;
97
+ return $this;
98
+ }
99
+
100
+ /**
101
+ * Amount being collected.
102
+ *
103
+ * @return \PayPal\Api\Amount
104
+ */
105
+ public function getAmount()
106
+ {
107
+ return $this->amount;
108
+ }
109
+
110
+ /**
111
+ * Specifies payment mode of the transaction. Only supported when the `payment_method` is set to `paypal`.
112
+ * Valid Values: ["INSTANT_TRANSFER", "MANUAL_BANK_TRANSFER", "DELAYED_TRANSFER", "ECHECK"]
113
+ *
114
+ * @param string $payment_mode
115
+ *
116
+ * @return $this
117
+ */
118
+ public function setPaymentMode($payment_mode)
119
+ {
120
+ $this->payment_mode = $payment_mode;
121
+ return $this;
122
+ }
123
+
124
+ /**
125
+ * Specifies payment mode of the transaction. Only supported when the `payment_method` is set to `paypal`.
126
+ *
127
+ * @return string
128
+ */
129
+ public function getPaymentMode()
130
+ {
131
+ return $this->payment_mode;
132
+ }
133
+
134
+ /**
135
+ * State of the sale.
136
+ * Valid Values: ["completed", "partially_refunded", "pending", "refunded"]
137
+ *
138
+ * @param string $state
139
+ *
140
+ * @return $this
141
+ */
142
+ public function setState($state)
143
+ {
144
+ $this->state = $state;
145
+ return $this;
146
+ }
147
+
148
+ /**
149
+ * State of the sale.
150
+ *
151
+ * @return string
152
+ */
153
+ public function getState()
154
+ {
155
+ return $this->state;
156
+ }
157
+
158
+ /**
159
+ * Reason code for the transaction state being Pending or Reversed. Only supported when the `payment_method` is set to `paypal`.
160
+ * 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"]
161
+ *
162
+ * @param string $reason_code
163
+ *
164
+ * @return $this
165
+ */
166
+ public function setReasonCode($reason_code)
167
+ {
168
+ $this->reason_code = $reason_code;
169
+ return $this;
170
+ }
171
+
172
+ /**
173
+ * Reason code for the transaction state being Pending or Reversed. Only supported when the `payment_method` is set to `paypal`.
174
+ *
175
+ * @return string
176
+ */
177
+ public function getReasonCode()
178
+ {
179
+ return $this->reason_code;
180
+ }
181
+
182
+ /**
183
+ * The level of seller protection in force for the transaction. Only supported when the `payment_method` is set to `paypal`.
184
+ * Valid Values: ["ELIGIBLE", "PARTIALLY_ELIGIBLE", "INELIGIBLE"]
185
+ *
186
+ * @param string $protection_eligibility
187
+ *
188
+ * @return $this
189
+ */
190
+ public function setProtectionEligibility($protection_eligibility)
191
+ {
192
+ $this->protection_eligibility = $protection_eligibility;
193
+ return $this;
194
+ }
195
+
196
+ /**
197
+ * The level of seller protection in force for the transaction. Only supported when the `payment_method` is set to `paypal`.
198
+ *
199
+ * @return string
200
+ */
201
+ public function getProtectionEligibility()
202
+ {
203
+ return $this->protection_eligibility;
204
+ }
205
+
206
+ /**
207
+ * The kind of seller protection in force for the transaction. It is returned only when protection_eligibility is ELIGIBLE or PARTIALLY_ELIGIBLE. Only supported when the `payment_method` is set to `paypal`.
208
+ * Valid Values: ["ITEM_NOT_RECEIVED_ELIGIBLE", "UNAUTHORIZED_PAYMENT_ELIGIBLE", "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE"]
209
+ *
210
+ * @param string $protection_eligibility_type
211
+ *
212
+ * @return $this
213
+ */
214
+ public function setProtectionEligibilityType($protection_eligibility_type)
215
+ {
216
+ $this->protection_eligibility_type = $protection_eligibility_type;
217
+ return $this;
218
+ }
219
+
220
+ /**
221
+ * The kind of seller protection in force for the transaction. It is returned only when protection_eligibility is ELIGIBLE or PARTIALLY_ELIGIBLE. Only supported when the `payment_method` is set to `paypal`.
222
+ *
223
+ * @return string
224
+ */
225
+ public function getProtectionEligibilityType()
226
+ {
227
+ return $this->protection_eligibility_type;
228
+ }
229
+
230
+ /**
231
+ * Expected clearing time for eCheck transactions. Only supported when the `payment_method` is set to `paypal`.
232
+ *
233
+ * @param string $clearing_time
234
+ *
235
+ * @return $this
236
+ */
237
+ public function setClearingTime($clearing_time)
238
+ {
239
+ $this->clearing_time = $clearing_time;
240
+ return $this;
241
+ }
242
+
243
+ /**
244
+ * Expected clearing time for eCheck transactions. Only supported when the `payment_method` is set to `paypal`.
245
+ *
246
+ * @return string
247
+ */
248
+ public function getClearingTime()
249
+ {
250
+ return $this->clearing_time;
251
+ }
252
+
253
+ /**
254
+ * Status of the Recipient Fund. For now, it will be returned only when fund status is held
255
+ * Valid Values: ["HELD"]
256
+ *
257
+ * @param string $payment_hold_status
258
+ *
259
+ * @return $this
260
+ */
261
+ public function setPaymentHoldStatus($payment_hold_status)
262
+ {
263
+ $this->payment_hold_status = $payment_hold_status;
264
+ return $this;
265
+ }
266
+
267
+ /**
268
+ * Status of the Recipient Fund. For now, it will be returned only when fund status is held
269
+ *
270
+ * @return string
271
+ */
272
+ public function getPaymentHoldStatus()
273
+ {
274
+ return $this->payment_hold_status;
275
+ }
276
+
277
+ /**
278
+ * Reasons for PayPal holding recipient fund. It is set only if payment hold status is held
279
+ *
280
+ * @param string[] $payment_hold_reasons
281
+ *
282
+ * @return $this
283
+ */
284
+ public function setPaymentHoldReasons($payment_hold_reasons)
285
+ {
286
+ $this->payment_hold_reasons = $payment_hold_reasons;
287
+ return $this;
288
+ }
289
+
290
+ /**
291
+ * Reasons for PayPal holding recipient fund. It is set only if payment hold status is held
292
+ *
293
+ * @return string[]
294
+ */
295
+ public function getPaymentHoldReasons()
296
+ {
297
+ return $this->payment_hold_reasons;
298
+ }
299
+
300
+ /**
301
+ * Append PaymentHoldReasons to the list.
302
+ *
303
+ * @param string $string
304
+ * @return $this
305
+ */
306
+ public function addPaymentHoldReason($string)
307
+ {
308
+ if (!$this->getPaymentHoldReasons()) {
309
+ return $this->setPaymentHoldReasons(array($string));
310
+ } else {
311
+ return $this->setPaymentHoldReasons(
312
+ array_merge($this->getPaymentHoldReasons(), array($string))
313
+ );
314
+ }
315
+ }
316
+
317
+ /**
318
+ * Remove PaymentHoldReasons from the list.
319
+ *
320
+ * @param string $string
321
+ * @return $this
322
+ */
323
+ public function removePaymentHoldReason($string)
324
+ {
325
+ return $this->setPaymentHoldReasons(
326
+ array_diff($this->getPaymentHoldReasons(), array($string))
327
+ );
328
+ }
329
+
330
+ /**
331
+ * Transaction fee charged by PayPal for this transaction.
332
+ *
333
+ * @param \PayPal\Api\Currency $transaction_fee
334
+ *
335
+ * @return $this
336
+ */
337
+ public function setTransactionFee($transaction_fee)
338
+ {
339
+ $this->transaction_fee = $transaction_fee;
340
+ return $this;
341
+ }
342
+
343
+ /**
344
+ * Transaction fee charged by PayPal for this transaction.
345
+ *
346
+ * @return \PayPal\Api\Currency
347
+ */
348
+ public function getTransactionFee()
349
+ {
350
+ return $this->transaction_fee;
351
+ }
352
+
353
+ /**
354
+ * Net amount the merchant receives for this transaction in their receivable currency. Returned only in cross-currency use cases where a merchant bills a buyer in a non-primary currency for that buyer.
355
+ *
356
+ * @param \PayPal\Api\Currency $receivable_amount
357
+ *
358
+ * @return $this
359
+ */
360
+ public function setReceivableAmount($receivable_amount)
361
+ {
362
+ $this->receivable_amount = $receivable_amount;
363
+ return $this;
364
+ }
365
+
366
+ /**
367
+ * Net amount the merchant receives for this transaction in their receivable currency. Returned only in cross-currency use cases where a merchant bills a buyer in a non-primary currency for that buyer.
368
+ *
369
+ * @return \PayPal\Api\Currency
370
+ */
371
+ public function getReceivableAmount()
372
+ {
373
+ return $this->receivable_amount;
374
+ }
375
+
376
+ /**
377
+ * Exchange rate applied for this transaction. Returned only in cross-currency use cases where a merchant bills a buyer in a non-primary currency for that buyer.
378
+ *
379
+ * @param string $exchange_rate
380
+ *
381
+ * @return $this
382
+ */
383
+ public function setExchangeRate($exchange_rate)
384
+ {
385
+ $this->exchange_rate = $exchange_rate;
386
+ return $this;
387
+ }
388
+
389
+ /**
390
+ * Exchange rate applied for this transaction. Returned only in cross-currency use cases where a merchant bills a buyer in a non-primary currency for that buyer.
391
+ *
392
+ * @return string
393
+ */
394
+ public function getExchangeRate()
395
+ {
396
+ return $this->exchange_rate;
397
+ }
398
+
399
+ /**
400
+ * Fraud Management Filter (FMF) details applied for the payment that could result in accept, deny, or pending action. Returned in a payment response only if the merchant has enabled FMF in the profile settings and one of the fraud filters was triggered based on those settings. See [Fraud Management Filters Summary](/docs/classic/fmf/integration-guide/FMFSummary/) for more information.
401
+ *
402
+ * @param \PayPal\Api\FmfDetails $fmf_details
403
+ *
404
+ * @return $this
405
+ */
406
+ public function setFmfDetails($fmf_details)
407
+ {
408
+ $this->fmf_details = $fmf_details;
409
+ return $this;
410
+ }
411
+
412
+ /**
413
+ * Fraud Management Filter (FMF) details applied for the payment that could result in accept, deny, or pending action. Returned in a payment response only if the merchant has enabled FMF in the profile settings and one of the fraud filters was triggered based on those settings. See [Fraud Management Filters Summary](/docs/classic/fmf/integration-guide/FMFSummary/) for more information.
414
+ *
415
+ * @return \PayPal\Api\FmfDetails
416
+ */
417
+ public function getFmfDetails()
418
+ {
419
+ return $this->fmf_details;
420
+ }
421
+
422
+ /**
423
+ * Receipt id is a payment identification number returned for guest users to identify the payment.
424
+ *
425
+ * @param string $receipt_id
426
+ *
427
+ * @return $this
428
+ */
429
+ public function setReceiptId($receipt_id)
430
+ {
431
+ $this->receipt_id = $receipt_id;
432
+ return $this;
433
+ }
434
+
435
+ /**
436
+ * Receipt id is a payment identification number returned for guest users to identify the payment.
437
+ *
438
+ * @return string
439
+ */
440
+ public function getReceiptId()
441
+ {
442
+ return $this->receipt_id;
443
+ }
444
+
445
+ /**
446
+ * ID of the payment resource on which this transaction is based.
447
+ *
448
+ * @param string $parent_payment
449
+ *
450
+ * @return $this
451
+ */
452
+ public function setParentPayment($parent_payment)
453
+ {
454
+ $this->parent_payment = $parent_payment;
455
+ return $this;
456
+ }
457
+
458
+ /**
459
+ * ID of the payment resource on which this transaction is based.
460
+ *
461
+ * @return string
462
+ */
463
+ public function getParentPayment()
464
+ {
465
+ return $this->parent_payment;
466
+ }
467
+
468
+ /**
469
+ * Response codes returned by the processor concerning the submitted payment. Only supported when the `payment_method` is set to `credit_card`.
470
+ *
471
+ * @param \PayPal\Api\ProcessorResponse $processor_response
472
+ *
473
+ * @return $this
474
+ */
475
+ public function setProcessorResponse($processor_response)
476
+ {
477
+ $this->processor_response = $processor_response;
478
+ return $this;
479
+ }
480
+
481
+ /**
482
+ * Response codes returned by the processor concerning the submitted payment. Only supported when the `payment_method` is set to `credit_card`.
483
+ *
484
+ * @return \PayPal\Api\ProcessorResponse
485
+ */
486
+ public function getProcessorResponse()
487
+ {
488
+ return $this->processor_response;
489
+ }
490
+
491
+ /**
492
+ * ID of the billing agreement used as reference to execute this transaction.
493
+ *
494
+ * @param string $billing_agreement_id
495
+ *
496
+ * @return $this
497
+ */
498
+ public function setBillingAgreementId($billing_agreement_id)
499
+ {
500
+ $this->billing_agreement_id = $billing_agreement_id;
501
+ return $this;
502
+ }
503
+
504
+ /**
505
+ * ID of the billing agreement used as reference to execute this transaction.
506
+ *
507
+ * @return string
508
+ */
509
+ public function getBillingAgreementId()
510
+ {
511
+ return $this->billing_agreement_id;
512
+ }
513
+
514
+ /**
515
+ * Time of sale as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6)
516
+ *
517
+ * @param string $create_time
518
+ *
519
+ * @return $this
520
+ */
521
+ public function setCreateTime($create_time)
522
+ {
523
+ $this->create_time = $create_time;
524
+ return $this;
525
+ }
526
+
527
+ /**
528
+ * Time of sale as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6)
529
+ *
530
+ * @return string
531
+ */
532
+ public function getCreateTime()
533
+ {
534
+ return $this->create_time;
535
+ }
536
+
537
+ /**
538
+ * Time the resource was last updated in UTC ISO8601 format.
539
+ *
540
+ * @param string $update_time
541
+ *
542
+ * @return $this
543
+ */
544
+ public function setUpdateTime($update_time)
545
+ {
546
+ $this->update_time = $update_time;
547
+ return $this;
548
+ }
549
+
550
+ /**
551
+ * Time the resource was last updated in UTC ISO8601 format.
552
+ *
553
+ * @return string
554
+ */
555
+ public function getUpdateTime()
556
+ {
557
+ return $this->update_time;
558
+ }
559
+
560
+ /**
561
+ * Retrieve details about a sale transaction by passing the sale_id in the request URI. This request returns only the sales that were created via the REST API.
562
+ *
563
+ * @param string $saleId
564
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
565
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
566
+ * @return Sale
567
+ */
568
+ public static function get($saleId, $apiContext = null, $restCall = null)
569
+ {
570
+ ArgumentValidator::validate($saleId, 'saleId');
571
+ $payLoad = "";
572
+ $json = self::executeCall(
573
+ "/v1/payments/sale/$saleId",
574
+ "GET",
575
+ $payLoad,
576
+ null,
577
+ $apiContext,
578
+ $restCall
579
+ );
580
+ $ret = new Sale();
581
+ $ret->fromJson($json);
582
+ return $ret;
583
+ }
584
+
585
+ /**
586
+ * Refund a completed payment by passing the sale_id in the request URI. In addition, include an empty JSON payload in the request body for a full refund. For a partial refund, include an amount object in the request body.
587
+ *
588
+ * @param Refund $refund
589
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
590
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
591
+ * @return Refund
592
+ */
593
+ public function refund($refund, $apiContext = null, $restCall = null)
594
+ {
595
+ ArgumentValidator::validate($this->getId(), "Id");
596
+ ArgumentValidator::validate($refund, 'refund');
597
+ $payLoad = $refund->toJSON();
598
+ $json = self::executeCall(
599
+ "/v1/payments/sale/{$this->getId()}/refund",
600
+ "POST",
601
+ $payLoad,
602
+ null,
603
+ $apiContext,
604
+ $restCall
605
+ );
606
+ $ret = new Refund();
607
+ $ret->fromJson($json);
608
+ return $ret;
609
+ }
610
+
611
+ }
lib/PayPal/Api/Search.php ADDED
@@ -0,0 +1,474 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class Search
9
+ *
10
+ * Invoice search parameters.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string email
15
+ * @property string recipient_first_name
16
+ * @property string recipient_last_name
17
+ * @property string recipient_business_name
18
+ * @property string number
19
+ * @property string status
20
+ * @property \PayPal\Api\Currency lower_total_amount
21
+ * @property \PayPal\Api\Currency upper_total_amount
22
+ * @property string start_invoice_date
23
+ * @property string end_invoice_date
24
+ * @property string start_due_date
25
+ * @property string end_due_date
26
+ * @property string start_payment_date
27
+ * @property string end_payment_date
28
+ * @property string start_creation_date
29
+ * @property string end_creation_date
30
+ * @property \PayPal\Api\number page
31
+ * @property \PayPal\Api\number page_size
32
+ * @property bool total_count_required
33
+ */
34
+ class Search extends PayPalModel
35
+ {
36
+ /**
37
+ * Initial letters of the email address.
38
+ *
39
+ * @param string $email
40
+ *
41
+ * @return $this
42
+ */
43
+ public function setEmail($email)
44
+ {
45
+ $this->email = $email;
46
+ return $this;
47
+ }
48
+
49
+ /**
50
+ * Initial letters of the email address.
51
+ *
52
+ * @return string
53
+ */
54
+ public function getEmail()
55
+ {
56
+ return $this->email;
57
+ }
58
+
59
+ /**
60
+ * Initial letters of the recipient's first name.
61
+ *
62
+ * @param string $recipient_first_name
63
+ *
64
+ * @return $this
65
+ */
66
+ public function setRecipientFirstName($recipient_first_name)
67
+ {
68
+ $this->recipient_first_name = $recipient_first_name;
69
+ return $this;
70
+ }
71
+
72
+ /**
73
+ * Initial letters of the recipient's first name.
74
+ *
75
+ * @return string
76
+ */
77
+ public function getRecipientFirstName()
78
+ {
79
+ return $this->recipient_first_name;
80
+ }
81
+
82
+ /**
83
+ * Initial letters of the recipient's last name.
84
+ *
85
+ * @param string $recipient_last_name
86
+ *
87
+ * @return $this
88
+ */
89
+ public function setRecipientLastName($recipient_last_name)
90
+ {
91
+ $this->recipient_last_name = $recipient_last_name;
92
+ return $this;
93
+ }
94
+
95
+ /**
96
+ * Initial letters of the recipient's last name.
97
+ *
98
+ * @return string
99
+ */
100
+ public function getRecipientLastName()
101
+ {
102
+ return $this->recipient_last_name;
103
+ }
104
+
105
+ /**
106
+ * Initial letters of the recipient's business name.
107
+ *
108
+ * @param string $recipient_business_name
109
+ *
110
+ * @return $this
111
+ */
112
+ public function setRecipientBusinessName($recipient_business_name)
113
+ {
114
+ $this->recipient_business_name = $recipient_business_name;
115
+ return $this;
116
+ }
117
+
118
+ /**
119
+ * Initial letters of the recipient's business name.
120
+ *
121
+ * @return string
122
+ */
123
+ public function getRecipientBusinessName()
124
+ {
125
+ return $this->recipient_business_name;
126
+ }
127
+
128
+ /**
129
+ * The invoice number that appears on the invoice.
130
+ *
131
+ * @param string $number
132
+ *
133
+ * @return $this
134
+ */
135
+ public function setNumber($number)
136
+ {
137
+ $this->number = $number;
138
+ return $this;
139
+ }
140
+
141
+ /**
142
+ * The invoice number that appears on the invoice.
143
+ *
144
+ * @return string
145
+ */
146
+ public function getNumber()
147
+ {
148
+ return $this->number;
149
+ }
150
+
151
+ /**
152
+ * Status of the invoice.
153
+ * Valid Values: ["DRAFT", "SENT", "PAID", "MARKED_AS_PAID", "CANCELLED", "REFUNDED", "PARTIALLY_REFUNDED", "MARKED_AS_REFUNDED"]
154
+ *
155
+ * @param string $status
156
+ *
157
+ * @return $this
158
+ */
159
+ public function setStatus($status)
160
+ {
161
+ $this->status = $status;
162
+ return $this;
163
+ }
164
+
165
+ /**
166
+ * Status of the invoice.
167
+ *
168
+ * @return string
169
+ */
170
+ public function getStatus()
171
+ {
172
+ return $this->status;
173
+ }
174
+
175
+ /**
176
+ * Lower limit of total amount.
177
+ *
178
+ * @param \PayPal\Api\Currency $lower_total_amount
179
+ *
180
+ * @return $this
181
+ */
182
+ public function setLowerTotalAmount($lower_total_amount)
183
+ {
184
+ $this->lower_total_amount = $lower_total_amount;
185
+ return $this;
186
+ }
187
+
188
+ /**
189
+ * Lower limit of total amount.
190
+ *
191
+ * @return \PayPal\Api\Currency
192
+ */
193
+ public function getLowerTotalAmount()
194
+ {
195
+ return $this->lower_total_amount;
196
+ }
197
+
198
+ /**
199
+ * Upper limit of total amount.
200
+ *
201
+ * @param \PayPal\Api\Currency $upper_total_amount
202
+ *
203
+ * @return $this
204
+ */
205
+ public function setUpperTotalAmount($upper_total_amount)
206
+ {
207
+ $this->upper_total_amount = $upper_total_amount;
208
+ return $this;
209
+ }
210
+
211
+ /**
212
+ * Upper limit of total amount.
213
+ *
214
+ * @return \PayPal\Api\Currency
215
+ */
216
+ public function getUpperTotalAmount()
217
+ {
218
+ return $this->upper_total_amount;
219
+ }
220
+
221
+ /**
222
+ * Start invoice date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
223
+ *
224
+ * @param string $start_invoice_date
225
+ *
226
+ * @return $this
227
+ */
228
+ public function setStartInvoiceDate($start_invoice_date)
229
+ {
230
+ $this->start_invoice_date = $start_invoice_date;
231
+ return $this;
232
+ }
233
+
234
+ /**
235
+ * Start invoice date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
236
+ *
237
+ * @return string
238
+ */
239
+ public function getStartInvoiceDate()
240
+ {
241
+ return $this->start_invoice_date;
242
+ }
243
+
244
+ /**
245
+ * End invoice date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
246
+ *
247
+ * @param string $end_invoice_date
248
+ *
249
+ * @return $this
250
+ */
251
+ public function setEndInvoiceDate($end_invoice_date)
252
+ {
253
+ $this->end_invoice_date = $end_invoice_date;
254
+ return $this;
255
+ }
256
+
257
+ /**
258
+ * End invoice date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
259
+ *
260
+ * @return string
261
+ */
262
+ public function getEndInvoiceDate()
263
+ {
264
+ return $this->end_invoice_date;
265
+ }
266
+
267
+ /**
268
+ * Start invoice due date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
269
+ *
270
+ * @param string $start_due_date
271
+ *
272
+ * @return $this
273
+ */
274
+ public function setStartDueDate($start_due_date)
275
+ {
276
+ $this->start_due_date = $start_due_date;
277
+ return $this;
278
+ }
279
+
280
+ /**
281
+ * Start invoice due date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
282
+ *
283
+ * @return string
284
+ */
285
+ public function getStartDueDate()
286
+ {
287
+ return $this->start_due_date;
288
+ }
289
+
290
+ /**
291
+ * End invoice due date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
292
+ *
293
+ * @param string $end_due_date
294
+ *
295
+ * @return $this
296
+ */
297
+ public function setEndDueDate($end_due_date)
298
+ {
299
+ $this->end_due_date = $end_due_date;
300
+ return $this;
301
+ }
302
+
303
+ /**
304
+ * End invoice due date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
305
+ *
306
+ * @return string
307
+ */
308
+ public function getEndDueDate()
309
+ {
310
+ return $this->end_due_date;
311
+ }
312
+
313
+ /**
314
+ * Start invoice payment date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
315
+ *
316
+ * @param string $start_payment_date
317
+ *
318
+ * @return $this
319
+ */
320
+ public function setStartPaymentDate($start_payment_date)
321
+ {
322
+ $this->start_payment_date = $start_payment_date;
323
+ return $this;
324
+ }
325
+
326
+ /**
327
+ * Start invoice payment date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
328
+ *
329
+ * @return string
330
+ */
331
+ public function getStartPaymentDate()
332
+ {
333
+ return $this->start_payment_date;
334
+ }
335
+
336
+ /**
337
+ * End invoice payment date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
338
+ *
339
+ * @param string $end_payment_date
340
+ *
341
+ * @return $this
342
+ */
343
+ public function setEndPaymentDate($end_payment_date)
344
+ {
345
+ $this->end_payment_date = $end_payment_date;
346
+ return $this;
347
+ }
348
+
349
+ /**
350
+ * End invoice payment date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
351
+ *
352
+ * @return string
353
+ */
354
+ public function getEndPaymentDate()
355
+ {
356
+ return $this->end_payment_date;
357
+ }
358
+
359
+ /**
360
+ * Start invoice creation date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
361
+ *
362
+ * @param string $start_creation_date
363
+ *
364
+ * @return $this
365
+ */
366
+ public function setStartCreationDate($start_creation_date)
367
+ {
368
+ $this->start_creation_date = $start_creation_date;
369
+ return $this;
370
+ }
371
+
372
+ /**
373
+ * Start invoice creation date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
374
+ *
375
+ * @return string
376
+ */
377
+ public function getStartCreationDate()
378
+ {
379
+ return $this->start_creation_date;
380
+ }
381
+
382
+ /**
383
+ * End invoice creation date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
384
+ *
385
+ * @param string $end_creation_date
386
+ *
387
+ * @return $this
388
+ */
389
+ public function setEndCreationDate($end_creation_date)
390
+ {
391
+ $this->end_creation_date = $end_creation_date;
392
+ return $this;
393
+ }
394
+
395
+ /**
396
+ * End invoice creation date. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6).
397
+ *
398
+ * @return string
399
+ */
400
+ public function getEndCreationDate()
401
+ {
402
+ return $this->end_creation_date;
403
+ }
404
+
405
+ /**
406
+ * Offset of the search results.
407
+ *
408
+ * @param \PayPal\Api\number $page
409
+ *
410
+ * @return $this
411
+ */
412
+ public function setPage($page)
413
+ {
414
+ $this->page = $page;
415
+ return $this;
416
+ }
417
+
418
+ /**
419
+ * Offset of the search results.
420
+ *
421
+ * @return \PayPal\Api\number
422
+ */
423
+ public function getPage()
424
+ {
425
+ return $this->page;
426
+ }
427
+
428
+ /**
429
+ * Page size of the search results.
430
+ *
431
+ * @param \PayPal\Api\number $page_size
432
+ *
433
+ * @return $this
434
+ */
435
+ public function setPageSize($page_size)
436
+ {
437
+ $this->page_size = $page_size;
438
+ return $this;
439
+ }
440
+
441
+ /**
442
+ * Page size of the search results.
443
+ *
444
+ * @return \PayPal\Api\number
445
+ */
446
+ public function getPageSize()
447
+ {
448
+ return $this->page_size;
449
+ }
450
+
451
+ /**
452
+ * A flag indicating whether total count is required in the response.
453
+ *
454
+ * @param bool $total_count_required
455
+ *
456
+ * @return $this
457
+ */
458
+ public function setTotalCountRequired($total_count_required)
459
+ {
460
+ $this->total_count_required = $total_count_required;
461
+ return $this;
462
+ }
463
+
464
+ /**
465
+ * A flag indicating whether total count is required in the response.
466
+ *
467
+ * @return bool
468
+ */
469
+ public function getTotalCountRequired()
470
+ {
471
+ return $this->total_count_required;
472
+ }
473
+
474
+ }
lib/PayPal/Api/ShippingAddress.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ /**
6
+ * Class ShippingAddress
7
+ *
8
+ * Extended Address object used as shipping address in a payment.
9
+ *
10
+ * @package PayPal\Api
11
+ *
12
+ * @property string id
13
+ * @property string recipient_name
14
+ * @property bool default_address
15
+ * @property bool preferred_address
16
+ */
17
+ class ShippingAddress extends Address
18
+ {
19
+ /**
20
+ * Address ID assigned in PayPal system.
21
+ *
22
+ * @param string $id
23
+ *
24
+ * @return $this
25
+ */
26
+ public function setId($id)
27
+ {
28
+ $this->id = $id;
29
+ return $this;
30
+ }
31
+
32
+ /**
33
+ * Address ID assigned in PayPal system.
34
+ *
35
+ * @return string
36
+ */
37
+ public function getId()
38
+ {
39
+ return $this->id;
40
+ }
41
+
42
+ /**
43
+ * Name of the recipient at this address.
44
+ *
45
+ * @param string $recipient_name
46
+ *
47
+ * @return $this
48
+ */
49
+ public function setRecipientName($recipient_name)
50
+ {
51
+ $this->recipient_name = $recipient_name;
52
+ return $this;
53
+ }
54
+
55
+ /**
56
+ * Name of the recipient at this address.
57
+ *
58
+ * @return string
59
+ */
60
+ public function getRecipientName()
61
+ {
62
+ return $this->recipient_name;
63
+ }
64
+
65
+ /**
66
+ * Default shipping address of the Payer.
67
+ *
68
+ * @param bool $default_address
69
+ *
70
+ * @return $this
71
+ */
72
+ public function setDefaultAddress($default_address)
73
+ {
74
+ $this->default_address = $default_address;
75
+ return $this;
76
+ }
77
+
78
+ /**
79
+ * Default shipping address of the Payer.
80
+ *
81
+ * @return bool
82
+ */
83
+ public function getDefaultAddress()
84
+ {
85
+ return $this->default_address;
86
+ }
87
+
88
+ /**
89
+ * Shipping Address marked as preferred by Payer.
90
+ *
91
+ * @param bool $preferred_address
92
+ *
93
+ * @return $this
94
+ */
95
+ public function setPreferredAddress($preferred_address)
96
+ {
97
+ $this->preferred_address = $preferred_address;
98
+ return $this;
99
+ }
100
+
101
+ /**
102
+ * Shipping Address marked as preferred by Payer.
103
+ *
104
+ * @return bool
105
+ */
106
+ public function getPreferredAddress()
107
+ {
108
+ return $this->preferred_address;
109
+ }
110
+
111
+ }
lib/PayPal/Api/ShippingCost.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class ShippingCost
9
+ *
10
+ * Shipping cost in percent or amount.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property \PayPal\Api\Currency amount
15
+ * @property \PayPal\Api\Tax tax
16
+ */
17
+ class ShippingCost extends PayPalModel
18
+ {
19
+ /**
20
+ * Shipping cost in amount. Range of 0 to 999999.99.
21
+ *
22
+ * @param \PayPal\Api\Currency $amount
23
+ *
24
+ * @return $this
25
+ */
26
+ public function setAmount($amount)
27
+ {
28
+ $this->amount = $amount;
29
+ return $this;
30
+ }
31
+
32
+ /**
33
+ * Shipping cost in amount. Range of 0 to 999999.99.
34
+ *
35
+ * @return \PayPal\Api\Currency
36
+ */
37
+ public function getAmount()
38
+ {
39
+ return $this->amount;
40
+ }
41
+
42
+ /**
43
+ * Tax percentage on shipping amount.
44
+ *
45
+ * @param \PayPal\Api\Tax $tax
46
+ *
47
+ * @return $this
48
+ */
49
+ public function setTax($tax)
50
+ {
51
+ $this->tax = $tax;
52
+ return $this;
53
+ }
54
+
55
+ /**
56
+ * Tax percentage on shipping amount.
57
+ *
58
+ * @return \PayPal\Api\Tax
59
+ */
60
+ public function getTax()
61
+ {
62
+ return $this->tax;
63
+ }
64
+
65
+ }
lib/PayPal/Api/ShippingInfo.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class ShippingInfo
9
+ *
10
+ * Shipping information for the invoice recipient.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string first_name
15
+ * @property string last_name
16
+ * @property string business_name
17
+ * @property \PayPal\Api\Phone phone
18
+ * @property \PayPal\Api\InvoiceAddress address
19
+ */
20
+ class ShippingInfo extends PayPalModel
21
+ {
22
+ /**
23
+ * First name of the invoice recipient. 30 characters max.
24
+ *
25
+ * @param string $first_name
26
+ *
27
+ * @return $this
28
+ */
29
+ public function setFirstName($first_name)
30
+ {
31
+ $this->first_name = $first_name;
32
+ return $this;
33
+ }
34
+
35
+ /**
36
+ * First name of the invoice recipient. 30 characters max.
37
+ *
38
+ * @return string
39
+ */
40
+ public function getFirstName()
41
+ {
42
+ return $this->first_name;
43
+ }
44
+
45
+ /**
46
+ * Last name of the invoice recipient. 30 characters max.
47
+ *
48
+ * @param string $last_name
49
+ *
50
+ * @return $this
51
+ */
52
+ public function setLastName($last_name)
53
+ {
54
+ $this->last_name = $last_name;
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * Last name of the invoice recipient. 30 characters max.
60
+ *
61
+ * @return string
62
+ */
63
+ public function getLastName()
64
+ {
65
+ return $this->last_name;
66
+ }
67
+
68
+ /**
69
+ * Company business name of the invoice recipient. 100 characters max.
70
+ *
71
+ * @param string $business_name
72
+ *
73
+ * @return $this
74
+ */
75
+ public function setBusinessName($business_name)
76
+ {
77
+ $this->business_name = $business_name;
78
+ return $this;
79
+ }
80
+
81
+ /**
82
+ * Company business name of the invoice recipient. 100 characters max.
83
+ *
84
+ * @return string
85
+ */
86
+ public function getBusinessName()
87
+ {
88
+ return $this->business_name;
89
+ }
90
+
91
+ /**
92
+ *
93
+ *
94
+ * @param \PayPal\Api\Phone $phone
95
+ * @return $this
96
+ */
97
+ public function setPhone($phone)
98
+ {
99
+ $this->phone = $phone;
100
+ return $this;
101
+ }
102
+
103
+ /**
104
+ *
105
+ *
106
+ * @return \PayPal\Api\Phone
107
+ */
108
+ public function getPhone()
109
+ {
110
+ return $this->phone;
111
+ }
112
+
113
+ /**
114
+ *
115
+ *
116
+ * @param string $email
117
+ * @return $this
118
+ */
119
+ public function setEmail($email)
120
+ {
121
+ $this->email = $email;
122
+ return $this;
123
+ }
124
+
125
+ /**
126
+ *
127
+ *
128
+ * @return string
129
+ */
130
+ public function getEmail()
131
+ {
132
+ return $this->email;
133
+ }
134
+
135
+ /**
136
+ * Address of the invoice recipient.
137
+ *
138
+ * @param \PayPal\Api\InvoiceAddress $address
139
+ *
140
+ * @return $this
141
+ */
142
+ public function setAddress($address)
143
+ {
144
+ $this->address = $address;
145
+ return $this;
146
+ }
147
+
148
+ /**
149
+ * Address of the invoice recipient.
150
+ *
151
+ * @return \PayPal\Api\InvoiceAddress
152
+ */
153
+ public function getAddress()
154
+ {
155
+ return $this->address;
156
+ }
157
+
158
+ }
lib/PayPal/Api/Tax.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+ use PayPal\Converter\FormatConverter;
7
+ use PayPal\Validation\NumericValidator;
8
+
9
+ /**
10
+ * Class Tax
11
+ *
12
+ * Tax information.
13
+ *
14
+ * @package PayPal\Api
15
+ *
16
+ * @property string id
17
+ * @property string name
18
+ * @property \PayPal\Api\number percent
19
+ * @property \PayPal\Api\Currency amount
20
+ */
21
+ class Tax extends PayPalModel
22
+ {
23
+ /**
24
+ * Identifier of the resource.
25
+ *
26
+ * @param string $id
27
+ *
28
+ * @return $this
29
+ */
30
+ public function setId($id)
31
+ {
32
+ $this->id = $id;
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * Identifier of the resource.
38
+ *
39
+ * @return string
40
+ */
41
+ public function getId()
42
+ {
43
+ return $this->id;
44
+ }
45
+
46
+ /**
47
+ * Name of the tax. 10 characters max.
48
+ *
49
+ * @param string $name
50
+ *
51
+ * @return $this
52
+ */
53
+ public function setName($name)
54
+ {
55
+ $this->name = $name;
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * Name of the tax. 10 characters max.
61
+ *
62
+ * @return string
63
+ */
64
+ public function getName()
65
+ {
66
+ return $this->name;
67
+ }
68
+
69
+ /**
70
+ * Rate of the specified tax. Range of 0.001 to 99.999.
71
+ *
72
+ * @param string|double $percent
73
+ *
74
+ * @return $this
75
+ */
76
+ public function setPercent($percent)
77
+ {
78
+ NumericValidator::validate($percent, "Percent");
79
+ $percent = FormatConverter::formatToPrice($percent);
80
+ $this->percent = $percent;
81
+ return $this;
82
+ }
83
+
84
+ /**
85
+ * Rate of the specified tax. Range of 0.001 to 99.999.
86
+ *
87
+ * @return string
88
+ */
89
+ public function getPercent()
90
+ {
91
+ return $this->percent;
92
+ }
93
+
94
+ /**
95
+ * Tax in the form of money. Cannot be specified in a request.
96
+ *
97
+ * @param \PayPal\Api\Currency $amount
98
+ *
99
+ * @return $this
100
+ */
101
+ public function setAmount($amount)
102
+ {
103
+ $this->amount = $amount;
104
+ return $this;
105
+ }
106
+
107
+ /**
108
+ * Tax in the form of money. Cannot be specified in a request.
109
+ *
110
+ * @return \PayPal\Api\Currency
111
+ */
112
+ public function getAmount()
113
+ {
114
+ return $this->amount;
115
+ }
116
+
117
+ }
lib/PayPal/Api/Terms.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class Terms
9
+ *
10
+ * Resource representing terms used by the plan.
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property string id
15
+ * @property string type
16
+ * @property \PayPal\Api\Currency max_billing_amount
17
+ * @property string occurrences
18
+ * @property \PayPal\Api\Currency amount_range
19
+ * @property string buyer_editable
20
+ */
21
+ class Terms extends PayPalModel
22
+ {
23
+ /**
24
+ * Identifier of the terms. 128 characters max.
25
+ *
26
+ * @param string $id
27
+ *
28
+ * @return $this
29
+ */
30
+ public function setId($id)
31
+ {
32
+ $this->id = $id;
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * Identifier of the terms. 128 characters max.
38
+ *
39
+ * @return string
40
+ */
41
+ public function getId()
42
+ {
43
+ return $this->id;
44
+ }
45
+
46
+ /**
47
+ * Term type. Allowed values: `MONTHLY`, `WEEKLY`, `YEARLY`.
48
+ *
49
+ * @param string $type
50
+ *
51
+ * @return $this
52
+ */
53
+ public function setType($type)
54
+ {
55
+ $this->type = $type;
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * Term type. Allowed values: `MONTHLY`, `WEEKLY`, `YEARLY`.
61
+ *
62
+ * @return string
63
+ */
64
+ public function getType()
65
+ {
66
+ return $this->type;
67
+ }
68
+
69
+ /**
70
+ * Max Amount associated with this term.
71
+ *
72
+ * @param \PayPal\Api\Currency $max_billing_amount
73
+ *
74
+ * @return $this
75
+ */
76
+ public function setMaxBillingAmount($max_billing_amount)
77
+ {
78
+ $this->max_billing_amount = $max_billing_amount;
79
+ return $this;
80
+ }
81
+
82
+ /**
83
+ * Max Amount associated with this term.
84
+ *
85
+ * @return \PayPal\Api\Currency
86
+ */
87
+ public function getMaxBillingAmount()
88
+ {
89
+ return $this->max_billing_amount;
90
+ }
91
+
92
+ /**
93
+ * How many times money can be pulled during this term.
94
+ *
95
+ * @param string $occurrences
96
+ *
97
+ * @return $this
98
+ */
99
+ public function setOccurrences($occurrences)
100
+ {
101
+ $this->occurrences = $occurrences;
102
+ return $this;
103
+ }
104
+
105
+ /**
106
+ * How many times money can be pulled during this term.
107
+ *
108
+ * @return string
109
+ */
110
+ public function getOccurrences()
111
+ {
112
+ return $this->occurrences;
113
+ }
114
+
115
+ /**
116
+ * Amount_range associated with this term.
117
+ *
118
+ * @param \PayPal\Api\Currency $amount_range
119
+ *
120
+ * @return $this
121
+ */
122
+ public function setAmountRange($amount_range)
123
+ {
124
+ $this->amount_range = $amount_range;
125
+ return $this;
126
+ }
127
+
128
+ /**
129
+ * Amount_range associated with this term.
130
+ *
131
+ * @return \PayPal\Api\Currency
132
+ */
133
+ public function getAmountRange()
134
+ {
135
+ return $this->amount_range;
136
+ }
137
+
138
+ /**
139
+ * Buyer's ability to edit the amount in this term.
140
+ *
141
+ * @param string $buyer_editable
142
+ *
143
+ * @return $this
144
+ */
145
+ public function setBuyerEditable($buyer_editable)
146
+ {
147
+ $this->buyer_editable = $buyer_editable;
148
+ return $this;
149
+ }
150
+
151
+ /**
152
+ * Buyer's ability to edit the amount in this term.
153
+ *
154
+ * @return string
155
+ */
156
+ public function getBuyerEditable()
157
+ {
158
+ return $this->buyer_editable;
159
+ }
160
+
161
+ }
lib/PayPal/Api/Transaction.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ /**
6
+ * Class Transaction
7
+ *
8
+ * A transaction defines the contract of a payment - what is the payment for and who is fulfilling it.
9
+ *
10
+ * @package PayPal\Api
11
+ *
12
+ */
13
+ class Transaction extends TransactionBase
14
+ {
15
+ /**
16
+ * Additional transactions for complex payment scenarios.
17
+ *
18
+ *
19
+ * @param self $transactions
20
+ *
21
+ * @return $this
22
+ */
23
+ public function setTransactions($transactions)
24
+ {
25
+ $this->transactions = $transactions;
26
+ return $this;
27
+ }
28
+
29
+ /**
30
+ * Additional transactions for complex payment scenarios.
31
+ *
32
+ * @return self[]
33
+ */
34
+ public function getTransactions()
35
+ {
36
+ return $this->transactions;
37
+ }
38
+
39
+ /**
40
+ * Identifier to the purchase unit corresponding to this sale transaction
41
+ *
42
+ * @param string $purchase_unit_reference_id
43
+ *
44
+ * @return $this
45
+ */
46
+ public function setPurchaseUnitReferenceId($purchase_unit_reference_id)
47
+ {
48
+ $this->purchase_unit_reference_id = $purchase_unit_reference_id;
49
+ return $this;
50
+ }
51
+
52
+ /**
53
+ * Identifier to the purchase unit corresponding to this sale transaction
54
+ *
55
+ * @return string
56
+ */
57
+ public function getPurchaseUnitReferenceId()
58
+ {
59
+ return $this->purchase_unit_reference_id;
60
+ }
61
+
62
+ }
lib/PayPal/Api/TransactionBase.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ /**
6
+ * Class TransactionBase
7
+ *
8
+ * A transaction defines the contract of a payment - what is the payment for and who is fulfilling it.
9
+ *
10
+ * @package PayPal\Api
11
+ *
12
+ * @property \PayPal\Api\RelatedResources related_resources
13
+ */
14
+ class TransactionBase extends CartBase
15
+ {
16
+ /**
17
+ * List of financial transactions (Sale, Authorization, Capture, Refund) related to the payment.
18
+ *
19
+ *
20
+ * @param \PayPal\Api\RelatedResources $related_resources
21
+ *
22
+ * @return $this
23
+ */
24
+ public function setRelatedResources($related_resources)
25
+ {
26
+ $this->related_resources = $related_resources;
27
+ return $this;
28
+ }
29
+
30
+ /**
31
+ * List of financial transactions (Sale, Authorization, Capture, Refund) related to the payment.
32
+ *
33
+ * @return \PayPal\Api\RelatedResources[]
34
+ */
35
+ public function getRelatedResources()
36
+ {
37
+ return $this->related_resources;
38
+ }
39
+
40
+ }
lib/PayPal/Api/Transactions.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class Transactions
9
+ *
10
+ *
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property \PayPal\Api\Amount amount
15
+ */
16
+ class Transactions extends PayPalModel
17
+ {
18
+ /**
19
+ * Amount being collected.
20
+ *
21
+ *
22
+ * @param \PayPal\Api\Amount $amount
23
+ *
24
+ * @return $this
25
+ */
26
+ public function setAmount($amount)
27
+ {
28
+ $this->amount = $amount;
29
+ return $this;
30
+ }
31
+
32
+ /**
33
+ * Amount being collected.
34
+ *
35
+ * @return \PayPal\Api\Amount
36
+ */
37
+ public function getAmount()
38
+ {
39
+ return $this->amount;
40
+ }
41
+
42
+ }
lib/PayPal/Api/WebProfile.php ADDED
@@ -0,0 +1,286 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalResourceModel;
6
+ use PayPal\Rest\ApiContext;
7
+ use PayPal\Transport\PayPalRestCall;
8
+ use PayPal\Validation\ArgumentValidator;
9
+
10
+ /**
11
+ * Class WebProfile
12
+ *
13
+ * Payment Web experience profile resource
14
+ *
15
+ * @package PayPal\Api
16
+ *
17
+ * @property string id
18
+ * @property string name
19
+ * @property \PayPal\Api\FlowConfig flow_config
20
+ * @property \PayPal\Api\InputFields input_fields
21
+ * @property \PayPal\Api\Presentation presentation
22
+ */
23
+ class WebProfile extends PayPalResourceModel
24
+ {
25
+ /**
26
+ * ID of the web experience profile.
27
+ *
28
+ *
29
+ * @param string $id
30
+ *
31
+ * @return $this
32
+ */
33
+ public function setId($id)
34
+ {
35
+ $this->id = $id;
36
+ return $this;
37
+ }
38
+
39
+ /**
40
+ * ID of the web experience profile.
41
+ *
42
+ * @return string
43
+ */
44
+ public function getId()
45
+ {
46
+ return $this->id;
47
+ }
48
+
49
+ /**
50
+ * Name of the web experience profile.
51
+ *
52
+ *
53
+ * @param string $name
54
+ *
55
+ * @return $this
56
+ */
57
+ public function setName($name)
58
+ {
59
+ $this->name = $name;
60
+ return $this;
61
+ }
62
+
63
+ /**
64
+ * Name of the web experience profile.
65
+ *
66
+ * @return string
67
+ */
68
+ public function getName()
69
+ {
70
+ return $this->name;
71
+ }
72
+
73
+ /**
74
+ * Parameters for flow configuration.
75
+ *
76
+ *
77
+ * @param \PayPal\Api\FlowConfig $flow_config
78
+ *
79
+ * @return $this
80
+ */
81
+ public function setFlowConfig($flow_config)
82
+ {
83
+ $this->flow_config = $flow_config;
84
+ return $this;
85
+ }
86
+
87
+ /**
88
+ * Parameters for flow configuration.
89
+ *
90
+ * @return \PayPal\Api\FlowConfig
91
+ */
92
+ public function getFlowConfig()
93
+ {
94
+ return $this->flow_config;
95
+ }
96
+
97
+ /**
98
+ * Parameters for input fields customization.
99
+ *
100
+ *
101
+ * @param \PayPal\Api\InputFields $input_fields
102
+ *
103
+ * @return $this
104
+ */
105
+ public function setInputFields($input_fields)
106
+ {
107
+ $this->input_fields = $input_fields;
108
+ return $this;
109
+ }
110
+
111
+ /**
112
+ * Parameters for input fields customization.
113
+ *
114
+ * @return \PayPal\Api\InputFields
115
+ */
116
+ public function getInputFields()
117
+ {
118
+ return $this->input_fields;
119
+ }
120
+
121
+ /**
122
+ * Parameters for style and presentation.
123
+ *
124
+ *
125
+ * @param \PayPal\Api\Presentation $presentation
126
+ *
127
+ * @return $this
128
+ */
129
+ public function setPresentation($presentation)
130
+ {
131
+ $this->presentation = $presentation;
132
+ return $this;
133
+ }
134
+
135
+ /**
136
+ * Parameters for style and presentation.
137
+ *
138
+ * @return \PayPal\Api\Presentation
139
+ */
140
+ public function getPresentation()
141
+ {
142
+ return $this->presentation;
143
+ }
144
+
145
+ /**
146
+ * Create a web experience profile by passing the name of the profile and other profile details in the request JSON to the request URI.
147
+ *
148
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
149
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
150
+ * @return CreateProfileResponse
151
+ */
152
+ public function create($apiContext = null, $restCall = null)
153
+ {
154
+ $payLoad = $this->toJSON();
155
+ $json = self::executeCall(
156
+ "/v1/payment-experience/web-profiles/",
157
+ "POST",
158
+ $payLoad,
159
+ null,
160
+ $apiContext,
161
+ $restCall
162
+ );
163
+ $ret = new CreateProfileResponse();
164
+ $ret->fromJson($json);
165
+ return $ret;
166
+ }
167
+
168
+ /**
169
+ * Update a web experience profile by passing the ID of the profile to the request URI. In addition, pass the profile details in the request JSON. If your request does not include values for all profile detail fields, the previously set values for the omitted fields are removed by this operation.
170
+ *
171
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
172
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
173
+ * @return bool
174
+ */
175
+ public function update($apiContext = null, $restCall = null)
176
+ {
177
+ ArgumentValidator::validate($this->getId(), "Id");
178
+ $payLoad = $this->toJSON();
179
+ self::executeCall(
180
+ "/v1/payment-experience/web-profiles/{$this->getId()}",
181
+ "PUT",
182
+ $payLoad,
183
+ null,
184
+ $apiContext,
185
+ $restCall
186
+ );
187
+ return true;
188
+ }
189
+
190
+ /**
191
+ * Partially update an existing web experience profile by passing the ID of the profile to the request URI. In addition, pass a patch object in the request JSON that specifies the operation to perform, path of the profile location to update, and a new value if needed to complete the operation.
192
+ *
193
+ * @param Patch[] $patch
194
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
195
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
196
+ * @return bool
197
+ */
198
+ public function partial_update($patch, $apiContext = null, $restCall = null)
199
+ {
200
+ ArgumentValidator::validate($this->getId(), "Id");
201
+ ArgumentValidator::validate($patch, 'patch');
202
+ $payload = array();
203
+ foreach ($patch as $patchObject) {
204
+ $payload[] = $patchObject->toArray();
205
+ }
206
+ $payLoad = json_encode($payload);
207
+ self::executeCall(
208
+ "/v1/payment-experience/web-profiles/{$this->getId()}",
209
+ "PATCH",
210
+ $payLoad,
211
+ null,
212
+ $apiContext,
213
+ $restCall
214
+ );
215
+ return true;
216
+ }
217
+
218
+ /**
219
+ * Retrieve the details of a particular web experience profile by passing the ID of the profile to the request URI.
220
+ *
221
+ * @param string $profileId
222
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
223
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
224
+ * @return WebProfile
225
+ */
226
+ public static function get($profileId, $apiContext = null, $restCall = null)
227
+ {
228
+ ArgumentValidator::validate($profileId, 'profileId');
229
+ $payLoad = "";
230
+ $json = self::executeCall(
231
+ "/v1/payment-experience/web-profiles/$profileId",
232
+ "GET",
233
+ $payLoad,
234
+ null,
235
+ $apiContext,
236
+ $restCall
237
+ );
238
+ $ret = new WebProfile();
239
+ $ret->fromJson($json);
240
+ return $ret;
241
+ }
242
+
243
+ /**
244
+ * Lists all web experience profiles that exist for a merchant (or subject).
245
+ *
246
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
247
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
248
+ * @return WebProfile[]
249
+ */
250
+ public static function get_list($apiContext = null, $restCall = null)
251
+ {
252
+ $payLoad = "";
253
+ $json = self::executeCall(
254
+ "/v1/payment-experience/web-profiles/",
255
+ "GET",
256
+ $payLoad,
257
+ null,
258
+ $apiContext,
259
+ $restCall
260
+ );
261
+ return WebProfile::getList($json);
262
+ }
263
+
264
+ /**
265
+ * Delete an existing web experience profile by passing the profile ID to the request URI.
266
+ *
267
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
268
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
269
+ * @return bool
270
+ */
271
+ public function delete($apiContext = null, $restCall = null)
272
+ {
273
+ ArgumentValidator::validate($this->getId(), "Id");
274
+ $payLoad = "";
275
+ self::executeCall(
276
+ "/v1/payment-experience/web-profiles/{$this->getId()}",
277
+ "DELETE",
278
+ $payLoad,
279
+ null,
280
+ $apiContext,
281
+ $restCall
282
+ );
283
+ return true;
284
+ }
285
+
286
+ }
lib/PayPal/Api/Webhook.php ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalResourceModel;
6
+ use PayPal\Rest\ApiContext;
7
+ use PayPal\Transport\PayPalRestCall;
8
+ use PayPal\Validation\ArgumentValidator;
9
+ use PayPal\Validation\UrlValidator;
10
+
11
+ /**
12
+ * Class Webhook
13
+ *
14
+ * Represents Webhook resource.
15
+ *
16
+ * @package PayPal\Api
17
+ *
18
+ * @property string id
19
+ * @property string url
20
+ * @property \PayPal\Api\WebhookEventType[] event_types
21
+ */
22
+ class Webhook extends PayPalResourceModel
23
+ {
24
+ /**
25
+ * Identifier of the webhook resource.
26
+ *
27
+ * @param string $id
28
+ *
29
+ * @return $this
30
+ */
31
+ public function setId($id)
32
+ {
33
+ $this->id = $id;
34
+ return $this;
35
+ }
36
+
37
+ /**
38
+ * Identifier of the webhook resource.
39
+ *
40
+ * @return string
41
+ */
42
+ public function getId()
43
+ {
44
+ return $this->id;
45
+ }
46
+
47
+ /**
48
+ * Webhook notification endpoint url.
49
+ *
50
+ * @param string $url
51
+ * @throws \InvalidArgumentException
52
+ * @return $this
53
+ */
54
+ public function setUrl($url)
55
+ {
56
+ UrlValidator::validate($url, "Url");
57
+ $this->url = $url;
58
+ return $this;
59
+ }
60
+
61
+ /**
62
+ * Webhook notification endpoint url.
63
+ *
64
+ * @return string
65
+ */
66
+ public function getUrl()
67
+ {
68
+ return $this->url;
69
+ }
70
+
71
+ /**
72
+ * List of Webhooks event-types.
73
+ *
74
+ * @param \PayPal\Api\WebhookEventType[] $event_types
75
+ *
76
+ * @return $this
77
+ */
78
+ public function setEventTypes($event_types)
79
+ {
80
+ $this->event_types = $event_types;
81
+ return $this;
82
+ }
83
+
84
+ /**
85
+ * List of Webhooks event-types.
86
+ *
87
+ * @return \PayPal\Api\WebhookEventType[]
88
+ */
89
+ public function getEventTypes()
90
+ {
91
+ return $this->event_types;
92
+ }
93
+
94
+ /**
95
+ * Append EventTypes to the list.
96
+ *
97
+ * @param \PayPal\Api\WebhookEventType $webhookEventType
98
+ * @return $this
99
+ */
100
+ public function addEventType($webhookEventType)
101
+ {
102
+ if (!$this->getEventTypes()) {
103
+ return $this->setEventTypes(array($webhookEventType));
104
+ } else {
105
+ return $this->setEventTypes(
106
+ array_merge($this->getEventTypes(), array($webhookEventType))
107
+ );
108
+ }
109
+ }
110
+
111
+ /**
112
+ * Remove EventTypes from the list.
113
+ *
114
+ * @param \PayPal\Api\WebhookEventType $webhookEventType
115
+ * @return $this
116
+ */
117
+ public function removeEventType($webhookEventType)
118
+ {
119
+ return $this->setEventTypes(
120
+ array_diff($this->getEventTypes(), array($webhookEventType))
121
+ );
122
+ }
123
+
124
+ /**
125
+ * Creates the Webhook for the application associated with the access token.
126
+ *
127
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
128
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
129
+ * @return Webhook
130
+ */
131
+ public function create($apiContext = null, $restCall = null)
132
+ {
133
+ $payLoad = $this->toJSON();
134
+ $json = self::executeCall(
135
+ "/v1/notifications/webhooks",
136
+ "POST",
137
+ $payLoad,
138
+ null,
139
+ $apiContext,
140
+ $restCall
141
+ );
142
+ $this->fromJson($json);
143
+ return $this;
144
+ }
145
+
146
+ /**
147
+ * Retrieves the Webhook identified by webhook_id for the application associated with access token.
148
+ *
149
+ * @param string $webhookId
150
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
151
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
152
+ * @return Webhook
153
+ */
154
+ public static function get($webhookId, $apiContext = null, $restCall = null)
155
+ {
156
+ ArgumentValidator::validate($webhookId, 'webhookId');
157
+ $payLoad = "";
158
+ $json = self::executeCall(
159
+ "/v1/notifications/webhooks/$webhookId",
160
+ "GET",
161
+ $payLoad,
162
+ null,
163
+ $apiContext,
164
+ $restCall
165
+ );
166
+ $ret = new Webhook();
167
+ $ret->fromJson($json);
168
+ return $ret;
169
+ }
170
+
171
+ /**
172
+ * Retrieves all Webhooks for the application associated with access token.
173
+ *
174
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
175
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
176
+ * @return WebhookList
177
+ */
178
+ public static function getAll($apiContext = null, $restCall = null)
179
+ {
180
+ $payLoad = "";
181
+ $json = self::executeCall(
182
+ "/v1/notifications/webhooks",
183
+ "GET",
184
+ $payLoad,
185
+ null,
186
+ $apiContext,
187
+ $restCall
188
+ );
189
+ $ret = new WebhookList();
190
+ $ret->fromJson($json);
191
+ return $ret;
192
+ }
193
+
194
+ /**
195
+ * Updates the Webhook identified by webhook_id for the application associated with access token.
196
+ *
197
+ * @param PatchRequest $patchRequest
198
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
199
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
200
+ * @return Webhook
201
+ */
202
+ public function update($patchRequest, $apiContext = null, $restCall = null)
203
+ {
204
+ ArgumentValidator::validate($this->getId(), "Id");
205
+ ArgumentValidator::validate($patchRequest, 'patchRequest');
206
+ $payLoad = $patchRequest->toJSON();
207
+ $json = self::executeCall(
208
+ "/v1/notifications/webhooks/{$this->getId()}",
209
+ "PATCH",
210
+ $payLoad,
211
+ null,
212
+ $apiContext,
213
+ $restCall
214
+ );
215
+ $this->fromJson($json);
216
+ return $this;
217
+ }
218
+
219
+ /**
220
+ * Deletes the Webhook identified by webhook_id for the application associated with access token.
221
+ *
222
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
223
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
224
+ * @return bool
225
+ */
226
+ public function delete($apiContext = null, $restCall = null)
227
+ {
228
+ ArgumentValidator::validate($this->getId(), "Id");
229
+ $payLoad = "";
230
+ self::executeCall(
231
+ "/v1/notifications/webhooks/{$this->getId()}",
232
+ "DELETE",
233
+ $payLoad,
234
+ null,
235
+ $apiContext,
236
+ $restCall
237
+ );
238
+ return true;
239
+ }
240
+
241
+ }
lib/PayPal/Api/WebhookEvent.php ADDED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalResourceModel;
6
+ use PayPal\Exception\PayPalConnectionException;
7
+ use PayPal\Rest\ApiContext;
8
+ use PayPal\Transport\PayPalRestCall;
9
+ use PayPal\Validation\ArgumentValidator;
10
+ use PayPal\Validation\JsonValidator;
11
+
12
+ /**
13
+ * Class WebhookEvent
14
+ *
15
+ * Represents a Webhooks event
16
+ *
17
+ * @package PayPal\Api
18
+ *
19
+ * @property string id
20
+ * @property string create_time
21
+ * @property string resource_type
22
+ * @property string event_type
23
+ * @property string summary
24
+ * @property mixed resource
25
+ */
26
+ class WebhookEvent extends PayPalResourceModel
27
+ {
28
+ /**
29
+ * Identifier of the Webhooks event resource.
30
+ *
31
+ * @param string $id
32
+ *
33
+ * @return $this
34
+ */
35
+ public function setId($id)
36
+ {
37
+ $this->id = $id;
38
+ return $this;
39
+ }
40
+
41
+ /**
42
+ * Identifier of the Webhooks event resource.
43
+ *
44
+ * @return string
45
+ */
46
+ public function getId()
47
+ {
48
+ return $this->id;
49
+ }
50
+
51
+ /**
52
+ * Time the resource was created.
53
+ *
54
+ * @param string $create_time
55
+ *
56
+ * @return $this
57
+ */
58
+ public function setCreateTime($create_time)
59
+ {
60
+ $this->create_time = $create_time;
61
+ return $this;
62
+ }
63
+
64
+ /**
65
+ * Time the resource was created.
66
+ *
67
+ * @return string
68
+ */
69
+ public function getCreateTime()
70
+ {
71
+ return $this->create_time;
72
+ }
73
+
74
+ /**
75
+ * Name of the resource contained in resource element.
76
+ *
77
+ * @param string $resource_type
78
+ *
79
+ * @return $this
80
+ */
81
+ public function setResourceType($resource_type)
82
+ {
83
+ $this->resource_type = $resource_type;
84
+ return $this;
85
+ }
86
+
87
+ /**
88
+ * Name of the resource contained in resource element.
89
+ *
90
+ * @return string
91
+ */
92
+ public function getResourceType()
93
+ {
94
+ return $this->resource_type;
95
+ }
96
+
97
+ /**
98
+ * Name of the event type that occurred on resource, identified by data_resource element, to trigger the Webhooks event.
99
+ *
100
+ * @param string $event_type
101
+ *
102
+ * @return $this
103
+ */
104
+ public function setEventType($event_type)
105
+ {
106
+ $this->event_type = $event_type;
107
+ return $this;
108
+ }
109
+
110
+ /**
111
+ * Name of the event type that occurred on resource, identified by data_resource element, to trigger the Webhooks event.
112
+ *
113
+ * @return string
114
+ */
115
+ public function getEventType()
116
+ {
117
+ return $this->event_type;
118
+ }
119
+
120
+ /**
121
+ * A summary description of the event. E.g. A successful payment authorization was created for $$
122
+ *
123
+ * @param string $summary
124
+ *
125
+ * @return $this
126
+ */
127
+ public function setSummary($summary)
128
+ {
129
+ $this->summary = $summary;
130
+ return $this;
131
+ }
132
+
133
+ /**
134
+ * A summary description of the event. E.g. A successful payment authorization was created for $$
135
+ *
136
+ * @return string
137
+ */
138
+ public function getSummary()
139
+ {
140
+ return $this->summary;
141
+ }
142
+
143
+ /**
144
+ * This contains the resource that is identified by resource_type element.
145
+ *
146
+ * @param \PayPal\Common\PayPalModel $resource
147
+ *
148
+ * @return $this
149
+ */
150
+ public function setResource($resource)
151
+ {
152
+ $this->resource = $resource;
153
+ return $this;
154
+ }
155
+
156
+ /**
157
+ * This contains the resource that is identified by resource_type element.
158
+ *
159
+ * @return \PayPal\Common\PayPalModel
160
+ */
161
+ public function getResource()
162
+ {
163
+ return $this->resource;
164
+ }
165
+
166
+ /**
167
+ * Validates Received Event from Webhook, and returns the webhook event object. Because security verifications by verifying certificate chain is not enabled in PHP yet,
168
+ * we need to fallback to default behavior of retrieving the ID attribute of the data, and make a separate GET call to PayPal APIs, to retrieve the data.
169
+ * This is important to do again, as hacker could have faked the data, and the retrieved data cannot be trusted without either doing client side security validation, or making a separate call
170
+ * to PayPal APIs to retrieve the actual data. This limits the hacker to mimick a fake data, as hacker wont be able to predict the Id correctly.
171
+ *
172
+ * NOTE: PLEASE DO NOT USE THE DATA PROVIDED IN WEBHOOK DIRECTLY, AS HACKER COULD PASS IN FAKE DATA. IT IS VERY IMPORTANT THAT YOU RETRIEVE THE ID AND MAKE A SEPARATE CALL TO PAYPAL API.
173
+ *
174
+ * @param string $body
175
+ * @param ApiContext $apiContext
176
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
177
+ * @return WebhookEvent
178
+ * @throws \InvalidArgumentException if input arguments are incorrect, or Id is not found.
179
+ * @throws PayPalConnectionException if any exception from PayPal APIs other than not found is sent.
180
+ */
181
+ public static function validateAndGetReceivedEvent($body, $apiContext = null, $restCall = null)
182
+ {
183
+ if ($body == null | empty($body)){
184
+ throw new \InvalidArgumentException("Body cannot be null or empty");
185
+ }
186
+ if (!JsonValidator::validate($body, true)) {
187
+ throw new \InvalidArgumentException("Request Body is not a valid JSON.");
188
+ }
189
+ $object = new WebhookEvent($body);
190
+ if ($object->getId() == null) {
191
+ throw new \InvalidArgumentException("Id attribute not found in JSON. Possible reason could be invalid JSON Object");
192
+ }
193
+ try {
194
+ return self::get($object->getId(), $apiContext, $restCall);
195
+ } catch(PayPalConnectionException $ex) {
196
+ if ($ex->getCode() == 404) {
197
+ // It means that the given webhook event Id is not found for this merchant.
198
+ throw new \InvalidArgumentException("Webhook Event Id provided in the data is incorrect. This could happen if anyone other than PayPal is faking the incoming webhook data.");
199
+ }
200
+ throw $ex;
201
+ }
202
+ }
203
+
204
+ /**
205
+ * Retrieves the Webhooks event resource identified by event_id. Can be used to retrieve the payload for an event.
206
+ *
207
+ * @param string $eventId
208
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
209
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
210
+ * @return WebhookEvent
211
+ */
212
+ public static function get($eventId, $apiContext = null, $restCall = null)
213
+ {
214
+ ArgumentValidator::validate($eventId, 'eventId');
215
+ $payLoad = "";
216
+ $json = self::executeCall(
217
+ "/v1/notifications/webhooks-events/$eventId",
218
+ "GET",
219
+ $payLoad,
220
+ null,
221
+ $apiContext,
222
+ $restCall
223
+ );
224
+ $ret = new WebhookEvent();
225
+ $ret->fromJson($json);
226
+ return $ret;
227
+ }
228
+
229
+ /**
230
+ * Resends the Webhooks event resource identified by event_id.
231
+ *
232
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
233
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
234
+ * @return WebhookEvent
235
+ */
236
+ public function resend($apiContext = null, $restCall = null)
237
+ {
238
+ ArgumentValidator::validate($this->getId(), "Id");
239
+ $payLoad = "";
240
+ $json = self::executeCall(
241
+ "/v1/notifications/webhooks-events/{$this->getId()}/resend",
242
+ "POST",
243
+ $payLoad,
244
+ null,
245
+ $apiContext,
246
+ $restCall
247
+ );
248
+ $this->fromJson($json);
249
+ return $this;
250
+ }
251
+
252
+ /**
253
+ * Retrieves the list of Webhooks events resources for the application associated with token. The developers can use it to see list of past webhooks events.
254
+ *
255
+ * @param array $params
256
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
257
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
258
+ * @return WebhookEventList
259
+ */
260
+ public static function all($params, $apiContext = null, $restCall = null)
261
+ {
262
+ ArgumentValidator::validate($params, 'params');
263
+ $payLoad = "";
264
+ $allowedParams = array(
265
+ 'page_size' => 1,
266
+ 'start_time' => 1,
267
+ 'end_time' => 1,
268
+ );
269
+ $json = self::executeCall(
270
+ "/v1/notifications/webhooks-events" . "?" . http_build_query(array_intersect_key($params, $allowedParams)),
271
+ "GET",
272
+ $payLoad,
273
+ null,
274
+ $apiContext,
275
+ $restCall
276
+ );
277
+ $ret = new WebhookEventList();
278
+ $ret->fromJson($json);
279
+ return $ret;
280
+ }
281
+
282
+ }
lib/PayPal/Api/WebhookEventList.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class WebhookEventList
9
+ *
10
+ * List of Webhooks event resources
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property \PayPal\Api\WebhookEvent[] events
15
+ * @property int count
16
+ * @property \PayPal\Api\Links[] links
17
+ */
18
+ class WebhookEventList extends PayPalModel
19
+ {
20
+ /**
21
+ * A list of Webhooks event resources
22
+ *
23
+ * @param \PayPal\Api\WebhookEvent[] $events
24
+ *
25
+ * @return $this
26
+ */
27
+ public function setEvents($events)
28
+ {
29
+ $this->events = $events;
30
+ return $this;
31
+ }
32
+
33
+ /**
34
+ * A list of Webhooks event resources
35
+ *
36
+ * @return \PayPal\Api\WebhookEvent[]
37
+ */
38
+ public function getEvents()
39
+ {
40
+ return $this->events;
41
+ }
42
+
43
+ /**
44
+ * Append Events to the list.
45
+ *
46
+ * @param \PayPal\Api\WebhookEvent $webhookEvent
47
+ * @return $this
48
+ */
49
+ public function addEvent($webhookEvent)
50
+ {
51
+ if (!$this->getEvents()) {
52
+ return $this->setEvents(array($webhookEvent));
53
+ } else {
54
+ return $this->setEvents(
55
+ array_merge($this->getEvents(), array($webhookEvent))
56
+ );
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Remove Events from the list.
62
+ *
63
+ * @param \PayPal\Api\WebhookEvent $webhookEvent
64
+ * @return $this
65
+ */
66
+ public function removeEvent($webhookEvent)
67
+ {
68
+ return $this->setEvents(
69
+ array_diff($this->getEvents(), array($webhookEvent))
70
+ );
71
+ }
72
+
73
+ /**
74
+ * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items.
75
+ *
76
+ * @param int $count
77
+ *
78
+ * @return $this
79
+ */
80
+ public function setCount($count)
81
+ {
82
+ $this->count = $count;
83
+ return $this;
84
+ }
85
+
86
+ /**
87
+ * Number of items returned in each range of results. Note that the last results range could have fewer items than the requested number of items.
88
+ *
89
+ * @return int
90
+ */
91
+ public function getCount()
92
+ {
93
+ return $this->count;
94
+ }
95
+
96
+ /**
97
+ * Sets Links
98
+ *
99
+ * @param \PayPal\Api\Links[] $links
100
+ *
101
+ * @return $this
102
+ */
103
+ public function setLinks($links)
104
+ {
105
+ $this->links = $links;
106
+ return $this;
107
+ }
108
+
109
+ /**
110
+ * Gets Links
111
+ *
112
+ * @return \PayPal\Api\Links[]
113
+ */
114
+ public function getLinks()
115
+ {
116
+ return $this->links;
117
+ }
118
+
119
+ /**
120
+ * Append Links to the list.
121
+ *
122
+ * @param \PayPal\Api\Links $links
123
+ * @return $this
124
+ */
125
+ public function addLink($links)
126
+ {
127
+ if (!$this->getLinks()) {
128
+ return $this->setLinks(array($links));
129
+ } else {
130
+ return $this->setLinks(
131
+ array_merge($this->getLinks(), array($links))
132
+ );
133
+ }
134
+ }
135
+
136
+ /**
137
+ * Remove Links from the list.
138
+ *
139
+ * @param \PayPal\Api\Links $links
140
+ * @return $this
141
+ */
142
+ public function removeLink($links)
143
+ {
144
+ return $this->setLinks(
145
+ array_diff($this->getLinks(), array($links))
146
+ );
147
+ }
148
+
149
+ }
lib/PayPal/Api/WebhookEventType.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalResourceModel;
6
+ use PayPal\Rest\ApiContext;
7
+ use PayPal\Transport\PayPalRestCall;
8
+ use PayPal\Validation\ArgumentValidator;
9
+
10
+ /**
11
+ * Class WebhookEventType
12
+ *
13
+ * Contains the information for a Webhooks event-type
14
+ *
15
+ * @package PayPal\Api
16
+ *
17
+ * @property string name
18
+ * @property string description
19
+ */
20
+ class WebhookEventType extends PayPalResourceModel
21
+ {
22
+ /**
23
+ * Unique event-type name.
24
+ *
25
+ * @param string $name
26
+ *
27
+ * @return $this
28
+ */
29
+ public function setName($name)
30
+ {
31
+ $this->name = $name;
32
+ return $this;
33
+ }
34
+
35
+ /**
36
+ * Unique event-type name.
37
+ *
38
+ * @return string
39
+ */
40
+ public function getName()
41
+ {
42
+ return $this->name;
43
+ }
44
+
45
+ /**
46
+ * Human readable description of the event-type
47
+ *
48
+ * @param string $description
49
+ *
50
+ * @return $this
51
+ */
52
+ public function setDescription($description)
53
+ {
54
+ $this->description = $description;
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * Human readable description of the event-type
60
+ *
61
+ * @return string
62
+ */
63
+ public function getDescription()
64
+ {
65
+ return $this->description;
66
+ }
67
+
68
+ /**
69
+ * Retrieves the list of events-types subscribed by the given Webhook.
70
+ *
71
+ * @param string $webhookId
72
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
73
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
74
+ * @return WebhookEventTypeList
75
+ */
76
+ public static function subscribedEventTypes($webhookId, $apiContext = null, $restCall = null)
77
+ {
78
+ ArgumentValidator::validate($webhookId, 'webhookId');
79
+ $payLoad = "";
80
+ $json = self::executeCall(
81
+ "/v1/notifications/webhooks/$webhookId/event-types",
82
+ "GET",
83
+ $payLoad,
84
+ null,
85
+ $apiContext,
86
+ $restCall
87
+ );
88
+ $ret = new WebhookEventTypeList();
89
+ $ret->fromJson($json);
90
+ return $ret;
91
+ }
92
+
93
+ /**
94
+ * Retrieves the master list of available Webhooks events-types resources for any webhook to subscribe to.
95
+ *
96
+ * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
97
+ * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
98
+ * @return WebhookEventTypeList
99
+ */
100
+ public static function availableEventTypes($apiContext = null, $restCall = null)
101
+ {
102
+ $payLoad = "";
103
+ $json = self::executeCall(
104
+ "/v1/notifications/webhooks-event-types",
105
+ "GET",
106
+ $payLoad,
107
+ null,
108
+ $apiContext,
109
+ $restCall
110
+ );
111
+ $ret = new WebhookEventTypeList();
112
+ $ret->fromJson($json);
113
+ return $ret;
114
+ }
115
+
116
+ }
lib/PayPal/Api/WebhookEventTypeList.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class WebhookEventTypeList
9
+ *
10
+ * List of Webhooks event-types
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property \PayPal\Api\WebhookEventType[] event_types
15
+ */
16
+ class WebhookEventTypeList extends PayPalModel
17
+ {
18
+ /**
19
+ * A list of Webhooks event-types
20
+ *
21
+ * @param \PayPal\Api\WebhookEventType[] $event_types
22
+ *
23
+ * @return $this
24
+ */
25
+ public function setEventTypes($event_types)
26
+ {
27
+ $this->event_types = $event_types;
28
+ return $this;
29
+ }
30
+
31
+ /**
32
+ * A list of Webhooks event-types
33
+ *
34
+ * @return \PayPal\Api\WebhookEventType[]
35
+ */
36
+ public function getEventTypes()
37
+ {
38
+ return $this->event_types;
39
+ }
40
+
41
+ /**
42
+ * Append EventTypes to the list.
43
+ *
44
+ * @param \PayPal\Api\WebhookEventType $webhookEventType
45
+ * @return $this
46
+ */
47
+ public function addEventType($webhookEventType)
48
+ {
49
+ if (!$this->getEventTypes()) {
50
+ return $this->setEventTypes(array($webhookEventType));
51
+ } else {
52
+ return $this->setEventTypes(
53
+ array_merge($this->getEventTypes(), array($webhookEventType))
54
+ );
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Remove EventTypes from the list.
60
+ *
61
+ * @param \PayPal\Api\WebhookEventType $webhookEventType
62
+ * @return $this
63
+ */
64
+ public function removeEventType($webhookEventType)
65
+ {
66
+ return $this->setEventTypes(
67
+ array_diff($this->getEventTypes(), array($webhookEventType))
68
+ );
69
+ }
70
+
71
+ }
lib/PayPal/Api/WebhookList.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Api;
4
+
5
+ use PayPal\Common\PayPalModel;
6
+
7
+ /**
8
+ * Class WebhookList
9
+ *
10
+ * List of Webhooks
11
+ *
12
+ * @package PayPal\Api
13
+ *
14
+ * @property \PayPal\Api\Webhook[] webhooks
15
+ */
16
+ class WebhookList extends PayPalModel
17
+ {
18
+ /**
19
+ * A list of Webhooks
20
+ *
21
+ * @param \PayPal\Api\Webhook[] $webhooks
22
+ *
23
+ * @return $this
24
+ */
25
+ public function setWebhooks($webhooks)
26
+ {
27
+ $this->webhooks = $webhooks;
28
+ return $this;
29
+ }
30
+
31
+ /**
32
+ * A list of Webhooks
33
+ *
34
+ * @return \PayPal\Api\Webhook[]
35
+ */
36
+ public function getWebhooks()
37
+ {
38
+ return $this->webhooks;
39
+ }
40
+
41
+ /**
42
+ * Append Webhooks to the list.
43
+ *
44
+ * @param \PayPal\Api\Webhook $webhook
45
+ * @return $this
46
+ */
47
+ public function addWebhook($webhook)
48
+ {
49
+ if (!$this->getWebhooks()) {
50
+ return $this->setWebhooks(array($webhook));
51
+ } else {
52
+ return $this->setWebhooks(
53
+ array_merge($this->getWebhooks(), array($webhook))
54
+ );
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Remove Webhooks from the list.
60
+ *
61
+ * @param \PayPal\Api\Webhook $webhook
62
+ * @return $this
63
+ */
64
+ public function removeWebhook($webhook)
65
+ {
66
+ return $this->setWebhooks(
67
+ array_diff($this->getWebhooks(), array($webhook))
68
+ );
69
+ }
70
+
71
+ }
lib/PayPal/Auth/OAuthTokenCredential.php ADDED
@@ -0,0 +1,313 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Auth;
4
+
5
+ use PayPal\Cache\AuthorizationCache;
6
+ use PayPal\Common\PayPalResourceModel;
7
+ use PayPal\Core\PayPalHttpConfig;
8
+ use PayPal\Core\PayPalHttpConnection;
9
+ use PayPal\Core\PayPalLoggingManager;
10
+ use PayPal\Exception\PayPalConfigurationException;
11
+ use PayPal\Exception\PayPalConnectionException;
12
+ use PayPal\Handler\IPayPalHandler;
13
+ use PayPal\Rest\ApiContext;
14
+ use PayPal\Security\Cipher;
15
+
16
+ /**
17
+ * Class OAuthTokenCredential
18
+ */
19
+ class OAuthTokenCredential extends PayPalResourceModel
20
+ {
21
+
22
+ public static $CACHE_PATH = '/../../../var/auth.cache';
23
+
24
+ /**
25
+ * @var string Default Auth Handler
26
+ */
27
+ public static $AUTH_HANDLER = 'PayPal\Handler\OauthHandler';
28
+
29
+ /**
30
+ * Private Variable
31
+ *
32
+ * @var int $expiryBufferTime
33
+ */
34
+ private static $expiryBufferTime = 120;
35
+
36
+ /**
37
+ * Private Variable
38
+ *
39
+ * @var \PayPal\Core\PayPalLoggingManager $logger
40
+ */
41
+ private $logger;
42
+
43
+ /**
44
+ * Client ID as obtained from the developer portal
45
+ *
46
+ * @var string $clientId
47
+ */
48
+ private $clientId;
49
+
50
+ /**
51
+ * Client secret as obtained from the developer portal
52
+ *
53
+ * @var string $clientSecret
54
+ */
55
+ private $clientSecret;
56
+
57
+ /**
58
+ * Generated Access Token
59
+ *
60
+ * @var string $accessToken
61
+ */
62
+ private $accessToken;
63
+
64
+ /**
65
+ * Seconds for with access token is valid
66
+ *
67
+ * @var $tokenExpiresIn
68
+ */
69
+ private $tokenExpiresIn;
70
+
71
+ /**
72
+ * Last time (in milliseconds) when access token was generated
73
+ *
74
+ * @var $tokenCreateTime
75
+ */
76
+ private $tokenCreateTime;
77
+
78
+ /**
79
+ * Instance of cipher used to encrypt/decrypt data while storing in cache.
80
+ *
81
+ * @var Cipher
82
+ */
83
+ private $cipher;
84
+
85
+ /**
86
+ * Construct
87
+ *
88
+ * @param string $clientId client id obtained from the developer portal
89
+ * @param string $clientSecret client secret obtained from the developer portal
90
+ */
91
+ public function __construct($clientId, $clientSecret)
92
+ {
93
+ $this->clientId = $clientId;
94
+ $this->clientSecret = $clientSecret;
95
+ $this->cipher = new Cipher($this->clientSecret);
96
+ $this->logger = PayPalLoggingManager::getInstance(__CLASS__);
97
+ }
98
+
99
+ /**
100
+ * Get Client ID
101
+ *
102
+ * @return string
103
+ */
104
+ public function getClientId()
105
+ {
106
+ return $this->clientId;
107
+ }
108
+
109
+ /**
110
+ * Get Client Secret
111
+ *
112
+ * @return string
113
+ */
114
+ public function getClientSecret()
115
+ {
116
+ return $this->clientSecret;
117
+ }
118
+
119
+ /**
120
+ * Get AccessToken
121
+ *
122
+ * @param $config
123
+ *
124
+ * @return null|string
125
+ */
126
+ public function getAccessToken($config)
127
+ {
128
+ // Check if we already have accessToken in Cache
129
+ if ($this->accessToken && (time() - $this->tokenCreateTime) < ($this->tokenExpiresIn - self::$expiryBufferTime)) {
130
+ return $this->accessToken;
131
+ }
132
+ // Check for persisted data first
133
+ $token = AuthorizationCache::pull($config, $this->clientId);
134
+ if ($token) {
135
+ // We found it
136
+ // This code block is for backward compatibility only.
137
+ if (array_key_exists('accessToken', $token)) {
138
+ $this->accessToken = $token['accessToken'];
139
+ }
140
+
141
+ $this->tokenCreateTime = $token['tokenCreateTime'];
142
+ $this->tokenExpiresIn = $token['tokenExpiresIn'];
143
+
144
+ // Case where we have an old unencrypted cache file
145
+ if (!array_key_exists('accessTokenEncrypted', $token)) {
146
+ AuthorizationCache::push($config, $this->clientId, $this->encrypt($this->accessToken), $this->tokenCreateTime, $this->tokenExpiresIn);
147
+ } else {
148
+ $this->accessToken = $this->decrypt($token['accessTokenEncrypted']);
149
+ }
150
+ }
151
+
152
+ // Check if Access Token is not null and has not expired.
153
+ // The API returns expiry time as a relative time unit
154
+ // We use a buffer time when checking for token expiry to account
155
+ // for API call delays and any delay between the time the token is
156
+ // retrieved and subsequently used
157
+ if (
158
+ $this->accessToken != null &&
159
+ (time() - $this->tokenCreateTime) > ($this->tokenExpiresIn - self::$expiryBufferTime)
160
+ ) {
161
+ $this->accessToken = null;
162
+ }
163
+
164
+
165
+ // If accessToken is Null, obtain a new token
166
+ if ($this->accessToken == null) {
167
+ // Get a new one by making calls to API
168
+ $this->updateAccessToken($config);
169
+ AuthorizationCache::push($config, $this->clientId, $this->encrypt($this->accessToken), $this->tokenCreateTime, $this->tokenExpiresIn);
170
+ }
171
+
172
+ return $this->accessToken;
173
+ }
174
+
175
+
176
+ /**
177
+ * Get a Refresh Token from Authorization Code
178
+ *
179
+ * @param $config
180
+ * @param $authorizationCode
181
+ * @param array $params optional arrays to override defaults
182
+ * @return string|null
183
+ */
184
+ public function getRefreshToken($config, $authorizationCode = null, $params = array())
185
+ {
186
+ static $allowedParams = array(
187
+ 'grant_type' => 'authorization_code',
188
+ 'code' => 1,
189
+ 'redirect_uri' => 'urn:ietf:wg:oauth:2.0:oob',
190
+ 'response_type' => 'token'
191
+ );
192
+
193
+ $params = is_array($params) ? $params : array();
194
+ if ($authorizationCode) {
195
+ //Override the authorizationCode if value is explicitly set
196
+ $params['code'] = $authorizationCode;
197
+ }
198
+ $payload = http_build_query(array_merge($allowedParams, array_intersect_key($params, $allowedParams)));
199
+
200
+ $response = $this->getToken($config, $this->clientId, $this->clientSecret, $payload);
201
+
202
+ if ($response != null && isset($response["refresh_token"])) {
203
+ return $response['refresh_token'];
204
+ }
205
+
206
+ return null;
207
+ }
208
+
209
+ /**
210
+ * Updates Access Token based on given input
211
+ *
212
+ * @param array $config
213
+ * @param string|null $refreshToken
214
+ * @return string
215
+ */
216
+ public function updateAccessToken($config, $refreshToken = null)
217
+ {
218
+ $this->generateAccessToken($config, $refreshToken);
219
+ return $this->accessToken;
220
+ }
221
+
222
+ /**
223
+ * Retrieves the token based on the input configuration
224
+ *
225
+ * @param array $config
226
+ * @param string $clientId
227
+ * @param string $clientSecret
228
+ * @param string $payload
229
+ * @return mixed
230
+ * @throws PayPalConfigurationException
231
+ * @throws \PayPal\Exception\PayPalConnectionException
232
+ */
233
+ protected function getToken($config, $clientId, $clientSecret, $payload)
234
+ {
235
+ $httpConfig = new PayPalHttpConfig(null, 'POST', $config);
236
+
237
+ $handlers = array(self::$AUTH_HANDLER);
238
+
239
+ /** @var IPayPalHandler $handler */
240
+ foreach ($handlers as $handler) {
241
+ if (!is_object($handler)) {
242
+ $fullHandler = "\\" . (string)$handler;
243
+ $handler = new $fullHandler(new ApiContext($this));
244
+ }
245
+ $handler->handle($httpConfig, $payload, array('clientId' => $clientId, 'clientSecret' => $clientSecret));
246
+ }
247
+
248
+ $connection = new PayPalHttpConnection($httpConfig, $config);
249
+ $res = $connection->execute($payload);
250
+ $response = json_decode($res, true);
251
+
252
+ return $response;
253
+ }
254
+
255
+
256
+ /**
257
+ * Generates a new access token
258
+ *
259
+ * @param array $config
260
+ * @param null|string $refreshToken
261
+ * @return null
262
+ * @throws PayPalConnectionException
263
+ */
264
+ private function generateAccessToken($config, $refreshToken = null)
265
+ {
266
+ $params = array('grant_type' => 'client_credentials');
267
+ if ($refreshToken != null) {
268
+ // If the refresh token is provided, it would get access token using refresh token
269
+ // Used for Future Payments
270
+ $params['grant_type'] = 'refresh_token';
271
+ $params['refresh_token'] = $refreshToken;
272
+ }
273
+ $payload = http_build_query($params);
274
+ $response = $this->getToken($config, $this->clientId, $this->clientSecret, $payload);
275
+
276
+ if ($response == null || !isset($response["access_token"]) || !isset($response["expires_in"])) {
277
+ $this->accessToken = null;
278
+ $this->tokenExpiresIn = null;
279
+ $this->logger->warning(
280
+ "Could not generate new Access token. Invalid response from server: "
281
+ );
282
+ throw new PayPalConnectionException(null, "Could not generate new Access token. Invalid response from server: ");
283
+ } else {
284
+ $this->accessToken = $response["access_token"];
285
+ $this->tokenExpiresIn = $response["expires_in"];
286
+ }
287
+ $this->tokenCreateTime = time();
288
+
289
+ return $this->accessToken;
290
+ }
291
+
292
+ /**
293
+ * Helper method to encrypt data using clientSecret as key
294
+ *
295
+ * @param $data
296
+ * @return string
297
+ */
298
+ public function encrypt($data)
299
+ {
300
+ return $this->cipher->encrypt($data);
301
+ }
302
+
303
+ /**
304
+ * Helper method to decrypt data using clientSecret as key
305
+ *
306
+ * @param $data
307
+ * @return string
308
+ */
309
+ public function decrypt($data)
310
+ {
311
+ return $this->cipher->decrypt($data);
312
+ }
313
+ }
lib/PayPal/Cache/AuthorizationCache.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Cache;
4
+
5
+ use PayPal\Core\PayPalConfigManager;
6
+ use PayPal\Validation\JsonValidator;
7
+
8
+ abstract class AuthorizationCache
9
+ {
10
+ public static $CACHE_PATH = '/../../../var/auth.cache';
11
+
12
+ /**
13
+ * A pull method which would read the persisted data based on clientId.
14
+ * If clientId is not provided, an array with all the tokens would be passed.
15
+ *
16
+ * @param array|null $config
17
+ * @param string $clientId
18
+ * @return mixed|null
19
+ */
20
+ public static function pull($config = null, $clientId = null)
21
+ {
22
+ // Return if not enabled
23
+ if (!self::isEnabled($config)) { return null; }
24
+
25
+ $tokens = null;
26
+ $cachePath = self::cachePath($config);
27
+ if (file_exists($cachePath)) {
28
+ // Read from the file
29
+ $cachedToken = file_get_contents($cachePath);
30
+ if ($cachedToken && JsonValidator::validate($cachedToken, true)) {
31
+ $tokens = json_decode($cachedToken, true);
32
+ if ($clientId && is_array($tokens) && array_key_exists($clientId, $tokens)) {
33
+ // If client Id is found, just send in that data only
34
+ return $tokens[$clientId];
35
+ } else if ($clientId) {
36
+ // If client Id is provided, but no key in persisted data found matching it.
37
+ return null;
38
+ }
39
+ }
40
+ }
41
+ return $tokens;
42
+ }
43
+
44
+ /**
45
+ * Persists the data into a cache file provided in $CACHE_PATH
46
+ *
47
+ * @param array|null $config
48
+ * @param $clientId
49
+ * @param $accessToken
50
+ * @param $tokenCreateTime
51
+ * @param $tokenExpiresIn
52
+ * @throws \Exception
53
+ */
54
+ public static function push($config = null, $clientId, $accessToken, $tokenCreateTime, $tokenExpiresIn)
55
+ {
56
+ // Return if not enabled
57
+ if (!self::isEnabled($config)) { return; }
58
+
59
+ $cachePath = self::cachePath($config);
60
+ if (!is_dir(dirname($cachePath))) {
61
+ if (mkdir(dirname($cachePath), 0755, true) == false) {
62
+ throw new \Exception("Failed to create directory at $cachePath");
63
+ }
64
+ }
65
+
66
+ // Reads all the existing persisted data
67
+ $tokens = self::pull();
68
+ $tokens = $tokens ? $tokens : array();
69
+ if (is_array($tokens)) {
70
+ $tokens[$clientId] = array(
71
+ 'clientId' => $clientId,
72
+ 'accessTokenEncrypted' => $accessToken,
73
+ 'tokenCreateTime' => $tokenCreateTime,
74
+ 'tokenExpiresIn' => $tokenExpiresIn
75
+ );
76
+ }
77
+ if(!file_put_contents($cachePath, json_encode($tokens))) {
78
+ throw new \Exception("Failed to write cache");
79
+ };
80
+ }
81
+
82
+ /**
83
+ * Determines from the Configuration if caching is currently enabled/disabled
84
+ *
85
+ * @param $config
86
+ * @return bool
87
+ */
88
+ public static function isEnabled($config)
89
+ {
90
+ $value = self::getConfigValue('cache.enabled', $config);
91
+ return empty($value) ? false : ((trim($value) == true || trim($value) == 'true'));
92
+ }
93
+
94
+ /**
95
+ * Returns the cache file path
96
+ *
97
+ * @param $config
98
+ * @return string
99
+ */
100
+ public static function cachePath($config)
101
+ {
102
+ $cachePath = self::getConfigValue('cache.FileName', $config);
103
+ return empty($cachePath) ? __DIR__ . self::$CACHE_PATH : $cachePath;
104
+ }
105
+
106
+ /**
107
+ * Returns the Value of the key if found in given config, or from PayPal Config Manager
108
+ * Returns null if not found
109
+ *
110
+ * @param $key
111
+ * @param $config
112
+ * @return null|string
113
+ */
114
+ private static function getConfigValue($key, $config)
115
+ {
116
+ $config = ($config && is_array($config)) ? $config : PayPalConfigManager::getInstance()->getConfigHashmap();
117
+ return (array_key_exists($key, $config)) ? trim($config[$key]) : null;
118
+ }
119
+
120
+
121
+ }
lib/PayPal/Common/ArrayUtil.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Common;
4
+
5
+ /**
6
+ * Class ArrayUtil
7
+ * Util Class for Arrays
8
+ *
9
+ * @package PayPal\Common
10
+ */
11
+ class ArrayUtil
12
+ {
13
+ /**
14
+ *
15
+ * @param array $arr
16
+ * @return true if $arr is an associative array
17
+ */
18
+ public static function isAssocArray(array $arr)
19
+ {
20
+ foreach ($arr as $k => $v) {
21
+ if (is_int($k)) {
22
+ return false;
23
+ }
24
+ }
25
+ return true;
26
+ }
27
+ }
lib/PayPal/Common/PayPalModel.php ADDED
@@ -0,0 +1,307 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Common;
4
+ use PayPal\Validation\JsonValidator;
5
+ use PayPal\Validation\ModelAccessorValidator;
6
+
7
+ /**
8
+ * Generic Model class that all API domain classes extend
9
+ * Stores all member data in a Hashmap that enables easy
10
+ * JSON encoding/decoding
11
+ */
12
+ class PayPalModel
13
+ {
14
+
15
+ private $_propMap = array();
16
+
17
+ /**
18
+ * OAuth Credentials to use for this call
19
+ *
20
+ * @var \PayPal\Auth\OAuthTokenCredential $credential
21
+ */
22
+ protected static $credential;
23
+
24
+ /**
25
+ * Sets Credential
26
+ *
27
+ * @deprecated Pass ApiContext to create/get methods instead
28
+ * @param \PayPal\Auth\OAuthTokenCredential $credential
29
+ */
30
+ public static function setCredential($credential)
31
+ {
32
+ self::$credential = $credential;
33
+ }
34
+
35
+ /**
36
+ * Default Constructor
37
+ *
38
+ * You can pass data as a json representation or array object. This argument eliminates the need
39
+ * to do $obj->fromJson($data) later after creating the object.
40
+ *
41
+ * @param null $data
42
+ * @throws \InvalidArgumentException
43
+ */
44
+ public function __construct($data = null)
45
+ {
46
+ switch (gettype($data)) {
47
+ case "NULL":
48
+ break;
49
+ case "string":
50
+ JsonValidator::validate($data);
51
+ $this->fromJson($data);
52
+ break;
53
+ case "array":
54
+ $this->fromArray($data);
55
+ break;
56
+ default:
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Returns a list of Object from Array or Json String. It is generally used when your json
62
+ * contains an array of this object
63
+ *
64
+ * @param mixed $data Array object or json string representation
65
+ * @return array
66
+ */
67
+ public static function getList($data)
68
+ {
69
+ // Return Null if Null
70
+ if ($data === null) { return null; }
71
+
72
+ if (is_a($data, get_class(new \stdClass()))) {
73
+ //This means, root element is object
74
+ return new static(json_encode($data));
75
+ }
76
+
77
+ $list = array();
78
+
79
+ if (is_array($data)) {
80
+ $data = json_encode($data);
81
+ }
82
+
83
+ if (JsonValidator::validate($data)) {
84
+ // It is valid JSON
85
+ $decoded = json_decode($data);
86
+ if ($decoded === null) {
87
+ return $list;
88
+ }
89
+ if (is_array($decoded)) {
90
+ foreach ($decoded as $k => $v) {
91
+ $list[] = self::getList($v);
92
+ }
93
+ }
94
+ if (is_a($decoded, get_class(new \stdClass()))) {
95
+ //This means, root element is object
96
+ $list[] = new static(json_encode($decoded));
97
+ }
98
+ }
99
+
100
+ return $list;
101
+ }
102
+
103
+ /**
104
+ * Magic Get Method
105
+ *
106
+ * @param $key
107
+ * @return mixed
108
+ */
109
+ public function __get($key)
110
+ {
111
+ if ($this->__isset($key)) {
112
+ return $this->_propMap[$key];
113
+ }
114
+ return null;
115
+ }
116
+
117
+ /**
118
+ * Magic Set Method
119
+ *
120
+ * @param $key
121
+ * @param $value
122
+ */
123
+ public function __set($key, $value)
124
+ {
125
+ if (!is_array($value) && $value === null) {
126
+ $this->__unset($key);
127
+ } else {
128
+ $this->_propMap[$key] = $value;
129
+ }
130
+ }
131
+
132
+ /**
133
+ * Converts the input key into a valid Setter Method Name
134
+ *
135
+ * @param $key
136
+ * @return mixed
137
+ */
138
+ private function convertToCamelCase($key)
139
+ {
140
+ return str_replace(' ', '', ucwords(str_replace(array('_', '-'), ' ', $key)));
141
+ }
142
+
143
+ /**
144
+ * Magic isSet Method
145
+ *
146
+ * @param $key
147
+ * @return bool
148
+ */
149
+ public function __isset($key)
150
+ {
151
+ return isset($this->_propMap[$key]);
152
+ }
153
+
154
+ /**
155
+ * Magic Unset Method
156
+ *
157
+ * @param $key
158
+ */
159
+ public function __unset($key)
160
+ {
161
+ unset($this->_propMap[$key]);
162
+ }
163
+
164
+ /**
165
+ * Converts Params to Array
166
+ *
167
+ * @param $param
168
+ * @return array
169
+ */
170
+ private function _convertToArray($param)
171
+ {
172
+ $ret = array();
173
+ foreach ($param as $k => $v) {
174
+ if ($v instanceof PayPalModel) {
175
+ $ret[$k] = $v->toArray();
176
+ } else if (sizeof($v) <= 0 && is_array($v)) {
177
+ $ret[$k] = array();
178
+ } else if (is_array($v)) {
179
+ $ret[$k] = $this->_convertToArray($v);
180
+ } else {
181
+ $ret[$k] = $v;
182
+ }
183
+ }
184
+ // If the array is empty, which means an empty object,
185
+ // we need to convert array to StdClass object to properly
186
+ // represent JSON String
187
+ if (sizeof($ret) <= 0) {
188
+ $ret = new PayPalModel();
189
+ }
190
+ return $ret;
191
+ }
192
+
193
+ /**
194
+ * Fills object value from Array list
195
+ *
196
+ * @param $arr
197
+ * @return $this
198
+ */
199
+ public function fromArray($arr)
200
+ {
201
+ if (!empty($arr)) {
202
+ // Iterate over each element in array
203
+ foreach ($arr as $k => $v) {
204
+ // If the value is an array, it means, it is an object after conversion
205
+ if (is_array($v)) {
206
+ // Determine the class of the object
207
+ if (($clazz = ReflectionUtil::getPropertyClass(get_class($this), $k)) != null){
208
+ // If the value is an associative array, it means, its an object. Just make recursive call to it.
209
+ if (empty($v)){
210
+ if (ReflectionUtil::isPropertyClassArray(get_class($this), $k)) {
211
+ // It means, it is an array of objects.
212
+ $this->assignValue($k, array());
213
+ continue;
214
+ }
215
+ $o = new $clazz();
216
+ //$arr = array();
217
+ $this->assignValue($k, $o);
218
+ } elseif (ArrayUtil::isAssocArray($v)) {
219
+ /** @var self $o */
220
+ $o = new $clazz();
221
+ $o->fromArray($v);
222
+ $this->assignValue($k, $o);
223
+ } else {
224
+ // Else, value is an array of object/data
225
+ $arr = array();
226
+ // Iterate through each element in that array.
227
+ foreach ($v as $nk => $nv) {
228
+ if (is_array($nv)) {
229
+ $o = new $clazz();
230
+ $o->fromArray($nv);
231
+ $arr[$nk] = $o;
232
+ } else {
233
+ $arr[$nk] = $nv;
234
+ }
235
+ }
236
+ $this->assignValue($k, $arr);
237
+ }
238
+ } else {
239
+ $this->assignValue($k, $v);
240
+ }
241
+ } else {
242
+ $this->assignValue($k, $v);
243
+ }
244
+ }
245
+ }
246
+ return $this;
247
+ }
248
+
249
+ private function assignValue($key, $value)
250
+ {
251
+ $setter = 'set'. $this->convertToCamelCase($key);
252
+ // If we find the setter, use that, otherwise use magic method.
253
+ if (method_exists($this, $setter)) {
254
+ $this->$setter($value);
255
+ } else {
256
+ $this->__set($key, $value);
257
+ }
258
+ }
259
+
260
+ /**
261
+ * Fills object value from Json string
262
+ *
263
+ * @param $json
264
+ * @return $this
265
+ */
266
+ public function fromJson($json)
267
+ {
268
+ return $this->fromArray(json_decode($json, true));
269
+ }
270
+
271
+ /**
272
+ * Returns array representation of object
273
+ *
274
+ * @return array
275
+ */
276
+ public function toArray()
277
+ {
278
+ return $this->_convertToArray($this->_propMap);
279
+ }
280
+
281
+ /**
282
+ * Returns object JSON representation
283
+ *
284
+ * @param int $options http://php.net/manual/en/json.constants.php
285
+ * @return string
286
+ */
287
+ public function toJSON($options = 0)
288
+ {
289
+ // Because of PHP Version 5.3, we cannot use JSON_UNESCAPED_SLASHES option
290
+ // Instead we would use the str_replace command for now.
291
+ // TODO: Replace this code with return json_encode($this->toArray(), $options | 64); once we support PHP >= 5.4
292
+ if (version_compare(phpversion(), '5.4.0', '>=') === true) {
293
+ return json_encode($this->toArray(), $options | 64);
294
+ }
295
+ return str_replace('\\/', '/', json_encode($this->toArray(), $options));
296
+ }
297
+
298
+ /**
299
+ * Magic Method for toString
300
+ *
301
+ * @return string
302
+ */
303
+ public function __toString()
304
+ {
305
+ return $this->toJSON(128);
306
+ }
307
+ }
lib/PayPal/Common/PayPalResourceModel.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Common;
4
+
5
+ use PayPal\Rest\ApiContext;
6
+ use PayPal\Rest\IResource;
7
+ use PayPal\Transport\PayPalRestCall;
8
+
9
+ /**
10
+ * Class PayPalResourceModel
11
+ * An Executable PayPalModel Class
12
+ *
13
+ * @property \PayPal\Api\Links[] links
14
+ * @package PayPal\Common
15
+ */
16
+ class PayPalResourceModel extends PayPalModel implements IResource
17
+ {
18
+
19
+ /**
20
+ * Sets Links
21
+ *
22
+ * @param \PayPal\Api\Links[] $links
23
+ *
24
+ * @return $this
25
+ */
26
+ public function setLinks($links)
27
+ {
28
+ $this->links = $links;
29
+ return $this;
30
+ }
31
+
32
+ /**
33
+ * Gets Links
34
+ *
35
+ * @return \PayPal\Api\Links[]
36
+ */
37
+ public function getLinks()
38
+ {
39
+ return $this->links;
40
+ }
41
+
42
+ public function getLink($rel)
43
+ {
44
+ foreach ($this->links as $link) {
45
+ if ($link->getRel() == $rel) {
46
+ return $link->getHref();
47
+ }
48
+ }
49
+ return null;
50
+ }
51
+
52
+ /**
53
+ * Append Links to the list.
54
+ *
55
+ * @param \PayPal\Api\Links $links
56
+ * @return $this
57
+ */
58
+ public function addLink($links)
59
+ {
60
+ if (!$this->getLinks()) {
61
+ return $this->setLinks(array($links));
62
+ } else {
63
+ return $this->setLinks(
64
+ array_merge($this->getLinks(), array($links))
65
+ );
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Remove Links from the list.
71
+ *
72
+ * @param \PayPal\Api\Links $links
73
+ * @return $this
74
+ */
75
+ public function removeLink($links)
76
+ {
77
+ return $this->setLinks(
78
+ array_diff($this->getLinks(), array($links))
79
+ );
80
+ }
81
+
82
+
83
+ /**
84
+ * Execute SDK Call to Paypal services
85
+ *
86
+ * @param string $url
87
+ * @param string $method
88
+ * @param string $payLoad
89
+ * @param array $headers
90
+ * @param ApiContext $apiContext
91
+ * @param PayPalRestCall $restCall
92
+ * @param array $handlers
93
+ * @return string json response of the object
94
+ */
95
+ protected static function executeCall($url, $method, $payLoad, $headers = array(), $apiContext = null, $restCall = null, $handlers = array('PayPal\Handler\RestHandler'))
96
+ {
97
+ //Initialize the context and rest call object if not provided explicitly
98
+ $apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential);
99
+ $restCall = $restCall ? $restCall : new PayPalRestCall($apiContext);
100
+
101
+ //Make the execution call
102
+ $json = $restCall->execute($handlers, $url, $method, $payLoad, $headers);
103
+ return $json;
104
+ }
105
+ }
lib/PayPal/Common/PayPalUserAgent.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Common;
4
+
5
+ /**
6
+ * Class PayPalUserAgent
7
+ * PayPalUserAgent generates User Agent for curl requests
8
+ *
9
+ * @package PayPal\Common
10
+ */
11
+ class PayPalUserAgent
12
+ {
13
+
14
+ /**
15
+ * Returns the value of the User-Agent header
16
+ * Add environment values and php version numbers
17
+ *
18
+ * @param string $sdkName
19
+ * @param string $sdkVersion
20
+ * @return string
21
+ */
22
+ public static function getValue($sdkName, $sdkVersion)
23
+ {
24
+
25
+ $featureList = array(
26
+ 'platform-ver=' . PHP_VERSION,
27
+ 'bit=' . self::_getPHPBit(),
28
+ 'os=' . str_replace(' ', '_', php_uname('s') . ' ' . php_uname('r')),
29
+ 'machine=' . php_uname('m')
30
+ );
31
+ if (defined('OPENSSL_VERSION_TEXT')) {
32
+ $opensslVersion = explode(' ', OPENSSL_VERSION_TEXT);
33
+ $featureList[] = 'crypto-lib-ver=' . $opensslVersion[1];
34
+ }
35
+ if (function_exists('curl_version')) {
36
+ $curlVersion = curl_version();
37
+ $featureList[] = 'curl=' . $curlVersion['version'];
38
+ }
39
+ return sprintf("PayPalSDK/%s %s (%s)", $sdkName, $sdkVersion, implode('; ', $featureList));
40
+ }
41
+
42
+ /**
43
+ * Gets PHP Bit version
44
+ *
45
+ * @return int|string
46
+ */
47
+ private static function _getPHPBit()
48
+ {
49
+ switch (PHP_INT_SIZE) {
50
+ case 4:
51
+ return '32';
52
+ case 8:
53
+ return '64';
54
+ default:
55
+ return PHP_INT_SIZE;
56
+ }
57
+ }
58
+ }
lib/PayPal/Common/ReflectionUtil.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Common;
4
+ use PayPal\Exception\PayPalConfigurationException;
5
+
6
+ /**
7
+ * Class ReflectionUtil
8
+ *
9
+ * @package PayPal\Common
10
+ */
11
+ class ReflectionUtil
12
+ {
13
+
14
+ /**
15
+ * Reflection Methods
16
+ *
17
+ * @var \ReflectionMethod[]
18
+ */
19
+ private static $propertiesRefl = array();
20
+
21
+ /**
22
+ * Properties Type
23
+ *
24
+ * @var string[]
25
+ */
26
+ private static $propertiesType = array();
27
+
28
+
29
+ /**
30
+ * Gets Property Class of the given property.
31
+ * If the class is null, it returns null.
32
+ * If the property is not found, it returns null.
33
+ *
34
+ * @param $class
35
+ * @param $propertyName
36
+ * @return null|string
37
+ * @throws PayPalConfigurationException
38
+ */
39
+ public static function getPropertyClass($class, $propertyName)
40
+ {
41
+ if ($class == get_class(new PayPalModel())) {
42
+ // Make it generic if PayPalModel is used for generating this
43
+ return get_class(new PayPalModel());
44
+ }
45
+
46
+ // If the class doesn't exist, or the method doesn't exist, return null.
47
+ if (!class_exists($class) || !method_exists($class, self::getter($class, $propertyName))) {
48
+ return null;
49
+ }
50
+
51
+ if (($annotations = self::propertyAnnotations($class, $propertyName)) && isset($annotations['return'])) {
52
+ $param = $annotations['return'];
53
+ }
54
+
55
+ if (isset($param)) {
56
+ $anno = preg_split("/[\s\[\]]+/", $param);
57
+ return $anno[0];
58
+ } else {
59
+ throw new PayPalConfigurationException("Getter function for '$propertyName' in '$class' class should have a proper return type.");
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Checks if the Property is of type array or an object
65
+ *
66
+ * @param $class
67
+ * @param $propertyName
68
+ * @return null|boolean
69
+ * @throws PayPalConfigurationException
70
+ */
71
+ public static function isPropertyClassArray($class, $propertyName)
72
+ {
73
+ // If the class doesn't exist, or the method doesn't exist, return null.
74
+ if (!class_exists($class) || !method_exists($class, self::getter($class, $propertyName))) {
75
+ return null;
76
+ }
77
+
78
+ if (($annotations = self::propertyAnnotations($class, $propertyName)) && isset($annotations['return'])) {
79
+ $param = $annotations['return'];
80
+ }
81
+
82
+ if (isset($param)) {
83
+ return substr($param, -strlen('[]'))==='[]';
84
+ } else {
85
+ throw new PayPalConfigurationException("Getter function for '$propertyName' in '$class' class should have a proper return type.");
86
+ }
87
+ }
88
+
89
+ /**
90
+ * Retrieves Annotations of each property
91
+ *
92
+ * @param $class
93
+ * @param $propertyName
94
+ * @throws \RuntimeException
95
+ * @return mixed
96
+ */
97
+ public static function propertyAnnotations($class, $propertyName)
98
+ {
99
+ $class = is_object($class) ? get_class($class) : $class;
100
+ if (!class_exists('ReflectionProperty')) {
101
+ throw new \RuntimeException("Property type of " . $class . "::{$propertyName} cannot be resolved");
102
+ }
103
+
104
+ if ($annotations =& self::$propertiesType[$class][$propertyName]) {
105
+ return $annotations;
106
+ }
107
+
108
+ if (!($refl =& self::$propertiesRefl[$class][$propertyName])) {
109
+ $getter = self::getter($class, $propertyName);
110
+ $refl = new \ReflectionMethod($class, $getter);
111
+ self::$propertiesRefl[$class][$propertyName] = $refl;
112
+ }
113
+
114
+ // todo: smarter regexp
115
+ if ( !preg_match_all(
116
+ '~\@([^\s@\(]+)[\t ]*(?:\(?([^\n@]+)\)?)?~i',
117
+ $refl->getDocComment(),
118
+ $annots,
119
+ PREG_PATTERN_ORDER)) {
120
+ return null;
121
+ }
122
+ foreach ($annots[1] as $i => $annot) {
123
+ $annotations[strtolower($annot)] = empty($annots[2][$i]) ? TRUE : rtrim($annots[2][$i], " \t\n\r)");
124
+ }
125
+
126
+ return $annotations;
127
+ }
128
+
129
+ /**
130
+ * preg_replace_callback callback function
131
+ *
132
+ * @param $match
133
+ * @return string
134
+ */
135
+ private static function replace_callback($match)
136
+ {
137
+ return ucwords($match[2]);
138
+ }
139
+
140
+ /**
141
+ * Returns the properly formatted getter function name based on class name and property
142
+ * Formats the property name to a standard getter function
143
+ *
144
+ * @param string $class
145
+ * @param string $propertyName
146
+ * @return string getter function name
147
+ */
148
+ public static function getter($class, $propertyName)
149
+ {
150
+ return method_exists($class, "get" . ucfirst($propertyName)) ?
151
+ "get" . ucfirst($propertyName) :
152
+ "get" . preg_replace_callback("/([_\-\s]?([a-z0-9]+))/", "self::replace_callback", $propertyName);
153
+ }
154
+ }
lib/PayPal/Converter/FormatConverter.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Converter;
4
+
5
+ class FormatConverter
6
+ {
7
+ /**
8
+ * Format the data based on the input formatter value
9
+ *
10
+ * @param $value
11
+ * @param $formatter
12
+ * @return string
13
+ */
14
+ public static function format($value, $formatter)
15
+ {
16
+ return sprintf($formatter, $value);
17
+ }
18
+
19
+ /**
20
+ * Format the input data with decimal places
21
+ *
22
+ * Defaults to 2 decimal places
23
+ *
24
+ * @param $value
25
+ * @param int $decimals
26
+ * @return null|string
27
+ */
28
+ public static function formatToNumber($value, $decimals = 2)
29
+ {
30
+ if (trim($value) != null) {
31
+ return number_format($value, $decimals, '.', '');
32
+ }
33
+ return null;
34
+ }
35
+
36
+ /**
37
+ * Helper method to format price values with associated currency information.
38
+ *
39
+ * It covers the cases where certain currencies does not accept decimal values. We will be adding
40
+ * any specific currency level rules as required here.
41
+ *
42
+ * @param $value
43
+ * @param null $currency
44
+ * @return null|string
45
+ */
46
+ public static function formatToPrice($value, $currency = null)
47
+ {
48
+ $decimals = 2;
49
+ $currencyDecimals = array('JPY' => 0, 'TWD' => 0);
50
+ if ($currency && array_key_exists($currency, $currencyDecimals)) {
51
+ if (strpos($value, ".") !== false && (floor($value) != $value)) {
52
+ //throw exception if it has decimal values for JPY and TWD which does not ends with .00
53
+ throw new \InvalidArgumentException("value cannot have decimals for $currency currency");
54
+ }
55
+ $decimals = $currencyDecimals[$currency];
56
+ } else if (strpos($value, ".") === false) {
57
+ // Check if value has decimal values. If not no need to assign 2 decimals with .00 at the end
58
+ $decimals = 0;
59
+ }
60
+ return self::formatToNumber($value, $decimals);
61
+ }
62
+ }
lib/PayPal/Core/PayPalConfigManager.php ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Core;
4
+
5
+ /**
6
+ * Class PayPalConfigManager
7
+ *
8
+ * PayPalConfigManager loads the SDK configuration file and
9
+ * hands out appropriate config params to other classes
10
+ *
11
+ * @package PayPal\Core
12
+ */
13
+ class PayPalConfigManager
14
+ {
15
+
16
+ /**
17
+ * Configuration Options
18
+ *
19
+ * @var array
20
+ */
21
+ private $configs = array(
22
+ );
23
+
24
+ /**
25
+ * Singleton Object
26
+ *
27
+ * @var $this
28
+ */
29
+ private static $instance;
30
+
31
+ /**
32
+ * Private Constructor
33
+ */
34
+ private function __construct()
35
+ {
36
+ if (defined('PP_CONFIG_PATH')) {
37
+ $configFile = constant('PP_CONFIG_PATH') . '/sdk_config.ini';
38
+ } else {
39
+ $configFile = implode(DIRECTORY_SEPARATOR,
40
+ array(dirname(__FILE__), "..", "config", "sdk_config.ini"));
41
+ }
42
+ if (file_exists($configFile)) {
43
+ $this->addConfigFromIni($configFile);
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Returns the singleton object
49
+ *
50
+ * @return $this
51
+ */
52
+ public static function getInstance()
53
+ {
54
+ if (!isset(self::$instance)) {
55
+ self::$instance = new self();
56
+ }
57
+ return self::$instance;
58
+ }
59
+
60
+ /**
61
+ * Add Configuration from configuration.ini files
62
+ *
63
+ * @param string $fileName
64
+ * @return $this
65
+ */
66
+ public function addConfigFromIni($fileName)
67
+ {
68
+ if ($configs = parse_ini_file($fileName)) {
69
+ $this->addConfigs($configs);
70
+ }
71
+ return $this;
72
+ }
73
+
74
+ /**
75
+ * If a configuration exists in both arrays,
76
+ * then the element from the first array will be used and
77
+ * the matching key's element from the second array will be ignored.
78
+ *
79
+ * @param array $configs
80
+ * @return $this
81
+ */
82
+ public function addConfigs($configs = array())
83
+ {
84
+ $this->configs = $configs + $this->configs;
85
+ return $this;
86
+ }
87
+
88
+ /**
89
+ * Simple getter for configuration params
90
+ * If an exact match for key is not found,
91
+ * does a "contains" search on the key
92
+ *
93
+ * @param string $searchKey
94
+ * @return array
95
+ */
96
+ public function get($searchKey)
97
+ {
98
+
99
+ if (array_key_exists($searchKey, $this->configs)) {
100
+ return $this->configs[$searchKey];
101
+ } else {
102
+ $arr = array();
103
+ foreach ($this->configs as $k => $v) {
104
+ if (strstr($k, $searchKey)) {
105
+ $arr[$k] = $v;
106
+ }
107
+ }
108
+
109
+ return $arr;
110
+ }
111
+
112
+ }
113
+
114
+ /**
115
+ * Utility method for handling account configuration
116
+ * return config key corresponding to the API userId passed in
117
+ *
118
+ * If $userId is null, returns config keys corresponding to
119
+ * all configured accounts
120
+ *
121
+ * @param string|null $userId
122
+ * @return array|string
123
+ */
124
+ public function getIniPrefix($userId = null)
125
+ {
126
+
127
+ if ($userId == null) {
128
+ $arr = array();
129
+ foreach ($this->configs as $key => $value) {
130
+ $pos = strpos($key, '.');
131
+ if (strstr($key, "acct")) {
132
+ $arr[] = substr($key, 0, $pos);
133
+ }
134
+ }
135
+ return array_unique($arr);
136
+ } else {
137
+ $iniPrefix = array_search($userId, $this->configs);
138
+ $pos = strpos($iniPrefix, '.');
139
+ $acct = substr($iniPrefix, 0, $pos);
140
+
141
+ return $acct;
142
+ }
143
+ }
144
+
145
+ /**
146
+ * returns the config file hashmap
147
+ */
148
+ public function getConfigHashmap()
149
+ {
150
+ return $this->configs;
151
+ }
152
+
153
+ /**
154
+ * Disabling __clone call
155
+ */
156
+ public function __clone()
157
+ {
158
+ trigger_error('Clone is not allowed.', E_USER_ERROR);
159
+ }
160
+
161
+ }
162
+
163
+
lib/PayPal/Core/PayPalConstants.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Core;
4
+
5
+ /**
6
+ * Class PayPalConstants
7
+ * Placeholder for Paypal Constants
8
+ *
9
+ * @package PayPal\Core
10
+ */
11
+ class PayPalConstants
12
+ {
13
+
14
+ const SDK_NAME = 'PayPal-PHP-SDK';
15
+ const SDK_VERSION = '1.6.4';
16
+
17
+ /**
18
+ * Approval URL for Payment
19
+ */
20
+ const APPROVAL_URL = 'approval_url';
21
+
22
+ const REST_SANDBOX_ENDPOINT = "https://api.sandbox.paypal.com/";
23
+ const OPENID_REDIRECT_SANDBOX_URL = "https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect";
24
+
25
+ const REST_LIVE_ENDPOINT = "https://api.paypal.com/";
26
+ const OPENID_REDIRECT_LIVE_URL = "https://www.paypal.com/webapps/auth/protocol/openidconnect";
27
+ }
lib/PayPal/Core/PayPalCredentialManager.php ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Core;
4
+
5
+ use PayPal\Auth\OAuthTokenCredential;
6
+ use PayPal\Exception\PayPalInvalidCredentialException;
7
+
8
+ /**
9
+ * Class PayPalCredentialManager
10
+ *
11
+ * PayPalCredentialManager holds all the credential information in one place.
12
+ *
13
+ * @package PayPal\Core
14
+ */
15
+ class PayPalCredentialManager
16
+ {
17
+ /**
18
+ * Singleton Object
19
+ *
20
+ * @var PayPalCredentialManager
21
+ */
22
+ private static $instance;
23
+
24
+ /**
25
+ * Hashmap to contain credentials for accounts.
26
+ *
27
+ * @var array
28
+ */
29
+ private $credentialHashmap = array();
30
+
31
+ /**
32
+ * Contains the API username of the default account to use
33
+ * when authenticating API calls
34
+ *
35
+ * @var string
36
+ */
37
+ private $defaultAccountName;
38
+
39
+ /**
40
+ * Constructor initialize credential for multiple accounts specified in property file
41
+ *
42
+ * @param $config
43
+ * @throws \Exception
44
+ */
45
+ private function __construct($config)
46
+ {
47
+ try {
48
+ $this->initCredential($config);
49
+ } catch (\Exception $e) {
50
+ $this->credentialHashmap = array();
51
+ throw $e;
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Create singleton instance for this class.
57
+ *
58
+ * @param array|null $config
59
+ * @return PayPalCredentialManager
60
+ */
61
+ public static function getInstance($config = null)
62
+ {
63
+ if (!self::$instance) {
64
+ self::$instance = new self($config == null ? PayPalConfigManager::getInstance()->getConfigHashmap() : $config);
65
+ }
66
+ return self::$instance;
67
+ }
68
+
69
+ /**
70
+ * Load credentials for multiple accounts, with priority given to Signature credential.
71
+ *
72
+ * @param array $config
73
+ */
74
+ private function initCredential($config)
75
+ {
76
+ $suffix = 1;
77
+ $prefix = "acct";
78
+
79
+ $arr = array();
80
+ foreach ($config as $k => $v) {
81
+ if (strstr($k, $prefix)) {
82
+ $arr[$k] = $v;
83
+ }
84
+ }
85
+ $credArr = $arr;
86
+
87
+ $arr = array();
88
+ foreach ($config as $key => $value) {
89
+ $pos = strpos($key, '.');
90
+ if (strstr($key, "acct")) {
91
+ $arr[] = substr($key, 0, $pos);
92
+ }
93
+ }
94
+ $arrayPartKeys = array_unique($arr);
95
+
96
+ $key = $prefix . $suffix;
97
+ $userName = null;
98
+ while (in_array($key, $arrayPartKeys)) {
99
+ if (isset($credArr[$key . ".ClientId"]) && isset($credArr[$key . ".ClientId"])) {
100
+ $userName = $key;
101
+ $this->credentialHashmap[$userName] = new OAuthTokenCredential(
102
+ $credArr[$key . ".ClientId"],
103
+ $credArr[$key . ".ClientSecret"]
104
+ );
105
+ }
106
+ if ($userName && $this->defaultAccountName == null) {
107
+ if (array_key_exists($key . '.UserName', $credArr)) {
108
+ $this->defaultAccountName = $credArr[$key . '.UserName'];
109
+ } else {
110
+ $this->defaultAccountName = $key;
111
+ }
112
+ }
113
+ $suffix++;
114
+ $key = $prefix . $suffix;
115
+ }
116
+
117
+ }
118
+
119
+ /**
120
+ * Sets credential object for users
121
+ *
122
+ * @param \PayPal\Auth\OAuthTokenCredential $credential
123
+ * @param string|null $userId User Id associated with the account
124
+ * @param bool $default If set, it would make it as a default credential for all requests
125
+ *
126
+ * @return $this
127
+ */
128
+ public function setCredentialObject(OAuthTokenCredential $credential, $userId = null, $default = true)
129
+ {
130
+ $key = $userId == null ? 'default' : $userId;
131
+ $this->credentialHashmap[$key] = $credential;
132
+ if ($default) {
133
+ $this->defaultAccountName = $key;
134
+ }
135
+ return $this;
136
+ }
137
+
138
+ /**
139
+ * Obtain Credential Object based on UserId provided.
140
+ *
141
+ * @param null $userId
142
+ * @return OAuthTokenCredential
143
+ * @throws PayPalInvalidCredentialException
144
+ */
145
+ public function getCredentialObject($userId = null)
146
+ {
147
+ if ($userId == null && array_key_exists($this->defaultAccountName, $this->credentialHashmap)) {
148
+ $credObj = $this->credentialHashmap[$this->defaultAccountName];
149
+ } else if (array_key_exists($userId, $this->credentialHashmap)) {
150
+ $credObj = $this->credentialHashmap[$userId];
151
+ }
152
+
153
+ if (empty($credObj)) {
154
+ throw new PayPalInvalidCredentialException("Credential not found for " . ($userId ? $userId : " default user") .
155
+ ". Please make sure your configuration/APIContext has credential information");
156
+ }
157
+ return $credObj;
158
+ }
159
+
160
+ /**
161
+ * Disabling __clone call
162
+ */
163
+ public function __clone()
164
+ {
165
+ trigger_error('Clone is not allowed.', E_USER_ERROR);
166
+ }
167
+
168
+ }
lib/PayPal/Core/PayPalHttpConfig.php ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Core;
4
+
5
+ use PayPal\Exception\PayPalConfigurationException;
6
+
7
+ /**
8
+ * Class PayPalHttpConfig
9
+ * Http Configuration Class
10
+ *
11
+ * @package PayPal\Core
12
+ */
13
+ class PayPalHttpConfig
14
+ {
15
+ /**
16
+ * Some default options for curl
17
+ * These are typically overridden by PayPalConnectionManager
18
+ *
19
+ * @var array
20
+ */
21
+ public static $defaultCurlOptions = array(
22
+ CURLOPT_SSLVERSION => 6,
23
+ CURLOPT_CONNECTTIMEOUT => 10,
24
+ CURLOPT_RETURNTRANSFER => TRUE,
25
+ CURLOPT_TIMEOUT => 60, // maximum number of seconds to allow cURL functions to execute
26
+ CURLOPT_USERAGENT => 'PayPal-PHP-SDK',
27
+ CURLOPT_HTTPHEADER => array(),
28
+ CURLOPT_SSL_VERIFYHOST => 2,
29
+ CURLOPT_SSL_VERIFYPEER => 1,
30
+ CURLOPT_SSL_CIPHER_LIST => 'TLSv1'
31
+ //Allowing TLSv1 cipher list.
32
+ //Adding it like this for backward compatibility with older versions of curl
33
+ );
34
+
35
+ const HEADER_SEPARATOR = ';';
36
+ const HTTP_GET = 'GET';
37
+ const HTTP_POST = 'POST';
38
+
39
+ private $headers = array();
40
+
41
+ private $curlOptions;
42
+
43
+ private $url;
44
+
45
+ private $method;
46
+
47
+ /***
48
+ * Number of times to retry a failed HTTP call
49
+ */
50
+ private $retryCount = 0;
51
+
52
+ /**
53
+ * Default Constructor
54
+ *
55
+ * @param string $url
56
+ * @param string $method HTTP method (GET, POST etc) defaults to POST
57
+ * @param array $configs All Configurations
58
+ */
59
+ public function __construct($url = null, $method = self::HTTP_POST, $configs = array())
60
+ {
61
+ $this->url = $url;
62
+ $this->method = $method;
63
+ $this->curlOptions = $this->getHttpConstantsFromConfigs($configs, 'http.') + self::$defaultCurlOptions;
64
+ // Update the Cipher List based on OpenSSL or NSS settings
65
+ $curl = curl_version();
66
+ $sslVersion = isset($curl['ssl_version']) ? $curl['ssl_version'] : '';
67
+ if (substr_compare($sslVersion, "NSS/", 0, strlen("NSS/")) === 0) {
68
+ //Remove the Cipher List for NSS
69
+ $this->removeCurlOption(CURLOPT_SSL_CIPHER_LIST);
70
+ }
71
+ }
72
+
73
+ /**
74
+ * Gets Url
75
+ *
76
+ * @return null|string
77
+ */
78
+ public function getUrl()
79
+ {
80
+ return $this->url;
81
+ }
82
+
83
+ /**
84
+ * Gets Method
85
+ *
86
+ * @return string
87
+ */
88
+ public function getMethod()
89
+ {
90
+ return $this->method;
91
+ }
92
+
93
+ /**
94
+ * Gets all Headers
95
+ *
96
+ * @return array
97
+ */
98
+ public function getHeaders()
99
+ {
100
+ return $this->headers;
101
+ }
102
+
103
+ /**
104
+ * Get Header by Name
105
+ *
106
+ * @param $name
107
+ * @return string|null
108
+ */
109
+ public function getHeader($name)
110
+ {
111
+ if (array_key_exists($name, $this->headers)) {
112
+ return $this->headers[$name];
113
+ }
114
+ return null;
115
+ }
116
+
117
+ /**
118
+ * Sets Url
119
+ *
120
+ * @param $url
121
+ */
122
+ public function setUrl($url)
123
+ {
124
+ $this->url = $url;
125
+ }
126
+
127
+ /**
128
+ * Set Headers
129
+ *
130
+ * @param array $headers
131
+ */
132
+ public function setHeaders(array $headers = array())
133
+ {
134
+ $this->headers = $headers;
135
+ }
136
+
137
+ /**
138
+ * Adds a Header
139
+ *
140
+ * @param $name
141
+ * @param $value
142
+ * @param bool $overWrite allows you to override header value
143
+ */
144
+ public function addHeader($name, $value, $overWrite = true)
145
+ {
146
+ if (!array_key_exists($name, $this->headers) || $overWrite) {
147
+ $this->headers[$name] = $value;
148
+ } else {
149
+ $this->headers[$name] = $this->headers[$name] . self::HEADER_SEPARATOR . $value;
150
+ }
151
+ }
152
+
153
+ /**
154
+ * Removes a Header
155
+ *
156
+ * @param $name
157
+ */
158
+ public function removeHeader($name)
159
+ {
160
+ unset($this->headers[$name]);
161
+ }
162
+
163
+ /**
164
+ * Gets all curl options
165
+ *
166
+ * @return array
167
+ */
168
+ public function getCurlOptions()
169
+ {
170
+ return $this->curlOptions;
171
+ }
172
+
173
+ /**
174
+ * Add Curl Option
175
+ *
176
+ * @param string $name
177
+ * @param mixed $value
178
+ */
179
+ public function addCurlOption($name, $value)
180
+ {
181
+ $this->curlOptions[$name] = $value;
182
+ }
183
+
184
+ /**
185
+ * Removes a curl option from the list
186
+ *
187
+ * @param $name
188
+ */
189
+ public function removeCurlOption($name)
190
+ {
191
+ unset($this->curlOptions[$name]);
192
+ }
193
+
194
+ /**
195
+ * Set Curl Options. Overrides all curl options
196
+ *
197
+ * @param $options
198
+ */
199
+ public function setCurlOptions($options)
200
+ {
201
+ $this->curlOptions = $options;
202
+ }
203
+
204
+ /**
205
+ * Set ssl parameters for certificate based client authentication
206
+ *
207
+ * @param $certPath
208
+ * @param null $passPhrase
209
+ */
210
+ public function setSSLCert($certPath, $passPhrase = null)
211
+ {
212
+ $this->curlOptions[CURLOPT_SSLCERT] = realpath($certPath);
213
+ if (isset($passPhrase) && trim($passPhrase) != "") {
214
+ $this->curlOptions[CURLOPT_SSLCERTPASSWD] = $passPhrase;
215
+ }
216
+ }
217
+
218
+ /**
219
+ * Set connection timeout in seconds
220
+ *
221
+ * @param integer $timeout
222
+ */
223
+ public function setHttpTimeout($timeout)
224
+ {
225
+ $this->curlOptions[CURLOPT_CONNECTTIMEOUT] = $timeout;
226
+ }
227
+
228
+ /**
229
+ * Set HTTP proxy information
230
+ *
231
+ * @param string $proxy
232
+ * @throws PayPalConfigurationException
233
+ */
234
+ public function setHttpProxy($proxy)
235
+ {
236
+ $urlParts = parse_url($proxy);
237
+ if ($urlParts == false || !array_key_exists("host", $urlParts)) {
238
+ throw new PayPalConfigurationException("Invalid proxy configuration " . $proxy);
239
+ }
240
+ $this->curlOptions[CURLOPT_PROXY] = $urlParts["host"];
241
+ if (isset($urlParts["port"])) {
242
+ $this->curlOptions[CURLOPT_PROXY] .= ":" . $urlParts["port"];
243
+ }
244
+ if (isset($urlParts["user"])) {
245
+ $this->curlOptions[CURLOPT_PROXYUSERPWD] = $urlParts["user"] . ":" . $urlParts["pass"];
246
+ }
247
+ }
248
+
249
+ /**
250
+ * Set Http Retry Counts
251
+ *
252
+ * @param int $retryCount
253
+ */
254
+ public function setHttpRetryCount($retryCount)
255
+ {
256
+ $this->retryCount = $retryCount;
257
+ }
258
+
259
+ /**
260
+ * Get Http Retry Counts
261
+ *
262
+ * @return int
263
+ */
264
+ public function getHttpRetryCount()
265
+ {
266
+ return $this->retryCount;
267
+ }
268
+
269
+ /**
270
+ * Sets the User-Agent string on the HTTP request
271
+ *
272
+ * @param string $userAgentString
273
+ */
274
+ public function setUserAgent($userAgentString)
275
+ {
276
+ $this->curlOptions[CURLOPT_USERAGENT] = $userAgentString;
277
+ }
278
+
279
+ /**
280
+ * Retrieves an array of constant key, and value based on Prefix
281
+ *
282
+ * @param array $configs
283
+ * @param $prefix
284
+ * @return array
285
+ */
286
+ public function getHttpConstantsFromConfigs($configs = array(), $prefix)
287
+ {
288
+ $arr = array();
289
+ if ($prefix != null && is_array($configs)) {
290
+ foreach ($configs as $k => $v) {
291
+ // Check if it startsWith
292
+ if (substr($k, 0, strlen($prefix)) === $prefix) {
293
+ $newKey = ltrim($k, $prefix);
294
+ if (defined($newKey)) {
295
+ $arr[constant($newKey)] = $v;
296
+ }
297
+ }
298
+ }
299
+ }
300
+ return $arr;
301
+ }
302
+ }
lib/PayPal/Core/PayPalHttpConnection.php ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Core;
4
+
5
+ use PayPal\Exception\PayPalConfigurationException;
6
+ use PayPal\Exception\PayPalConnectionException;
7
+
8
+ /**
9
+ * A wrapper class based on the curl extension.
10
+ * Requires the PHP curl module to be enabled.
11
+ * See for full requirements the PHP manual: http://php.net/curl
12
+ */
13
+ class PayPalHttpConnection
14
+ {
15
+
16
+ /**
17
+ * @var PayPalHttpConfig
18
+ */
19
+ private $httpConfig;
20
+
21
+ /**
22
+ * HTTP status codes for which a retry must be attempted
23
+ * retry is currently attempted for Request timeout, Bad Gateway,
24
+ * Service Unavailable and Gateway timeout errors.
25
+ */
26
+ private static $retryCodes = array('408', '502', '503', '504',);
27
+
28
+ /**
29
+ * LoggingManager
30
+ *
31
+ * @var PayPalLoggingManager
32
+ */
33
+ private $logger;
34
+
35
+ /**
36
+ * Default Constructor
37
+ *
38
+ * @param PayPalHttpConfig $httpConfig
39
+ * @param array $config
40
+ * @throws PayPalConfigurationException
41
+ */
42
+ public function __construct(PayPalHttpConfig $httpConfig, array $config)
43
+ {
44
+ if (!function_exists("curl_init")) {
45
+ throw new PayPalConfigurationException("Curl module is not available on this system");
46
+ }
47
+ $this->httpConfig = $httpConfig;
48
+ $this->logger = PayPalLoggingManager::getInstance(__CLASS__);
49
+ }
50
+
51
+ /**
52
+ * Gets all Http Headers
53
+ *
54
+ * @return array
55
+ */
56
+ private function getHttpHeaders()
57
+ {
58
+
59
+ $ret = array();
60
+ foreach ($this->httpConfig->getHeaders() as $k => $v) {
61
+ $ret[] = "$k: $v";
62
+ }
63
+ return $ret;
64
+ }
65
+
66
+ /**
67
+ * Executes an HTTP request
68
+ *
69
+ * @param string $data query string OR POST content as a string
70
+ * @return mixed
71
+ * @throws PayPalConnectionException
72
+ */
73
+ public function execute($data)
74
+ {
75
+ //Initialize the logger
76
+ $this->logger->info($this->httpConfig->getMethod() . ' ' . $this->httpConfig->getUrl());
77
+
78
+ //Initialize Curl Options
79
+ $ch = curl_init($this->httpConfig->getUrl());
80
+ curl_setopt_array($ch, $this->httpConfig->getCurlOptions());
81
+ curl_setopt($ch, CURLOPT_URL, $this->httpConfig->getUrl());
82
+ curl_setopt($ch, CURLOPT_HEADER, true);
83
+ curl_setopt($ch, CURLINFO_HEADER_OUT, true);
84
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $this->getHttpHeaders());
85
+
86
+ //Determine Curl Options based on Method
87
+ switch ($this->httpConfig->getMethod()) {
88
+ case 'POST':
89
+ curl_setopt($ch, CURLOPT_POST, true);
90
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
91
+ break;
92
+ case 'PUT':
93
+ case 'PATCH':
94
+ case 'DELETE':
95
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
96
+ break;
97
+ }
98
+
99
+ //Default Option if Method not of given types in switch case
100
+ if ($this->httpConfig->getMethod() != NULL) {
101
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->httpConfig->getMethod());
102
+ }
103
+
104
+ //Logging Each Headers for debugging purposes
105
+ foreach ($this->getHttpHeaders() as $header) {
106
+ //TODO: Strip out credentials and other secure info when logging.
107
+ // $this->logger->debug($header);
108
+ }
109
+
110
+ //Execute Curl Request
111
+ $result = curl_exec($ch);
112
+ //Retrieve Response Status
113
+ $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
114
+
115
+ //Retry if Certificate Exception
116
+ if (curl_errno($ch) == 60) {
117
+ $this->logger->info("Invalid or no certificate authority found - Retrying using bundled CA certs file");
118
+ curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
119
+ $result = curl_exec($ch);
120
+ //Retrieve Response Status
121
+ $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
122
+ }
123
+
124
+ //Retry if Failing
125
+ $retries = 0;
126
+ if (in_array($httpStatus, self::$retryCodes) && $this->httpConfig->getHttpRetryCount() != null) {
127
+ $this->logger->info("Got $httpStatus response from server. Retrying");
128
+ do {
129
+ $result = curl_exec($ch);
130
+ //Retrieve Response Status
131
+ $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
132
+ } while (in_array($httpStatus, self::$retryCodes) && (++$retries < $this->httpConfig->getHttpRetryCount()));
133
+ }
134
+
135
+ //Throw Exception if Retries and Certificates doenst work
136
+ if (curl_errno($ch)) {
137
+ $ex = new PayPalConnectionException(
138
+ $this->httpConfig->getUrl(),
139
+ curl_error($ch),
140
+ curl_errno($ch)
141
+ );
142
+ curl_close($ch);
143
+ throw $ex;
144
+ }
145
+
146
+ // Get Request and Response Headers
147
+ $requestHeaders = curl_getinfo($ch, CURLINFO_HEADER_OUT);
148
+ //Using alternative solution to CURLINFO_HEADER_SIZE as it throws invalid number when called using PROXY.
149
+ $responseHeaderSize = strlen($result) - curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD);
150
+ $responseHeaders = substr($result, 0, $responseHeaderSize);
151
+ $result = substr($result, $responseHeaderSize);
152
+
153
+ $this->logger->debug("Request Headers \t: " . str_replace("\r\n", ", ", $requestHeaders));
154
+ $this->logger->debug(($data && $data != '' ? "Request Data\t\t: " . $data : "No Request Payload") . "\n" . str_repeat('-', 128) . "\n");
155
+ $this->logger->info("Response Status \t: " . $httpStatus);
156
+ $this->logger->debug("Response Headers\t: " . str_replace("\r\n", ", ", $responseHeaders));
157
+
158
+ //Close the curl request
159
+ curl_close($ch);
160
+
161
+ //More Exceptions based on HttpStatus Code
162
+ if (in_array($httpStatus, self::$retryCodes)) {
163
+ $ex = new PayPalConnectionException(
164
+ $this->httpConfig->getUrl(),
165
+ "Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}. " .
166
+ "Retried $retries times."
167
+ );
168
+ $ex->setData($result);
169
+ $this->logger->error("Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}. " .
170
+ "Retried $retries times." . $result);
171
+ $this->logger->debug("\n\n" . str_repeat('=', 128) . "\n");
172
+ throw $ex;
173
+ } else if ($httpStatus < 200 || $httpStatus >= 300) {
174
+ $ex = new PayPalConnectionException(
175
+ $this->httpConfig->getUrl(),
176
+ "Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}.",
177
+ $httpStatus
178
+ );
179
+ $ex->setData($result);
180
+ $this->logger->error("Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}. " . $result );
181
+ $this->logger->debug("\n\n" . str_repeat('=', 128) . "\n");
182
+ throw $ex;
183
+ }
184
+
185
+ $this->logger->debug(($result && $result != '' ? "Response Data \t: " . $result : "No Response Body") . "\n\n" . str_repeat('=', 128) . "\n");
186
+
187
+ //Return result object
188
+ return $result;
189
+ }
190
+
191
+ }
lib/PayPal/Core/PayPalLoggingLevel.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Core;
4
+
5
+ /**
6
+ * Logging Levels.
7
+ * Class containing all the constants for Logging Levels.
8
+ */
9
+ class PayPalLoggingLevel
10
+ {
11
+
12
+ // DEBUG Logging Level
13
+ const DEBUG = 4;
14
+
15
+ // FINE Logging Level
16
+ const FINE = 3;
17
+
18
+ // INFO Logging Level
19
+ const INFO = 2;
20
+
21
+ // WARN Logging Level
22
+ const WARN = 1;
23
+
24
+ // ERROR Logging Level
25
+ const ERROR = 0;
26
+ }
lib/PayPal/Core/PayPalLoggingManager.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Core;
4
+
5
+ /**
6
+ * Simple Logging Manager.
7
+ * This does an error_log for now
8
+ * Potential frameworks to use are PEAR logger, log4php from Apache
9
+ */
10
+ class PayPalLoggingManager
11
+ {
12
+
13
+ /**
14
+ * Default Logging Level
15
+ */
16
+ const DEFAULT_LOGGING_LEVEL = 0;
17
+
18
+ /**
19
+ * Logger Name
20
+ * @var string
21
+ */
22
+ private $loggerName;
23
+
24
+ /**
25
+ * Log Enabled
26
+ *
27
+ * @var bool
28
+ */
29
+ private $isLoggingEnabled;
30
+
31
+ /**
32
+ * Configured Logging Level
33
+ *
34
+ * @var int|mixed
35
+ */
36
+ private $loggingLevel;
37
+
38
+ /**
39
+ * Configured Logging File
40
+ *
41
+ * @var string
42
+ */
43
+ private $loggerFile;
44
+
45
+ /**
46
+ * Returns the singleton object
47
+ *
48
+ * @param string $loggerName
49
+ * @return $this
50
+ */
51
+ public static function getInstance($loggerName = __CLASS__)
52
+ {
53
+ $instance = new self();
54
+ $instance->setLoggerName($loggerName);
55
+ return $instance;
56
+ }
57
+
58
+ /**
59
+ * Sets Logger Name. Generally defaulted to Logging Class
60
+ *
61
+ * @param string $loggerName
62
+ */
63
+ public function setLoggerName($loggerName = __CLASS__)
64
+ {
65
+ $this->loggerName = $loggerName;
66
+ }
67
+
68
+ /**
69
+ * Default Constructor
70
+ */
71
+ public function __construct()
72
+ {
73
+ $config = PayPalConfigManager::getInstance()->getConfigHashmap();
74
+
75
+ $this->isLoggingEnabled = (array_key_exists('log.LogEnabled', $config) && $config['log.LogEnabled'] == '1');
76
+
77
+ if ($this->isLoggingEnabled) {
78
+ $this->loggerFile = ($config['log.FileName']) ? $config['log.FileName'] : ini_get('error_log');
79
+ $loggingLevel = strtoupper($config['log.LogLevel']);
80
+ $this->loggingLevel =
81
+ (isset($loggingLevel) && defined(__NAMESPACE__ . "\\PayPalLoggingLevel::$loggingLevel")) ?
82
+ constant(__NAMESPACE__ . "\\PayPalLoggingLevel::$loggingLevel") :
83
+ PayPalLoggingManager::DEFAULT_LOGGING_LEVEL;
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Default Logger
89
+ *
90
+ * @param string $message
91
+ * @param int $level
92
+ */
93
+ private function log($message, $level = PayPalLoggingLevel::INFO)
94
+ {
95
+ if ($this->isLoggingEnabled) {
96
+ $config = PayPalConfigManager::getInstance()->getConfigHashmap();
97
+ // Check if logging in live
98
+ if (array_key_exists('mode', $config) && $config['mode'] == 'live') {
99
+ // Live should not have logging level above INFO.
100
+ if ($this->loggingLevel >= PayPalLoggingLevel::INFO) {
101
+ // If it is at Debug Level, throw an warning in the log.
102
+ if ($this->loggingLevel == PayPalLoggingLevel::DEBUG) {
103
+ error_log("[" . date('d-m-Y h:i:s') . "] " . $this->loggerName . ": ERROR\t: Not allowed to keep 'Debug' level for Live Environments. Reduced to 'INFO'\n", 3, $this->loggerFile);
104
+ }
105
+ // Reducing it to info level
106
+ $this->loggingLevel = PayPalLoggingLevel::INFO;
107
+ }
108
+ }
109
+
110
+ if ($level <= $this->loggingLevel) {
111
+ error_log("[" . date('d-m-Y h:i:s') . "] " . $this->loggerName . ": $message\n", 3, $this->loggerFile);
112
+ }
113
+ }
114
+ }
115
+
116
+ /**
117
+ * Log Error
118
+ *
119
+ * @param string $message
120
+ */
121
+ public function error($message)
122
+ {
123
+ $this->log("ERROR\t: " . $message, PayPalLoggingLevel::ERROR);
124
+ }
125
+
126
+ /**
127
+ * Log Warning
128
+ *
129
+ * @param string $message
130
+ */
131
+ public function warning($message)
132
+ {
133
+ $this->log("WARNING\t: " . $message, PayPalLoggingLevel::WARN);
134
+ }
135
+
136
+ /**
137
+ * Log Info
138
+ *
139
+ * @param string $message
140
+ */
141
+ public function info($message)
142
+ {
143
+ $this->log("INFO\t: " . $message, PayPalLoggingLevel::INFO);
144
+ }
145
+
146
+ /**
147
+ * Log Fine
148
+ *
149
+ * @param string $message
150
+ */
151
+ public function fine($message)
152
+ {
153
+ $this->log("FINE\t: " . $message, PayPalLoggingLevel::FINE);
154
+ }
155
+
156
+ /**
157
+ * Log Fine
158
+ *
159
+ * @param string $message
160
+ */
161
+ public function debug($message)
162
+ {
163
+ $this->log("DEBUG\t: " . $message, PayPalLoggingLevel::DEBUG);
164
+ }
165
+
166
+ }
lib/PayPal/Core/cacert.pem ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Verisign Class 3 Public Primary Certification Authority
2
+ =======================================================
3
+ -----BEGIN CERTIFICATE-----
4
+ MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkGA1UEBhMCVVMx
5
+ FzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmltYXJ5
6
+ IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVow
7
+ XzELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAz
8
+ IFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUA
9
+ A4GNADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhEBarsAx94
10
+ f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/isI19wKTakyYbnsZogy1Ol
11
+ hec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0GCSqGSIb3DQEBAgUAA4GBALtMEivPLCYA
12
+ TxQT3ab7/AoRhIzzKBxnki98tsX63/Dolbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59Ah
13
+ WM1pF+NEHJwZRDmJXNycAA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2Omuf
14
+ Tqj/ZA1k
15
+ -----END CERTIFICATE-----
16
+
17
+ Verisign Class 3 Public Primary Certification Authority - G2
18
+ ============================================================
19
+ -----BEGIN CERTIFICATE-----
20
+ MIIDAjCCAmsCEH3Z/gfPqB63EHln+6eJNMYwDQYJKoZIhvcNAQEFBQAwgcExCzAJBgNVBAYTAlVT
21
+ MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFy
22
+ eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2ln
23
+ biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVz
24
+ dCBOZXR3b3JrMB4XDTk4MDUxODAwMDAwMFoXDTI4MDgwMTIzNTk1OVowgcExCzAJBgNVBAYTAlVT
25
+ MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFy
26
+ eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2ln
27
+ biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVz
28
+ dCBOZXR3b3JrMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDMXtERXVxp0KvTuWpMmR9ZmDCO
29
+ FoUgRm1HP9SFIIThbbP4pO0M8RcPO/mn+SXXwc+EY/J8Y8+iR/LGWzOOZEAEaMGAuWQcRXfH2G71
30
+ lSk8UOg013gfqLptQ5GVj0VXXn7F+8qkBOvqlzdUMG+7AUcyM83cV5tkaWH4mx0ciU9cZwIDAQAB
31
+ MA0GCSqGSIb3DQEBBQUAA4GBAFFNzb5cy5gZnBWyATl4Lk0PZ3BwmcYQWpSkU01UbSuvDV1Ai2TT
32
+ 1+7eVmGSX6bEHRBhNtMsJzzoKQm5EWR0zLVznxxIqbxhAe7iF6YM40AIOw7n60RzKprxaZLvcRTD
33
+ Oaxxp5EJb+RxBrO6WVcmeQD2+A2iMzAo1KpYoJ2daZH9
34
+ -----END CERTIFICATE-----
35
+
36
+
37
+ Verisign Class 3 Public Primary Certification Authority - G3
38
+ ============================================================
39
+ -----BEGIN CERTIFICATE-----
40
+ MIIEGjCCAwICEQCbfgZJoz5iudXukEhxKe9XMA0GCSqGSIb3DQEBBQUAMIHKMQswCQYDVQQGEwJV
41
+ UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv
42
+ cmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl
43
+ IG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNh
44
+ dGlvbiBBdXRob3JpdHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQsw
45
+ CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRy
46
+ dXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhv
47
+ cml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDMgUHVibGljIFByaW1hcnkg
48
+ Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
49
+ ggEBAMu6nFL8eB8aHm8bN3O9+MlrlBIwT/A2R/XQkQr1F8ilYcEWQE37imGQ5XYgwREGfassbqb1
50
+ EUGO+i2tKmFZpGcmTNDovFJbcCAEWNF6yaRpvIMXZK0Fi7zQWM6NjPXr8EJJC52XJ2cybuGukxUc
51
+ cLwgTS8Y3pKI6GyFVxEa6X7jJhFUokWWVYPKMIno3Nij7SqAP395ZVc+FSBmCC+Vk7+qRy+oRpfw
52
+ EuL+wgorUeZ25rdGt+INpsyow0xZVYnm6FNcHOqd8GIWC6fJXwzw3sJ2zq/3avL6QaaiMxTJ5Xpj
53
+ 055iN9WFZZ4O5lMkdBteHRJTW8cs54NJOxWuimi5V5cCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA
54
+ ERSWwauSCPc/L8my/uRan2Te2yFPhpk0djZX3dAVL8WtfxUfN2JzPtTnX84XA9s1+ivbrmAJXx5f
55
+ j267Cz3qWhMeDGBvtcC1IyIuBwvLqXTLR7sdwdela8wv0kL9Sd2nic9TutoAWii/gt/4uhMdUIaC
56
+ /Y4wjylGsB49Ndo4YhYYSq3mtlFs3q9i6wHQHiT+eo8SGhJouPtmmRQURVyu565pF4ErWjfJXir0
57
+ xuKhXFSbplQAz/DxwceYMBo7Nhbbo27q/a2ywtrvAkcTisDxszGtTxzhT5yvDwyd93gN2PQ1VoDa
58
+ t20Xj50egWTh/sVFuq1ruQp6Tk9LhO5L8X3dEQ==
59
+ -----END CERTIFICATE-----
60
+
61
+ Verisign Class 4 Public Primary Certification Authority - G3
62
+ ============================================================
63
+ -----BEGIN CERTIFICATE-----
64
+ MIIEGjCCAwICEQDsoKeLbnVqAc/EfMwvlF7XMA0GCSqGSIb3DQEBBQUAMIHKMQswCQYDVQQGEwJV
65
+ UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv
66
+ cmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl
67
+ IG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDQgUHVibGljIFByaW1hcnkgQ2VydGlmaWNh
68
+ dGlvbiBBdXRob3JpdHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQsw
69
+ CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRy
70
+ dXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhv
71
+ cml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDQgUHVibGljIFByaW1hcnkg
72
+ Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
73
+ ggEBAK3LpRFpxlmr8Y+1GQ9Wzsy1HyDkniYlS+BzZYlZ3tCD5PUPtbut8XzoIfzk6AzufEUiGXaS
74
+ tBO3IFsJ+mGuqPKljYXCKtbeZjbSmwL0qJJgfJxptI8kHtCGUvYynEFYHiK9zUVilQhu0GbdU6LM
75
+ 8BDcVHOLBKFGMzNcF0C5nk3T875Vg+ixiY5afJqWIpA7iCXy0lOIAgwLePLmNxdLMEYH5IBtptiW
76
+ Lugs+BGzOA1mppvqySNb247i8xOOGlktqgLw7KSHZtzBP/XYufTsgsbSPZUd5cBPhMnZo0QoBmrX
77
+ Razwa2rvTl/4EYIeOGM0ZlDUPpNz+jDDZq3/ky2X7wMCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA
78
+ j/ola09b5KROJ1WrIhVZPMq1CtRK26vdoV9TxaBXOcLORyu+OshWv8LZJxA6sQU8wHcxuzrTBXtt
79
+ mhwwjIDLk5Mqg6sFUYICABFna/OIYUdfA5PVWw3g8dShMjWFsjrbsIKr0csKvE+MW8VLADsfKoKm
80
+ fjaF3H48ZwC15DtS4KjrXRX5xm3wrR0OhbepmnMUWluPQSjA1egtTaRezarZ7c7c2NU8Qh0XwRJd
81
+ RTjDOPP8hS6DRkiy1yBfkjaP53kPmF6Z6PDQpLv1U70qzlmwr25/bLvSHgCwIe34QWKCudiyxLtG
82
+ UPMxxY8BqHTr9Xgn2uf3ZkPznoM+IKrDNWCRzg==
83
+ -----END CERTIFICATE-----
84
+ VeriSign Class 3 Public Primary Certification Authority - G5
85
+ ============================================================
86
+ -----BEGIN CERTIFICATE-----
87
+ MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCByjELMAkGA1UE
88
+ BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO
89
+ ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk
90
+ IHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRp
91
+ ZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCB
92
+ yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2ln
93
+ biBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBh
94
+ dXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmlt
95
+ YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
96
+ ggEKAoIBAQCvJAgIKXo1nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKz
97
+ j/i5Vbext0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIzSdhD
98
+ Y2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQGBO+QueQA5N06tRn/
99
+ Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+rCpSx4/VBEnkjWNHiDxpg8v+R70r
100
+ fk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/
101
+ BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2Uv
102
+ Z2lmMCEwHzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy
103
+ aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKvMzEzMA0GCSqG
104
+ SIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzEp6B4Eq1iDkVwZMXnl2YtmAl+
105
+ X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKE
106
+ KQsTb47bDN0lAtukixlE0kF6BWlKWE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiC
107
+ Km0oHw0LxOXnGiYZ4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vE
108
+ ZV8NhnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq
109
+ -----END CERTIFICATE-----
110
+ VeriSign Universal Root Certification Authority
111
+ ===============================================
112
+ -----BEGIN CERTIFICATE-----
113
+ MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCBvTELMAkGA1UE
114
+ BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO
115
+ ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwOCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk
116
+ IHVzZSBvbmx5MTgwNgYDVQQDEy9WZXJpU2lnbiBVbml2ZXJzYWwgUm9vdCBDZXJ0aWZpY2F0aW9u
117
+ IEF1dGhvcml0eTAeFw0wODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIG9MQswCQYDVQQGEwJV
118
+ UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv
119
+ cmsxOjA4BgNVBAsTMShjKSAyMDA4IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl
120
+ IG9ubHkxODA2BgNVBAMTL1ZlcmlTaWduIFVuaXZlcnNhbCBSb290IENlcnRpZmljYXRpb24gQXV0
121
+ aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx2E3XrEBNNti1xWb/1hajCMj
122
+ 1mCOkdeQmIN65lgZOIzF9uVkhbSicfvtvbnazU0AtMgtc6XHaXGVHzk8skQHnOgO+k1KxCHfKWGP
123
+ MiJhgsWHH26MfF8WIFFE0XBPV+rjHOPMee5Y2A7Cs0WTwCznmhcrewA3ekEzeOEz4vMQGn+HLL72
124
+ 9fdC4uW/h2KJXwBL38Xd5HVEMkE6HnFuacsLdUYI0crSK5XQz/u5QGtkjFdN/BMReYTtXlT2NJ8I
125
+ AfMQJQYXStrxHXpma5hgZqTZ79IugvHw7wnqRMkVauIDbjPTrJ9VAMf2CGqUuV/c4DPxhGD5WycR
126
+ tPwW8rtWaoAljQIDAQABo4GyMIGvMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMG0G
127
+ CCsGAQUFBwEMBGEwX6FdoFswWTBXMFUWCWltYWdlL2dpZjAhMB8wBwYFKw4DAhoEFI/l0xqGrI2O
128
+ a8PPgGrUSBgsexkuMCUWI2h0dHA6Ly9sb2dvLnZlcmlzaWduLmNvbS92c2xvZ28uZ2lmMB0GA1Ud
129
+ DgQWBBS2d/ppSEefUxLVwuoHMnYH0ZcHGTANBgkqhkiG9w0BAQsFAAOCAQEASvj4sAPmLGd75JR3
130
+ Y8xuTPl9Dg3cyLk1uXBPY/ok+myDjEedO2Pzmvl2MpWRsXe8rJq+seQxIcaBlVZaDrHC1LGmWazx
131
+ Y8u4TB1ZkErvkBYoH1quEPuBUDgMbMzxPcP1Y+Oz4yHJJDnp/RVmRvQbEdBNc6N9Rvk97ahfYtTx
132
+ P/jgdFcrGJ2BtMQo2pSXpXDrrB2+BxHw1dvd5Yzw1TKwg+ZX4o+/vqGqvz0dtdQ46tewXDpPaj+P
133
+ wGZsY6rp2aQW9IHRlRQOfc2VNNnSj3BzgXucfr2YYdhFh5iQxeuGMMY1v/D/w1WIg0vvBZIGcfK4
134
+ mJO37M2CYfE45k+XmCpajQ==
135
+ -----END CERTIFICATE-----
136
+
137
+ VeriSign Class 3 Public Primary Certification Authority - G4
138
+ ============================================================
139
+ -----BEGIN CERTIFICATE-----
140
+ MIIDhDCCAwqgAwIBAgIQL4D+I4wOIg9IZxIokYesszAKBggqhkjOPQQDAzCByjELMAkGA1UEBhMC
141
+ VVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3
142
+ b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVz
143
+ ZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmlj
144
+ YXRpb24gQXV0aG9yaXR5IC0gRzQwHhcNMDcxMTA1MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCByjEL
145
+ MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBU
146
+ cnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRo
147
+ b3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5
148
+ IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASnVnp8
149
+ Utpkmw4tXNherJI9/gHmGUo9FANL+mAnINmDiWn6VMaaGF5VKmTeBvaNSjutEDxlPZCIBIngMGGz
150
+ rl0Bp3vefLK+ymVhAIau2o970ImtTR1ZmkGxvEeA3J5iw/mjgbIwga8wDwYDVR0TAQH/BAUwAwEB
151
+ /zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEw
152
+ HzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVyaXNpZ24u
153
+ Y29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFLMWkf3upm7ktS5Jj4d4gYDs5bG1MAoGCCqGSM49BAMD
154
+ A2gAMGUCMGYhDBgmYFo4e1ZC4Kf8NoRRkSAsdk1DPcQdhCPQrNZ8NQbOzWm9kA3bbEhCHQ6qQgIx
155
+ AJw9SDkjOVgaFRJZap7v1VmyHVIsmXHNxynfGyphe3HR3vPA5Q06Sqotp9iGKt0uEA==
156
+ -----END CERTIFICATE-----
157
+ Verisign Class 3 Public Primary Certification Authority
158
+ =======================================================
159
+ -----BEGIN CERTIFICATE-----
160
+ MIICPDCCAaUCEDyRMcsf9tAbDpq40ES/Er4wDQYJKoZIhvcNAQEFBQAwXzELMAkGA1UEBhMCVVMx
161
+ FzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmltYXJ5
162
+ IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2MDEyOTAwMDAwMFoXDTI4MDgwMjIzNTk1OVow
163
+ XzELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAz
164
+ IFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUA
165
+ A4GNADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhEBarsAx94
166
+ f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/isI19wKTakyYbnsZogy1Ol
167
+ hec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0GCSqGSIb3DQEBBQUAA4GBABByUqkFFBky
168
+ CEHwxWsKzH4PIRnN5GfcX6kb5sroc50i2JhucwNhkcV8sEVAbkSdjbCxlnRhLQ2pRdKkkirWmnWX
169
+ bj9T/UWZYB2oK0z5XqcJ2HUw19JlYD1n1khVdWk/kfVIC0dpImmClr7JyDiGSnoscxlIaU5rfGW/
170
+ D/xwzoiQ
171
+ -----END CERTIFICATE-----
lib/PayPal/Exception/PayPalConfigurationException.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Exception;
4
+
5
+ /**
6
+ * Class PayPalConfigurationException
7
+ *
8
+ * @package PayPal\Exception
9
+ */
10
+ class PayPalConfigurationException extends \Exception
11
+ {
12
+
13
+ /**
14
+ * Default Constructor
15
+ *
16
+ * @param string|null $message
17
+ * @param int $code
18
+ */
19
+ public function __construct($message = null, $code = 0)
20
+ {
21
+ parent::__construct($message, $code);
22
+ }
23
+ }
lib/PayPal/Exception/PayPalConnectionException.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Exception;
4
+
5
+ /**
6
+ * Class PayPalConnectionException
7
+ *
8
+ * @package PayPal\Exception
9
+ */
10
+ class PayPalConnectionException extends \Exception
11
+ {
12
+ /**
13
+ * The url that was being connected to when the exception occured
14
+ *
15
+ * @var string
16
+ */
17
+ private $url;
18
+
19
+ /**
20
+ * Any response data that was returned by the server
21
+ *
22
+ * @var string
23
+ */
24
+ private $data;
25
+
26
+ /**
27
+ * Default Constructor
28
+ *
29
+ * @param string $url
30
+ * @param string $message
31
+ * @param int $code
32
+ */
33
+ public function __construct($url, $message, $code = 0)
34
+ {
35
+ parent::__construct($message, $code);
36
+ $this->url = $url;
37
+ }
38
+
39
+ /**
40
+ * Sets Data
41
+ *
42
+ * @param $data
43
+ */
44
+ public function setData($data)
45
+ {
46
+ $this->data = $data;
47
+ }
48
+
49
+ /**
50
+ * Gets Data
51
+ *
52
+ * @return string
53
+ */
54
+ public function getData()
55
+ {
56
+ return $this->data;
57
+ }
58
+
59
+ /**
60
+ * Gets Url
61
+ *
62
+ * @return string
63
+ */
64
+ public function getUrl()
65
+ {
66
+ return $this->url;
67
+ }
68
+ }
lib/PayPal/Exception/PayPalInvalidCredentialException.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Exception;
4
+
5
+ /**
6
+ * Class PayPalInvalidCredentialException
7
+ *
8
+ * @package PayPal\Exception
9
+ */
10
+ class PayPalInvalidCredentialException extends \Exception
11
+ {
12
+
13
+ /**
14
+ * Default Constructor
15
+ *
16
+ * @param string|null $message
17
+ * @param int $code
18
+ */
19
+ public function __construct($message = null, $code = 0)
20
+ {
21
+ parent::__construct($message, $code);
22
+ }
23
+
24
+ /**
25
+ * prints error message
26
+ *
27
+ * @return string
28
+ */
29
+ public function errorMessage()
30
+ {
31
+ $errorMsg = 'Error on line ' . $this->getLine() . ' in ' . $this->getFile()
32
+ . ': <b>' . $this->getMessage() . '</b>';
33
+ return $errorMsg;
34
+ }
35
+
36
+ }
lib/PayPal/Exception/PayPalMissingCredentialException.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Exception;
4
+
5
+ /**
6
+ * Class PayPalMissingCredentialException
7
+ *
8
+ * @package PayPal\Exception
9
+ */
10
+ class PayPalMissingCredentialException extends \Exception
11
+ {
12
+
13
+ /**
14
+ * Default Constructor
15
+ *
16
+ * @param string $message
17
+ * @param int $code
18
+ */
19
+ public function __construct($message = null, $code = 0)
20
+ {
21
+ parent::__construct($message, $code);
22
+ }
23
+
24
+ /**
25
+ * prints error message
26
+ *
27
+ * @return string
28
+ */
29
+ public function errorMessage()
30
+ {
31
+ $errorMsg = 'Error on line ' . $this->getLine() . ' in ' . $this->getFile()
32
+ . ': <b>' . $this->getMessage() . '</b>';
33
+
34
+ return $errorMsg;
35
+ }
36
+
37
+ }
lib/PayPal/Handler/IPayPalHandler.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Handler;
4
+
5
+ /**
6
+ * Interface IPayPalHandler
7
+ *
8
+ * @package PayPal\Handler
9
+ */
10
+ interface IPayPalHandler
11
+ {
12
+ /**
13
+ *
14
+ * @param \Paypal\Core\PayPalHttpConfig $httpConfig
15
+ * @param string $request
16
+ * @param mixed $options
17
+ * @return mixed
18
+ */
19
+ public function handle($httpConfig, $request, $options);
20
+ }
lib/PayPal/Handler/OauthHandler.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * API handler for OAuth Token Request REST API calls
4
+ */
5
+
6
+ namespace PayPal\Handler;
7
+
8
+ use PayPal\Common\PayPalUserAgent;
9
+ use PayPal\Core\PayPalConstants;
10
+ use PayPal\Core\PayPalHttpConfig;
11
+ use PayPal\Exception\PayPalConfigurationException;
12
+ use PayPal\Exception\PayPalInvalidCredentialException;
13
+ use PayPal\Exception\PayPalMissingCredentialException;
14
+
15
+ /**
16
+ * Class OauthHandler
17
+ */
18
+ class OauthHandler implements IPayPalHandler
19
+ {
20
+ /**
21
+ * Private Variable
22
+ *
23
+ * @var \Paypal\Rest\ApiContext $apiContext
24
+ */
25
+ private $apiContext;
26
+
27
+ /**
28
+ * Construct
29
+ *
30
+ * @param \Paypal\Rest\ApiContext $apiContext
31
+ */
32
+ public function __construct($apiContext)
33
+ {
34
+ $this->apiContext = $apiContext;
35
+ }
36
+
37
+ /**
38
+ * @param PayPalHttpConfig $httpConfig
39
+ * @param string $request
40
+ * @param mixed $options
41
+ * @return mixed|void
42
+ * @throws PayPalConfigurationException
43
+ * @throws PayPalInvalidCredentialException
44
+ * @throws PayPalMissingCredentialException
45
+ */
46
+ public function handle($httpConfig, $request, $options)
47
+ {
48
+ $config = $this->apiContext->getConfig();
49
+
50
+ $httpConfig->setUrl(
51
+ rtrim(trim($this->_getEndpoint($config)), '/') .
52
+ (isset($options['path']) ? $options['path'] : '')
53
+ );
54
+
55
+ $headers = array(
56
+ "User-Agent" => PayPalUserAgent::getValue(PayPalConstants::SDK_NAME, PayPalConstants::SDK_VERSION),
57
+ "Authorization" => "Basic " . base64_encode($options['clientId'] . ":" . $options['clientSecret']),
58
+ "Accept" => "*/*"
59
+ );
60
+ $httpConfig->setHeaders($headers);
61
+
62
+ // Add any additional Headers that they may have provided
63
+ $headers = $this->apiContext->getRequestHeaders();
64
+ foreach ($headers as $key => $value) {
65
+ $httpConfig->addHeader($key, $value);
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Get HttpConfiguration object for OAuth API
71
+ *
72
+ * @param array $config
73
+ *
74
+ * @return PayPalHttpConfig
75
+ * @throws \PayPal\Exception\PayPalConfigurationException
76
+ */
77
+ private static function _getEndpoint($config)
78
+ {
79
+ if (isset($config['oauth.EndPoint'])) {
80
+ $baseEndpoint = $config['oauth.EndPoint'];
81
+ } else if (isset($config['service.EndPoint'])) {
82
+ $baseEndpoint = $config['service.EndPoint'];
83
+ } else if (isset($config['mode'])) {
84
+ switch (strtoupper($config['mode'])) {
85
+ case 'SANDBOX':
86
+ $baseEndpoint = PayPalConstants::REST_SANDBOX_ENDPOINT;
87
+ break;
88
+ case 'LIVE':
89
+ $baseEndpoint = PayPalConstants::REST_LIVE_ENDPOINT;
90
+ break;
91
+ default:
92
+ throw new PayPalConfigurationException('The mode config parameter must be set to either sandbox/live');
93
+ }
94
+ } else {
95
+ // Defaulting to Sandbox
96
+ $baseEndpoint = PayPalConstants::REST_SANDBOX_ENDPOINT;
97
+ }
98
+
99
+ $baseEndpoint = rtrim(trim($baseEndpoint), '/') . "/v1/oauth2/token";
100
+
101
+ return $baseEndpoint;
102
+ }
103
+ }
lib/PayPal/Handler/RestHandler.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * API handler for all REST API calls
4
+ */
5
+
6
+ namespace PayPal\Handler;
7
+
8
+ use PayPal\Auth\OAuthTokenCredential;
9
+ use PayPal\Common\PayPalUserAgent;
10
+ use PayPal\Core\PayPalConstants;
11
+ use PayPal\Core\PayPalCredentialManager;
12
+ use PayPal\Core\PayPalHttpConfig;
13
+ use PayPal\Exception\PayPalConfigurationException;
14
+ use PayPal\Exception\PayPalInvalidCredentialException;
15
+ use PayPal\Exception\PayPalMissingCredentialException;
16
+
17
+ /**
18
+ * Class RestHandler
19
+ */
20
+ class RestHandler implements IPayPalHandler
21
+ {
22
+ /**
23
+ * Private Variable
24
+ *
25
+ * @var \Paypal\Rest\ApiContext $apiContext
26
+ */
27
+ private $apiContext;
28
+
29
+ /**
30
+ * Construct
31
+ *
32
+ * @param \Paypal\Rest\ApiContext $apiContext
33
+ */
34
+ public function __construct($apiContext)
35
+ {
36
+ $this->apiContext = $apiContext;
37
+ }
38
+
39
+ /**
40
+ * @param PayPalHttpConfig $httpConfig
41
+ * @param string $request
42
+ * @param mixed $options
43
+ * @return mixed|void
44
+ * @throws PayPalConfigurationException
45
+ * @throws PayPalInvalidCredentialException
46
+ * @throws PayPalMissingCredentialException
47
+ */
48
+ public function handle($httpConfig, $request, $options)
49
+ {
50
+
51
+ $credential = $this->apiContext->getCredential();
52
+ $config = $this->apiContext->getConfig();
53
+
54
+ if ($credential == null) {
55
+ // Try picking credentials from the config file
56
+ $credMgr = PayPalCredentialManager::getInstance($config);
57
+ $credValues = $credMgr->getCredentialObject();
58
+
59
+ if (!is_array($credValues)) {
60
+ throw new PayPalMissingCredentialException("Empty or invalid credentials passed");
61
+ }
62
+
63
+ $credential = new OAuthTokenCredential($credValues['clientId'], $credValues['clientSecret']);
64
+ }
65
+
66
+ if ($credential == null || !($credential instanceof OAuthTokenCredential)) {
67
+ throw new PayPalInvalidCredentialException("Invalid credentials passed");
68
+ }
69
+
70
+ $httpConfig->setUrl(
71
+ rtrim(trim($this->_getEndpoint($config)), '/') .
72
+ (isset($options['path']) ? $options['path'] : '')
73
+ );
74
+
75
+ // Overwrite Expect Header to disable 100 Continue Issue
76
+ $httpConfig->addHeader("Expect", null);
77
+
78
+ if (!array_key_exists("User-Agent", $httpConfig->getHeaders())) {
79
+ $httpConfig->addHeader("User-Agent", PayPalUserAgent::getValue(PayPalConstants::SDK_NAME, PayPalConstants::SDK_VERSION));
80
+ }
81
+
82
+ if (!is_null($credential) && $credential instanceof OAuthTokenCredential && is_null($httpConfig->getHeader('Authorization'))) {
83
+ $httpConfig->addHeader('Authorization', "Bearer " . $credential->getAccessToken($config), false);
84
+ }
85
+
86
+ if ($httpConfig->getMethod() == 'POST' || $httpConfig->getMethod() == 'PUT') {
87
+ $httpConfig->addHeader('PayPal-Request-Id', $this->apiContext->getRequestId());
88
+ }
89
+ // Add any additional Headers that they may have provided
90
+ $headers = $this->apiContext->getRequestHeaders();
91
+ foreach ($headers as $key => $value) {
92
+ $httpConfig->addHeader($key, $value);
93
+ }
94
+ }
95
+
96
+ /**
97
+ * End Point
98
+ *
99
+ * @param array $config
100
+ *
101
+ * @return string
102
+ * @throws \PayPal\Exception\PayPalConfigurationException
103
+ */
104
+ private function _getEndpoint($config)
105
+ {
106
+ if (isset($config['service.EndPoint'])) {
107
+ return $config['service.EndPoint'];
108
+ } else if (isset($config['mode'])) {
109
+ switch (strtoupper($config['mode'])) {
110
+ case 'SANDBOX':
111
+ return PayPalConstants::REST_SANDBOX_ENDPOINT;
112
+ break;
113
+ case 'LIVE':
114
+ return PayPalConstants::REST_LIVE_ENDPOINT;
115
+ break;
116
+ default:
117
+ throw new PayPalConfigurationException('The mode config parameter must be set to either sandbox/live');
118
+ break;
119
+ }
120
+ } else {
121
+ // Defaulting to Sandbox
122
+ return PayPalConstants::REST_SANDBOX_ENDPOINT;
123
+ }
124
+ }
125
+ }
lib/PayPal/Rest/ApiContext.php ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Rest;
4
+
5
+ use PayPal\Core\PayPalConfigManager;
6
+ use PayPal\Core\PayPalCredentialManager;
7
+
8
+ /**
9
+ * Class ApiContext
10
+ *
11
+ * Call level parameters such as request id, credentials etc
12
+ *
13
+ * @package PayPal\Rest
14
+ */
15
+ class ApiContext
16
+ {
17
+
18
+ /**
19
+ * Unique request id to be used for this call
20
+ * The user can either generate one as per application
21
+ * needs or let the SDK generate one
22
+ *
23
+ * @var null|string $requestId
24
+ */
25
+ private $requestId;
26
+
27
+ /**
28
+ * This is a placeholder for holding credential for the request
29
+ * If the value is not set, it would get the value from @\PayPal\Core\PayPalCredentialManager
30
+ *
31
+ * @var \Paypal\Auth\OAuthTokenCredential
32
+ */
33
+ private $credential;
34
+
35
+
36
+ /**
37
+ * Construct
38
+ *
39
+ * @param \PayPal\Auth\OAuthTokenCredential $credential
40
+ * @param string|null $requestId
41
+ */
42
+ public function __construct($credential = null, $requestId = null)
43
+ {
44
+ $this->requestId = $requestId;
45
+ $this->credential = $credential;
46
+ }
47
+
48
+ /**
49
+ * Get Credential
50
+ *
51
+ * @return \PayPal\Auth\OAuthTokenCredential
52
+ */
53
+ public function getCredential()
54
+ {
55
+ if ($this->credential == null) {
56
+ return PayPalCredentialManager::getInstance()->getCredentialObject();
57
+ }
58
+ return $this->credential;
59
+ }
60
+
61
+ public function getRequestHeaders()
62
+ {
63
+ $result = PayPalConfigManager::getInstance()->get('http.headers');
64
+ $headers = array();
65
+ foreach ($result as $header => $value) {
66
+ $headerName = ltrim($header, 'http.headers');
67
+ $headers[$headerName] = $value;
68
+ }
69
+ return $headers;
70
+ }
71
+
72
+ public function addRequestHeader($name, $value)
73
+ {
74
+ // Determine if the name already has a 'http.headers' prefix. If not, add one.
75
+ if (!(substr($name, 0, strlen('http.headers')) === 'http.headers')) {
76
+ $name = 'http.headers.' . $name;
77
+ }
78
+ PayPalConfigManager::getInstance()->addConfigs(array($name => $value));
79
+ }
80
+
81
+ /**
82
+ * Get Request ID
83
+ *
84
+ * @return string
85
+ */
86
+ public function getRequestId()
87
+ {
88
+ if ($this->requestId == null) {
89
+ $this->requestId = $this->generateRequestId();
90
+ }
91
+
92
+ return $this->requestId;
93
+ }
94
+
95
+ /**
96
+ * Resets the requestId that can be used to set the PayPal-request-id
97
+ * header used for idempotency. In cases where you need to make multiple create calls
98
+ * using the same ApiContext object, you need to reset request Id.
99
+ *
100
+ * @return string
101
+ */
102
+ public function resetRequestId()
103
+ {
104
+ $this->requestId = $this->generateRequestId();
105
+ return $this->getRequestId();
106
+ }
107
+
108
+ /**
109
+ * Sets Config
110
+ *
111
+ * @param array $config SDK configuration parameters
112
+ */
113
+ public function setConfig(array $config)
114
+ {
115
+ PayPalConfigManager::getInstance()->addConfigs($config);
116
+ }
117
+
118
+ /**
119
+ * Gets Configurations
120
+ *
121
+ * @return array
122
+ */
123
+ public function getConfig()
124
+ {
125
+ return PayPalConfigManager::getInstance()->getConfigHashmap();
126
+ }
127
+
128
+ /**
129
+ * Gets a specific configuration from key
130
+ *
131
+ * @param $searchKey
132
+ * @return mixed
133
+ */
134
+ public function get($searchKey)
135
+ {
136
+ return PayPalConfigManager::getInstance()->get($searchKey);
137
+ }
138
+
139
+ /**
140
+ * Generates a unique per request id that
141
+ * can be used to set the PayPal-Request-Id header
142
+ * that is used for idempotency
143
+ *
144
+ * @return string
145
+ */
146
+ private function generateRequestId()
147
+ {
148
+ static $pid = -1;
149
+ static $addr = -1;
150
+
151
+ if ($pid == -1) {
152
+ $pid = getmypid();
153
+ }
154
+
155
+ if ($addr == -1) {
156
+ if (array_key_exists('SERVER_ADDR', $_SERVER)) {
157
+ $addr = ip2long($_SERVER['SERVER_ADDR']);
158
+ } else {
159
+ $addr = php_uname('n');
160
+ }
161
+ }
162
+
163
+ return $addr . $pid . $_SERVER['REQUEST_TIME'] . mt_rand(0, 0xffff);
164
+ }
165
+ }
lib/PayPal/Rest/IResource.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Rest;
4
+
5
+ /**
6
+ * Interface IResource
7
+ *
8
+ * @package PayPal\Rest
9
+ */
10
+ interface IResource
11
+ {
12
+ }
lib/PayPal/Security/Cipher.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Security;
4
+
5
+ /**
6
+ * Class Cipher
7
+ *
8
+ * Helper class to encrypt/decrypt data with secret key
9
+ *
10
+ * @package PayPal\Security
11
+ */
12
+ class Cipher
13
+ {
14
+ private $secretKey;
15
+
16
+ /**
17
+ * Fixed IV Size
18
+ */
19
+ const IV_SIZE = 16;
20
+
21
+ function __construct($secretKey)
22
+ {
23
+ $this->secretKey = $secretKey;
24
+ }
25
+
26
+ /**
27
+ * Encrypts the input text using the cipher key
28
+ *
29
+ * @param $input
30
+ * @return string
31
+ */
32
+ function encrypt($input)
33
+ {
34
+ // Create a random IV. Not using mcrypt to generate one, as to not have a dependency on it.
35
+ $iv = substr(uniqid("", true), 0, Cipher::IV_SIZE);
36
+ // Encrypt the data
37
+ $encrypted = openssl_encrypt($input, "AES-256-CBC", $this->secretKey, 0, $iv);
38
+ // Encode the data with IV as prefix
39
+ return base64_encode($iv . $encrypted);
40
+ }
41
+
42
+ /**
43
+ * Decrypts the input text from the cipher key
44
+ *
45
+ * @param $input
46
+ * @return string
47
+ */
48
+ function decrypt($input)
49
+ {
50
+ // Decode the IV + data
51
+ $input = base64_decode($input);
52
+ // Remove the IV
53
+ $iv = substr($input, 0, Cipher::IV_SIZE);
54
+ // Return Decrypted Data
55
+ return openssl_decrypt(substr($input, Cipher::IV_SIZE), "AES-256-CBC", $this->secretKey, 0, $iv);
56
+ }
57
+ }
lib/PayPal/Transport/PayPalRestCall.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PayPal\Transport;
3
+
4
+ use PayPal\Core\PayPalHttpConfig;
5
+ use PayPal\Core\PayPalHttpConnection;
6
+ use PayPal\Core\PayPalLoggingManager;
7
+ use PayPal\Rest\ApiContext;
8
+
9
+ /**
10
+ * Class PayPalRestCall
11
+ *
12
+ * @package PayPal\Transport
13
+ */
14
+ class PayPalRestCall
15
+ {
16
+
17
+
18
+ /**
19
+ * Paypal Logger
20
+ *
21
+ * @var PayPalLoggingManager logger interface
22
+ */
23
+ private $logger;
24
+
25
+ /**
26
+ * API Context
27
+ *
28
+ * @var ApiContext
29
+ */
30
+ private $apiContext;
31
+
32
+
33
+ /**
34
+ * Default Constructor
35
+ *
36
+ * @param ApiContext $apiContext
37
+ */
38
+ public function __construct(ApiContext $apiContext)
39
+ {
40
+ $this->apiContext = $apiContext;
41
+ $this->logger = PayPalLoggingManager::getInstance(__CLASS__);
42
+ }
43
+
44
+ /**
45
+ * @param array $handlers Array of handlers
46
+ * @param string $path Resource path relative to base service endpoint
47
+ * @param string $method HTTP method - one of GET, POST, PUT, DELETE, PATCH etc
48
+ * @param string $data Request payload
49
+ * @param array $headers HTTP headers
50
+ * @return mixed
51
+ * @throws \PayPal\Exception\PayPalConnectionException
52
+ */
53
+ public function execute($handlers = array(), $path, $method, $data = '', $headers = array())
54
+ {
55
+
56
+ $config = $this->apiContext->getConfig();
57
+ $httpConfig = new PayPalHttpConfig(null, $method, $config);
58
+ $headers = $headers ? $headers : array();
59
+ $httpConfig->setHeaders($headers +
60
+ array(
61
+ 'Content-Type' => 'application/json'
62
+ )
63
+ );
64
+
65
+ /** @var \Paypal\Handler\IPayPalHandler $handler */
66
+ foreach ($handlers as $handler) {
67
+ if (!is_object($handler)) {
68
+ $fullHandler = "\\" . (string)$handler;
69
+ $handler = new $fullHandler($this->apiContext);
70
+ }
71
+ $handler->handle($httpConfig, $data, array('path' => $path, 'apiContext' => $this->apiContext));
72
+ }
73
+ $connection = new PayPalHttpConnection($httpConfig, $config);
74
+ $response = $connection->execute($data);
75
+
76
+ return $response;
77
+ }
78
+
79
+ }
lib/PayPal/Validation/ArgumentValidator.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Validation;
4
+
5
+ /**
6
+ * Class ArgumentValidator
7
+ *
8
+ * @package PayPal\Validation
9
+ */
10
+ class ArgumentValidator
11
+ {
12
+
13
+ /**
14
+ * Helper method for validating an argument that will be used by this API in any requests.
15
+ *
16
+ * @param $argument mixed The object to be validated
17
+ * @param $argumentName string|null The name of the argument.
18
+ * This will be placed in the exception message for easy reference
19
+ * @return bool
20
+ */
21
+ public static function validate($argument, $argumentName = null)
22
+ {
23
+ if ($argument === null) {
24
+ // Error if Object Null
25
+ throw new \InvalidArgumentException("$argumentName cannot be null");
26
+ } else if (gettype($argument) == 'string' && trim($argument) == ''){
27
+ // Error if String Empty
28
+ throw new \InvalidArgumentException("$argumentName string cannot be empty");
29
+ }
30
+ return true;
31
+ }
32
+ }
lib/PayPal/Validation/JsonValidator.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Validation;
4
+
5
+ /**
6
+ * Class JsonValidator
7
+ *
8
+ * @package PayPal\Validation
9
+ */
10
+ class JsonValidator
11
+ {
12
+
13
+ /**
14
+ * Helper method for validating if string provided is a valid json.
15
+ *
16
+ * @param string $string String representation of Json object
17
+ * @param bool $silent Flag to not throw \InvalidArgumentException
18
+ * @return bool
19
+ */
20
+ public static function validate($string, $silent = false)
21
+ {
22
+ @json_decode($string);
23
+ if (json_last_error() != JSON_ERROR_NONE) {
24
+ if ($string === '' || $string === null) {
25
+ return true;
26
+ }
27
+ if ($silent == false) {
28
+ //Throw an Exception for string or array
29
+ throw new \InvalidArgumentException("Invalid JSON String");
30
+ }
31
+ return false;
32
+ }
33
+ return true;
34
+ }
35
+ }
lib/PayPal/Validation/NumericValidator.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Validation;
4
+
5
+ /**
6
+ * Class NumericValidator
7
+ *
8
+ * @package PayPal\Validation
9
+ */
10
+ class NumericValidator
11
+ {
12
+
13
+ /**
14
+ * Helper method for validating an argument if it is numeric
15
+ *
16
+ * @param mixed $argument
17
+ * @param string|null $argumentName
18
+ * @return bool
19
+ */
20
+ public static function validate($argument, $argumentName = null)
21
+ {
22
+ if (trim($argument) != null && !is_numeric($argument)) {
23
+ throw new \InvalidArgumentException("$argumentName is not a valid numeric value");
24
+
25
+ }
26
+ return true;
27
+ }
28
+ }
lib/PayPal/Validation/UrlValidator.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayPal\Validation;
4
+
5
+ /**
6
+ * Class UrlValidator
7
+ *
8
+ * @package PayPal\Validation
9
+ */
10
+ class UrlValidator
11
+ {
12
+
13
+ /**
14
+ * Helper method for validating URLs that will be used by this API in any requests.
15
+ *
16
+ * @param $url
17
+ * @param string|null $urlName
18
+ * @throws \InvalidArgumentException
19
+ */
20
+ public static function validate($url, $urlName = null)
21
+ {
22
+ if (filter_var($url, FILTER_VALIDATE_URL) === false) {
23
+ throw new \InvalidArgumentException("$urlName is not a fully qualified URL");
24
+ }
25
+ }
26
+ }
package.xml ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Iways_PayPalPlus</name>
4
+ <version>1.7.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>PayPal PLUS is a solution where PayPal offers PayPal, Credit Card and ELV (pay upon invoice will be added in a later phase) as individual payment options on the payment selection page.</summary>
10
+ <description>PayPal PLUS is a solution where PayPal offers PayPal, Credit Card and ELV (pay upon invoice will be added in a later phase) as individual payment options on the payment selection page.&#xD;
11
+ &#xD;
12
+ Based on the payment method selected by the buyer, he will at a later stage be presented with either the PayPal Login page or an input mask for bank / credit card details.</description>
13
+ <notes>==== 1.7.0 ====&#xD;
14
+ Update PayPal Rest SDK to 1.6.4&#xD;
15
+ Fixed parent transaction id&#xD;
16
+ Fixed wrong PayPal payment id in Idev_OSC&#xD;
17
+ Added partial refund&#xD;
18
+ Show payment instructions for manual banktransfer payments on order success page&#xD;
19
+ Added totals to patchPayment&#xD;
20
+ Possible MagentoConnect File-&gt;directory fix&#xD;
21
+ &#xD;
22
+ ==== 1.6.2 ====&#xD;
23
+ Enable/disable loading indicator for PayPal Plus iframe&#xD;
24
+ Fixed order status if PayPal payment is still pending (Now payment_review until Webhooks approves payment)&#xD;
25
+ ==== 1.6.1 ====&#xD;
26
+ Fixed suspected fraud for different currency&#xD;
27
+ Changed payment method title for germany in frontend&#xD;
28
+ &#xD;
29
+ ==== 1.6.0 ====&#xD;
30
+ Added support for IWD_OSC&#xD;
31
+ Fixed problem with store code in url&#xD;
32
+ Changed first recieved transaction id from PayPal to transaction id from payment id&#xD;
33
+ &#xD;
34
+ &#xD;
35
+ ==== 1.5.2 ====&#xD;
36
+ Fixed state/status of authorizations and gateway-confirmation&#xD;
37
+ Added last transaction number to order information&#xD;
38
+ Added transfer order's id as invoice number setting&#xD;
39
+ &#xD;
40
+ ==== 1.5.1 ====&#xD;
41
+ Fixed paymentmethod choice for Idev_OSC&#xD;
42
+ Updated PayPal SDK to 1.6&#xD;
43
+ &#xD;
44
+ ==== 1.5.0 ====&#xD;
45
+ Added support for Payment upon Invoice&#xD;
46
+ &#xD;
47
+ ==== 1.4.5 ====&#xD;
48
+ Added information block to checkout/success&#xD;
49
+ &#xD;
50
+ ==== 1.4.4 ====&#xD;
51
+ Fixed wrong locale code in presentation error&#xD;
52
+ &#xD;
53
+ ==== 1.4.3 ====&#xD;
54
+ Fixed empty order status Magento 1.7&#xD;
55
+ Added localisation&#xD;
56
+ &#xD;
57
+ ==== 1.4.2 ====&#xD;
58
+ Force webhooks url to be https even if not&#xD;
59
+ Fixed tax calculation with discount&#xD;
60
+ &#xD;
61
+ ==== 1.4.1 ====&#xD;
62
+ Fixed none responding payment method select&#xD;
63
+ Removed unnecessary code line&#xD;
64
+ &#xD;
65
+ ==== 1.4.0 ====&#xD;
66
+ Added support for TM_Firecheckout and Magestore_Onestepcheckout&#xD;
67
+ Added form key validateion for Magento 1.9</notes>
68
+ <authors><author><name>i-ways sales solutions GmbH</name><user>iways_magento</user><email>magento@i-ways.de</email></author><author><name>Robert Hillebrand</name><user>robat</user><email>hillebrand@i-ways.de</email></author></authors>
69
+ <date>2016-03-11</date>
70
+ <time>13:48:07</time>
71
+ <contents><target name="magecommunity"><dir name="Iways"><dir name="PayPalPlus"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Payment.php" hash="b39107fb6a77525fa2c4e7eef9c00622"/></dir><file name="Thirdpartyinfo.php" hash="d9bee1de53c95b487e59c594d1fe80af"/></dir></dir></dir><dir name="Onepage"><dir name="Payment"><file name="Methods.php" hash="006b15175f8706610cb48371f0373c6b"/></dir><file name="Success.php" hash="2270b25b0f1b4451ffdeb574c17aaa60"/></dir><dir name="Payment"><file name="Form.php" hash="3ed060b7d3f4fa2d470d956eddb7c8b7"/><file name="Info.php" hash="7d580974e47366e30ad3c596f7b841ca"/></dir></dir><dir name="Helper"><file name="Data.php" hash="3175693a33b895e01f6854643fcbd40b"/></dir><dir name="Model"><file name="Api.php" hash="30a5787c11ee9686884568bf0d129fb0"/><dir name="Api2"><dir name="Order"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="4a2d2653d4185d813ec443a39f1deda6"/></dir><dir name="Customer"><file name="V1.php" hash="ab2c8ed8f7a513923924b5af173c88fa"/></dir></dir><file name="Rest.php" hash="bd1965bbe2a88d98fbc8dd8bfcce4211"/></dir><file name="Order.php" hash="4e710744d0bf27c1477f7d61ad8b1ed8"/></dir><file name="Autoloader.php" hash="071318081a1896009334c6202457a004"/><file name="Observer.php" hash="d33925459ea015a7c858e14c38da1bfe"/><file name="Payment.php" hash="729ef5f1c735439bdec0d28faf8a5a40"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Mode.php" hash="b5fa6748dc151b22f386952764cae366"/><file name="Thirdpartymoduls.php" hash="5400f09fb1f24e877cbd3a8c81f7e237"/></dir></dir></dir><dir name="Webhook"><file name="Event.php" hash="d547f59c986e268d4daadfe1841981ba"/></dir></dir><file name="RELEASE_NOTES.txt" hash="e1ae012d299b726d1a8403316e2f7f52"/><dir name="controllers"><file name="IndexController.php" hash="dc9485a35c1555a2e5e56ae1f6bce375"/></dir><dir name="etc"><file name="api2.xml" hash="b6960f0761b795e7cc420bcb7352eec0"/><file name="config.xml" hash="84baabbb47f04642532a53ddbf075d4f"/><file name="system.xml" hash="5249ba61419d7375c5aa1c8d537e89eb"/><file name="wsdl.xml" hash="cc0f30b1164095c431d8c86c7bb73aba"/><file name="wsi.xml" hash="fcf0fd620181006c2d38d3409749e0a5"/></dir><dir name="sql"><dir name="iways_paypalplus_setup"><file name="install-1.5.0.php" hash="08f4cb2451999b645938ea286e4e47a7"/><file name="upgrade-1.4.5-1.5.0.php" hash="08f4cb2451999b645938ea286e4e47a7"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="paypalplus"><dir name="form"><file name="payment.phtml" hash="06ea054bec3b1924830b7d7afc2f5b3e"/></dir><file name="methods.phtml" hash="850b5e4e7b151a75390139018591d0d0"/><dir name="payment"><file name="info.phtml" hash="a7ce3e7f52e76b6438a3b15347b5efd6"/></dir><dir name="review"><file name="button.phtml" hash="25ac7756f31ad6c60fd01ef6e63db4e8"/></dir><file name="success.phtml" hash="166123ef13ac78faf3d5b404c7596139"/></dir></dir><dir name="layout"><file name="iways_paypalplus.xml" hash="3b6aa7dd109c9433fc32bbda61beaa45"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="paypalplus"><dir><dir name="payment"><file name="info.phtml" hash="dac1490669ed6fe1242ca08802d5a92a"/><dir name="pdf"><file name="info.phtml" hash="534abe39ab464b71b04fecb0581dcf7a"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Iways_PayPalPlus.xml" hash="3c3b187e1a2860bd376e26173a9abd00"/></dir></target><target name="magelocale"><dir name="de_DE"><file name="Iways_PayPalPlus.csv" hash="a334682da80d865824ad976697b7b902"/></dir></target><target name="magelib"><dir name="PayPal"><dir name="Api"><file name="Address.php" hash="9d0ab517cafbff834d19c5628f71c1d1"/><file name="Agreement.php" hash="346a1aec08bce0a94988c95c421bf26a"/><file name="AgreementDetails.php" hash="c28e00d1e2f43e715ee6dca41b4bbae0"/><file name="AgreementStateDescriptor.php" hash="7492486e86af3fa602fd40b3c6884f9c"/><file name="AgreementTransaction.php" hash="70333874a6d6e59f760eea62bee1ec49"/><file name="AgreementTransactions.php" hash="e3ab61b9adcbecf03ffafe3dab80f71e"/><file name="AlternatePayment.php" hash="299b1913efa1f5052f6525643b88251e"/><file name="Amount.php" hash="af5d5175363d779a696120439335b61e"/><file name="Authorization.php" hash="109c312c1b52182eb1885d9d8721377b"/><file name="BankAccount.php" hash="65d61f63e75ffd25fc368c50256f9484"/><file name="BankAccountsList.php" hash="4d7a9083615d9ed5f82834310ed9afba"/><file name="BankToken.php" hash="62f7ba5228d9e22ae4605fbdf8900364"/><file name="BaseAddress.php" hash="b1b7223a81a9f841c4b900fc42122c51"/><file name="Billing.php" hash="38246f4ccdd0e6af716f3a5710ab7f72"/><file name="BillingAgreementToken.php" hash="b414a03bddd46352124d38e0b8cd464d"/><file name="BillingInfo.php" hash="30423445dc705f10ae47fff4808be22e"/><file name="CancelNotification.php" hash="4e7be9c711e63d5e2c3c93ff719503c1"/><file name="Capture.php" hash="2b4d201cb7cffcb5213fbcf692e89baa"/><file name="CarrierAccount.php" hash="53d36ebafdfd57f8b3bb5ed59b5ae994"/><file name="CarrierAccountToken.php" hash="813e1e683efc5767a966b4e9e1932a22"/><file name="CartBase.php" hash="df26a3bab1a95828c86a65182d5a0327"/><file name="ChargeModel.php" hash="889ba10df61538ed2027b5af7cbf5e37"/><file name="Cost.php" hash="9f70896e83f6dba7a781b7a183c0ff9d"/><file name="CountryCode.php" hash="b4dfc82a2948f495f32615ba8c6648ed"/><file name="CreateProfileResponse.php" hash="9a554170a175aa9c82482a35cd1674f1"/><file name="Credit.php" hash="2a311a58dbfe6ece44fe068b3813a3e7"/><file name="CreditCard.php" hash="1b7242f2db7707ff8926805c74b24fd3"/><file name="CreditCardHistory.php" hash="a54d0cc39e54b937466ba5779be6082d"/><file name="CreditCardList.php" hash="321ef25d43a00d8a83291b6c99a660a0"/><file name="CreditCardToken.php" hash="db28406f0f7dc492633212800d7af26a"/><file name="CreditFinancingOffered.php" hash="7bfcd390d43f4f257966932407579482"/><file name="Currency.php" hash="ae31b2376a97260b4e0e6f0467ad2b37"/><file name="CurrencyConversion.php" hash="6903ea8093e972d434203442f0c9cbad"/><file name="CustomAmount.php" hash="cad62a51d15b03d1220ad6a32d572b93"/><file name="Details.php" hash="cb438e70e4e643bd809a3bdc4151a50e"/><file name="Error.php" hash="8e6c906c9b49a8da31a7d1de9ca56e1a"/><file name="ErrorDetails.php" hash="3c96de8a7428c3efb4cab6a0d30651fe"/><file name="ExtendedBankAccount.php" hash="e6320a07d3795a8a82532f4639a70a97"/><file name="ExternalFunding.php" hash="fca94624795066ed0c319598c870fd57"/><file name="FlowConfig.php" hash="cf61bf1df6b3e190d697fae6aeb18105"/><file name="FmfDetails.php" hash="640d162ae40cef473a14d92b4f7be3db"/><file name="FundingDetail.php" hash="0a59087007ccd6ae2e654e1d61877811"/><file name="FundingInstrument.php" hash="ff8c9933af8c830b2b2eac68b2ff3931"/><file name="FundingOption.php" hash="5a53081c94c25803898bb591fc36ca28"/><file name="FundingSource.php" hash="d75290b8f2686b9aaaa4490c31e35280"/><file name="FuturePayment.php" hash="3e659a3501ab07bd341a1127d4980f19"/><file name="HyperSchema.php" hash="e7aa1de64b9a33952405ef8dceeb6de7"/><file name="Image.php" hash="2a608e583497c27f42c24731f0bb3b3f"/><file name="Incentive.php" hash="f75e02e7b9f5555226e83936e933993c"/><file name="InputFields.php" hash="09a22ab55a6078e74771b0a5d5991e79"/><file name="InstallmentInfo.php" hash="1ffac8239c0db6e57fa4616f8efde768"/><file name="InstallmentOption.php" hash="cf1010ce916d70778331455564070f26"/><file name="Invoice.php" hash="a0a2129ef119e0479904a3228dadf672"/><file name="InvoiceAddress.php" hash="3f3498d6825eeb927b8386ffaaf7c5ff"/><file name="InvoiceItem.php" hash="fed23c1532005b90ea281bdda056f01e"/><file name="InvoiceSearchResponse.php" hash="842c4ff7472bc5f7be15e2e9aaf6dca9"/><file name="Item.php" hash="204e5862a8b1cb9ed113eb78a610ffa3"/><file name="ItemList.php" hash="23a6c7b9e6e83f5464e8793931f885f4"/><file name="Links.php" hash="6cd3ac5493d6b2f1641cb0f93460b226"/><file name="Measurement.php" hash="13b63a8d572754743643b16436498b21"/><file name="MerchantInfo.php" hash="4a6f53f224709e894fd07355e257c906"/><file name="MerchantPreferences.php" hash="07c0e1401dc4c4d8ff4784d9726324f9"/><file name="Metadata.php" hash="437a16b05945c27f660f4b9afdcd7743"/><file name="NameValuePair.php" hash="c6f7d380e6133815e3cd0f7967a6eb85"/><file name="Notification.php" hash="2467b4d11238b6feabd347dffd3fe5d0"/><file name="OpenIdAddress.php" hash="189e2eccf8cafc1f2916e1d54943b635"/><file name="OpenIdError.php" hash="73bb4a1d3dc4ef297aab469751d07019"/><file name="OpenIdSession.php" hash="349ff859610e5b3142470d708f9acc33"/><file name="OpenIdTokeninfo.php" hash="6e407e338785d8d6ec6536f384788b9c"/><file name="OpenIdUserinfo.php" hash="194e117cb7bb7d90e039b49b7254534f"/><file name="Order.php" hash="47f4c0da5745622458d0c635a3fb732d"/><file name="OverrideChargeModel.php" hash="6c7140dec5765fe9f2b87c34a5ab8ab9"/><file name="Patch.php" hash="575724b7d55fed3725bcb81f8ec8f3e7"/><file name="PatchRequest.php" hash="17d46d1cbd10d0dd8a35317fff7f6c49"/><file name="Payee.php" hash="743c1d3d49be4ed702ba8f1384a61269"/><file name="Payer.php" hash="ea48b7e59d8380b457a8057c65918a87"/><file name="PayerInfo.php" hash="4a763dff29c0fd32856cc462a6f05ce9"/><file name="Payment.php" hash="a9184f4fc8f5c9efd6918372cf440fb9"/><file name="PaymentCard.php" hash="798d75240a399228978cfb175e128263"/><file name="PaymentCardToken.php" hash="0e2910acb59a5566a317e21fcfba7642"/><file name="PaymentDefinition.php" hash="189e288bebe81baf05a0dbf55c2383f2"/><file name="PaymentDetail.php" hash="071712fe77c27e36585fd95e032ec1e0"/><file name="PaymentExecution.php" hash="02fdfbd0eef1fdea3b01416116763f8f"/><file name="PaymentHistory.php" hash="3461c19997d95143300d4beabcb06190"/><file name="PaymentInstruction.php" hash="bd5fa06d0da5565c952333748c6ebeea"/><file name="PaymentOptions.php" hash="20ba1e4b2d9c56d369f7871a7da059bb"/><file name="PaymentTerm.php" hash="a7d139c47db1a680a9bb04b57f491917"/><file name="Payout.php" hash="1d06f076cb550354e29898b72975e737"/><file name="PayoutBatch.php" hash="be3afe9fc6a4cfa233d8557743ebbd39"/><file name="PayoutBatchHeader.php" hash="3d5912b2e922f189d9912e092d80191a"/><file name="PayoutItem.php" hash="ad510dbbe583b78226ae813f474f5582"/><file name="PayoutItemDetails.php" hash="9b9510b953d0b2ebf95830ad48ddb0f8"/><file name="PayoutSenderBatchHeader.php" hash="0db9dd2031d36c7bd728ae8d3845b3b6"/><file name="Phone.php" hash="6c137d6984692552a86310a52a625c7f"/><file name="Plan.php" hash="ec8dcb5a38993a3c43e51d623a87438b"/><file name="PlanList.php" hash="46ff82f188e0aeeb6891c626c5a132dc"/><file name="PotentialPayerInfo.php" hash="e6fa5bfca5821812ad4b034d8cf64e9e"/><file name="Presentation.php" hash="58a1163f981aba36d394bcf1b24f04e4"/><file name="PrivateLabelCard.php" hash="85dc8e870a1c644519009c47b38a8d93"/><file name="ProcessorResponse.php" hash="65caffc4473a29b5e509e0698203c6dd"/><file name="RecipientBankingInstruction.php" hash="9149af25e66a70f8321bca3e03e909af"/><file name="RedirectUrls.php" hash="f9adcf2e0ac56095217bac6372340536"/><file name="Refund.php" hash="efa7c77783c44df54bdea689a3618bdb"/><file name="RefundDetail.php" hash="10b4e38e9d9260f78a313a74e18e7508"/><file name="RelatedResources.php" hash="7757e2721aadb739fed0eb9a8d629df8"/><file name="Sale.php" hash="4fdafb87630808b6aba3cd5fbe72ca00"/><file name="Search.php" hash="b85046daf5b49235678f1eebbf2bd665"/><file name="ShippingAddress.php" hash="faa92bcb11b7fc815d48298b47b8a1f9"/><file name="ShippingCost.php" hash="83e3e2a71a3ac5197f3dd7a16574d19b"/><file name="ShippingInfo.php" hash="a3fb2089bdab64a4790692f7f2dabf81"/><file name="Tax.php" hash="e0cfea9a1395eb1913faf76b04c6dcb2"/><file name="Terms.php" hash="2c605993f3611d02b70cbb87b2c76b00"/><file name="Transaction.php" hash="32175e204772a4ac7894578a3b8ea1e4"/><file name="TransactionBase.php" hash="054f66bc789a90a9dbbe1c7dea0a00ed"/><file name="Transactions.php" hash="7aa6a708a39835666dac689dec34b623"/><file name="WebProfile.php" hash="277888d15bca634c1496583a9180a7e0"/><file name="Webhook.php" hash="a543c0f07a8175c304fd2db1662df0e4"/><file name="WebhookEvent.php" hash="bbfadf2829d1ddc36e0b97f567e29db6"/><file name="WebhookEventList.php" hash="48b3f6d97932cca67bf5a050163b2381"/><file name="WebhookEventType.php" hash="f6039c6d5044c7dedff03955554ed61f"/><file name="WebhookEventTypeList.php" hash="cb6ad875f0774b4127c6882f30c6c522"/><file name="WebhookList.php" hash="ce78a04e84a864895a4942ca1d13c2fd"/></dir><dir name="Auth"><file name="OAuthTokenCredential.php" hash="8231d932c45ba76928fa5c6ea38de158"/></dir><dir name="Cache"><file name="AuthorizationCache.php" hash="1b5935ad6dd8e5d4bf907006f5d36d54"/></dir><dir name="Common"><file name="ArrayUtil.php" hash="b41119fb9b40bdb3bb137c5f716e2666"/><file name="PayPalModel.php" hash="86da41d7f429704dad19a1426a640f09"/><file name="PayPalResourceModel.php" hash="2ac746c97a26fd57aa74d523d45e4fb9"/><file name="PayPalUserAgent.php" hash="5544e7dfd56d5c378cb411caa974dc1b"/><file name="ReflectionUtil.php" hash="ce8f00a362260a11b5bbc86f86fe3105"/></dir><dir name="Converter"><file name="FormatConverter.php" hash="f55eb6b3daa76cb425ea380850fb94a7"/></dir><dir name="Core"><file name="PayPalConfigManager.php" hash="5c68196e2aa57d3d5887849e20f1ff16"/><file name="PayPalConstants.php" hash="ef0e24de1382667bf52b1744281366cc"/><file name="PayPalCredentialManager.php" hash="2cd3b8246fa17ffffdc0f7e736b1b76f"/><file name="PayPalHttpConfig.php" hash="7e38f1fe721a864f1d99bfa0025157d4"/><file name="PayPalHttpConnection.php" hash="2ace269f17b5eda4ea30b7fffca10e16"/><file name="PayPalLoggingLevel.php" hash="24d4ebd6129f619adba2814a54cc3c80"/><file name="PayPalLoggingManager.php" hash="d18d38b49436b16e72a6d8b2c5b5591f"/><file name="cacert.pem" hash="d4b2ab71266521d7376ebeee490fba2b"/></dir><dir name="Exception"><file name="PayPalConfigurationException.php" hash="f14c778e88c9a8c917a1d25fc250d594"/><file name="PayPalConnectionException.php" hash="6b125eb06dce5dec2a44d166b505fe18"/><file name="PayPalInvalidCredentialException.php" hash="3fa38244fdc20de74fda7892c4b04f8d"/><file name="PayPalMissingCredentialException.php" hash="72f45ecc61324ce36f4cb097e355c081"/></dir><dir name="Handler"><file name="IPayPalHandler.php" hash="03b0eb03e1b5cfc5d90ccda1a768cf8c"/><file name="OauthHandler.php" hash="6c09466149ee92f18aebfd2c991599bf"/><file name="RestHandler.php" hash="4842641a6071decb8733930214e9b54b"/></dir><dir name="Rest"><file name="ApiContext.php" hash="20391a33cb068b75e3692b9d89d2cc35"/><file name="IResource.php" hash="d2a7e80b6373a9112e9a006668d34bbe"/></dir><dir name="Security"><file name="Cipher.php" hash="1ca619c0bf0a57129d6497794413c238"/></dir><dir name="Transport"><file name="PayPalRestCall.php" hash="4f9f3c84cf3b557a80ab09818af682da"/></dir><dir name="Validation"><file name="ArgumentValidator.php" hash="d85d4e0c3662976d0f69217221beceb5"/><file name="JsonValidator.php" hash="353b6bd0ea99b2355850c961b89e1791"/><file name="NumericValidator.php" hash="1e40d8506333053a316176ecbee42dc7"/><file name="UrlValidator.php" hash="55f326f8e8f5321e721ef8021959958f"/></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="iways-paypalplus.css" hash="84ce329eb25fb82375abc90daaf7d2cf"/></dir><dir name="images"><dir name="iways"><file name="checkmark.png" hash="9879d16c7618d54ca45e984406eb3934"/></dir></dir></dir></dir></dir></target></contents>
72
+ <compatible/>
73
+ <dependencies><required><php><min>5.3.7</min><max>6.0.0</max></php></required></dependencies>
74
+ </package>
skin/frontend/base/default/css/iways-paypalplus.css ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #checkout-payment-method-load dt.ppp {
2
+ background-color: #fff;
3
+ margin: 0;
4
+ padding:0;
5
+ border-top: 1px solid #dfdfdf;
6
+ overflow: hidden;
7
+ }
8
+
9
+ #checkout-payment-method-load dt.ppp label {
10
+ padding: 0px;
11
+ background: transparent;
12
+ width: 100%;
13
+ display: inline-block;
14
+ cursor: pointer;
15
+ padding: 20px 10px !important;
16
+ font-family: Arial !important;
17
+ font-size: 12px !important;
18
+ font-weight: normal !important;
19
+ }
20
+
21
+ #checkout-payment-method-load dt.ppp.ppp-selected {
22
+ background-image: url("../images/iways/checkmark.png");
23
+ background-repeat: no-repeat;
24
+ background-position: right 15px;
25
+ background-color: #f9f9f9;
26
+ }
27
+ #checkout-payment-method-load dt.ppp.ppp-selected label{font-weight: bold;padding-bottom:10px;}
28
+
29
+ #checkout-payment-method-load dd.ppp.ppp-selected {
30
+ background-color: #f9f9f9;
31
+ padding:0 0 10px;
32
+ }
33
+
34
+ #checkout-payment-method-load dt.ppp:hover {
35
+ background-color: #f9f9f9;
36
+ }
37
+
38
+ #checkout-payment-method-load dt.ppp input {
39
+ display: none;
40
+ }
41
+
42
+ #checkout-payment-method-load dt.ppp label:hover {
43
+ background: transparent;
44
+ }
45
+
46
+ #checkout-payment-method-load dd.ppp {
47
+ padding:0;
48
+ }
49
+ #checkout-payment-method-load dd.ppp:last-child {
50
+ border-bottom: 1px solid #dfdfdf;
51
+ }
52
+
53
+ #checkout-payment-method-load dt.ppp.iways_paypalplus_payment {
54
+ border-top: none;
55
+ }
56
+
57
+ #checkout-payment-method-load dd.ppp.iways_paypalplus_payment {
58
+ border-bottom: none;
59
+ }
60
+
61
+ #checkout-payment-method-load dd.ppp.iways_paypalplus_payment.ppp-selected {
62
+ background: transparent;
63
+ }
64
+
65
+ #checkout-payment-method-load .form-list .ppp li{margin-bottom:0px;padding-bottom: 8px;}
66
+ div.ppp-pui table{margin-left: auto;margin-right: auto;}
67
+ div.ppp-pui table tbody tr td{text-align:left;padding:0 5px;}
68
+
69
+
70
+ body.opc-index-index #checkout-payment-method-load dt.ppp label{color: inherit;text-align: inherit;height: inherit;text-transform: inherit;line-height: inherit;}
skin/frontend/base/default/images/iways/checkmark.png ADDED
Binary file