From a4fd969973709ac516f252f3cb6fdc62ef33a474 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 21 Apr 2023 19:13:03 +0000 Subject: [PATCH] prepare workflows --- paypal/PayPal/Api/Address.php | 62 + paypal/PayPal/Api/Agreement.php | 647 ++++++++ paypal/PayPal/Api/AgreementDetails.php | 209 +++ .../PayPal/Api/AgreementStateDescriptor.php | 65 + paypal/PayPal/Api/AgreementTransaction.php | 257 ++++ paypal/PayPal/Api/AgreementTransactions.php | 71 + paypal/PayPal/Api/AlternatePayment.php | 91 ++ paypal/PayPal/Api/Amount.php | 93 ++ paypal/PayPal/Api/Authorization.php | 507 +++++++ paypal/PayPal/Api/BankAccount.php | 629 ++++++++ paypal/PayPal/Api/BankAccountsList.php | 119 ++ paypal/PayPal/Api/BankToken.php | 89 ++ paypal/PayPal/Api/BaseAddress.php | 211 +++ paypal/PayPal/Api/Billing.php | 43 + paypal/PayPal/Api/BillingAgreementToken.php | 17 + paypal/PayPal/Api/BillingInfo.php | 235 +++ paypal/PayPal/Api/CancelNotification.php | 167 ++ paypal/PayPal/Api/Capture.php | 341 +++++ paypal/PayPal/Api/CarrierAccount.php | 138 ++ paypal/PayPal/Api/CarrierAccountToken.php | 65 + paypal/PayPal/Api/CartBase.php | 408 +++++ paypal/PayPal/Api/ChargeModel.php | 89 ++ paypal/PayPal/Api/Cost.php | 69 + paypal/PayPal/Api/CountryCode.php | 41 + paypal/PayPal/Api/CreateProfileResponse.php | 40 + paypal/PayPal/Api/Credit.php | 66 + paypal/PayPal/Api/CreditCard.php | 560 +++++++ paypal/PayPal/Api/CreditCardHistory.php | 91 ++ paypal/PayPal/Api/CreditCardList.php | 120 ++ paypal/PayPal/Api/CreditCardToken.php | 161 ++ paypal/PayPal/Api/CreditFinancingOffered.php | 161 ++ paypal/PayPal/Api/Currency.php | 69 + paypal/PayPal/Api/CurrencyConversion.php | 266 ++++ paypal/PayPal/Api/CustomAmount.php | 65 + paypal/PayPal/Api/DetailedRefund.php | 160 ++ paypal/PayPal/Api/Details.php | 227 +++ paypal/PayPal/Api/Error.php | 320 ++++ paypal/PayPal/Api/ErrorDetails.php | 111 ++ paypal/PayPal/Api/ExtendedBankAccount.php | 38 + paypal/PayPal/Api/ExternalFunding.php | 161 ++ paypal/PayPal/Api/FileAttachment.php | 67 + paypal/PayPal/Api/FlowConfig.php | 115 ++ paypal/PayPal/Api/FmfDetails.php | 115 ++ paypal/PayPal/Api/FundingDetail.php | 114 ++ paypal/PayPal/Api/FundingInstrument.php | 321 ++++ paypal/PayPal/Api/FundingOption.php | 221 +++ paypal/PayPal/Api/FundingSource.php | 292 ++++ paypal/PayPal/Api/FuturePayment.php | 59 + paypal/PayPal/Api/HyperSchema.php | 191 +++ paypal/PayPal/Api/Image.php | 56 + paypal/PayPal/Api/Incentive.php | 236 +++ paypal/PayPal/Api/InputFields.php | 89 ++ paypal/PayPal/Api/InstallmentInfo.php | 144 ++ paypal/PayPal/Api/InstallmentOption.php | 113 ++ paypal/PayPal/Api/Invoice.php | 1340 +++++++++++++++++ paypal/PayPal/Api/InvoiceAddress.php | 39 + paypal/PayPal/Api/InvoiceItem.php | 239 +++ paypal/PayPal/Api/InvoiceNumber.php | 38 + paypal/PayPal/Api/InvoiceSearchResponse.php | 95 ++ paypal/PayPal/Api/Item.php | 439 ++++++ paypal/PayPal/Api/ItemList.php | 143 ++ paypal/PayPal/Api/Links.php | 161 ++ paypal/PayPal/Api/Measurement.php | 65 + paypal/PayPal/Api/MerchantInfo.php | 281 ++++ paypal/PayPal/Api/MerchantPreferences.php | 261 ++++ paypal/PayPal/Api/Metadata.php | 259 ++++ paypal/PayPal/Api/NameValuePair.php | 65 + paypal/PayPal/Api/Notification.php | 143 ++ paypal/PayPal/Api/OpenIdAddress.php | 133 ++ paypal/PayPal/Api/OpenIdError.php | 85 ++ paypal/PayPal/Api/OpenIdSession.php | 107 ++ paypal/PayPal/Api/OpenIdTokeninfo.php | 255 ++++ paypal/PayPal/Api/OpenIdUserinfo.php | 540 +++++++ paypal/PayPal/Api/Order.php | 464 ++++++ paypal/PayPal/Api/OverrideChargeModel.php | 65 + paypal/PayPal/Api/Participant.php | 233 +++ paypal/PayPal/Api/Patch.php | 114 ++ paypal/PayPal/Api/PatchRequest.php | 86 ++ paypal/PayPal/Api/Payee.php | 157 ++ paypal/PayPal/Api/Payer.php | 288 ++++ paypal/PayPal/Api/PayerInfo.php | 453 ++++++ paypal/PayPal/Api/Payment.php | 691 +++++++++ paypal/PayPal/Api/PaymentCard.php | 482 ++++++ paypal/PayPal/Api/PaymentCardToken.php | 162 ++ paypal/PayPal/Api/PaymentDefinition.php | 239 +++ paypal/PayPal/Api/PaymentDetail.php | 188 +++ paypal/PayPal/Api/PaymentExecution.php | 118 ++ paypal/PayPal/Api/PaymentHistory.php | 119 ++ paypal/PayPal/Api/PaymentInstruction.php | 190 +++ paypal/PayPal/Api/PaymentOptions.php | 88 ++ paypal/PayPal/Api/PaymentSummary.php | 65 + paypal/PayPal/Api/PaymentTerm.php | 66 + paypal/PayPal/Api/Payout.php | 166 ++ paypal/PayPal/Api/PayoutBatch.php | 120 ++ paypal/PayPal/Api/PayoutBatchHeader.php | 263 ++++ paypal/PayPal/Api/PayoutItem.php | 189 +++ paypal/PayPal/Api/PayoutItemDetails.php | 287 ++++ paypal/PayPal/Api/PayoutSenderBatchHeader.php | 107 ++ paypal/PayPal/Api/Phone.php | 89 ++ paypal/PayPal/Api/Plan.php | 445 ++++++ paypal/PayPal/Api/PlanList.php | 173 +++ paypal/PayPal/Api/PotentialPayerInfo.php | 109 ++ paypal/PayPal/Api/Presentation.php | 137 ++ paypal/PayPal/Api/PrivateLabelCard.php | 137 ++ paypal/PayPal/Api/ProcessorResponse.php | 162 ++ .../Api/RecipientBankingInstruction.php | 161 ++ paypal/PayPal/Api/RedirectUrls.php | 68 + paypal/PayPal/Api/Refund.php | 335 +++++ paypal/PayPal/Api/RefundDetail.php | 138 ++ paypal/PayPal/Api/RefundRequest.php | 162 ++ paypal/PayPal/Api/RelatedResources.php | 137 ++ paypal/PayPal/Api/Sale.php | 637 ++++++++ paypal/PayPal/Api/Search.php | 498 ++++++ paypal/PayPal/Api/ShippingAddress.php | 108 ++ paypal/PayPal/Api/ShippingCost.php | 65 + paypal/PayPal/Api/ShippingInfo.php | 158 ++ paypal/PayPal/Api/Tax.php | 117 ++ paypal/PayPal/Api/Template.php | 309 ++++ paypal/PayPal/Api/TemplateData.php | 619 ++++++++ paypal/PayPal/Api/TemplateSettings.php | 65 + .../PayPal/Api/TemplateSettingsMetadata.php | 41 + paypal/PayPal/Api/Templates.php | 292 ++++ paypal/PayPal/Api/Terms.php | 161 ++ paypal/PayPal/Api/Transaction.php | 63 + paypal/PayPal/Api/TransactionBase.php | 40 + paypal/PayPal/Api/Transactions.php | 42 + paypal/PayPal/Api/VerifyWebhookSignature.php | 256 ++++ .../Api/VerifyWebhookSignatureResponse.php | 42 + paypal/PayPal/Api/WebProfile.php | 305 ++++ paypal/PayPal/Api/Webhook.php | 260 ++++ paypal/PayPal/Api/WebhookEvent.php | 312 ++++ paypal/PayPal/Api/WebhookEventList.php | 149 ++ paypal/PayPal/Api/WebhookEventType.php | 140 ++ paypal/PayPal/Api/WebhookEventTypeList.php | 71 + paypal/PayPal/Api/WebhookList.php | 71 + paypal/PayPal/Auth/OAuthTokenCredential.php | 317 ++++ paypal/PayPal/Cache/AuthorizationCache.php | 123 ++ paypal/PayPal/Common/ArrayUtil.php | 27 + paypal/PayPal/Common/PayPalModel.php | 309 ++++ paypal/PayPal/Common/PayPalResourceModel.php | 120 ++ paypal/PayPal/Common/PayPalUserAgent.php | 57 + paypal/PayPal/Common/ReflectionUtil.php | 155 ++ paypal/PayPal/Converter/FormatConverter.php | 62 + paypal/PayPal/Core/PayPalConfigManager.php | 159 ++ paypal/PayPal/Core/PayPalConstants.php | 27 + .../PayPal/Core/PayPalCredentialManager.php | 166 ++ paypal/PayPal/Core/PayPalHttpConfig.php | 302 ++++ paypal/PayPal/Core/PayPalHttpConnection.php | 223 +++ paypal/PayPal/Core/PayPalLoggingManager.php | 119 ++ paypal/PayPal/Core/cacert.pem | 171 +++ .../PayPalConfigurationException.php | 23 + .../Exception/PayPalConnectionException.php | 68 + .../PayPalInvalidCredentialException.php | 35 + .../PayPalMissingCredentialException.php | 36 + paypal/PayPal/Handler/IPayPalHandler.php | 20 + paypal/PayPal/Handler/OauthHandler.php | 103 ++ paypal/PayPal/Handler/RestHandler.php | 124 ++ paypal/PayPal/LICENSE | 171 +++ paypal/PayPal/Log/PayPalDefaultLogFactory.php | 26 + paypal/PayPal/Log/PayPalLogFactory.php | 16 + paypal/PayPal/Log/PayPalLogger.php | 84 ++ paypal/PayPal/Rest/ApiContext.php | 173 +++ paypal/PayPal/Rest/IResource.php | 12 + paypal/PayPal/Security/Cipher.php | 57 + paypal/PayPal/Transport/PayPalRestCall.php | 82 + .../PayPal/Validation/ArgumentValidator.php | 32 + paypal/PayPal/Validation/JsonValidator.php | 35 + paypal/PayPal/Validation/NumericValidator.php | 27 + paypal/PayPal/Validation/UrlValidator.php | 26 + 169 files changed, 30061 insertions(+) create mode 100644 paypal/PayPal/Api/Address.php create mode 100644 paypal/PayPal/Api/Agreement.php create mode 100644 paypal/PayPal/Api/AgreementDetails.php create mode 100644 paypal/PayPal/Api/AgreementStateDescriptor.php create mode 100644 paypal/PayPal/Api/AgreementTransaction.php create mode 100644 paypal/PayPal/Api/AgreementTransactions.php create mode 100644 paypal/PayPal/Api/AlternatePayment.php create mode 100644 paypal/PayPal/Api/Amount.php create mode 100644 paypal/PayPal/Api/Authorization.php create mode 100644 paypal/PayPal/Api/BankAccount.php create mode 100644 paypal/PayPal/Api/BankAccountsList.php create mode 100644 paypal/PayPal/Api/BankToken.php create mode 100644 paypal/PayPal/Api/BaseAddress.php create mode 100644 paypal/PayPal/Api/Billing.php create mode 100644 paypal/PayPal/Api/BillingAgreementToken.php create mode 100644 paypal/PayPal/Api/BillingInfo.php create mode 100644 paypal/PayPal/Api/CancelNotification.php create mode 100644 paypal/PayPal/Api/Capture.php create mode 100644 paypal/PayPal/Api/CarrierAccount.php create mode 100644 paypal/PayPal/Api/CarrierAccountToken.php create mode 100644 paypal/PayPal/Api/CartBase.php create mode 100644 paypal/PayPal/Api/ChargeModel.php create mode 100644 paypal/PayPal/Api/Cost.php create mode 100644 paypal/PayPal/Api/CountryCode.php create mode 100644 paypal/PayPal/Api/CreateProfileResponse.php create mode 100644 paypal/PayPal/Api/Credit.php create mode 100644 paypal/PayPal/Api/CreditCard.php create mode 100644 paypal/PayPal/Api/CreditCardHistory.php create mode 100644 paypal/PayPal/Api/CreditCardList.php create mode 100644 paypal/PayPal/Api/CreditCardToken.php create mode 100644 paypal/PayPal/Api/CreditFinancingOffered.php create mode 100644 paypal/PayPal/Api/Currency.php create mode 100644 paypal/PayPal/Api/CurrencyConversion.php create mode 100644 paypal/PayPal/Api/CustomAmount.php create mode 100644 paypal/PayPal/Api/DetailedRefund.php create mode 100644 paypal/PayPal/Api/Details.php create mode 100644 paypal/PayPal/Api/Error.php create mode 100644 paypal/PayPal/Api/ErrorDetails.php create mode 100644 paypal/PayPal/Api/ExtendedBankAccount.php create mode 100644 paypal/PayPal/Api/ExternalFunding.php create mode 100644 paypal/PayPal/Api/FileAttachment.php create mode 100644 paypal/PayPal/Api/FlowConfig.php create mode 100644 paypal/PayPal/Api/FmfDetails.php create mode 100644 paypal/PayPal/Api/FundingDetail.php create mode 100644 paypal/PayPal/Api/FundingInstrument.php create mode 100644 paypal/PayPal/Api/FundingOption.php create mode 100644 paypal/PayPal/Api/FundingSource.php create mode 100644 paypal/PayPal/Api/FuturePayment.php create mode 100644 paypal/PayPal/Api/HyperSchema.php create mode 100644 paypal/PayPal/Api/Image.php create mode 100644 paypal/PayPal/Api/Incentive.php create mode 100644 paypal/PayPal/Api/InputFields.php create mode 100644 paypal/PayPal/Api/InstallmentInfo.php create mode 100644 paypal/PayPal/Api/InstallmentOption.php create mode 100644 paypal/PayPal/Api/Invoice.php create mode 100644 paypal/PayPal/Api/InvoiceAddress.php create mode 100644 paypal/PayPal/Api/InvoiceItem.php create mode 100644 paypal/PayPal/Api/InvoiceNumber.php create mode 100644 paypal/PayPal/Api/InvoiceSearchResponse.php create mode 100644 paypal/PayPal/Api/Item.php create mode 100644 paypal/PayPal/Api/ItemList.php create mode 100644 paypal/PayPal/Api/Links.php create mode 100644 paypal/PayPal/Api/Measurement.php create mode 100644 paypal/PayPal/Api/MerchantInfo.php create mode 100644 paypal/PayPal/Api/MerchantPreferences.php create mode 100644 paypal/PayPal/Api/Metadata.php create mode 100644 paypal/PayPal/Api/NameValuePair.php create mode 100644 paypal/PayPal/Api/Notification.php create mode 100644 paypal/PayPal/Api/OpenIdAddress.php create mode 100644 paypal/PayPal/Api/OpenIdError.php create mode 100644 paypal/PayPal/Api/OpenIdSession.php create mode 100644 paypal/PayPal/Api/OpenIdTokeninfo.php create mode 100644 paypal/PayPal/Api/OpenIdUserinfo.php create mode 100644 paypal/PayPal/Api/Order.php create mode 100644 paypal/PayPal/Api/OverrideChargeModel.php create mode 100644 paypal/PayPal/Api/Participant.php create mode 100644 paypal/PayPal/Api/Patch.php create mode 100644 paypal/PayPal/Api/PatchRequest.php create mode 100644 paypal/PayPal/Api/Payee.php create mode 100644 paypal/PayPal/Api/Payer.php create mode 100644 paypal/PayPal/Api/PayerInfo.php create mode 100644 paypal/PayPal/Api/Payment.php create mode 100644 paypal/PayPal/Api/PaymentCard.php create mode 100644 paypal/PayPal/Api/PaymentCardToken.php create mode 100644 paypal/PayPal/Api/PaymentDefinition.php create mode 100644 paypal/PayPal/Api/PaymentDetail.php create mode 100644 paypal/PayPal/Api/PaymentExecution.php create mode 100644 paypal/PayPal/Api/PaymentHistory.php create mode 100644 paypal/PayPal/Api/PaymentInstruction.php create mode 100644 paypal/PayPal/Api/PaymentOptions.php create mode 100644 paypal/PayPal/Api/PaymentSummary.php create mode 100644 paypal/PayPal/Api/PaymentTerm.php create mode 100644 paypal/PayPal/Api/Payout.php create mode 100644 paypal/PayPal/Api/PayoutBatch.php create mode 100644 paypal/PayPal/Api/PayoutBatchHeader.php create mode 100644 paypal/PayPal/Api/PayoutItem.php create mode 100644 paypal/PayPal/Api/PayoutItemDetails.php create mode 100644 paypal/PayPal/Api/PayoutSenderBatchHeader.php create mode 100644 paypal/PayPal/Api/Phone.php create mode 100644 paypal/PayPal/Api/Plan.php create mode 100644 paypal/PayPal/Api/PlanList.php create mode 100644 paypal/PayPal/Api/PotentialPayerInfo.php create mode 100644 paypal/PayPal/Api/Presentation.php create mode 100644 paypal/PayPal/Api/PrivateLabelCard.php create mode 100644 paypal/PayPal/Api/ProcessorResponse.php create mode 100644 paypal/PayPal/Api/RecipientBankingInstruction.php create mode 100644 paypal/PayPal/Api/RedirectUrls.php create mode 100644 paypal/PayPal/Api/Refund.php create mode 100644 paypal/PayPal/Api/RefundDetail.php create mode 100644 paypal/PayPal/Api/RefundRequest.php create mode 100644 paypal/PayPal/Api/RelatedResources.php create mode 100644 paypal/PayPal/Api/Sale.php create mode 100644 paypal/PayPal/Api/Search.php create mode 100644 paypal/PayPal/Api/ShippingAddress.php create mode 100644 paypal/PayPal/Api/ShippingCost.php create mode 100644 paypal/PayPal/Api/ShippingInfo.php create mode 100644 paypal/PayPal/Api/Tax.php create mode 100644 paypal/PayPal/Api/Template.php create mode 100644 paypal/PayPal/Api/TemplateData.php create mode 100644 paypal/PayPal/Api/TemplateSettings.php create mode 100644 paypal/PayPal/Api/TemplateSettingsMetadata.php create mode 100644 paypal/PayPal/Api/Templates.php create mode 100644 paypal/PayPal/Api/Terms.php create mode 100644 paypal/PayPal/Api/Transaction.php create mode 100644 paypal/PayPal/Api/TransactionBase.php create mode 100644 paypal/PayPal/Api/Transactions.php create mode 100644 paypal/PayPal/Api/VerifyWebhookSignature.php create mode 100644 paypal/PayPal/Api/VerifyWebhookSignatureResponse.php create mode 100644 paypal/PayPal/Api/WebProfile.php create mode 100644 paypal/PayPal/Api/Webhook.php create mode 100644 paypal/PayPal/Api/WebhookEvent.php create mode 100644 paypal/PayPal/Api/WebhookEventList.php create mode 100644 paypal/PayPal/Api/WebhookEventType.php create mode 100644 paypal/PayPal/Api/WebhookEventTypeList.php create mode 100644 paypal/PayPal/Api/WebhookList.php create mode 100644 paypal/PayPal/Auth/OAuthTokenCredential.php create mode 100644 paypal/PayPal/Cache/AuthorizationCache.php create mode 100644 paypal/PayPal/Common/ArrayUtil.php create mode 100644 paypal/PayPal/Common/PayPalModel.php create mode 100644 paypal/PayPal/Common/PayPalResourceModel.php create mode 100644 paypal/PayPal/Common/PayPalUserAgent.php create mode 100644 paypal/PayPal/Common/ReflectionUtil.php create mode 100644 paypal/PayPal/Converter/FormatConverter.php create mode 100644 paypal/PayPal/Core/PayPalConfigManager.php create mode 100644 paypal/PayPal/Core/PayPalConstants.php create mode 100644 paypal/PayPal/Core/PayPalCredentialManager.php create mode 100644 paypal/PayPal/Core/PayPalHttpConfig.php create mode 100644 paypal/PayPal/Core/PayPalHttpConnection.php create mode 100644 paypal/PayPal/Core/PayPalLoggingManager.php create mode 100644 paypal/PayPal/Core/cacert.pem create mode 100644 paypal/PayPal/Exception/PayPalConfigurationException.php create mode 100644 paypal/PayPal/Exception/PayPalConnectionException.php create mode 100644 paypal/PayPal/Exception/PayPalInvalidCredentialException.php create mode 100644 paypal/PayPal/Exception/PayPalMissingCredentialException.php create mode 100644 paypal/PayPal/Handler/IPayPalHandler.php create mode 100644 paypal/PayPal/Handler/OauthHandler.php create mode 100644 paypal/PayPal/Handler/RestHandler.php create mode 100644 paypal/PayPal/LICENSE create mode 100644 paypal/PayPal/Log/PayPalDefaultLogFactory.php create mode 100644 paypal/PayPal/Log/PayPalLogFactory.php create mode 100644 paypal/PayPal/Log/PayPalLogger.php create mode 100644 paypal/PayPal/Rest/ApiContext.php create mode 100644 paypal/PayPal/Rest/IResource.php create mode 100644 paypal/PayPal/Security/Cipher.php create mode 100644 paypal/PayPal/Transport/PayPalRestCall.php create mode 100644 paypal/PayPal/Validation/ArgumentValidator.php create mode 100644 paypal/PayPal/Validation/JsonValidator.php create mode 100644 paypal/PayPal/Validation/NumericValidator.php create mode 100644 paypal/PayPal/Validation/UrlValidator.php diff --git a/paypal/PayPal/Api/Address.php b/paypal/PayPal/Api/Address.php new file mode 100644 index 0000000..56d95e8 --- /dev/null +++ b/paypal/PayPal/Api/Address.php @@ -0,0 +1,62 @@ +phone = $phone; + return $this; + } + + /** + * Phone number in E.123 format. 50 characters max. + * + * @return string + */ + public function getPhone() + { + return $this->phone; + } + + /** + * Type of address (e.g., HOME_OR_WORK, GIFT etc). + * + * @param string $type + * + * @return $this + */ + public function setType($type) + { + $this->type = $type; + return $this; + } + + /** + * Type of address (e.g., HOME_OR_WORK, GIFT etc). + * + * @return string + */ + public function getType() + { + return $this->type; + } +} diff --git a/paypal/PayPal/Api/Agreement.php b/paypal/PayPal/Api/Agreement.php new file mode 100644 index 0000000..810dde2 --- /dev/null +++ b/paypal/PayPal/Api/Agreement.php @@ -0,0 +1,647 @@ +id = $id; + return $this; + } + + /** + * Identifier of the agreement. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * State of the agreement. + * + * @param string $state + * + * @return $this + */ + public function setState($state) + { + $this->state = $state; + return $this; + } + + /** + * State of the agreement. + * + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * Name of the agreement. + * + * @param string $name + * + * @return $this + */ + public function setName($name) + { + $this->name = $name; + return $this; + } + + /** + * Name of the agreement. + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Description of the agreement. + * + * @param string $description + * + * @return $this + */ + public function setDescription($description) + { + $this->description = $description; + return $this; + } + + /** + * Description of the agreement. + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Start date of the agreement. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @param string $start_date + * + * @return $this + */ + public function setStartDate($start_date) + { + $this->start_date = $start_date; + return $this; + } + + /** + * Start date of the agreement. Date format yyyy-MM-dd z, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return string + */ + public function getStartDate() + { + return $this->start_date; + } + + /** + * Details of the buyer who is enrolling in this agreement. This information is gathered from execution of the approval URL. + * + * @param \PayPal\Api\Payer $payer + * + * @return $this + */ + public function setPayer($payer) + { + $this->payer = $payer; + return $this; + } + + /** + * Details of the buyer who is enrolling in this agreement. This information is gathered from execution of the approval URL. + * + * @return \PayPal\Api\Payer + */ + public function getPayer() + { + return $this->payer; + } + + /** + * Shipping address object of the agreement, which should be provided if it is different from the default address. + * + * @param \PayPal\Api\Address $shipping_address + * + * @return $this + */ + public function setShippingAddress($shipping_address) + { + $this->shipping_address = $shipping_address; + return $this; + } + + /** + * Shipping address object of the agreement, which should be provided if it is different from the default address. + * + * @return \PayPal\Api\Address + */ + public function getShippingAddress() + { + return $this->shipping_address; + } + + /** + * Default merchant preferences from the billing plan are used, unless override preferences are provided here. + * + * @param \PayPal\Api\MerchantPreferences $override_merchant_preferences + * + * @return $this + */ + public function setOverrideMerchantPreferences($override_merchant_preferences) + { + $this->override_merchant_preferences = $override_merchant_preferences; + return $this; + } + + /** + * Default merchant preferences from the billing plan are used, unless override preferences are provided here. + * + * @return \PayPal\Api\MerchantPreferences + */ + public function getOverrideMerchantPreferences() + { + return $this->override_merchant_preferences; + } + + /** + * Array of override_charge_model for this agreement if needed to change the default models from the billing plan. + * + * @param \PayPal\Api\OverrideChargeModel[] $override_charge_models + * + * @return $this + */ + public function setOverrideChargeModels($override_charge_models) + { + $this->override_charge_models = $override_charge_models; + return $this; + } + + /** + * Array of override_charge_model for this agreement if needed to change the default models from the billing plan. + * + * @return \PayPal\Api\OverrideChargeModel[] + */ + public function getOverrideChargeModels() + { + return $this->override_charge_models; + } + + /** + * Append OverrideChargeModels to the list. + * + * @param \PayPal\Api\OverrideChargeModel $overrideChargeModel + * @return $this + */ + public function addOverrideChargeModel($overrideChargeModel) + { + if (!$this->getOverrideChargeModels()) { + return $this->setOverrideChargeModels(array($overrideChargeModel)); + } else { + return $this->setOverrideChargeModels( + array_merge($this->getOverrideChargeModels(), array($overrideChargeModel)) + ); + } + } + + /** + * Remove OverrideChargeModels from the list. + * + * @param \PayPal\Api\OverrideChargeModel $overrideChargeModel + * @return $this + */ + public function removeOverrideChargeModel($overrideChargeModel) + { + return $this->setOverrideChargeModels( + array_diff($this->getOverrideChargeModels(), array($overrideChargeModel)) + ); + } + + /** + * Plan details for this agreement. + * + * @param \PayPal\Api\Plan $plan + * + * @return $this + */ + public function setPlan($plan) + { + $this->plan = $plan; + return $this; + } + + /** + * Plan details for this agreement. + * + * @return \PayPal\Api\Plan + */ + public function getPlan() + { + return $this->plan; + } + + /** + * 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). + * + * @param string $create_time + * + * @return $this + */ + public function setCreateTime($create_time) + { + $this->create_time = $create_time; + return $this; + } + + /** + * 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). + * + * @return string + */ + public function getCreateTime() + { + return $this->create_time; + } + + /** + * 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). + * + * @param string $update_time + * + * @return $this + */ + public function setUpdateTime($update_time) + { + $this->update_time = $update_time; + return $this; + } + + /** + * 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). + * + * @return string + */ + public function getUpdateTime() + { + return $this->update_time; + } + + /** + * Agreement Details + * + * @param \PayPal\Api\AgreementDetails $agreement_details + * + * @return $this + */ + public function setAgreementDetails($agreement_details) + { + $this->agreement_details = $agreement_details; + return $this; + } + + /** + * Agreement Details + * + * @return \PayPal\Api\AgreementDetails + */ + public function getAgreementDetails() + { + return $this->agreement_details; + } + + /** + * Get Approval Link + * + * @return null|string + */ + public function getApprovalLink() + { + return $this->getLink(PayPalConstants::APPROVAL_URL); + } + + /** + * 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. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Agreement + */ + public function create($apiContext = null, $restCall = null) + { + $payLoad = $this->toJSON(); + $json = self::executeCall( + "/v1/payments/billing-agreements/", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $this->fromJson($json); + return $this; + } + + /** + * Execute a billing agreement after buyer approval by passing the payment token to the request URI. + * + * @param $paymentToken + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Agreement + */ + public function execute($paymentToken, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($paymentToken, 'paymentToken'); + $payLoad = ""; + $json = self::executeCall( + "/v1/payments/billing-agreements/$paymentToken/agreement-execute", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $this->fromJson($json); + return $this; + } + + /** + * Retrieve details for a particular billing agreement by passing the ID of the agreement to the request URI. + * + * @param string $agreementId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Agreement + */ + public static function get($agreementId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($agreementId, 'agreementId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/payments/billing-agreements/$agreementId", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new Agreement(); + $ret->fromJson($json); + return $ret; + } + + /** + * 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. + * + * @param PatchRequest $patchRequest + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function update($patchRequest, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($patchRequest, 'patchRequest'); + $payLoad = $patchRequest->toJSON(); + self::executeCall( + "/v1/payments/billing-agreements/{$this->getId()}", + "PATCH", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * Suspend a particular billing agreement by passing the ID of the agreement to the request URI. + * + * @param AgreementStateDescriptor $agreementStateDescriptor + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function suspend($agreementStateDescriptor, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($agreementStateDescriptor, 'agreementStateDescriptor'); + $payLoad = $agreementStateDescriptor->toJSON(); + self::executeCall( + "/v1/payments/billing-agreements/{$this->getId()}/suspend", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * 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. + * + * @param AgreementStateDescriptor $agreementStateDescriptor + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function reActivate($agreementStateDescriptor, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($agreementStateDescriptor, 'agreementStateDescriptor'); + $payLoad = $agreementStateDescriptor->toJSON(); + self::executeCall( + "/v1/payments/billing-agreements/{$this->getId()}/re-activate", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * 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. + * + * @param AgreementStateDescriptor $agreementStateDescriptor + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function cancel($agreementStateDescriptor, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($agreementStateDescriptor, 'agreementStateDescriptor'); + $payLoad = $agreementStateDescriptor->toJSON(); + self::executeCall( + "/v1/payments/billing-agreements/{$this->getId()}/cancel", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * 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. + * + * @param AgreementStateDescriptor $agreementStateDescriptor + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function billBalance($agreementStateDescriptor, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($agreementStateDescriptor, 'agreementStateDescriptor'); + $payLoad = $agreementStateDescriptor->toJSON(); + self::executeCall( + "/v1/payments/billing-agreements/{$this->getId()}/bill-balance", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * 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. + * + * @param Currency $currency + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function setBalance($currency, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($currency, 'currency'); + $payLoad = $currency->toJSON(); + self::executeCall( + "/v1/payments/billing-agreements/{$this->getId()}/set-balance", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * 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. + * + * @deprecated Please use searchTransactions Instead + * @param string $agreementId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return AgreementTransactions + */ + public static function transactions($agreementId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($agreementId, 'agreementId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/payments/billing-agreements/$agreementId/transactions", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new AgreementTransactions(); + $ret->fromJson($json); + return $ret; + } + + /** + * 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. + * + * @param string $agreementId + * @param array $params Parameters for search string. Options: start_date, and end_date + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return AgreementTransactions + */ + public static function searchTransactions($agreementId, $params = array(), $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($agreementId, 'agreementId'); + ArgumentValidator::validate($params, 'params'); + + $allowedParams = array( + 'start_date' => 1, + 'end_date' => 1, + ); + + $payLoad = ""; + $json = self::executeCall( + "/v1/payments/billing-agreements/$agreementId/transactions?" . http_build_query(array_intersect_key($params, $allowedParams)), + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new AgreementTransactions(); + $ret->fromJson($json); + return $ret; + } + +} diff --git a/paypal/PayPal/Api/AgreementDetails.php b/paypal/PayPal/Api/AgreementDetails.php new file mode 100644 index 0000000..94e90cd --- /dev/null +++ b/paypal/PayPal/Api/AgreementDetails.php @@ -0,0 +1,209 @@ +outstanding_balance = $outstanding_balance; + return $this; + } + + /** + * The outstanding balance for this agreement. + * + * @return \PayPal\Api\Currency + */ + public function getOutstandingBalance() + { + return $this->outstanding_balance; + } + + /** + * Number of cycles remaining for this agreement. + * + * @param string $cycles_remaining + * + * @return $this + */ + public function setCyclesRemaining($cycles_remaining) + { + $this->cycles_remaining = $cycles_remaining; + return $this; + } + + /** + * Number of cycles remaining for this agreement. + * + * @return string + */ + public function getCyclesRemaining() + { + return $this->cycles_remaining; + } + + /** + * Number of cycles completed for this agreement. + * + * @param string $cycles_completed + * + * @return $this + */ + public function setCyclesCompleted($cycles_completed) + { + $this->cycles_completed = $cycles_completed; + return $this; + } + + /** + * Number of cycles completed for this agreement. + * + * @return string + */ + public function getCyclesCompleted() + { + return $this->cycles_completed; + } + + /** + * The next billing date for this agreement, represented as 2014-02-19T10:00:00Z format. + * + * @param string $next_billing_date + * + * @return $this + */ + public function setNextBillingDate($next_billing_date) + { + $this->next_billing_date = $next_billing_date; + return $this; + } + + /** + * The next billing date for this agreement, represented as 2014-02-19T10:00:00Z format. + * + * @return string + */ + public function getNextBillingDate() + { + return $this->next_billing_date; + } + + /** + * Last payment date for this agreement, represented as 2014-06-09T09:42:31Z format. + * + * @param string $last_payment_date + * + * @return $this + */ + public function setLastPaymentDate($last_payment_date) + { + $this->last_payment_date = $last_payment_date; + return $this; + } + + /** + * Last payment date for this agreement, represented as 2014-06-09T09:42:31Z format. + * + * @return string + */ + public function getLastPaymentDate() + { + return $this->last_payment_date; + } + + /** + * Last payment amount for this agreement. + * + * @param \PayPal\Api\Currency $last_payment_amount + * + * @return $this + */ + public function setLastPaymentAmount($last_payment_amount) + { + $this->last_payment_amount = $last_payment_amount; + return $this; + } + + /** + * Last payment amount for this agreement. + * + * @return \PayPal\Api\Currency + */ + public function getLastPaymentAmount() + { + return $this->last_payment_amount; + } + + /** + * Last payment date for this agreement, represented as 2015-02-19T10:00:00Z format. + * + * @param string $final_payment_date + * + * @return $this + */ + public function setFinalPaymentDate($final_payment_date) + { + $this->final_payment_date = $final_payment_date; + return $this; + } + + /** + * Last payment date for this agreement, represented as 2015-02-19T10:00:00Z format. + * + * @return string + */ + public function getFinalPaymentDate() + { + return $this->final_payment_date; + } + + /** + * Total number of failed payments for this agreement. + * + * @param string $failed_payment_count + * + * @return $this + */ + public function setFailedPaymentCount($failed_payment_count) + { + $this->failed_payment_count = $failed_payment_count; + return $this; + } + + /** + * Total number of failed payments for this agreement. + * + * @return string + */ + public function getFailedPaymentCount() + { + return $this->failed_payment_count; + } + +} diff --git a/paypal/PayPal/Api/AgreementStateDescriptor.php b/paypal/PayPal/Api/AgreementStateDescriptor.php new file mode 100644 index 0000000..619da31 --- /dev/null +++ b/paypal/PayPal/Api/AgreementStateDescriptor.php @@ -0,0 +1,65 @@ +note = $note; + return $this; + } + + /** + * Reason for changing the state of the agreement. + * + * @return string + */ + public function getNote() + { + return $this->note; + } + + /** + * The amount and currency of the agreement. + * + * @param \PayPal\Api\Currency $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * The amount and currency of the agreement. + * + * @return \PayPal\Api\Currency + */ + public function getAmount() + { + return $this->amount; + } + +} diff --git a/paypal/PayPal/Api/AgreementTransaction.php b/paypal/PayPal/Api/AgreementTransaction.php new file mode 100644 index 0000000..12cad0e --- /dev/null +++ b/paypal/PayPal/Api/AgreementTransaction.php @@ -0,0 +1,257 @@ +transaction_id = $transaction_id; + return $this; + } + + /** + * Id corresponding to this transaction. + * + * @return string + */ + public function getTransactionId() + { + return $this->transaction_id; + } + + /** + * State of the subscription at this time. + * + * @param string $status + * + * @return $this + */ + public function setStatus($status) + { + $this->status = $status; + return $this; + } + + /** + * State of the subscription at this time. + * + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * Type of transaction, usually Recurring Payment. + * + * @param string $transaction_type + * + * @return $this + */ + public function setTransactionType($transaction_type) + { + $this->transaction_type = $transaction_type; + return $this; + } + + /** + * Type of transaction, usually Recurring Payment. + * + * @return string + */ + public function getTransactionType() + { + return $this->transaction_type; + } + + /** + * Amount for this transaction. + * + * @param \PayPal\Api\Currency $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * Amount for this transaction. + * + * @return \PayPal\Api\Currency + */ + public function getAmount() + { + return $this->amount; + } + + /** + * Fee amount for this transaction. + * + * @param \PayPal\Api\Currency $fee_amount + * + * @return $this + */ + public function setFeeAmount($fee_amount) + { + $this->fee_amount = $fee_amount; + return $this; + } + + /** + * Fee amount for this transaction. + * + * @return \PayPal\Api\Currency + */ + public function getFeeAmount() + { + return $this->fee_amount; + } + + /** + * Net amount for this transaction. + * + * @param \PayPal\Api\Currency $net_amount + * + * @return $this + */ + public function setNetAmount($net_amount) + { + $this->net_amount = $net_amount; + return $this; + } + + /** + * Net amount for this transaction. + * + * @return \PayPal\Api\Currency + */ + public function getNetAmount() + { + return $this->net_amount; + } + + /** + * Email id of payer. + * + * @param string $payer_email + * + * @return $this + */ + public function setPayerEmail($payer_email) + { + $this->payer_email = $payer_email; + return $this; + } + + /** + * Email id of payer. + * + * @return string + */ + public function getPayerEmail() + { + return $this->payer_email; + } + + /** + * Business name of payer. + * + * @param string $payer_name + * + * @return $this + */ + public function setPayerName($payer_name) + { + $this->payer_name = $payer_name; + return $this; + } + + /** + * Business name of payer. + * + * @return string + */ + public function getPayerName() + { + return $this->payer_name; + } + + /** + * Time at which this transaction happened. + * + * @param string $time_stamp + * + * @return $this + */ + public function setTimeStamp($time_stamp) + { + $this->time_stamp = $time_stamp; + return $this; + } + + /** + * Time at which this transaction happened. + * + * @return string + */ + public function getTimeStamp() + { + return $this->time_stamp; + } + + /** + * Time zone of time_updated field. + * + * @param string $time_zone + * + * @return $this + */ + public function setTimeZone($time_zone) + { + $this->time_zone = $time_zone; + return $this; + } + + /** + * Time zone of time_updated field. + * + * @return string + */ + public function getTimeZone() + { + return $this->time_zone; + } + +} diff --git a/paypal/PayPal/Api/AgreementTransactions.php b/paypal/PayPal/Api/AgreementTransactions.php new file mode 100644 index 0000000..30d4527 --- /dev/null +++ b/paypal/PayPal/Api/AgreementTransactions.php @@ -0,0 +1,71 @@ +agreement_transaction_list = $agreement_transaction_list; + return $this; + } + + /** + * Array of agreement_transaction object. + * + * @return \PayPal\Api\AgreementTransaction[] + */ + public function getAgreementTransactionList() + { + return $this->agreement_transaction_list; + } + + /** + * Append AgreementTransactionList to the list. + * + * @param \PayPal\Api\AgreementTransaction $agreementTransaction + * @return $this + */ + public function addAgreementTransactionList($agreementTransaction) + { + if (!$this->getAgreementTransactionList()) { + return $this->setAgreementTransactionList(array($agreementTransaction)); + } else { + return $this->setAgreementTransactionList( + array_merge($this->getAgreementTransactionList(), array($agreementTransaction)) + ); + } + } + + /** + * Remove AgreementTransactionList from the list. + * + * @param \PayPal\Api\AgreementTransaction $agreementTransaction + * @return $this + */ + public function removeAgreementTransactionList($agreementTransaction) + { + return $this->setAgreementTransactionList( + array_diff($this->getAgreementTransactionList(), array($agreementTransaction)) + ); + } + +} diff --git a/paypal/PayPal/Api/AlternatePayment.php b/paypal/PayPal/Api/AlternatePayment.php new file mode 100644 index 0000000..7999c5f --- /dev/null +++ b/paypal/PayPal/Api/AlternatePayment.php @@ -0,0 +1,91 @@ +alternate_payment_account_id = $alternate_payment_account_id; + return $this; + } + + /** + * The unique identifier of the alternate payment account. + * + * @return string + */ + public function getAlternatePaymentAccountId() + { + return $this->alternate_payment_account_id; + } + + /** + * The unique identifier of the payer + * + * @param string $external_customer_id + * + * @return $this + */ + public function setExternalCustomerId($external_customer_id) + { + $this->external_customer_id = $external_customer_id; + return $this; + } + + /** + * The unique identifier of the payer + * + * @return string + */ + public function getExternalCustomerId() + { + return $this->external_customer_id; + } + + /** + * Alternate Payment provider id. This is an optional attribute needed only for certain alternate providers e.g Ideal + * + * @param string $alternate_payment_provider_id + * + * @return $this + */ + public function setAlternatePaymentProviderId($alternate_payment_provider_id) + { + $this->alternate_payment_provider_id = $alternate_payment_provider_id; + return $this; + } + + /** + * Alternate Payment provider id. This is an optional attribute needed only for certain alternate providers e.g Ideal + * + * @return string + */ + public function getAlternatePaymentProviderId() + { + return $this->alternate_payment_provider_id; + } + +} diff --git a/paypal/PayPal/Api/Amount.php b/paypal/PayPal/Api/Amount.php new file mode 100644 index 0000000..82fd6c8 --- /dev/null +++ b/paypal/PayPal/Api/Amount.php @@ -0,0 +1,93 @@ +currency = $currency; + return $this; + } + + /** + * 3-letter [currency code](https://developer.paypal.com/docs/integration/direct/rest_api_payment_country_currency_support/). PayPal does not support all currencies. + * + * @return string + */ + public function getCurrency() + { + return $this->currency; + } + + /** + * 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. + * + * @param string|double $total + * + * @return $this + */ + public function setTotal($total) + { + NumericValidator::validate($total, "Total"); + $total = FormatConverter::formatToPrice($total, $this->getCurrency()); + $this->total = $total; + return $this; + } + + /** + * 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. + * + * @return string + */ + public function getTotal() + { + return $this->total; + } + + /** + * Additional details of the payment amount. + * + * @param \PayPal\Api\Details $details + * + * @return $this + */ + public function setDetails($details) + { + $this->details = $details; + return $this; + } + + /** + * Additional details of the payment amount. + * + * @return \PayPal\Api\Details + */ + public function getDetails() + { + return $this->details; + } + +} diff --git a/paypal/PayPal/Api/Authorization.php b/paypal/PayPal/Api/Authorization.php new file mode 100644 index 0000000..5da9d45 --- /dev/null +++ b/paypal/PayPal/Api/Authorization.php @@ -0,0 +1,507 @@ +id = $id; + return $this; + } + + /** + * ID of the authorization transaction. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Amount being authorized. + * + * @param \PayPal\Api\Amount $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * Amount being authorized. + * + * @return \PayPal\Api\Amount + */ + public function getAmount() + { + return $this->amount; + } + + /** + * Specifies the payment mode of the transaction. + * Valid Values: ["INSTANT_TRANSFER"] + * + * @param string $payment_mode + * + * @return $this + */ + public function setPaymentMode($payment_mode) + { + $this->payment_mode = $payment_mode; + return $this; + } + + /** + * Specifies the payment mode of the transaction. + * + * @return string + */ + public function getPaymentMode() + { + return $this->payment_mode; + } + + /** + * State of the authorization. + * Valid Values: ["pending", "authorized", "partially_captured", "captured", "expired", "voided"] + * + * @param string $state + * + * @return $this + */ + public function setState($state) + { + $this->state = $state; + return $this; + } + + /** + * State of the authorization. + * + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * Reason code, `AUTHORIZATION`, for a transaction state of `pending`. + * Valid Values: ["AUTHORIZATION"] + * + * @param string $reason_code + * + * @return $this + */ + public function setReasonCode($reason_code) + { + $this->reason_code = $reason_code; + return $this; + } + + /** + * Reason code, `AUTHORIZATION`, for a transaction state of `pending`. + * + * @return string + */ + public function getReasonCode() + { + return $this->reason_code; + } + + /** + * [DEPRECATED] Reason code for the transaction state being Pending.Obsolete. use reason_code field instead. + * Valid Values: ["AUTHORIZATION"] + * + * @param string $pending_reason + * + * @return $this + */ + public function setPendingReason($pending_reason) + { + $this->pending_reason = $pending_reason; + return $this; + } + + /** + * @deprecated [DEPRECATED] Reason code for the transaction state being Pending.Obsolete. use reason_code field instead. + * + * @return string + */ + public function getPendingReason() + { + return $this->pending_reason; + } + + /** + * The level of seller protection in force for the transaction. Only supported when the `payment_method` is set to `paypal`. Allowed values:
`ELIGIBLE`- Merchant is protected by PayPal's Seller Protection Policy for Unauthorized Payments and Item Not Received.
`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.
`INELIGIBLE`- Merchant is not protected under the Seller Protection Policy. + * Valid Values: ["ELIGIBLE", "PARTIALLY_ELIGIBLE", "INELIGIBLE"] + * + * @param string $protection_eligibility + * + * @return $this + */ + public function setProtectionEligibility($protection_eligibility) + { + $this->protection_eligibility = $protection_eligibility; + return $this; + } + + /** + * The level of seller protection in force for the transaction. Only supported when the `payment_method` is set to `paypal`. Allowed values:
`ELIGIBLE`- Merchant is protected by PayPal's Seller Protection Policy for Unauthorized Payments and Item Not Received.
`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.
`INELIGIBLE`- Merchant is not protected under the Seller Protection Policy. + * + * @return string + */ + public function getProtectionEligibility() + { + return $this->protection_eligibility; + } + + /** + * 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:
`ITEM_NOT_RECEIVED_ELIGIBLE`- Sellers are protected against claims for items not received.
`UNAUTHORIZED_PAYMENT_ELIGIBLE`- Sellers are protected against claims for unauthorized payments.
One or both of the allowed values can be returned. + * Valid Values: ["ITEM_NOT_RECEIVED_ELIGIBLE", "UNAUTHORIZED_PAYMENT_ELIGIBLE", "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE"] + * + * @param string $protection_eligibility_type + * + * @return $this + */ + public function setProtectionEligibilityType($protection_eligibility_type) + { + $this->protection_eligibility_type = $protection_eligibility_type; + return $this; + } + + /** + * 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:
`ITEM_NOT_RECEIVED_ELIGIBLE`- Sellers are protected against claims for items not received.
`UNAUTHORIZED_PAYMENT_ELIGIBLE`- Sellers are protected against claims for unauthorized payments.
One or both of the allowed values can be returned. + * + * @return string + */ + public function getProtectionEligibilityType() + { + return $this->protection_eligibility_type; + } + + /** + * 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. + * + * @param \PayPal\Api\FmfDetails $fmf_details + * + * @return $this + */ + public function setFmfDetails($fmf_details) + { + $this->fmf_details = $fmf_details; + return $this; + } + + /** + * 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. + * + * @return \PayPal\Api\FmfDetails + */ + public function getFmfDetails() + { + return $this->fmf_details; + } + + /** + * ID of the Payment resource that this transaction is based on. + * + * @param string $parent_payment + * + * @return $this + */ + public function setParentPayment($parent_payment) + { + $this->parent_payment = $parent_payment; + return $this; + } + + /** + * ID of the Payment resource that this transaction is based on. + * + * @return string + */ + public function getParentPayment() + { + return $this->parent_payment; + } + + /** + * Response codes returned by the processor concerning the submitted payment. Only supported when the `payment_method` is set to `credit_card`. + * + * @param \PayPal\Api\ProcessorResponse $processor_response + * + * @return $this + */ + public function setProcessorResponse($processor_response) + { + $this->processor_response = $processor_response; + return $this; + } + + /** + * Response codes returned by the processor concerning the submitted payment. Only supported when the `payment_method` is set to `credit_card`. + * + * @return \PayPal\Api\ProcessorResponse + */ + public function getProcessorResponse() + { + return $this->processor_response; + } + + /** + * Authorization expiration time and date as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @param string $valid_until + * + * @return $this + */ + public function setValidUntil($valid_until) + { + $this->valid_until = $valid_until; + return $this; + } + + /** + * Authorization expiration time and date as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return string + */ + public function getValidUntil() + { + return $this->valid_until; + } + + /** + * Time of authorization as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @param string $create_time + * + * @return $this + */ + public function setCreateTime($create_time) + { + $this->create_time = $create_time; + return $this; + } + + /** + * Time of authorization as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return string + */ + public function getCreateTime() + { + return $this->create_time; + } + + /** + * Time that the resource was last updated. + * + * @param string $update_time + * + * @return $this + */ + public function setUpdateTime($update_time) + { + $this->update_time = $update_time; + return $this; + } + + /** + * Time that the resource was last updated. + * + * @return string + */ + public function getUpdateTime() + { + return $this->update_time; + } + + /** + * Identifier to the purchase or transaction unit corresponding to this authorization transaction. + * + * @param string $reference_id + * + * @return $this + */ + public function setReferenceId($reference_id) + { + $this->reference_id = $reference_id; + return $this; + } + + /** + * Identifier to the purchase or transaction unit corresponding to this authorization transaction. + * + * @return string + */ + public function getReferenceId() + { + return $this->reference_id; + } + + /** + * Receipt id is 16 digit number payment identification number returned for guest users to identify the payment. + * + * @param string $receipt_id + * + * @return $this + */ + public function setReceiptId($receipt_id) + { + $this->receipt_id = $receipt_id; + return $this; + } + + /** + * Receipt id is 16 digit number payment identification number returned for guest users to identify the payment. + * + * @return string + */ + public function getReceiptId() + { + return $this->receipt_id; + } + + /** + * Shows details for an authorization, by ID. + * + * @param string $authorizationId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Authorization + */ + public static function get($authorizationId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($authorizationId, 'authorizationId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/payments/authorization/$authorizationId", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new Authorization(); + $ret->fromJson($json); + return $ret; + } + + /** + * Captures and processes an authorization, by ID. To use this call, the original payment call must specify an intent of `authorize`. + * + * @param Capture $capture + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Capture + */ + public function capture($capture, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($capture, 'capture'); + $payLoad = $capture->toJSON(); + $json = self::executeCall( + "/v1/payments/authorization/{$this->getId()}/capture", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new Capture(); + $ret->fromJson($json); + return $ret; + } + + /** + * Voids, or cancels, an authorization, by ID. You cannot void a fully captured authorization. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Authorization + */ + public function void($apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + $payLoad = ""; + $json = self::executeCall( + "/v1/payments/authorization/{$this->getId()}/void", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $this->fromJson($json); + return $this; + } + + /** + * Reauthorizes a PayPal account payment, by authorization ID. To ensure that funds are still available, reauthorize a payment after the initial three-day honor period. Supports only the `amount` request parameter. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Authorization + */ + public function reauthorize($apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + $payLoad = $this->toJSON(); + $json = self::executeCall( + "/v1/payments/authorization/{$this->getId()}/reauthorize", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $this->fromJson($json); + return $this; + } + +} diff --git a/paypal/PayPal/Api/BankAccount.php b/paypal/PayPal/Api/BankAccount.php new file mode 100644 index 0000000..1ac63cf --- /dev/null +++ b/paypal/PayPal/Api/BankAccount.php @@ -0,0 +1,629 @@ +id = $id; + return $this; + } + + /** + * ID of the bank account being saved for later use. + * @deprecated Not publicly available + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Account number in either IBAN (max length 34) or BBAN (max length 17) format. + * + * @param string $account_number + * + * @return $this + */ + public function setAccountNumber($account_number) + { + $this->account_number = $account_number; + return $this; + } + + /** + * Account number in either IBAN (max length 34) or BBAN (max length 17) format. + * + * @return string + */ + public function getAccountNumber() + { + return $this->account_number; + } + + /** + * 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. + * Valid Values: ["BBAN", "IBAN"] + * + * @param string $account_number_type + * + * @return $this + */ + public function setAccountNumberType($account_number_type) + { + $this->account_number_type = $account_number_type; + return $this; + } + + /** + * 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. + * + * @return string + */ + public function getAccountNumberType() + { + return $this->account_number_type; + } + + /** + * 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. + * + * @param string $routing_number + * + * @return $this + */ + public function setRoutingNumber($routing_number) + { + $this->routing_number = $routing_number; + return $this; + } + + /** + * 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. + * + * @return string + */ + public function getRoutingNumber() + { + return $this->routing_number; + } + + /** + * Type of the bank account. + * Valid Values: ["CHECKING", "SAVINGS"] + * + * @param string $account_type + * + * @return $this + */ + public function setAccountType($account_type) + { + $this->account_type = $account_type; + return $this; + } + + /** + * Type of the bank account. + * + * @return string + */ + public function getAccountType() + { + return $this->account_type; + } + + /** + * A customer designated name. + * + * @param string $account_name + * + * @return $this + */ + public function setAccountName($account_name) + { + $this->account_name = $account_name; + return $this; + } + + /** + * A customer designated name. + * + * @return string + */ + public function getAccountName() + { + return $this->account_name; + } + + /** + * Type of the check when this information was obtained through a check by the facilitator or merchant. + * Valid Values: ["PERSONAL", "COMPANY"] + * + * @param string $check_type + * + * @return $this + */ + public function setCheckType($check_type) + { + $this->check_type = $check_type; + return $this; + } + + /** + * Type of the check when this information was obtained through a check by the facilitator or merchant. + * + * @return string + */ + public function getCheckType() + { + return $this->check_type; + } + + /** + * How the check was obtained from the customer, if check was the source of the information provided. + * Valid Values: ["CCD", "PPD", "TEL", "POP", "ARC", "RCK", "WEB"] + * + * @param string $auth_type + * + * @return $this + */ + public function setAuthType($auth_type) + { + $this->auth_type = $auth_type; + return $this; + } + + /** + * How the check was obtained from the customer, if check was the source of the information provided. + * + * @return string + */ + public function getAuthType() + { + return $this->auth_type; + } + + /** + * 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. + * + * @param string $auth_capture_timestamp + * + * @return $this + */ + public function setAuthCaptureTimestamp($auth_capture_timestamp) + { + $this->auth_capture_timestamp = $auth_capture_timestamp; + return $this; + } + + /** + * 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. + * + * @return string + */ + public function getAuthCaptureTimestamp() + { + return $this->auth_capture_timestamp; + } + + /** + * Name of the bank. + * + * @param string $bank_name + * + * @return $this + */ + public function setBankName($bank_name) + { + $this->bank_name = $bank_name; + return $this; + } + + /** + * Name of the bank. + * + * @return string + */ + public function getBankName() + { + return $this->bank_name; + } + + /** + * 2 letter country code of the Bank. + * + * @param string $country_code + * + * @return $this + */ + public function setCountryCode($country_code) + { + $this->country_code = $country_code; + return $this; + } + + /** + * 2 letter country code of the Bank. + * + * @return string + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * Account holder's first name. + * + * @param string $first_name + * + * @return $this + */ + public function setFirstName($first_name) + { + $this->first_name = $first_name; + return $this; + } + + /** + * Account holder's first name. + * + * @return string + */ + public function getFirstName() + { + return $this->first_name; + } + + /** + * Account holder's last name. + * + * @param string $last_name + * + * @return $this + */ + public function setLastName($last_name) + { + $this->last_name = $last_name; + return $this; + } + + /** + * Account holder's last name. + * + * @return string + */ + public function getLastName() + { + return $this->last_name; + } + + /** + * Birth date of the bank account holder. + * + * @param string $birth_date + * + * @return $this + */ + public function setBirthDate($birth_date) + { + $this->birth_date = $birth_date; + return $this; + } + + /** + * Birth date of the bank account holder. + * + * @return string + */ + public function getBirthDate() + { + return $this->birth_date; + } + + /** + * Billing address. + * + * @param \PayPal\Api\Address $billing_address + * + * @return $this + */ + public function setBillingAddress($billing_address) + { + $this->billing_address = $billing_address; + return $this; + } + + /** + * Billing address. + * + * @return \PayPal\Api\Address + */ + public function getBillingAddress() + { + return $this->billing_address; + } + + /** + * State of this funding instrument. + * Valid Values: ["ACTIVE", "INACTIVE", "DELETED"] + * + * @param string $state + * + * @return $this + */ + public function setState($state) + { + $this->state = $state; + return $this; + } + + /** + * State of this funding instrument. + * + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * Confirmation status of a bank account. + * Valid Values: ["UNCONFIRMED", "CONFIRMED"] + * + * @param string $confirmation_status + * + * @return $this + */ + public function setConfirmationStatus($confirmation_status) + { + $this->confirmation_status = $confirmation_status; + return $this; + } + + /** + * Confirmation status of a bank account. + * + * @return string + */ + public function getConfirmationStatus() + { + return $this->confirmation_status; + } + + /** + * [DEPRECATED] Use external_customer_id instead. + * + * @param string $payer_id + * + * @return $this + */ + public function setPayerId($payer_id) + { + $this->payer_id = $payer_id; + return $this; + } + + /** + * @deprecated [DEPRECATED] Use external_customer_id instead. + * + * @return string + */ + public function getPayerId() + { + return $this->payer_id; + } + + /** + * 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. + * + * @param string $external_customer_id + * + * @return $this + */ + public function setExternalCustomerId($external_customer_id) + { + $this->external_customer_id = $external_customer_id; + return $this; + } + + /** + * 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. + * + * @return string + */ + public function getExternalCustomerId() + { + return $this->external_customer_id; + } + + /** + * 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 merchant. + * + * @param string $merchant_id + * + * @return $this + */ + public function setMerchantId($merchant_id) + { + $this->merchant_id = $merchant_id; + return $this; + } + + /** + * 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 merchant. + * + * @return string + */ + public function getMerchantId() + { + return $this->merchant_id; + } + + /** + * Time the resource was created. + * + * @param string $create_time + * + * @return $this + */ + public function setCreateTime($create_time) + { + $this->create_time = $create_time; + return $this; + } + + /** + * Time the resource was created. + * + * @return string + */ + public function getCreateTime() + { + return $this->create_time; + } + + /** + * Time the resource was last updated. + * + * @param string $update_time + * + * @return $this + */ + public function setUpdateTime($update_time) + { + $this->update_time = $update_time; + return $this; + } + + /** + * Time the resource was last updated. + * + * @return string + */ + public function getUpdateTime() + { + return $this->update_time; + } + + /** + * Date/Time until this resource can be used to fund a payment. + * + * @param string $valid_until + * + * @return $this + */ + public function setValidUntil($valid_until) + { + $this->valid_until = $valid_until; + return $this; + } + + /** + * Date/Time until this resource can be used to fund a payment. + * + * @return string + */ + public function getValidUntil() + { + return $this->valid_until; + } + + /** + * Sets Links + * + * @param \PayPal\Api\Links[] $links + * + * @return $this + */ + public function setLinks($links) + { + $this->links = $links; + return $this; + } + + /** + * Gets Links + * + * @return \PayPal\Api\Links[] + */ + public function getLinks() + { + return $this->links; + } + + /** + * Append Links to the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function addLink($links) + { + if (!$this->getLinks()) { + return $this->setLinks(array($links)); + } else { + return $this->setLinks( + array_merge($this->getLinks(), array($links)) + ); + } + } + + /** + * Remove Links from the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function removeLink($links) + { + return $this->setLinks( + array_diff($this->getLinks(), array($links)) + ); + } + +} diff --git a/paypal/PayPal/Api/BankAccountsList.php b/paypal/PayPal/Api/BankAccountsList.php new file mode 100644 index 0000000..9120941 --- /dev/null +++ b/paypal/PayPal/Api/BankAccountsList.php @@ -0,0 +1,119 @@ +{"bank-accounts"} = $bank_accounts; + return $this; + } + + /** + * A list of bank account resources + * + * @return \PayPal\Api\BankAccount[] + */ + public function getBankAccounts() + { + return $this->{"bank-accounts"}; + } + + /** + * Append BankAccounts to the list. + * + * @param \PayPal\Api\BankAccount $bankAccount + * @return $this + */ + public function addBankAccount($bankAccount) + { + if (!$this->getBankAccounts()) { + return $this->setBankAccounts(array($bankAccount)); + } else { + return $this->setBankAccounts( + array_merge($this->getBankAccounts(), array($bankAccount)) + ); + } + } + + /** + * Remove BankAccounts from the list. + * + * @param \PayPal\Api\BankAccount $bankAccount + * @return $this + */ + public function removeBankAccount($bankAccount) + { + return $this->setBankAccounts( + array_diff($this->getBankAccounts(), array($bankAccount)) + ); + } + + /** + * 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. + * + * @param int $count + * + * @return $this + */ + public function setCount($count) + { + $this->count = $count; + return $this; + } + + /** + * 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. + * + * @return int + */ + public function getCount() + { + return $this->count; + } + + /** + * Identifier of the next element to get the next range of results. + * + * @param string $next_id + * + * @return $this + */ + public function setNextId($next_id) + { + $this->next_id = $next_id; + return $this; + } + + /** + * Identifier of the next element to get the next range of results. + * + * @return string + */ + public function getNextId() + { + return $this->next_id; + } + +} diff --git a/paypal/PayPal/Api/BankToken.php b/paypal/PayPal/Api/BankToken.php new file mode 100644 index 0000000..6cbee49 --- /dev/null +++ b/paypal/PayPal/Api/BankToken.php @@ -0,0 +1,89 @@ +bank_id = $bank_id; + return $this; + } + + /** + * ID of a previously saved Bank resource using /vault/bank API. + * + * @return string + */ + public function getBankId() + { + return $this->bank_id; + } + + /** + * The unique identifier of the payer used when saving this bank using /vault/bank API. + * + * @param string $external_customer_id + * + * @return $this + */ + public function setExternalCustomerId($external_customer_id) + { + $this->external_customer_id = $external_customer_id; + return $this; + } + + /** + * The unique identifier of the payer used when saving this bank using /vault/bank API. + * + * @return string + */ + public function getExternalCustomerId() + { + return $this->external_customer_id; + } + + /** + * Identifier of the direct debit mandate to validate. Currently supported only for EU bank accounts(SEPA). + * + * @param string $mandate_reference_number + * + * @return $this + */ + public function setMandateReferenceNumber($mandate_reference_number) + { + $this->mandate_reference_number = $mandate_reference_number; + return $this; + } + + /** + * Identifier of the direct debit mandate to validate. Currently supported only for EU bank accounts(SEPA). + * + * @return string + */ + public function getMandateReferenceNumber() + { + return $this->mandate_reference_number; + } + +} diff --git a/paypal/PayPal/Api/BaseAddress.php b/paypal/PayPal/Api/BaseAddress.php new file mode 100644 index 0000000..41900f6 --- /dev/null +++ b/paypal/PayPal/Api/BaseAddress.php @@ -0,0 +1,211 @@ +line1 = $line1; + return $this; + } + + /** + * Line 1 of the Address (eg. number, street, etc). + * + * @return string + */ + public function getLine1() + { + return $this->line1; + } + + /** + * Optional line 2 of the Address (eg. suite, apt #, etc.). + * + * @param string $line2 + * + * @return $this + */ + public function setLine2($line2) + { + $this->line2 = $line2; + return $this; + } + + /** + * Optional line 2 of the Address (eg. suite, apt #, etc.). + * + * @return string + */ + public function getLine2() + { + return $this->line2; + } + + /** + * City name. + * + * @param string $city + * + * @return $this + */ + public function setCity($city) + { + $this->city = $city; + return $this; + } + + /** + * City name. + * + * @return string + */ + public function getCity() + { + return $this->city; + } + + /** + * 2 letter country code. + * + * @param string $country_code + * + * @return $this + */ + public function setCountryCode($country_code) + { + $this->country_code = $country_code; + return $this; + } + + /** + * 2 letter country code. + * + * @return string + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * 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. + * + * @param string $postal_code + * + * @return $this + */ + public function setPostalCode($postal_code) + { + $this->postal_code = $postal_code; + return $this; + } + + /** + * 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. + * + * @return string + */ + public function getPostalCode() + { + return $this->postal_code; + } + + /** + * 2 letter code for US states, and the equivalent for other countries. + * + * @param string $state + * + * @return $this + */ + public function setState($state) + { + $this->state = $state; + return $this; + } + + /** + * 2 letter code for US states, and the equivalent for other countries. + * + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * Address normalization status + * Valid Values: ["UNKNOWN", "UNNORMALIZED_USER_PREFERRED", "NORMALIZED", "UNNORMALIZED"] + * + * @param string $normalization_status + * + * @return $this + */ + public function setNormalizationStatus($normalization_status) + { + $this->normalization_status = $normalization_status; + return $this; + } + + /** + * Address normalization status + * + * @return string + */ + public function getNormalizationStatus() + { + return $this->normalization_status; + } + + /** + * Address status + * Valid Values: ["CONFIRMED", "UNCONFIRMED"] + * + * @param string $status + * + * @return $this + */ + public function setStatus($status) + { + $this->status = $status; + return $this; + } + + /** + * Address status + * + * @return string + */ + public function getStatus() + { + return $this->status; + } + +} diff --git a/paypal/PayPal/Api/Billing.php b/paypal/PayPal/Api/Billing.php new file mode 100644 index 0000000..727f907 --- /dev/null +++ b/paypal/PayPal/Api/Billing.php @@ -0,0 +1,43 @@ +billing_agreement_id = $billing_agreement_id; + return $this; + } + + /** + * Identifier of the instrument in PayPal Wallet + * + * @return string + */ + public function getBillingAgreementId() + { + return $this->billing_agreement_id; + } + +} diff --git a/paypal/PayPal/Api/BillingAgreementToken.php b/paypal/PayPal/Api/BillingAgreementToken.php new file mode 100644 index 0000000..ca5ef6b --- /dev/null +++ b/paypal/PayPal/Api/BillingAgreementToken.php @@ -0,0 +1,17 @@ +email = $email; + return $this; + } + + /** + * The invoice recipient email address. Maximum length is 260 characters. + * + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * The invoice recipient first name. Maximum length is 30 characters. + * + * @param string $first_name + * + * @return $this + */ + public function setFirstName($first_name) + { + $this->first_name = $first_name; + return $this; + } + + /** + * The invoice recipient first name. Maximum length is 30 characters. + * + * @return string + */ + public function getFirstName() + { + return $this->first_name; + } + + /** + * The invoice recipient last name. Maximum length is 30 characters. + * + * @param string $last_name + * + * @return $this + */ + public function setLastName($last_name) + { + $this->last_name = $last_name; + return $this; + } + + /** + * The invoice recipient last name. Maximum length is 30 characters. + * + * @return string + */ + public function getLastName() + { + return $this->last_name; + } + + /** + * The invoice recipient company business name. Maximum length is 100 characters. + * + * @param string $business_name + * + * @return $this + */ + public function setBusinessName($business_name) + { + $this->business_name = $business_name; + return $this; + } + + /** + * The invoice recipient company business name. Maximum length is 100 characters. + * + * @return string + */ + public function getBusinessName() + { + return $this->business_name; + } + + /** + * The invoice recipient address. + * + * @param \PayPal\Api\InvoiceAddress $address + * + * @return $this + */ + public function setAddress($address) + { + $this->address = $address; + return $this; + } + + /** + * The invoice recipient address. + * + * @return \PayPal\Api\InvoiceAddress + */ + public function getAddress() + { + return $this->address; + } + + /** + * The language in which the email was sent to the payer. Used only when the payer does not have a PayPal account. + * 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"] + * + * @param string $language + * + * @return $this + */ + public function setLanguage($language) + { + $this->language = $language; + return $this; + } + + /** + * The language in which the email was sent to the payer. Used only when the payer does not have a PayPal account. + * + * @return string + */ + public function getLanguage() + { + return $this->language; + } + + /** + * Additional information, such as business hours. Maximum length is 40 characters. + * + * @param string $additional_info + * + * @return $this + */ + public function setAdditionalInfo($additional_info) + { + $this->additional_info = $additional_info; + return $this; + } + + /** + * Additional information, such as business hours. Maximum length is 40 characters. + * + * @return string + */ + public function getAdditionalInfo() + { + return $this->additional_info; + } + + /** + * Preferred notification channel of the payer. Email by default. + * Valid Values: ["SMS", "EMAIL"] + * + * @param string $notification_channel + * + * @return $this + */ + public function setNotificationChannel($notification_channel) + { + $this->notification_channel = $notification_channel; + return $this; + } + + /** + * Preferred notification channel of the payer. Email by default. + * + * @return string + */ + public function getNotificationChannel() + { + return $this->notification_channel; + } + + /** + * Mobile Phone number of the recipient to which SMS will be sent if notification_channel is SMS. + * + * @param \PayPal\Api\Phone $phone + * + * @return $this + */ + public function setPhone($phone) + { + $this->phone = $phone; + return $this; + } + + /** + * Mobile Phone number of the recipient to which SMS will be sent if notification_channel is SMS. + * + * @return \PayPal\Api\Phone + */ + public function getPhone() + { + return $this->phone; + } + +} diff --git a/paypal/PayPal/Api/CancelNotification.php b/paypal/PayPal/Api/CancelNotification.php new file mode 100644 index 0000000..ccbea45 --- /dev/null +++ b/paypal/PayPal/Api/CancelNotification.php @@ -0,0 +1,167 @@ +subject = $subject; + return $this; + } + + /** + * Subject of the notification. + * + * @return string + */ + public function getSubject() + { + return $this->subject; + } + + /** + * Note to the payer. + * + * @param string $note + * + * @return $this + */ + public function setNote($note) + { + $this->note = $note; + return $this; + } + + /** + * Note to the payer. + * + * @return string + */ + public function getNote() + { + return $this->note; + } + + /** + * Indicates whether to send a copy of the notification to the merchant. + * + * @param bool $send_to_merchant + * + * @return $this + */ + public function setSendToMerchant($send_to_merchant) + { + $this->send_to_merchant = $send_to_merchant; + return $this; + } + + /** + * Indicates whether to send a copy of the notification to the merchant. + * + * @return bool + */ + public function getSendToMerchant() + { + return $this->send_to_merchant; + } + + /** + * Indicates whether to send a copy of the notification to the payer. + * + * @param bool $send_to_payer + * + * @return $this + */ + public function setSendToPayer($send_to_payer) + { + $this->send_to_payer = $send_to_payer; + return $this; + } + + /** + * Indicates whether to send a copy of the notification to the payer. + * + * @return bool + */ + public function getSendToPayer() + { + return $this->send_to_payer; + } + + /** + * Applicable for invoices created with Cc emails. If this field is not in the body, all the cc email addresses added as part of the invoice shall be notified else this field can be used to limit the list of email addresses. Note: additional email addresses are not supported. + * + * @param string[] $cc_emails + * + * @return $this + */ + public function setCcEmails($cc_emails) + { + $this->cc_emails = $cc_emails; + return $this; + } + + /** + * Applicable for invoices created with Cc emails. If this field is not in the body, all the cc email addresses added as part of the invoice shall be notified else this field can be used to limit the list of email addresses. Note: additional email addresses are not supported. + * + * @return string[] + */ + public function getCcEmails() + { + return $this->cc_emails; + } + + /** + * Append CcEmails to the list. + * + * @param string $string + * @return $this + */ + public function addCcEmail($string) + { + if (!$this->getCcEmails()) { + return $this->setCcEmails(array($string)); + } else { + return $this->setCcEmails( + array_merge($this->getCcEmails(), array($string)) + ); + } + } + + /** + * Remove CcEmails from the list. + * + * @param string $string + * @return $this + */ + public function removeCcEmail($string) + { + return $this->setCcEmails( + array_diff($this->getCcEmails(), array($string)) + ); + } + +} diff --git a/paypal/PayPal/Api/Capture.php b/paypal/PayPal/Api/Capture.php new file mode 100644 index 0000000..8358bfd --- /dev/null +++ b/paypal/PayPal/Api/Capture.php @@ -0,0 +1,341 @@ +id = $id; + return $this; + } + + /** + * The ID of the capture transaction. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * The amount to capture. 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`. + * + * @param \PayPal\Api\Amount $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * The amount to capture. 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`. + * + * @return \PayPal\Api\Amount + */ + public function getAmount() + { + return $this->amount; + } + + /** + * Indicates whether to release all remaining funds that the authorization holds in the funding instrument. Default is `false`. + * + * @param bool $is_final_capture + * + * @return $this + */ + public function setIsFinalCapture($is_final_capture) + { + $this->is_final_capture = $is_final_capture; + return $this; + } + + /** + * Indicates whether to release all remaining funds that the authorization holds in the funding instrument. Default is `false`. + * + * @return bool + */ + public function getIsFinalCapture() + { + return $this->is_final_capture; + } + + /** + * The state of the capture. + * Valid Values: ["pending", "completed", "refunded", "partially_refunded"] + * + * @param string $state + * + * @return $this + */ + public function setState($state) + { + $this->state = $state; + return $this; + } + + /** + * The state of the capture. + * + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * The reason code that describes why the transaction state is pending or reversed. + * Valid Values: ["CHARGEBACK", "GUARANTEE", "BUYER_COMPLAINT", "REFUND", "UNCONFIRMED_SHIPPING_ADDRESS", "ECHECK", "INTERNATIONAL_WITHDRAWAL", "RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION", "PAYMENT_REVIEW", "REGULATORY_REVIEW", "UNILATERAL", "VERIFICATION_REQUIRED", "TRANSACTION_APPROVED_AWAITING_FUNDING"] + * + * @param string $reason_code + * + * @return $this + */ + public function setReasonCode($reason_code) + { + $this->reason_code = $reason_code; + return $this; + } + + /** + * The reason code that describes why the transaction state is pending or reversed. + * + * @return string + */ + public function getReasonCode() + { + return $this->reason_code; + } + + /** + * The ID of the payment on which this transaction is based. + * + * @param string $parent_payment + * + * @return $this + */ + public function setParentPayment($parent_payment) + { + $this->parent_payment = $parent_payment; + return $this; + } + + /** + * The ID of the payment on which this transaction is based. + * + * @return string + */ + public function getParentPayment() + { + return $this->parent_payment; + } + + /** + * The invoice number to track this payment. + * + * @param string $invoice_number + * + * @return $this + */ + public function setInvoiceNumber($invoice_number) + { + $this->invoice_number = $invoice_number; + return $this; + } + + /** + * The invoice number to track this payment. + * + * @return string + */ + public function getInvoiceNumber() + { + return $this->invoice_number; + } + + /** + * The transaction fee for this payment. + * + * @param \PayPal\Api\Currency $transaction_fee + * + * @return $this + */ + public function setTransactionFee($transaction_fee) + { + $this->transaction_fee = $transaction_fee; + return $this; + } + + /** + * The transaction fee for this payment. + * + * @return \PayPal\Api\Currency + */ + public function getTransactionFee() + { + return $this->transaction_fee; + } + + /** + * The date and time of capture, as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @param string $create_time + * + * @return $this + */ + public function setCreateTime($create_time) + { + $this->create_time = $create_time; + return $this; + } + + /** + * The date and time of capture, as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return string + */ + public function getCreateTime() + { + return $this->create_time; + } + + /** + * The date and time when the resource was last updated. + * + * @param string $update_time + * + * @return $this + */ + public function setUpdateTime($update_time) + { + $this->update_time = $update_time; + return $this; + } + + /** + * The date and time when the resource was last updated. + * + * @return string + */ + public function getUpdateTime() + { + return $this->update_time; + } + + /** + * Shows details for a captured payment, by ID. + * + * @param string $captureId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Capture + */ + public static function get($captureId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($captureId, 'captureId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/payments/capture/$captureId", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new Capture(); + $ret->fromJson($json); + return $ret; + } + + /** + * 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. + * + * @deprecated Please use #refundCapturedPayment instead. + * @param Refund $refund + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Refund + */ + public function refund($refund, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($refund, 'refund'); + $payLoad = $refund->toJSON(); + $json = self::executeCall( + "/v1/payments/capture/{$this->getId()}/refund", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new Refund(); + $ret->fromJson($json); + return $ret; + } + + /** + * Refunds a captured payment, by ID. Include an `amount` object in the JSON request body. + * + * @param RefundRequest $refundRequest + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return DetailedRefund + */ + public function refundCapturedPayment($refundRequest, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($refundRequest, 'refundRequest'); + $payLoad = $refundRequest->toJSON(); + $json = self::executeCall( + "/v1/payments/capture/{$this->getId()}/refund", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new DetailedRefund(); + $ret->fromJson($json); + return $ret; + } + +} diff --git a/paypal/PayPal/Api/CarrierAccount.php b/paypal/PayPal/Api/CarrierAccount.php new file mode 100644 index 0000000..7f245b0 --- /dev/null +++ b/paypal/PayPal/Api/CarrierAccount.php @@ -0,0 +1,138 @@ +id = $id; + return $this; + } + + /** + * The ID of the carrier account of the payer. Use in subsequent REST API calls. For example, to make payments. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * The phone number of the payer, in E.164 format. + * + * @param string $phone_number + * + * @return $this + */ + public function setPhoneNumber($phone_number) + { + $this->phone_number = $phone_number; + return $this; + } + + /** + * The phone number of the payer, in E.164 format. + * + * @return string + */ + public function getPhoneNumber() + { + return $this->phone_number; + } + + /** + * The ID of the customer, as created by the merchant. + * + * @param string $external_customer_id + * + * @return $this + */ + public function setExternalCustomerId($external_customer_id) + { + $this->external_customer_id = $external_customer_id; + return $this; + } + + /** + * The ID of the customer, as created by the merchant. + * + * @return string + */ + public function getExternalCustomerId() + { + return $this->external_customer_id; + } + + /** + * The method used to obtain the phone number. Value is `READ_FROM_DEVICE` or `USER_PROVIDED`. + * Valid Values: ["READ_FROM_DEVICE", "USER_PROVIDED"] + * + * @param string $phone_source + * + * @return $this + */ + public function setPhoneSource($phone_source) + { + $this->phone_source = $phone_source; + return $this; + } + + /** + * The method used to obtain the phone number. Value is `READ_FROM_DEVICE` or `USER_PROVIDED`. + * + * @return string + */ + public function getPhoneSource() + { + return $this->phone_source; + } + + /** + * The ISO 3166-1 alpha-2 country code where the phone number is registered. + * + * @param \PayPal\Api\CountryCode $country_code + * + * @return $this + */ + public function setCountryCode($country_code) + { + $this->country_code = $country_code; + return $this; + } + + /** + * The ISO 3166-1 alpha-2 country code where the phone number is registered. + * + * @return \PayPal\Api\CountryCode + */ + public function getCountryCode() + { + return $this->country_code; + } + +} diff --git a/paypal/PayPal/Api/CarrierAccountToken.php b/paypal/PayPal/Api/CarrierAccountToken.php new file mode 100644 index 0000000..9fc987b --- /dev/null +++ b/paypal/PayPal/Api/CarrierAccountToken.php @@ -0,0 +1,65 @@ +carrier_account_id = $carrier_account_id; + return $this; + } + + /** + * ID of a previously saved carrier account resource. + * + * @return string + */ + public function getCarrierAccountId() + { + return $this->carrier_account_id; + } + + /** + * The unique identifier of the payer used when saving this carrier account instrument. + * + * @param string $external_customer_id + * + * @return $this + */ + public function setExternalCustomerId($external_customer_id) + { + $this->external_customer_id = $external_customer_id; + return $this; + } + + /** + * The unique identifier of the payer used when saving this carrier account instrument. + * + * @return string + */ + public function getExternalCustomerId() + { + return $this->external_customer_id; + } + +} diff --git a/paypal/PayPal/Api/CartBase.php b/paypal/PayPal/Api/CartBase.php new file mode 100644 index 0000000..1f7ef1e --- /dev/null +++ b/paypal/PayPal/Api/CartBase.php @@ -0,0 +1,408 @@ +reference_id = $reference_id; + return $this; + } + + /** + * Merchant identifier to the purchase unit. Optional parameter + * + * @return string + */ + public function getReferenceId() + { + return $this->reference_id; + } + + /** + * Amount being collected. + * + * @param \PayPal\Api\Amount $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * Amount being collected. + * + * @return \PayPal\Api\Amount + */ + public function getAmount() + { + return $this->amount; + } + + /** + * Recipient of the funds in this transaction. + * + * @param \PayPal\Api\Payee $payee + * + * @return $this + */ + public function setPayee($payee) + { + $this->payee = $payee; + return $this; + } + + /** + * Recipient of the funds in this transaction. + * + * @return \PayPal\Api\Payee + */ + public function getPayee() + { + return $this->payee; + } + + /** + * Description of what is being paid for. + * + * @param string $description + * + * @return $this + */ + public function setDescription($description) + { + $this->description = $description; + return $this; + } + + /** + * Description of what is being paid for. + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Note to the recipient of the funds in this transaction. + * + * @param string $note_to_payee + * + * @return $this + */ + public function setNoteToPayee($note_to_payee) + { + $this->note_to_payee = $note_to_payee; + return $this; + } + + /** + * Note to the recipient of the funds in this transaction. + * + * @return string + */ + public function getNoteToPayee() + { + return $this->note_to_payee; + } + + /** + * free-form field for the use of clients + * + * @param string $custom + * + * @return $this + */ + public function setCustom($custom) + { + $this->custom = $custom; + return $this; + } + + /** + * free-form field for the use of clients + * + * @return string + */ + public function getCustom() + { + return $this->custom; + } + + /** + * invoice number to track this payment + * + * @param string $invoice_number + * + * @return $this + */ + public function setInvoiceNumber($invoice_number) + { + $this->invoice_number = $invoice_number; + return $this; + } + + /** + * invoice number to track this payment + * + * @return string + */ + public function getInvoiceNumber() + { + return $this->invoice_number; + } + + /** + * purchase order is number or id specific to this payment + * + * @param string $purchase_order + * + * @return $this + */ + public function setPurchaseOrder($purchase_order) + { + $this->purchase_order = $purchase_order; + return $this; + } + + /** + * purchase order is number or id specific to this payment + * + * @return string + */ + public function getPurchaseOrder() + { + return $this->purchase_order; + } + + /** + * Soft descriptor used when charging this funding source. If length exceeds max length, the value will be truncated + * + * @param string $soft_descriptor + * + * @return $this + */ + public function setSoftDescriptor($soft_descriptor) + { + $this->soft_descriptor = $soft_descriptor; + return $this; + } + + /** + * Soft descriptor used when charging this funding source. If length exceeds max length, the value will be truncated + * + * @return string + */ + public function getSoftDescriptor() + { + return $this->soft_descriptor; + } + + /** + * 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` + * @deprecated Not publicly available + * @param string $soft_descriptor_city + * + * @return $this + */ + public function setSoftDescriptorCity($soft_descriptor_city) + { + $this->soft_descriptor_city = $soft_descriptor_city; + return $this; + } + + /** + * 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` + * @deprecated Not publicly available + * @return string + */ + public function getSoftDescriptorCity() + { + return $this->soft_descriptor_city; + } + + /** + * Payment options requested for this purchase unit + * + * @param \PayPal\Api\PaymentOptions $payment_options + * + * @return $this + */ + public function setPaymentOptions($payment_options) + { + $this->payment_options = $payment_options; + return $this; + } + + /** + * Payment options requested for this purchase unit + * + * @return \PayPal\Api\PaymentOptions + */ + public function getPaymentOptions() + { + return $this->payment_options; + } + + /** + * List of items being paid for. + * + * @param \PayPal\Api\ItemList $item_list + * + * @return $this + */ + public function setItemList($item_list) + { + $this->item_list = $item_list; + return $this; + } + + /** + * List of items being paid for. + * + * @return \PayPal\Api\ItemList + */ + public function getItemList() + { + return $this->item_list; + } + + /** + * URL to send payment notifications + * + * @param string $notify_url + * @throws \InvalidArgumentException + * @return $this + */ + public function setNotifyUrl($notify_url) + { + UrlValidator::validate($notify_url, "NotifyUrl"); + $this->notify_url = $notify_url; + return $this; + } + + /** + * URL to send payment notifications + * + * @return string + */ + public function getNotifyUrl() + { + return $this->notify_url; + } + + /** + * Url on merchant site pertaining to this payment. + * + * @param string $order_url + * @throws \InvalidArgumentException + * @return $this + */ + public function setOrderUrl($order_url) + { + UrlValidator::validate($order_url, "OrderUrl"); + $this->order_url = $order_url; + return $this; + } + + /** + * Url on merchant site pertaining to this payment. + * + * @return string + */ + public function getOrderUrl() + { + return $this->order_url; + } + + /** + * List of external funding being applied to the purchase unit. Each external_funding unit should have a unique reference_id + * @deprecated Not publicly available + * @param \PayPal\Api\ExternalFunding[] $external_funding + * + * @return $this + */ + public function setExternalFunding($external_funding) + { + $this->external_funding = $external_funding; + return $this; + } + + /** + * List of external funding being applied to the purchase unit. Each external_funding unit should have a unique reference_id + * @deprecated Not publicly available + * @return \PayPal\Api\ExternalFunding[] + */ + public function getExternalFunding() + { + return $this->external_funding; + } + + /** + * Append ExternalFunding to the list. + * @deprecated Not publicly available + * @param \PayPal\Api\ExternalFunding $externalFunding + * @return $this + */ + public function addExternalFunding($externalFunding) + { + if (!$this->getExternalFunding()) { + return $this->setExternalFunding(array($externalFunding)); + } else { + return $this->setExternalFunding( + array_merge($this->getExternalFunding(), array($externalFunding)) + ); + } + } + + /** + * Remove ExternalFunding from the list. + * @deprecated Not publicly available + * @param \PayPal\Api\ExternalFunding $externalFunding + * @return $this + */ + public function removeExternalFunding($externalFunding) + { + return $this->setExternalFunding( + array_diff($this->getExternalFunding(), array($externalFunding)) + ); + } + +} diff --git a/paypal/PayPal/Api/ChargeModel.php b/paypal/PayPal/Api/ChargeModel.php new file mode 100644 index 0000000..de486fe --- /dev/null +++ b/paypal/PayPal/Api/ChargeModel.php @@ -0,0 +1,89 @@ +id = $id; + return $this; + } + + /** + * Identifier of the charge model. 128 characters max. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Type of charge model. Allowed values: `SHIPPING`, `TAX`. + * + * @param string $type + * + * @return $this + */ + public function setType($type) + { + $this->type = $type; + return $this; + } + + /** + * Type of charge model. Allowed values: `SHIPPING`, `TAX`. + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Specific amount for this charge model. + * + * @param \PayPal\Api\Currency $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * Specific amount for this charge model. + * + * @return \PayPal\Api\Currency + */ + public function getAmount() + { + return $this->amount; + } + +} diff --git a/paypal/PayPal/Api/Cost.php b/paypal/PayPal/Api/Cost.php new file mode 100644 index 0000000..5a96fba --- /dev/null +++ b/paypal/PayPal/Api/Cost.php @@ -0,0 +1,69 @@ +percent = $percent; + return $this; + } + + /** + * Cost in percent. Range of 0 to 100. + * + * @return string + */ + public function getPercent() + { + return $this->percent; + } + + /** + * The cost, as an amount. Valid range is from 0 to 1,000,000. + * + * @param \PayPal\Api\Currency $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * The cost, as an amount. Valid range is from 0 to 1,000,000. + * + * @return \PayPal\Api\Currency + */ + public function getAmount() + { + return $this->amount; + } + +} diff --git a/paypal/PayPal/Api/CountryCode.php b/paypal/PayPal/Api/CountryCode.php new file mode 100644 index 0000000..48ef51d --- /dev/null +++ b/paypal/PayPal/Api/CountryCode.php @@ -0,0 +1,41 @@ +country_code = $country_code; + return $this; + } + + /** + * ISO country code based on 2-character IS0-3166-1 codes. + * + * @return string + */ + public function getCountryCode() + { + return $this->country_code; + } + +} diff --git a/paypal/PayPal/Api/CreateProfileResponse.php b/paypal/PayPal/Api/CreateProfileResponse.php new file mode 100644 index 0000000..1b36faf --- /dev/null +++ b/paypal/PayPal/Api/CreateProfileResponse.php @@ -0,0 +1,40 @@ +id = $id; + return $this; + } + + /** + * ID of the payment web experience profile. + * + * @return string + */ + public function getId() + { + return $this->id; + } + +} diff --git a/paypal/PayPal/Api/Credit.php b/paypal/PayPal/Api/Credit.php new file mode 100644 index 0000000..14fca8d --- /dev/null +++ b/paypal/PayPal/Api/Credit.php @@ -0,0 +1,66 @@ +id = $id; + return $this; + } + + /** + * Unique identifier of credit resource. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * specifies type of credit + * Valid Values: ["BILL_ME_LATER", "PAYPAL_EXTRAS_MASTERCARD", "EBAY_MASTERCARD", "PAYPAL_SMART_CONNECT"] + * + * @param string $type + * + * @return $this + */ + public function setType($type) + { + $this->type = $type; + return $this; + } + + /** + * specifies type of credit + * + * @return string + */ + public function getType() + { + return $this->type; + } + +} diff --git a/paypal/PayPal/Api/CreditCard.php b/paypal/PayPal/Api/CreditCard.php new file mode 100644 index 0000000..ad00bb0 --- /dev/null +++ b/paypal/PayPal/Api/CreditCard.php @@ -0,0 +1,560 @@ +id = $id; + return $this; + } + + /** + * ID of the credit card. This ID is provided in the response when storing credit cards. **Required if using a stored credit card.** + * + * @deprecated Not publicly available + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * 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.* + * + * @param string $number + * + * @return $this + */ + public function setNumber($number) + { + $this->number = $number; + return $this; + } + + /** + * 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.* + * + * @return string + */ + public function getNumber() + { + return $this->number; + } + + /** + * Credit card type. Valid types are: `visa`, `mastercard`, `discover`, `amex` + * + * @param string $type + * + * @return $this + */ + public function setType($type) + { + $this->type = $type; + return $this; + } + + /** + * Credit card type. Valid types are: `visa`, `mastercard`, `discover`, `amex` + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Expiration month with no leading zero. Acceptable values are 1 through 12. + * + * @param int $expire_month + * + * @return $this + */ + public function setExpireMonth($expire_month) + { + $this->expire_month = $expire_month; + return $this; + } + + /** + * Expiration month with no leading zero. Acceptable values are 1 through 12. + * + * @return int + */ + public function getExpireMonth() + { + return $this->expire_month; + } + + /** + * 4-digit expiration year. + * + * @param int $expire_year + * + * @return $this + */ + public function setExpireYear($expire_year) + { + $this->expire_year = $expire_year; + return $this; + } + + /** + * 4-digit expiration year. + * + * @return int + */ + public function getExpireYear() + { + return $this->expire_year; + } + + /** + * 3-4 digit card validation code. + * + * @param string $cvv2 + * + * @return $this + */ + public function setCvv2($cvv2) + { + $this->cvv2 = $cvv2; + return $this; + } + + /** + * 3-4 digit card validation code. + * + * @return string + */ + public function getCvv2() + { + return $this->cvv2; + } + + /** + * Cardholder's first name. + * + * @param string $first_name + * + * @return $this + */ + public function setFirstName($first_name) + { + $this->first_name = $first_name; + return $this; + } + + /** + * Cardholder's first name. + * + * @return string + */ + public function getFirstName() + { + return $this->first_name; + } + + /** + * Cardholder's last name. + * + * @param string $last_name + * + * @return $this + */ + public function setLastName($last_name) + { + $this->last_name = $last_name; + return $this; + } + + /** + * Cardholder's last name. + * + * @return string + */ + public function getLastName() + { + return $this->last_name; + } + + /** + * Billing Address associated with this card. + * + * @param \PayPal\Api\Address $billing_address + * + * @return $this + */ + public function setBillingAddress($billing_address) + { + $this->billing_address = $billing_address; + return $this; + } + + /** + * Billing Address associated with this card. + * + * @return \PayPal\Api\Address + */ + public function getBillingAddress() + { + return $this->billing_address; + } + + /** + * 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.** + * + * @param string $external_customer_id + * + * @return $this + */ + public function setExternalCustomerId($external_customer_id) + { + $this->external_customer_id = $external_customer_id; + return $this; + } + + /** + * 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.** + * + * @return string + */ + public function getExternalCustomerId() + { + return $this->external_customer_id; + } + + /** + * 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 + * + * @param string $merchant_id + * + * @return $this + */ + public function setMerchantId($merchant_id) + { + $this->merchant_id = $merchant_id; + return $this; + } + + /** + * 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 + * + * @return string + */ + public function getMerchantId() + { + return $this->merchant_id; + } + + /** + * 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. + * + * @deprecated This is being deprecated in favor of the `external_customer_id` property. + * @param string $payer_id + * + * @return $this + */ + public function setPayerId($payer_id) + { + $this->payer_id = $payer_id; + return $this; + } + + /** + * 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. + * + * @deprecated This is being deprecated in favor of the `external_customer_id` property. + * @return string + */ + public function getPayerId() + { + return $this->payer_id; + } + + /** + * 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. + * + * @param string $external_card_id + * + * @return $this + */ + public function setExternalCardId($external_card_id) + { + $this->external_card_id = $external_card_id; + return $this; + } + + /** + * 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. + * + * @return string + */ + public function getExternalCardId() + { + return $this->external_card_id; + } + + /** + * State of the credit card funding instrument. + * Valid Values: ["expired", "ok"] + * + * @param string $state + * + * @return $this + */ + public function setState($state) + { + $this->state = $state; + return $this; + } + + /** + * State of the credit card funding instrument. + * + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * Funding instrument expiration date. + * + * @param string $create_time + * + * @return $this + */ + public function setCreateTime($create_time) + { + $this->create_time = $create_time; + return $this; + } + + /** + * Resource creation time as ISO8601 date-time format (ex: 1994-11-05T13:15:30Z) that indicates creation time. + * + * @return string + */ + public function getCreateTime() + { + return $this->create_time; + } + + /** + * Resource creation time as ISO8601 date-time format (ex: 1994-11-05T13:15:30Z) that indicates the updation time. + * + * @param string $update_time + * + * @return $this + */ + public function setUpdateTime($update_time) + { + $this->update_time = $update_time; + return $this; + } + + /** + * Resource creation time as ISO8601 date-time format (ex: 1994-11-05T13:15:30Z) that indicates the updation time. + * + * @return string + */ + public function getUpdateTime() + { + return $this->update_time; + } + + /** + * Date/Time until this resource can be used fund a payment. + * + * @param string $valid_until + * + * @return $this + */ + public function setValidUntil($valid_until) + { + $this->valid_until = $valid_until; + return $this; + } + + /** + * Funding instrument expiration date. + * + * @return string + */ + public function getValidUntil() + { + return $this->valid_until; + } + + /** + * Creates a new Credit Card Resource (aka Tokenize). + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return CreditCard + */ + public function create($apiContext = null, $restCall = null) + { + $payLoad = $this->toJSON(); + $json = self::executeCall( + "/v1/vault/credit-cards", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $this->fromJson($json); + return $this; + } + + /** + * Obtain the Credit Card resource for the given identifier. + * + * @param string $creditCardId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return CreditCard + */ + public static function get($creditCardId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($creditCardId, 'creditCardId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/vault/credit-cards/$creditCardId", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new CreditCard(); + $ret->fromJson($json); + return $ret; + } + + /** + * Delete the Credit Card resource for the given identifier. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function delete($apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + $payLoad = ""; + self::executeCall( + "/v1/vault/credit-cards/{$this->getId()}", + "DELETE", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * Update information in a previously saved card. Only the modified fields need to be passed in the request. + * + * @param PatchRequest $patchRequest + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return CreditCard + */ + public function update($patchRequest, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($patchRequest, 'patch'); + $payload = $patchRequest->toJSON(); + $json = self::executeCall( + "/v1/vault/credit-cards/{$this->getId()}", + "PATCH", + $payload, + null, + $apiContext, + $restCall + ); + $this->fromJson($json); + return $this; + } + + /** + * Retrieves a list of Credit Card resources. + * + * @param array $params + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return CreditCardList + */ + public static function all($params, $apiContext = null, $restCall = null) + { + if (is_null($params)) { + $params = array(); + } + ArgumentValidator::validate($params, 'params'); + $payLoad = ""; + $allowedParams = array( + 'page_size' => 1, + 'page' => 1, + 'start_time' => 1, + 'end_time' => 1, + 'sort_order' => 1, + 'sort_by' => 1, + 'merchant_id' => 1, + 'external_card_id' => 1, + 'external_customer_id' => 1, + 'total_required' => 1 + ); + $json = self::executeCall( + "/v1/vault/credit-cards" . "?" . http_build_query(array_intersect_key($params, $allowedParams)), + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new CreditCardList(); + $ret->fromJson($json); + return $ret; + } + +} diff --git a/paypal/PayPal/Api/CreditCardHistory.php b/paypal/PayPal/Api/CreditCardHistory.php new file mode 100644 index 0000000..f8d0a94 --- /dev/null +++ b/paypal/PayPal/Api/CreditCardHistory.php @@ -0,0 +1,91 @@ +{"credit-cards"} = $credit_cards; + return $this; + } + + /** + * A list of credit card resources + * + * @return \PayPal\Api\CreditCard + */ + public function getCreditCards() + { + return $this->{"credit-cards"}; + } + + /** + * 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. + * + * + * @param int $count + * + * @return $this + */ + public function setCount($count) + { + $this->count = $count; + return $this; + } + + /** + * 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. + * + * @return int + */ + public function getCount() + { + return $this->count; + } + + /** + * Identifier of the next element to get the next range of results. + * + * + * @param string $next_id + * + * @return $this + */ + public function setNextId($next_id) + { + $this->next_id = $next_id; + return $this; + } + + /** + * Identifier of the next element to get the next range of results. + * + * @return string + */ + public function getNextId() + { + return $this->next_id; + } + +} diff --git a/paypal/PayPal/Api/CreditCardList.php b/paypal/PayPal/Api/CreditCardList.php new file mode 100644 index 0000000..97ba6aa --- /dev/null +++ b/paypal/PayPal/Api/CreditCardList.php @@ -0,0 +1,120 @@ +items = $items; + return $this; + } + + /** + * A list of credit card resources + * + * @return \PayPal\Api\CreditCard[] + */ + public function getItems() + { + return $this->items; + } + + /** + * Append Items to the list. + * + * @param \PayPal\Api\CreditCard $creditCard + * @return $this + */ + public function addItem($creditCard) + { + if (!$this->getItems()) { + return $this->setItems(array($creditCard)); + } else { + return $this->setItems( + array_merge($this->getItems(), array($creditCard)) + ); + } + } + + /** + * Remove Items from the list. + * + * @param \PayPal\Api\CreditCard $creditCard + * @return $this + */ + public function removeItem($creditCard) + { + return $this->setItems( + array_diff($this->getItems(), array($creditCard)) + ); + } + + /** + * 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. + * + * @param int $total_items + * + * @return $this + */ + public function setTotalItems($total_items) + { + $this->total_items = $total_items; + return $this; + } + + /** + * 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. + * + * @return int + */ + public function getTotalItems() + { + return $this->total_items; + } + + /** + * Total number of pages that exist, for the total number of items, with the given page size. + * + * @param int $total_pages + * + * @return $this + */ + public function setTotalPages($total_pages) + { + $this->total_pages = $total_pages; + return $this; + } + + /** + * Total number of pages that exist, for the total number of items, with the given page size. + * + * @return int + */ + public function getTotalPages() + { + return $this->total_pages; + } + +} diff --git a/paypal/PayPal/Api/CreditCardToken.php b/paypal/PayPal/Api/CreditCardToken.php new file mode 100644 index 0000000..301e9dd --- /dev/null +++ b/paypal/PayPal/Api/CreditCardToken.php @@ -0,0 +1,161 @@ +credit_card_id = $credit_card_id; + return $this; + } + + /** + * ID of credit card previously stored using `/vault/credit-card`. + * + * @return string + */ + public function getCreditCardId() + { + return $this->credit_card_id; + } + + /** + * 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.** + * + * @param string $payer_id + * + * @return $this + */ + public function setPayerId($payer_id) + { + $this->payer_id = $payer_id; + return $this; + } + + /** + * 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.** + * + * @return string + */ + public function getPayerId() + { + return $this->payer_id; + } + + /** + * Last four digits of the stored credit card number. + * + * @param string $last4 + * + * @return $this + */ + public function setLast4($last4) + { + $this->last4 = $last4; + return $this; + } + + /** + * Last four digits of the stored credit card number. + * + * @return string + */ + public function getLast4() + { + return $this->last4; + } + + /** + * Credit card type. Valid types are: `visa`, `mastercard`, `discover`, `amex`. Values are presented in lowercase and not should not be used for display. + * + * @param string $type + * + * @return $this + */ + public function setType($type) + { + $this->type = $type; + return $this; + } + + /** + * Credit card type. Valid types are: `visa`, `mastercard`, `discover`, `amex`. Values are presented in lowercase and not should not be used for display. + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Expiration month with no leading zero. Acceptable values are 1 through 12. + * + * @param int $expire_month + * + * @return $this + */ + public function setExpireMonth($expire_month) + { + $this->expire_month = $expire_month; + return $this; + } + + /** + * Expiration month with no leading zero. Acceptable values are 1 through 12. + * + * @return int + */ + public function getExpireMonth() + { + return $this->expire_month; + } + + /** + * 4-digit expiration year. + * + * @param int $expire_year + * + * @return $this + */ + public function setExpireYear($expire_year) + { + $this->expire_year = $expire_year; + return $this; + } + + /** + * 4-digit expiration year. + * + * @return int + */ + public function getExpireYear() + { + return $this->expire_year; + } + +} diff --git a/paypal/PayPal/Api/CreditFinancingOffered.php b/paypal/PayPal/Api/CreditFinancingOffered.php new file mode 100644 index 0000000..bb24617 --- /dev/null +++ b/paypal/PayPal/Api/CreditFinancingOffered.php @@ -0,0 +1,161 @@ +total_cost = $total_cost; + return $this; + } + + /** + * This is the estimated total payment amount including interest and fees the user will pay during the lifetime of the loan. + * + * @return \PayPal\Api\Currency + */ + public function getTotalCost() + { + return $this->total_cost; + } + + /** + * Length of financing terms in month + * + * @param \PayPal\Api\number $term + * + * @return $this + */ + public function setTerm($term) + { + $this->term = $term; + return $this; + } + + /** + * Length of financing terms in month + * + * @return \PayPal\Api\number + */ + public function getTerm() + { + return $this->term; + } + + /** + * This is the estimated amount per month that the customer will need to pay including fees and interest. + * + * @param \PayPal\Api\Currency $monthly_payment + * + * @return $this + */ + public function setMonthlyPayment($monthly_payment) + { + $this->monthly_payment = $monthly_payment; + return $this; + } + + /** + * This is the estimated amount per month that the customer will need to pay including fees and interest. + * + * @return \PayPal\Api\Currency + */ + public function getMonthlyPayment() + { + return $this->monthly_payment; + } + + /** + * Estimated interest or fees amount the payer will have to pay during the lifetime of the loan. + * + * @param \PayPal\Api\Currency $total_interest + * + * @return $this + */ + public function setTotalInterest($total_interest) + { + $this->total_interest = $total_interest; + return $this; + } + + /** + * Estimated interest or fees amount the payer will have to pay during the lifetime of the loan. + * + * @return \PayPal\Api\Currency + */ + public function getTotalInterest() + { + return $this->total_interest; + } + + /** + * Status on whether the customer ultimately was approved for and chose to make the payment using the approved installment credit. + * + * @param bool $payer_acceptance + * + * @return $this + */ + public function setPayerAcceptance($payer_acceptance) + { + $this->payer_acceptance = $payer_acceptance; + return $this; + } + + /** + * Status on whether the customer ultimately was approved for and chose to make the payment using the approved installment credit. + * + * @return bool + */ + public function getPayerAcceptance() + { + return $this->payer_acceptance; + } + + /** + * Indicates whether the cart amount is editable after payer's acceptance on PayPal side + * + * @param bool $cart_amount_immutable + * + * @return $this + */ + public function setCartAmountImmutable($cart_amount_immutable) + { + $this->cart_amount_immutable = $cart_amount_immutable; + return $this; + } + + /** + * Indicates whether the cart amount is editable after payer's acceptance on PayPal side + * + * @return bool + */ + public function getCartAmountImmutable() + { + return $this->cart_amount_immutable; + } + +} diff --git a/paypal/PayPal/Api/Currency.php b/paypal/PayPal/Api/Currency.php new file mode 100644 index 0000000..eb53eb9 --- /dev/null +++ b/paypal/PayPal/Api/Currency.php @@ -0,0 +1,69 @@ +currency = $currency; + return $this; + } + + /** + * 3 letter currency code as defined by ISO 4217. + * + * @return string + */ + public function getCurrency() + { + return $this->currency; + } + + /** + * amount up to N digit after the decimals separator as defined in ISO 4217 for the appropriate currency code. + * + * @param string|double $value + * + * @return $this + */ + public function setValue($value) + { + NumericValidator::validate($value, "Value"); + $value = FormatConverter::formatToPrice($value, $this->getCurrency()); + $this->value = $value; + return $this; + } + + /** + * amount up to N digit after the decimals separator as defined in ISO 4217 for the appropriate currency code. + * + * @return string + */ + public function getValue() + { + return $this->value; + } + +} diff --git a/paypal/PayPal/Api/CurrencyConversion.php b/paypal/PayPal/Api/CurrencyConversion.php new file mode 100644 index 0000000..5347986 --- /dev/null +++ b/paypal/PayPal/Api/CurrencyConversion.php @@ -0,0 +1,266 @@ +conversion_date = $conversion_date; + return $this; + } + + /** + * Date of validity for the conversion rate. + * + * @return string + */ + public function getConversionDate() + { + return $this->conversion_date; + } + + /** + * 3 letter currency code + * + * @param string $from_currency + * + * @return $this + */ + public function setFromCurrency($from_currency) + { + $this->from_currency = $from_currency; + return $this; + } + + /** + * 3 letter currency code + * + * @return string + */ + public function getFromCurrency() + { + return $this->from_currency; + } + + /** + * Amount participating in currency conversion, set to 1 as default + * + * @param string $from_amount + * + * @return $this + */ + public function setFromAmount($from_amount) + { + $this->from_amount = $from_amount; + return $this; + } + + /** + * Amount participating in currency conversion, set to 1 as default + * + * @return string + */ + public function getFromAmount() + { + return $this->from_amount; + } + + /** + * 3 letter currency code + * + * @param string $to_currency + * + * @return $this + */ + public function setToCurrency($to_currency) + { + $this->to_currency = $to_currency; + return $this; + } + + /** + * 3 letter currency code + * + * @return string + */ + public function getToCurrency() + { + return $this->to_currency; + } + + /** + * Amount resulting from currency conversion. + * + * @param string $to_amount + * + * @return $this + */ + public function setToAmount($to_amount) + { + $this->to_amount = $to_amount; + return $this; + } + + /** + * Amount resulting from currency conversion. + * + * @return string + */ + public function getToAmount() + { + return $this->to_amount; + } + + /** + * Field indicating conversion type applied. + * Valid Values: ["PAYPAL", "VENDOR"] + * + * @param string $conversion_type + * + * @return $this + */ + public function setConversionType($conversion_type) + { + $this->conversion_type = $conversion_type; + return $this; + } + + /** + * Field indicating conversion type applied. + * + * @return string + */ + public function getConversionType() + { + return $this->conversion_type; + } + + /** + * Allow Payer to change conversion type. + * + * @param bool $conversion_type_changeable + * + * @return $this + */ + public function setConversionTypeChangeable($conversion_type_changeable) + { + $this->conversion_type_changeable = $conversion_type_changeable; + return $this; + } + + /** + * Allow Payer to change conversion type. + * + * @return bool + */ + public function getConversionTypeChangeable() + { + return $this->conversion_type_changeable; + } + + /** + * Base URL to web applications endpoint + * Valid Values: ["https://www.paypal.com/{country_code}/webapps/xocspartaweb/webflow/sparta/proxwebflow", "https://www.paypal.com/{country_code}/proxflow"] + * @deprecated Not publicly available + * @param string $web_url + * @throws \InvalidArgumentException + * @return $this + */ + public function setWebUrl($web_url) + { + UrlValidator::validate($web_url, "WebUrl"); + $this->web_url = $web_url; + return $this; + } + + /** + * Base URL to web applications endpoint + * @deprecated Not publicly available + * @return string + */ + public function getWebUrl() + { + return $this->web_url; + } + + /** + * Sets Links + * + * @param \PayPal\Api\Links[] $links + * + * @return $this + */ + public function setLinks($links) + { + $this->links = $links; + return $this; + } + + /** + * Gets Links + * + * @return \PayPal\Api\Links[] + */ + public function getLinks() + { + return $this->links; + } + + /** + * Append Links to the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function addLink($links) + { + if (!$this->getLinks()) { + return $this->setLinks(array($links)); + } else { + return $this->setLinks( + array_merge($this->getLinks(), array($links)) + ); + } + } + + /** + * Remove Links from the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function removeLink($links) + { + return $this->setLinks( + array_diff($this->getLinks(), array($links)) + ); + } + +} diff --git a/paypal/PayPal/Api/CustomAmount.php b/paypal/PayPal/Api/CustomAmount.php new file mode 100644 index 0000000..e61146c --- /dev/null +++ b/paypal/PayPal/Api/CustomAmount.php @@ -0,0 +1,65 @@ +label = $label; + return $this; + } + + /** + * The custom amount label. Maximum length is 25 characters. + * + * @return string + */ + public function getLabel() + { + return $this->label; + } + + /** + * The custom amount value. Valid range is from -999999.99 to 999999.99. + * + * @param \PayPal\Api\Currency $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * The custom amount value. Valid range is from -999999.99 to 999999.99. + * + * @return \PayPal\Api\Currency + */ + public function getAmount() + { + return $this->amount; + } + +} diff --git a/paypal/PayPal/Api/DetailedRefund.php b/paypal/PayPal/Api/DetailedRefund.php new file mode 100644 index 0000000..e010a1d --- /dev/null +++ b/paypal/PayPal/Api/DetailedRefund.php @@ -0,0 +1,160 @@ +custom = $custom; + return $this; + } + + /** + * free-form field for the use of clients + * + * @return string + */ + public function getCustom() + { + return $this->custom; + } + + /** + * Amount refunded to payer of the original transaction, in the current Refund call + * + * @param \PayPal\Api\Currency $refund_to_payer + * + * @return $this + */ + public function setRefundToPayer($refund_to_payer) + { + $this->refund_to_payer = $refund_to_payer; + return $this; + } + + /** + * Amount refunded to payer of the original transaction, in the current Refund call + * + * @return \PayPal\Api\Currency + */ + public function getRefundToPayer() + { + return $this->refund_to_payer; + } + + /** + * List of external funding that were refunded by the Refund call. Each external_funding unit should have a unique reference_id + * + * @param \PayPal\Api\ExternalFunding[] $refund_to_external_funding + * + * @return $this + */ + public function setRefundToExternalFunding($refund_to_external_funding) + { + $this->refund_to_external_funding = $refund_to_external_funding; + return $this; + } + + /** + * List of external funding that were refunded by the Refund call. Each external_funding unit should have a unique reference_id + * + * @return \PayPal\Api\ExternalFunding[] + */ + public function getRefundToExternalFunding() + { + return $this->refund_to_external_funding; + } + + /** + * Transaction fee refunded to original recipient of payment. + * + * @param \PayPal\Api\Currency $refund_from_transaction_fee + * + * @return $this + */ + public function setRefundFromTransactionFee($refund_from_transaction_fee) + { + $this->refund_from_transaction_fee = $refund_from_transaction_fee; + return $this; + } + + /** + * Transaction fee refunded to original recipient of payment. + * + * @return \PayPal\Api\Currency + */ + public function getRefundFromTransactionFee() + { + return $this->refund_from_transaction_fee; + } + + /** + * Amount subtracted from PayPal balance of the original recipient of payment, to make this refund. + * + * @param \PayPal\Api\Currency $refund_from_received_amount + * + * @return $this + */ + public function setRefundFromReceivedAmount($refund_from_received_amount) + { + $this->refund_from_received_amount = $refund_from_received_amount; + return $this; + } + + /** + * Amount subtracted from PayPal balance of the original recipient of payment, to make this refund. + * + * @return \PayPal\Api\Currency + */ + public function getRefundFromReceivedAmount() + { + return $this->refund_from_received_amount; + } + + /** + * Total amount refunded so far from the original purchase. Say, for example, a buyer makes $100 purchase, the buyer was refunded $20 a week ago and is refunded $30 in this transaction. The gross refund amount is $30 (in this transaction). The total refunded amount is $50. + * + * @param \PayPal\Api\Currency $total_refunded_amount + * + * @return $this + */ + public function setTotalRefundedAmount($total_refunded_amount) + { + $this->total_refunded_amount = $total_refunded_amount; + return $this; + } + + /** + * Total amount refunded so far from the original purchase. Say, for example, a buyer makes $100 purchase, the buyer was refunded $20 a week ago and is refunded $30 in this transaction. The gross refund amount is $30 (in this transaction). The total refunded amount is $50. + * + * @return \PayPal\Api\Currency + */ + public function getTotalRefundedAmount() + { + return $this->total_refunded_amount; + } + +} diff --git a/paypal/PayPal/Api/Details.php b/paypal/PayPal/Api/Details.php new file mode 100644 index 0000000..53212b7 --- /dev/null +++ b/paypal/PayPal/Api/Details.php @@ -0,0 +1,227 @@ +subtotal = $subtotal; + return $this; + } + + /** + * Amount of the subtotal of the items. **Required** if line items are specified. 10 characters max, with support for 2 decimal places. + * + * @return string + */ + public function getSubtotal() + { + return $this->subtotal; + } + + /** + * Amount charged for shipping. 10 characters max with support for 2 decimal places. + * + * @param string|double $shipping + * + * @return $this + */ + public function setShipping($shipping) + { + NumericValidator::validate($shipping, "Shipping"); + $shipping = FormatConverter::formatToPrice($shipping); + $this->shipping = $shipping; + return $this; + } + + /** + * Amount charged for shipping. 10 characters max with support for 2 decimal places. + * + * @return string + */ + public function getShipping() + { + return $this->shipping; + } + + /** + * Amount charged for tax. 10 characters max with support for 2 decimal places. + * + * @param string|double $tax + * + * @return $this + */ + public function setTax($tax) + { + NumericValidator::validate($tax, "Tax"); + $tax = FormatConverter::formatToPrice($tax); + $this->tax = $tax; + return $this; + } + + /** + * Amount charged for tax. 10 characters max with support for 2 decimal places. + * + * @return string + */ + public function getTax() + { + return $this->tax; + } + + /** + * Amount being charged for the handling fee. Only supported when the `payment_method` is set to `paypal`. + * + * @param string|double $handling_fee + * + * @return $this + */ + public function setHandlingFee($handling_fee) + { + NumericValidator::validate($handling_fee, "Handling Fee"); + $handling_fee = FormatConverter::formatToPrice($handling_fee); + $this->handling_fee = $handling_fee; + return $this; + } + + /** + * Amount being charged for the handling fee. Only supported when the `payment_method` is set to `paypal`. + * + * @return string + */ + public function getHandlingFee() + { + return $this->handling_fee; + } + + /** + * Amount being discounted for the shipping fee. Only supported when the `payment_method` is set to `paypal`. + * + * @param string|double $shipping_discount + * + * @return $this + */ + public function setShippingDiscount($shipping_discount) + { + NumericValidator::validate($shipping_discount, "Shipping Discount"); + $shipping_discount = FormatConverter::formatToPrice($shipping_discount); + $this->shipping_discount = $shipping_discount; + return $this; + } + + /** + * Amount being discounted for the shipping fee. Only supported when the `payment_method` is set to `paypal`. + * + * @return string + */ + public function getShippingDiscount() + { + return $this->shipping_discount; + } + + /** + * Amount being charged for the insurance fee. Only supported when the `payment_method` is set to `paypal`. + * + * @param string|double $insurance + * + * @return $this + */ + public function setInsurance($insurance) + { + NumericValidator::validate($insurance, "Insurance"); + $insurance = FormatConverter::formatToPrice($insurance); + $this->insurance = $insurance; + return $this; + } + + /** + * Amount being charged for the insurance fee. Only supported when the `payment_method` is set to `paypal`. + * + * @return string + */ + public function getInsurance() + { + return $this->insurance; + } + + /** + * Amount being charged as gift wrap fee. + * + * @param string|double $gift_wrap + * + * @return $this + */ + public function setGiftWrap($gift_wrap) + { + NumericValidator::validate($gift_wrap, "Gift Wrap"); + $gift_wrap = FormatConverter::formatToPrice($gift_wrap); + $this->gift_wrap = $gift_wrap; + return $this; + } + + /** + * Amount being charged as gift wrap fee. + * + * @return string + */ + public function getGiftWrap() + { + return $this->gift_wrap; + } + + /** + * Fee charged by PayPal. In case of a refund, this is the fee amount refunded to the original receipient of the payment. + * + * @param string|double $fee + * + * @return $this + */ + public function setFee($fee) + { + NumericValidator::validate($fee, "Fee"); + $fee = FormatConverter::formatToPrice($fee); + $this->fee = $fee; + return $this; + } + + /** + * Fee charged by PayPal. In case of a refund, this is the fee amount refunded to the original receipient of the payment. + * + * @return string + */ + public function getFee() + { + return $this->fee; + } + +} diff --git a/paypal/PayPal/Api/Error.php b/paypal/PayPal/Api/Error.php new file mode 100644 index 0000000..574dddc --- /dev/null +++ b/paypal/PayPal/Api/Error.php @@ -0,0 +1,320 @@ +name = $name; + return $this; + } + + /** + * Human readable, unique name of the error. + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Reference ID of the purchase_unit associated with this error + * + * @deprecated Not publicly available + * @param string $purchase_unit_reference_id + * + * @return $this + */ + public function setPurchaseUnitReferenceId($purchase_unit_reference_id) + { + $this->purchase_unit_reference_id = $purchase_unit_reference_id; + return $this; + } + + /** + * Reference ID of the purchase_unit associated with this error + * + * @deprecated Not publicly available + * @return string + */ + public function getPurchaseUnitReferenceId() + { + return $this->purchase_unit_reference_id; + } + + /** + * PayPal internal error code. + * + * @deprecated Not publicly available + * @param string $code + * + * @return $this + */ + public function setCode($code) + { + $this->code = $code; + return $this; + } + + /** + * PayPal internal error code. + * + * @deprecated Not publicly available + * @return string + */ + public function getCode() + { + return $this->code; + } + + /** + * PayPal internal identifier used for correlation purposes. + * + * @param string $debug_id + * + * @return $this + */ + public function setDebugId($debug_id) + { + $this->debug_id = $debug_id; + return $this; + } + + /** + * PayPal internal identifier used for correlation purposes. + * + * @return string + */ + public function getDebugId() + { + return $this->debug_id; + } + + /** + * Message describing the error. + * + * @param string $message + * + * @return $this + */ + public function setMessage($message) + { + $this->message = $message; + return $this; + } + + /** + * Message describing the error. + * + * @return string + */ + public function getMessage() + { + return $this->message; + } + + /** + * URI for detailed information related to this error for the developer. + * + * @param string $information_link + * + * @return $this + */ + public function setInformationLink($information_link) + { + $this->information_link = $information_link; + return $this; + } + + /** + * URI for detailed information related to this error for the developer. + * + * @return string + */ + public function getInformationLink() + { + return $this->information_link; + } + + /** + * Additional details of the error + * + * @param \PayPal\Api\ErrorDetails[] $details + * + * @return $this + */ + public function setDetails($details) + { + $this->details = $details; + return $this; + } + + /** + * Additional details of the error + * + * @return \PayPal\Api\ErrorDetails[] + */ + public function getDetails() + { + return $this->details; + } + + /** + * Append Details to the list. + * + * @param \PayPal\Api\ErrorDetails $errorDetails + * @return $this + */ + public function addDetail($errorDetails) + { + if (!$this->getDetails()) { + return $this->setDetails(array($errorDetails)); + } else { + return $this->setDetails( + array_merge($this->getDetails(), array($errorDetails)) + ); + } + } + + /** + * Remove Details from the list. + * + * @param \PayPal\Api\ErrorDetails $errorDetails + * @return $this + */ + public function removeDetail($errorDetails) + { + return $this->setDetails( + array_diff($this->getDetails(), array($errorDetails)) + ); + } + + /** + * response codes returned from a payment processor such as avs, cvv, etc. Only supported when the `payment_method` is set to `credit_card`. + * + * @deprecated Not publicly available + * @param \PayPal\Api\ProcessorResponse $processor_response + * + * @return $this + */ + public function setProcessorResponse($processor_response) + { + $this->processor_response = $processor_response; + return $this; + } + + /** + * response codes returned from a payment processor such as avs, cvv, etc. Only supported when the `payment_method` is set to `credit_card`. + * + * @deprecated Not publicly available + * @return \PayPal\Api\ProcessorResponse + */ + public function getProcessorResponse() + { + return $this->processor_response; + } + + /** + * Fraud filter details. Only supported when the `payment_method` is set to `credit_card` + * + * @deprecated Not publicly available + * @param \PayPal\Api\FmfDetails $fmf_details + * + * @return $this + */ + public function setFmfDetails($fmf_details) + { + $this->fmf_details = $fmf_details; + return $this; + } + + /** + * Fraud filter details. Only supported when the `payment_method` is set to `credit_card` + * + * @deprecated Not publicly available + * @return \PayPal\Api\FmfDetails + */ + public function getFmfDetails() + { + return $this->fmf_details; + } + + /** + * Sets Links + * + * @param \PayPal\Api\Links[] $links + * + * @return $this + */ + public function setLinks($links) + { + $this->links = $links; + return $this; + } + + /** + * Gets Links + * + * @return \PayPal\Api\Links[] + */ + public function getLinks() + { + return $this->links; + } + + /** + * Append Links to the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function addLink($links) + { + if (!$this->getLinks()) { + return $this->setLinks(array($links)); + } else { + return $this->setLinks( + array_merge($this->getLinks(), array($links)) + ); + } + } + + /** + * Remove Links from the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function removeLink($links) + { + return $this->setLinks( + array_diff($this->getLinks(), array($links)) + ); + } +} diff --git a/paypal/PayPal/Api/ErrorDetails.php b/paypal/PayPal/Api/ErrorDetails.php new file mode 100644 index 0000000..d120b0a --- /dev/null +++ b/paypal/PayPal/Api/ErrorDetails.php @@ -0,0 +1,111 @@ +field = $field; + return $this; + } + + /** + * Name of the field that caused the error. + * + * @return string + */ + public function getField() + { + return $this->field; + } + + /** + * Reason for the error. + * + * @param string $issue + * + * @return $this + */ + public function setIssue($issue) + { + $this->issue = $issue; + return $this; + } + + /** + * Reason for the error. + * + * @return string + */ + public function getIssue() + { + return $this->issue; + } + + /** + * Reference ID of the purchase_unit associated with this error + * @deprecated Not publicly available + * @param string $purchase_unit_reference_id + * + * @return $this + */ + public function setPurchaseUnitReferenceId($purchase_unit_reference_id) + { + $this->purchase_unit_reference_id = $purchase_unit_reference_id; + return $this; + } + + /** + * Reference ID of the purchase_unit associated with this error + * @deprecated Not publicly available + * @return string + */ + public function getPurchaseUnitReferenceId() + { + return $this->purchase_unit_reference_id; + } + + /** + * PayPal internal error code. + * @deprecated Not publicly available + * @param string $code + * + * @return $this + */ + public function setCode($code) + { + $this->code = $code; + return $this; + } + + /** + * PayPal internal error code. + * @deprecated Not publicly available + * @return string + */ + public function getCode() + { + return $this->code; + } + +} diff --git a/paypal/PayPal/Api/ExtendedBankAccount.php b/paypal/PayPal/Api/ExtendedBankAccount.php new file mode 100644 index 0000000..3206c9d --- /dev/null +++ b/paypal/PayPal/Api/ExtendedBankAccount.php @@ -0,0 +1,38 @@ +mandate_reference_number = $mandate_reference_number; + return $this; + } + + /** + * Identifier of the direct debit mandate to validate. Currently supported only for EU bank accounts(SEPA). + * @deprecated Not publicly available + * @return string + */ + public function getMandateReferenceNumber() + { + return $this->mandate_reference_number; + } + +} diff --git a/paypal/PayPal/Api/ExternalFunding.php b/paypal/PayPal/Api/ExternalFunding.php new file mode 100644 index 0000000..e03335b --- /dev/null +++ b/paypal/PayPal/Api/ExternalFunding.php @@ -0,0 +1,161 @@ +reference_id = $reference_id; + return $this; + } + + /** + * Unique identifier for the external funding + * + * @return string + */ + public function getReferenceId() + { + return $this->reference_id; + } + + /** + * Generic identifier for the external funding + * + * @param string $code + * + * @return $this + */ + public function setCode($code) + { + $this->code = $code; + return $this; + } + + /** + * Generic identifier for the external funding + * + * @return string + */ + public function getCode() + { + return $this->code; + } + + /** + * Encrypted PayPal Account identifier for the funding account + * + * @param string $funding_account_id + * + * @return $this + */ + public function setFundingAccountId($funding_account_id) + { + $this->funding_account_id = $funding_account_id; + return $this; + } + + /** + * Encrypted PayPal Account identifier for the funding account + * + * @return string + */ + public function getFundingAccountId() + { + return $this->funding_account_id; + } + + /** + * Description of the external funding being applied + * + * @param string $display_text + * + * @return $this + */ + public function setDisplayText($display_text) + { + $this->display_text = $display_text; + return $this; + } + + /** + * Description of the external funding being applied + * + * @return string + */ + public function getDisplayText() + { + return $this->display_text; + } + + /** + * Amount being funded by the external funding account + * + * @param \PayPal\Api\Amount $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * Amount being funded by the external funding account + * + * @return \PayPal\Api\Amount + */ + public function getAmount() + { + return $this->amount; + } + + /** + * Indicates that the Payment should be fully funded by External Funded Incentive + * Valid Values: ["FULLY_FUNDED"] + * + * @param string $funding_instruction + * + * @return $this + */ + public function setFundingInstruction($funding_instruction) + { + $this->funding_instruction = $funding_instruction; + return $this; + } + + /** + * Indicates that the Payment should be fully funded by External Funded Incentive + * + * @return string + */ + public function getFundingInstruction() + { + return $this->funding_instruction; + } +} diff --git a/paypal/PayPal/Api/FileAttachment.php b/paypal/PayPal/Api/FileAttachment.php new file mode 100644 index 0000000..23b9055 --- /dev/null +++ b/paypal/PayPal/Api/FileAttachment.php @@ -0,0 +1,67 @@ +name = $name; + return $this; + } + + /** + * Name of the file attached. + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * URL of the attached file that can be downloaded. + * + * @param string $url + * @throws \InvalidArgumentException + * @return $this + */ + public function setUrl($url) + { + UrlValidator::validate($url, "Url"); + $this->url = $url; + return $this; + } + + /** + * URL of the attached file that can be downloaded. + * + * @return string + */ + public function getUrl() + { + return $this->url; + } + +} diff --git a/paypal/PayPal/Api/FlowConfig.php b/paypal/PayPal/Api/FlowConfig.php new file mode 100644 index 0000000..975217c --- /dev/null +++ b/paypal/PayPal/Api/FlowConfig.php @@ -0,0 +1,115 @@ +landing_page_type = $landing_page_type; + return $this; + } + + /** + * The type of landing page to display on the PayPal site for user checkout. Set to `Billing` to use the non-PayPal account landing page. Set to `Login` to use the PayPal account login landing page. + * + * @return string + */ + public function getLandingPageType() + { + return $this->landing_page_type; + } + + /** + * The merchant site URL to display after a bank transfer payment. Valid for only the Giropay or bank transfer payment method in Germany. + * + * @param string $bank_txn_pending_url + * @throws \InvalidArgumentException + * @return $this + */ + public function setBankTxnPendingUrl($bank_txn_pending_url) + { + UrlValidator::validate($bank_txn_pending_url, "BankTxnPendingUrl"); + $this->bank_txn_pending_url = $bank_txn_pending_url; + return $this; + } + + /** + * The merchant site URL to display after a bank transfer payment. Valid for only the Giropay or bank transfer payment method in Germany. + * + * @return string + */ + public function getBankTxnPendingUrl() + { + return $this->bank_txn_pending_url; + } + + /** + * Defines whether buyers can complete purchases on the PayPal or merchant website. + * + * @param string $user_action + * + * @return $this + */ + public function setUserAction($user_action) + { + $this->user_action = $user_action; + return $this; + } + + /** + * Defines whether buyers can complete purchases on the PayPal or merchant website. + * + * @return string + */ + public function getUserAction() + { + return $this->user_action; + } + + /** + * Defines the HTTP method to use to redirect the user to a return URL. A valid value is `GET` or `POST`. + * + * @param string $return_uri_http_method + * + * @return $this + */ + public function setReturnUriHttpMethod($return_uri_http_method) + { + $this->return_uri_http_method = $return_uri_http_method; + return $this; + } + + /** + * Defines the HTTP method to use to redirect the user to a return URL. A valid value is `GET` or `POST`. + * + * @return string + */ + public function getReturnUriHttpMethod() + { + return $this->return_uri_http_method; + } + +} diff --git a/paypal/PayPal/Api/FmfDetails.php b/paypal/PayPal/Api/FmfDetails.php new file mode 100644 index 0000000..c5681c8 --- /dev/null +++ b/paypal/PayPal/Api/FmfDetails.php @@ -0,0 +1,115 @@ +filter_type = $filter_type; + return $this; + } + + /** + * Type of filter. + * + * @return string + */ + public function getFilterType() + { + return $this->filter_type; + } + + /** + * Filter Identifier. + * 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"] + * + * @param string $filter_id + * + * @return $this + */ + public function setFilterId($filter_id) + { + $this->filter_id = $filter_id; + return $this; + } + + /** + * Filter Identifier. + * + * @return string + */ + public function getFilterId() + { + return $this->filter_id; + } + + /** + * Name of the filter + * + * @param string $name + * + * @return $this + */ + public function setName($name) + { + $this->name = $name; + return $this; + } + + /** + * Name of the filter + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Description of the filter. + * + * @param string $description + * + * @return $this + */ + public function setDescription($description) + { + $this->description = $description; + return $this; + } + + /** + * Description of the filter. + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + +} diff --git a/paypal/PayPal/Api/FundingDetail.php b/paypal/PayPal/Api/FundingDetail.php new file mode 100644 index 0000000..66cc1f3 --- /dev/null +++ b/paypal/PayPal/Api/FundingDetail.php @@ -0,0 +1,114 @@ +clearing_time = $clearing_time; + return $this; + } + + /** + * Expected clearing time + * + * @return string + */ + public function getClearingTime() + { + return $this->clearing_time; + } + + /** + * [DEPRECATED] Hold-off duration of the payment. payment_debit_date should be used instead. + * + * @param string $payment_hold_date + * + * @return $this + */ + public function setPaymentHoldDate($payment_hold_date) + { + $this->payment_hold_date = $payment_hold_date; + return $this; + } + + /** + * @deprecated [DEPRECATED] Hold-off duration of the payment. payment_debit_date should be used instead. + * + * @return string + */ + public function getPaymentHoldDate() + { + return $this->payment_hold_date; + } + + /** + * Date when funds will be debited from the payer's account + * + * @param string $payment_debit_date + * + * @return $this + */ + public function setPaymentDebitDate($payment_debit_date) + { + $this->payment_debit_date = $payment_debit_date; + return $this; + } + + /** + * Date when funds will be debited from the payer's account + * + * @return string + */ + public function getPaymentDebitDate() + { + return $this->payment_debit_date; + } + + /** + * Processing type of the payment card + * Valid Values: ["CUP_SECURE", "PINLESS_DEBIT"] + * + * @param string $processing_type + * + * @return $this + */ + public function setProcessingType($processing_type) + { + $this->processing_type = $processing_type; + return $this; + } + + /** + * Processing type of the payment card + * + * @return string + */ + public function getProcessingType() + { + return $this->processing_type; + } + +} diff --git a/paypal/PayPal/Api/FundingInstrument.php b/paypal/PayPal/Api/FundingInstrument.php new file mode 100644 index 0000000..da311f4 --- /dev/null +++ b/paypal/PayPal/Api/FundingInstrument.php @@ -0,0 +1,321 @@ +credit_card = $credit_card; + return $this; + } + + /** + * Credit Card instrument. + * + * @return \PayPal\Api\CreditCard + */ + public function getCreditCard() + { + return $this->credit_card; + } + + /** + * PayPal vaulted credit Card instrument. + * + * @param \PayPal\Api\CreditCardToken $credit_card_token + * + * @return $this + */ + public function setCreditCardToken($credit_card_token) + { + $this->credit_card_token = $credit_card_token; + return $this; + } + + /** + * PayPal vaulted credit Card instrument. + * + * @return \PayPal\Api\CreditCardToken + */ + public function getCreditCardToken() + { + return $this->credit_card_token; + } + + /** + * Payment Card information. + * + * @param \PayPal\Api\PaymentCard $payment_card + * + * @return $this + */ + public function setPaymentCard($payment_card) + { + $this->payment_card = $payment_card; + return $this; + } + + /** + * Payment Card information. + * + * @return \PayPal\Api\PaymentCard + */ + public function getPaymentCard() + { + return $this->payment_card; + } + + /** + * Bank Account information. + * @deprecated Not publicly available + * @param \PayPal\Api\ExtendedBankAccount $bank_account + * + * @return $this + */ + public function setBankAccount($bank_account) + { + $this->bank_account = $bank_account; + return $this; + } + + /** + * Bank Account information. + * @deprecated Not publicly available + * @return \PayPal\Api\ExtendedBankAccount + */ + public function getBankAccount() + { + return $this->bank_account; + } + + /** + * Vaulted bank account instrument. + * @deprecated Not publicly available + * @param \PayPal\Api\BankToken $bank_account_token + * + * @return $this + */ + public function setBankAccountToken($bank_account_token) + { + $this->bank_account_token = $bank_account_token; + return $this; + } + + /** + * Vaulted bank account instrument. + * @deprecated Not publicly available + * @return \PayPal\Api\BankToken + */ + public function getBankAccountToken() + { + return $this->bank_account_token; + } + + /** + * PayPal credit funding instrument. + * @deprecated Not publicly available + * @param \PayPal\Api\Credit $credit + * + * @return $this + */ + public function setCredit($credit) + { + $this->credit = $credit; + return $this; + } + + /** + * PayPal credit funding instrument. + * @deprecated Not publicly available + * @return \PayPal\Api\Credit + */ + public function getCredit() + { + return $this->credit; + } + + /** + * Incentive funding instrument. + * @deprecated Not publicly available + * @param \PayPal\Api\Incentive $incentive + * + * @return $this + */ + public function setIncentive($incentive) + { + $this->incentive = $incentive; + return $this; + } + + /** + * Incentive funding instrument. + * @deprecated Not publicly available + * @return \PayPal\Api\Incentive + */ + public function getIncentive() + { + return $this->incentive; + } + + /** + * External funding instrument. + * @deprecated Not publicly available + * @param \PayPal\Api\ExternalFunding $external_funding + * + * @return $this + */ + public function setExternalFunding($external_funding) + { + $this->external_funding = $external_funding; + return $this; + } + + /** + * External funding instrument. + * @deprecated Not publicly available + * @return \PayPal\Api\ExternalFunding + */ + public function getExternalFunding() + { + return $this->external_funding; + } + + /** + * Carrier account token instrument. + * @deprecated Not publicly available + * @param \PayPal\Api\CarrierAccountToken $carrier_account_token + * + * @return $this + */ + public function setCarrierAccountToken($carrier_account_token) + { + $this->carrier_account_token = $carrier_account_token; + return $this; + } + + /** + * Carrier account token instrument. + * @deprecated Not publicly available + * @return \PayPal\Api\CarrierAccountToken + */ + public function getCarrierAccountToken() + { + return $this->carrier_account_token; + } + + /** + * Carrier account instrument + * @deprecated Not publicly available + * @param \PayPal\Api\CarrierAccount $carrier_account + * + * @return $this + */ + public function setCarrierAccount($carrier_account) + { + $this->carrier_account = $carrier_account; + return $this; + } + + /** + * Carrier account instrument + * @deprecated Not publicly available + * @return \PayPal\Api\CarrierAccount + */ + public function getCarrierAccount() + { + return $this->carrier_account; + } + + /** + * Private Label Card funding instrument. These are store cards provided by merchants to drive business with value to customer with convenience and rewards. + * @deprecated Not publicly available + * @param \PayPal\Api\PrivateLabelCard $private_label_card + * + * @return $this + */ + public function setPrivateLabelCard($private_label_card) + { + $this->private_label_card = $private_label_card; + return $this; + } + + /** + * Private Label Card funding instrument. These are store cards provided by merchants to drive business with value to customer with convenience and rewards. + * @deprecated Not publicly available + * @return \PayPal\Api\PrivateLabelCard + */ + public function getPrivateLabelCard() + { + return $this->private_label_card; + } + + /** + * Billing instrument that references pre-approval information for the payment + * + * @param \PayPal\Api\Billing $billing + * + * @return $this + */ + public function setBilling($billing) + { + $this->billing = $billing; + return $this; + } + + /** + * Billing instrument that references pre-approval information for the payment + * + * @return \PayPal\Api\Billing + */ + public function getBilling() + { + return $this->billing; + } + + /** + * Alternate Payment information - Mostly regional payment providers. For e.g iDEAL in Netherlands + * + * @deprecated Not publicly available + * @param \PayPal\Api\AlternatePayment $alternate_payment + * + * @return $this + */ + public function setAlternatePayment($alternate_payment) + { + $this->alternate_payment = $alternate_payment; + return $this; + } + + /** + * Alternate Payment information - Mostly regional payment providers. For e.g iDEAL in Netherlands + * + * @deprecated Not publicly available + * @return \PayPal\Api\AlternatePayment + */ + public function getAlternatePayment() + { + return $this->alternate_payment; + } + +} diff --git a/paypal/PayPal/Api/FundingOption.php b/paypal/PayPal/Api/FundingOption.php new file mode 100644 index 0000000..9848a0c --- /dev/null +++ b/paypal/PayPal/Api/FundingOption.php @@ -0,0 +1,221 @@ +id = $id; + return $this; + } + + /** + * id of the funding option. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * List of funding sources that contributes to a payment. + * + * @param \PayPal\Api\FundingSource[] $funding_sources + * + * @return $this + */ + public function setFundingSources($funding_sources) + { + $this->funding_sources = $funding_sources; + return $this; + } + + /** + * List of funding sources that contributes to a payment. + * + * @return \PayPal\Api\FundingSource[] + */ + public function getFundingSources() + { + return $this->funding_sources; + } + + /** + * Append FundingSources to the list. + * + * @param \PayPal\Api\FundingSource $fundingSource + * @return $this + */ + public function addFundingSource($fundingSource) + { + if (!$this->getFundingSources()) { + return $this->setFundingSources(array($fundingSource)); + } else { + return $this->setFundingSources( + array_merge($this->getFundingSources(), array($fundingSource)) + ); + } + } + + /** + * Remove FundingSources from the list. + * + * @param \PayPal\Api\FundingSource $fundingSource + * @return $this + */ + public function removeFundingSource($fundingSource) + { + return $this->setFundingSources( + array_diff($this->getFundingSources(), array($fundingSource)) + ); + } + + /** + * Backup funding instrument which will be used for payment if primary fails. + * + * @param \PayPal\Api\FundingInstrument $backup_funding_instrument + * + * @return $this + */ + public function setBackupFundingInstrument($backup_funding_instrument) + { + $this->backup_funding_instrument = $backup_funding_instrument; + return $this; + } + + /** + * Backup funding instrument which will be used for payment if primary fails. + * + * @return \PayPal\Api\FundingInstrument + */ + public function getBackupFundingInstrument() + { + return $this->backup_funding_instrument; + } + + /** + * Currency conversion applicable to this funding option. + * + * @param \PayPal\Api\CurrencyConversion $currency_conversion + * + * @return $this + */ + public function setCurrencyConversion($currency_conversion) + { + $this->currency_conversion = $currency_conversion; + return $this; + } + + /** + * Currency conversion applicable to this funding option. + * + * @return \PayPal\Api\CurrencyConversion + */ + public function getCurrencyConversion() + { + return $this->currency_conversion; + } + + /** + * Installment options available for a funding option. + * + * @param \PayPal\Api\InstallmentInfo $installment_info + * + * @return $this + */ + public function setInstallmentInfo($installment_info) + { + $this->installment_info = $installment_info; + return $this; + } + + /** + * Installment options available for a funding option. + * + * @return \PayPal\Api\InstallmentInfo + */ + public function getInstallmentInfo() + { + return $this->installment_info; + } + + /** + * Sets Links + * + * @param \PayPal\Api\Links[] $links + * + * @return $this + */ + public function setLinks($links) + { + $this->links = $links; + return $this; + } + + /** + * Gets Links + * + * @return \PayPal\Api\Links[] + */ + public function getLinks() + { + return $this->links; + } + + /** + * Append Links to the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function addLink($links) + { + if (!$this->getLinks()) { + return $this->setLinks(array($links)); + } else { + return $this->setLinks( + array_merge($this->getLinks(), array($links)) + ); + } + } + + /** + * Remove Links from the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function removeLink($links) + { + return $this->setLinks( + array_diff($this->getLinks(), array($links)) + ); + } + +} diff --git a/paypal/PayPal/Api/FundingSource.php b/paypal/PayPal/Api/FundingSource.php new file mode 100644 index 0000000..95f1799 --- /dev/null +++ b/paypal/PayPal/Api/FundingSource.php @@ -0,0 +1,292 @@ +funding_mode = $funding_mode; + return $this; + } + + /** + * specifies funding mode of the instrument + * + * @return string + */ + public function getFundingMode() + { + return $this->funding_mode; + } + + /** + * Instrument type for this funding source + * Valid Values: ["BALANCE", "PAYMENT_CARD", "BANK_ACCOUNT", "CREDIT", "INCENTIVE", "EXTERNAL_FUNDING", "TAB"] + * + * @param string $funding_instrument_type + * + * @return $this + */ + public function setFundingInstrumentType($funding_instrument_type) + { + $this->funding_instrument_type = $funding_instrument_type; + return $this; + } + + /** + * Instrument type for this funding source + * + * @return string + */ + public function getFundingInstrumentType() + { + return $this->funding_instrument_type; + } + + /** + * Soft descriptor used when charging this funding source. + * + * @param string $soft_descriptor + * + * @return $this + */ + public function setSoftDescriptor($soft_descriptor) + { + $this->soft_descriptor = $soft_descriptor; + return $this; + } + + /** + * Soft descriptor used when charging this funding source. + * + * @return string + */ + public function getSoftDescriptor() + { + return $this->soft_descriptor; + } + + /** + * Total anticipated amount of money to be pulled from instrument. + * + * @param \PayPal\Api\Currency $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * Total anticipated amount of money to be pulled from instrument. + * + * @return \PayPal\Api\Currency + */ + public function getAmount() + { + return $this->amount; + } + + /** + * Additional amount to be pulled from the instrument to recover a negative balance on the buyer's account that is owed to PayPal. + * + * @param \PayPal\Api\Currency $negative_balance_amount + * + * @return $this + */ + public function setNegativeBalanceAmount($negative_balance_amount) + { + $this->negative_balance_amount = $negative_balance_amount; + return $this; + } + + /** + * Additional amount to be pulled from the instrument to recover a negative balance on the buyer's account that is owed to PayPal. + * + * @return \PayPal\Api\Currency + */ + public function getNegativeBalanceAmount() + { + return $this->negative_balance_amount; + } + + /** + * Localized legal text relevant to funding source. + * + * @param string $legal_text + * + * @return $this + */ + public function setLegalText($legal_text) + { + $this->legal_text = $legal_text; + return $this; + } + + /** + * Localized legal text relevant to funding source. + * + * @return string + */ + public function getLegalText() + { + return $this->legal_text; + } + + /** + * Additional detail of the funding. + * + * @param \PayPal\Api\FundingDetail $funding_detail + * + * @return $this + */ + public function setFundingDetail($funding_detail) + { + $this->funding_detail = $funding_detail; + return $this; + } + + /** + * Additional detail of the funding. + * + * @return \PayPal\Api\FundingDetail + */ + public function getFundingDetail() + { + return $this->funding_detail; + } + + /** + * Additional text relevant to funding source. + * + * @param string $additional_text + * + * @return $this + */ + public function setAdditionalText($additional_text) + { + $this->additional_text = $additional_text; + return $this; + } + + /** + * Additional text relevant to funding source. + * + * @return string + */ + public function getAdditionalText() + { + return $this->additional_text; + } + + /** + * Sets Extends + * + * @param \PayPal\Api\FundingInstrument $extends + * + * @deprecated Unused + * + * @return $this + */ + public function setExtends($extends) + { + $this->extends = $extends; + return $this; + } + + /** + * Gets Extends + * + * @deprecated Unused + * + * @return \PayPal\Api\FundingInstrument + */ + public function getExtends() + { + return $this->extends; + } + + /** + * Sets Links + * + * @param \PayPal\Api\Links[] $links + * + * @return $this + */ + public function setLinks($links) + { + $this->links = $links; + return $this; + } + + /** + * Gets Links + * + * @return \PayPal\Api\Links[] + */ + public function getLinks() + { + return $this->links; + } + + /** + * Append Links to the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function addLink($links) + { + if (!$this->getLinks()) { + return $this->setLinks(array($links)); + } else { + return $this->setLinks( + array_merge($this->getLinks(), array($links)) + ); + } + } + + /** + * Remove Links from the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function removeLink($links) + { + return $this->setLinks( + array_diff($this->getLinks(), array($links)) + ); + } + +} diff --git a/paypal/PayPal/Api/FuturePayment.php b/paypal/PayPal/Api/FuturePayment.php new file mode 100644 index 0000000..9744808 --- /dev/null +++ b/paypal/PayPal/Api/FuturePayment.php @@ -0,0 +1,59 @@ + $clientMetadataId + ); + } + $payLoad = $this->toJSON(); + $json = self::executeCall( + "/v1/payments/payment", + "POST", + $payLoad, + $headers, + $apiContext, + $restCall + ); + $this->fromJson($json); + return $this; + } + + /** + * Get a Refresh Token from Authorization Code + * + * @param $authorizationCode + * @param ApiContext $apiContext + * @return string|null refresh token + */ + public static function getRefreshToken($authorizationCode, $apiContext = null) + { + $apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential); + $credential = $apiContext->getCredential(); + return $credential->getRefreshToken($apiContext->getConfig(), $authorizationCode); + } + +} diff --git a/paypal/PayPal/Api/HyperSchema.php b/paypal/PayPal/Api/HyperSchema.php new file mode 100644 index 0000000..7ef5dbb --- /dev/null +++ b/paypal/PayPal/Api/HyperSchema.php @@ -0,0 +1,191 @@ +links = $links; + return $this; + } + + /** + * Gets Links + * + * @return \PayPal\Api\Links[] + */ + public function getLinks() + { + return $this->links; + } + + /** + * Append Links to the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function addLink($links) + { + if (!$this->getLinks()) { + return $this->setLinks(array($links)); + } else { + return $this->setLinks( + array_merge($this->getLinks(), array($links)) + ); + } + } + + /** + * Remove Links from the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function removeLink($links) + { + return $this->setLinks( + array_diff($this->getLinks(), array($links)) + ); + } + + /** + * Sets FragmentResolution + * + * @param string $fragmentResolution + * + * @return $this + */ + public function setFragmentResolution($fragmentResolution) + { + $this->fragmentResolution = $fragmentResolution; + return $this; + } + + /** + * Gets FragmentResolution + * + * @return string + */ + public function getFragmentResolution() + { + return $this->fragmentResolution; + } + + /** + * Sets Readonly + * + * @param bool $readonly + * + * @return $this + */ + public function setReadonly($readonly) + { + $this->readonly = $readonly; + return $this; + } + + /** + * Gets Readonly + * + * @return bool + */ + public function getReadonly() + { + return $this->readonly; + } + + /** + * Sets ContentEncoding + * + * @param string $contentEncoding + * + * @return $this + */ + public function setContentEncoding($contentEncoding) + { + $this->contentEncoding = $contentEncoding; + return $this; + } + + /** + * Gets ContentEncoding + * + * @return string + */ + public function getContentEncoding() + { + return $this->contentEncoding; + } + + /** + * Sets PathStart + * + * @param string $pathStart + * + * @return $this + */ + public function setPathStart($pathStart) + { + $this->pathStart = $pathStart; + return $this; + } + + /** + * Gets PathStart + * + * @return string + */ + public function getPathStart() + { + return $this->pathStart; + } + + /** + * Sets MediaType + * + * @param string $mediaType + * + * @return $this + */ + public function setMediaType($mediaType) + { + $this->mediaType = $mediaType; + return $this; + } + + /** + * Gets MediaType + * + * @return string + */ + public function getMediaType() + { + return $this->mediaType; + } + +} diff --git a/paypal/PayPal/Api/Image.php b/paypal/PayPal/Api/Image.php new file mode 100644 index 0000000..71c7d15 --- /dev/null +++ b/paypal/PayPal/Api/Image.php @@ -0,0 +1,56 @@ +image = $imageBase64String; + return $this; + } + + /** + * Get Image as Base-64 encoded String + * + * @return string + */ + public function getImage() + { + return $this->image; + } + + /** + * Stores the Image to file + * + * @param string $name File Name + * @return string File name + */ + public function saveToFile($name = null) + { + // Self Generate File Location + if (!$name) { + $name = uniqid() . '.png'; + } + // Save to File + file_put_contents($name, base64_decode($this->getImage())); + return $name; + } + +} diff --git a/paypal/PayPal/Api/Incentive.php b/paypal/PayPal/Api/Incentive.php new file mode 100644 index 0000000..7493a65 --- /dev/null +++ b/paypal/PayPal/Api/Incentive.php @@ -0,0 +1,236 @@ +id = $id; + return $this; + } + + /** + * Identifier of the instrument in PayPal Wallet + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Code that identifies the incentive. + * + * @param string $code + * + * @return $this + */ + public function setCode($code) + { + $this->code = $code; + return $this; + } + + /** + * Code that identifies the incentive. + * + * @return string + */ + public function getCode() + { + return $this->code; + } + + /** + * Name of the incentive. + * + * @param string $name + * + * @return $this + */ + public function setName($name) + { + $this->name = $name; + return $this; + } + + /** + * Name of the incentive. + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Description of the incentive. + * + * @param string $description + * + * @return $this + */ + public function setDescription($description) + { + $this->description = $description; + return $this; + } + + /** + * Description of the incentive. + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Indicates incentive is applicable for this minimum purchase amount. + * + * @param \PayPal\Api\Currency $minimum_purchase_amount + * + * @return $this + */ + public function setMinimumPurchaseAmount($minimum_purchase_amount) + { + $this->minimum_purchase_amount = $minimum_purchase_amount; + return $this; + } + + /** + * Indicates incentive is applicable for this minimum purchase amount. + * + * @return \PayPal\Api\Currency + */ + public function getMinimumPurchaseAmount() + { + return $this->minimum_purchase_amount; + } + + /** + * Logo image url for the incentive. + * + * @param string $logo_image_url + * @throws \InvalidArgumentException + * @return $this + */ + public function setLogoImageUrl($logo_image_url) + { + UrlValidator::validate($logo_image_url, "LogoImageUrl"); + $this->logo_image_url = $logo_image_url; + return $this; + } + + /** + * Logo image url for the incentive. + * + * @return string + */ + public function getLogoImageUrl() + { + return $this->logo_image_url; + } + + /** + * expiry date of the incentive. + * + * @param string $expiry_date + * + * @return $this + */ + public function setExpiryDate($expiry_date) + { + $this->expiry_date = $expiry_date; + return $this; + } + + /** + * expiry date of the incentive. + * + * @return string + */ + public function getExpiryDate() + { + return $this->expiry_date; + } + + /** + * Specifies type of incentive + * Valid Values: ["COUPON", "GIFT_CARD", "MERCHANT_SPECIFIC_BALANCE", "VOUCHER"] + * + * @param string $type + * + * @return $this + */ + public function setType($type) + { + $this->type = $type; + return $this; + } + + /** + * Specifies type of incentive + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * URI to the associated terms + * + * @param string $terms + * + * @return $this + */ + public function setTerms($terms) + { + $this->terms = $terms; + return $this; + } + + /** + * URI to the associated terms + * + * @return string + */ + public function getTerms() + { + return $this->terms; + } + +} diff --git a/paypal/PayPal/Api/InputFields.php b/paypal/PayPal/Api/InputFields.php new file mode 100644 index 0000000..1b8c088 --- /dev/null +++ b/paypal/PayPal/Api/InputFields.php @@ -0,0 +1,89 @@ +allow_note = $allow_note; + return $this; + } + + /** + * Indicates whether the buyer can enter a note to the merchant on the PayPal page during checkout. + * + * @return bool + */ + public function getAllowNote() + { + return $this->allow_note; + } + + /** + * Indicates whether PayPal displays shipping address fields on the experience pages. Valid value is `0`, `1`, or `2`. Set to `0` to display the shipping address on the PayPal pages. Set to `1` to redact shipping address fields from the PayPal pages. Set to `2` to not pass the shipping address but instead get it from the buyer's account profile. For digital goods, this field is required and value must be `1`. + * + * @param int $no_shipping + * + * @return $this + */ + public function setNoShipping($no_shipping) + { + $this->no_shipping = $no_shipping; + return $this; + } + + /** + * Indicates whether PayPal displays shipping address fields on the experience pages. Valid value is `0`, `1`, or `2`. Set to `0` to display the shipping address on the PayPal pages. Set to `1` to redact shipping address fields from the PayPal pages. Set to `2` to not pass the shipping address but instead get it from the buyer's account profile. For digital goods, this field is required and value must be `1`. + * + * @return int + */ + public function getNoShipping() + { + return $this->no_shipping; + } + + /** + * Indicates whether to display the shipping address that is passed to this call rather than the one on file with PayPal for this buyer on the PayPal experience pages. Valid value is `0` or `1`. Set to `0` to display the shipping address on file. Set to `1` to display the shipping address supplied to this call; the buyer cannot edit this shipping address. + * + * @param int $address_override + * + * @return $this + */ + public function setAddressOverride($address_override) + { + $this->address_override = $address_override; + return $this; + } + + /** + * Indicates whether to display the shipping address that is passed to this call rather than the one on file with PayPal for this buyer on the PayPal experience pages. Valid value is `0` or `1`. Set to `0` to display the shipping address on file. Set to `1` to display the shipping address supplied to this call; the buyer cannot edit this shipping address. + * + * @return int + */ + public function getAddressOverride() + { + return $this->address_override; + } + +} diff --git a/paypal/PayPal/Api/InstallmentInfo.php b/paypal/PayPal/Api/InstallmentInfo.php new file mode 100644 index 0000000..d0cbc51 --- /dev/null +++ b/paypal/PayPal/Api/InstallmentInfo.php @@ -0,0 +1,144 @@ +installment_id = $installment_id; + return $this; + } + + /** + * Installment id. + * + * @return string + */ + public function getInstallmentId() + { + return $this->installment_id; + } + + /** + * Credit card network. + * Valid Values: ["VISA", "MASTERCARD"] + * + * @param string $network + * + * @return $this + */ + public function setNetwork($network) + { + $this->network = $network; + return $this; + } + + /** + * Credit card network. + * + * @return string + */ + public function getNetwork() + { + return $this->network; + } + + /** + * Credit card issuer. + * + * @param string $issuer + * + * @return $this + */ + public function setIssuer($issuer) + { + $this->issuer = $issuer; + return $this; + } + + /** + * Credit card issuer. + * + * @return string + */ + public function getIssuer() + { + return $this->issuer; + } + + /** + * List of available installment options and the cost associated with each one. + * + * @param \PayPal\Api\InstallmentOption[] $installment_options + * + * @return $this + */ + public function setInstallmentOptions($installment_options) + { + $this->installment_options = $installment_options; + return $this; + } + + /** + * List of available installment options and the cost associated with each one. + * + * @return \PayPal\Api\InstallmentOption[] + */ + public function getInstallmentOptions() + { + return $this->installment_options; + } + + /** + * Append InstallmentOptions to the list. + * + * @param \PayPal\Api\InstallmentOption $installmentOption + * @return $this + */ + public function addInstallmentOption($installmentOption) + { + if (!$this->getInstallmentOptions()) { + return $this->setInstallmentOptions(array($installmentOption)); + } else { + return $this->setInstallmentOptions( + array_merge($this->getInstallmentOptions(), array($installmentOption)) + ); + } + } + + /** + * Remove InstallmentOptions from the list. + * + * @param \PayPal\Api\InstallmentOption $installmentOption + * @return $this + */ + public function removeInstallmentOption($installmentOption) + { + return $this->setInstallmentOptions( + array_diff($this->getInstallmentOptions(), array($installmentOption)) + ); + } + +} diff --git a/paypal/PayPal/Api/InstallmentOption.php b/paypal/PayPal/Api/InstallmentOption.php new file mode 100644 index 0000000..58e1b92 --- /dev/null +++ b/paypal/PayPal/Api/InstallmentOption.php @@ -0,0 +1,113 @@ +term = $term; + return $this; + } + + /** + * Number of installments + * + * @return int + */ + public function getTerm() + { + return $this->term; + } + + /** + * Monthly payment + * + * @param \PayPal\Api\Currency $monthly_payment + * + * @return $this + */ + public function setMonthlyPayment($monthly_payment) + { + $this->monthly_payment = $monthly_payment; + return $this; + } + + /** + * Monthly payment + * + * @return \PayPal\Api\Currency + */ + public function getMonthlyPayment() + { + return $this->monthly_payment; + } + + /** + * Discount amount applied to the payment, if any + * + * @param \PayPal\Api\Currency $discount_amount + * + * @return $this + */ + public function setDiscountAmount($discount_amount) + { + $this->discount_amount = $discount_amount; + return $this; + } + + /** + * Discount amount applied to the payment, if any + * + * @return \PayPal\Api\Currency + */ + public function getDiscountAmount() + { + return $this->discount_amount; + } + + /** + * Discount percentage applied to the payment, if any + * + * @param string $discount_percentage + * + * @return $this + */ + public function setDiscountPercentage($discount_percentage) + { + $this->discount_percentage = $discount_percentage; + return $this; + } + + /** + * Discount percentage applied to the payment, if any + * + * @return string + */ + public function getDiscountPercentage() + { + return $this->discount_percentage; + } + +} diff --git a/paypal/PayPal/Api/Invoice.php b/paypal/PayPal/Api/Invoice.php new file mode 100644 index 0000000..37efa26 --- /dev/null +++ b/paypal/PayPal/Api/Invoice.php @@ -0,0 +1,1340 @@ +id = $id; + return $this; + } + + /** + * The unique invoice resource identifier. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Unique number that appears on the invoice. If left blank will be auto-incremented from the last number. 25 characters max. + * + * @param string $number + * + * @return $this + */ + public function setNumber($number) + { + $this->number = $number; + return $this; + } + + /** + * Unique number that appears on the invoice. If left blank will be auto-incremented from the last number. 25 characters max. + * + * @return string + */ + public function getNumber() + { + return $this->number; + } + + /** + * The template ID used for the invoice. Useful for copy functionality. + * + * @param string $template_id + * + * @return $this + */ + public function setTemplateId($template_id) + { + $this->template_id = $template_id; + return $this; + } + + /** + * The template ID used for the invoice. Useful for copy functionality. + * + * @return string + */ + public function getTemplateId() + { + return $this->template_id; + } + + /** + * URI of the invoice resource. + * + * @param string $uri + * + * @return $this + */ + public function setUri($uri) + { + $this->uri = $uri; + return $this; + } + + /** + * URI of the invoice resource. + * + * @return string + */ + public function getUri() + { + return $this->uri; + } + + /** + * Status of the invoice. + * Valid Values: ["DRAFT", "SENT", "PAID", "MARKED_AS_PAID", "CANCELLED", "REFUNDED", "PARTIALLY_REFUNDED", "MARKED_AS_REFUNDED", "UNPAID", "PAYMENT_PENDING"] + * + * @param string $status + * + * @return $this + */ + public function setStatus($status) + { + $this->status = $status; + return $this; + } + + /** + * Status of the invoice. + * + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * Information about the merchant who is sending the invoice. + * + * @param \PayPal\Api\MerchantInfo $merchant_info + * + * @return $this + */ + public function setMerchantInfo($merchant_info) + { + $this->merchant_info = $merchant_info; + return $this; + } + + /** + * Information about the merchant who is sending the invoice. + * + * @return \PayPal\Api\MerchantInfo + */ + public function getMerchantInfo() + { + return $this->merchant_info; + } + + /** + * The required invoice recipient email address and any optional billing information. One recipient is supported. + * + * @param \PayPal\Api\BillingInfo[] $billing_info + * + * @return $this + */ + public function setBillingInfo($billing_info) + { + $this->billing_info = $billing_info; + return $this; + } + + /** + * The required invoice recipient email address and any optional billing information. One recipient is supported. + * + * @return \PayPal\Api\BillingInfo[] + */ + public function getBillingInfo() + { + return $this->billing_info; + } + + /** + * Append BillingInfo to the list. + * + * @param \PayPal\Api\BillingInfo $billingInfo + * @return $this + */ + public function addBillingInfo($billingInfo) + { + if (!$this->getBillingInfo()) { + return $this->setBillingInfo(array($billingInfo)); + } else { + return $this->setBillingInfo( + array_merge($this->getBillingInfo(), array($billingInfo)) + ); + } + } + + /** + * Remove BillingInfo from the list. + * + * @param \PayPal\Api\BillingInfo $billingInfo + * @return $this + */ + public function removeBillingInfo($billingInfo) + { + return $this->setBillingInfo( + array_diff($this->getBillingInfo(), array($billingInfo)) + ); + } + + /** + * For invoices sent by email, one or more email addresses to which to send a Cc: copy of the notification. Supports only email addresses under participant. + * + * @param \PayPal\Api\Participant[] $cc_info + * + * @return $this + */ + public function setCcInfo($cc_info) + { + $this->cc_info = $cc_info; + return $this; + } + + /** + * For invoices sent by email, one or more email addresses to which to send a Cc: copy of the notification. Supports only email addresses under participant. + * + * @return \PayPal\Api\Participant[] + */ + public function getCcInfo() + { + return $this->cc_info; + } + + /** + * Append CcInfo to the list. + * + * @param \PayPal\Api\Participant $participant + * @return $this + */ + public function addCcInfo($participant) + { + if (!$this->getCcInfo()) { + return $this->setCcInfo(array($participant)); + } else { + return $this->setCcInfo( + array_merge($this->getCcInfo(), array($participant)) + ); + } + } + + /** + * Remove CcInfo from the list. + * + * @param \PayPal\Api\Participant $participant + * @return $this + */ + public function removeCcInfo($participant) + { + return $this->setCcInfo( + array_diff($this->getCcInfo(), array($participant)) + ); + } + + /** + * The shipping information for entities to whom items are being shipped. + * + * @param \PayPal\Api\ShippingInfo $shipping_info + * + * @return $this + */ + public function setShippingInfo($shipping_info) + { + $this->shipping_info = $shipping_info; + return $this; + } + + /** + * The shipping information for entities to whom items are being shipped. + * + * @return \PayPal\Api\ShippingInfo + */ + public function getShippingInfo() + { + return $this->shipping_info; + } + + /** + * The list of items to include in the invoice. Maximum value is 100 items per invoice. + * + * @param \PayPal\Api\InvoiceItem[] $items + * + * @return $this + */ + public function setItems($items) + { + $this->items = $items; + return $this; + } + + /** + * The list of items to include in the invoice. Maximum value is 100 items per invoice. + * + * @return \PayPal\Api\InvoiceItem[] + */ + public function getItems() + { + return $this->items; + } + + /** + * Append Items to the list. + * + * @param \PayPal\Api\InvoiceItem $invoiceItem + * @return $this + */ + public function addItem($invoiceItem) + { + if (!$this->getItems()) { + return $this->setItems(array($invoiceItem)); + } else { + return $this->setItems( + array_merge($this->getItems(), array($invoiceItem)) + ); + } + } + + /** + * Remove Items from the list. + * + * @param \PayPal\Api\InvoiceItem $invoiceItem + * @return $this + */ + public function removeItem($invoiceItem) + { + return $this->setItems( + array_diff($this->getItems(), array($invoiceItem)) + ); + } + + /** + * The date when the invoice was enabled. The date format is *yyyy*-*MM*-*dd* *z* as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @param string $invoice_date + * + * @return $this + */ + public function setInvoiceDate($invoice_date) + { + $this->invoice_date = $invoice_date; + return $this; + } + + /** + * The date when the invoice was enabled. The date format is *yyyy*-*MM*-*dd* *z* as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return string + */ + public function getInvoiceDate() + { + return $this->invoice_date; + } + + /** + * Optional. The payment deadline for the invoice. Value is either `term_type` or `due_date` but not both. + * + * @param \PayPal\Api\PaymentTerm $payment_term + * + * @return $this + */ + public function setPaymentTerm($payment_term) + { + $this->payment_term = $payment_term; + return $this; + } + + /** + * Optional. The payment deadline for the invoice. Value is either `term_type` or `due_date` but not both. + * + * @return \PayPal\Api\PaymentTerm + */ + public function getPaymentTerm() + { + return $this->payment_term; + } + + /** + * Reference data, such as PO number, to add to the invoice. Maximum length is 60 characters. + * + * @param string $reference + * + * @return $this + */ + public function setReference($reference) + { + $this->reference = $reference; + return $this; + } + + /** + * Reference data, such as PO number, to add to the invoice. Maximum length is 60 characters. + * + * @return string + */ + public function getReference() + { + return $this->reference; + } + + /** + * The invoice level discount, as a percent or an amount value. + * + * @param \PayPal\Api\Cost $discount + * + * @return $this + */ + public function setDiscount($discount) + { + $this->discount = $discount; + return $this; + } + + /** + * The invoice level discount, as a percent or an amount value. + * + * @return \PayPal\Api\Cost + */ + public function getDiscount() + { + return $this->discount; + } + + /** + * The shipping cost, as a percent or an amount value. + * + * @param \PayPal\Api\ShippingCost $shipping_cost + * + * @return $this + */ + public function setShippingCost($shipping_cost) + { + $this->shipping_cost = $shipping_cost; + return $this; + } + + /** + * The shipping cost, as a percent or an amount value. + * + * @return \PayPal\Api\ShippingCost + */ + public function getShippingCost() + { + return $this->shipping_cost; + } + + /** + * The custom amount to apply on an invoice. If you include a label, the amount cannot be empty. + * + * @param \PayPal\Api\CustomAmount $custom + * + * @return $this + */ + public function setCustom($custom) + { + $this->custom = $custom; + return $this; + } + + /** + * The custom amount to apply on an invoice. If you include a label, the amount cannot be empty. + * + * @return \PayPal\Api\CustomAmount + */ + public function getCustom() + { + return $this->custom; + } + + /** + * Indicates whether the invoice allows a partial payment. If set to `false`, invoice must be paid in full. If set to `true`, the invoice allows partial payments. Default is `false`. + * + * @param bool $allow_partial_payment + * + * @return $this + */ + public function setAllowPartialPayment($allow_partial_payment) + { + $this->allow_partial_payment = $allow_partial_payment; + return $this; + } + + /** + * Indicates whether the invoice allows a partial payment. If set to `false`, invoice must be paid in full. If set to `true`, the invoice allows partial payments. Default is `false`. + * + * @return bool + */ + public function getAllowPartialPayment() + { + return $this->allow_partial_payment; + } + + /** + * If `allow_partial_payment` is set to `true`, the minimum amount allowed for a partial payment. + * + * @param \PayPal\Api\Currency $minimum_amount_due + * + * @return $this + */ + public function setMinimumAmountDue($minimum_amount_due) + { + $this->minimum_amount_due = $minimum_amount_due; + return $this; + } + + /** + * If `allow_partial_payment` is set to `true`, the minimum amount allowed for a partial payment. + * + * @return \PayPal\Api\Currency + */ + public function getMinimumAmountDue() + { + return $this->minimum_amount_due; + } + + /** + * Indicates whether tax is calculated before or after a discount. If set to `false`, the tax is calculated before a discount. If set to `true`, the tax is calculated after a discount. Default is `false`. + * + * @param bool $tax_calculated_after_discount + * + * @return $this + */ + public function setTaxCalculatedAfterDiscount($tax_calculated_after_discount) + { + $this->tax_calculated_after_discount = $tax_calculated_after_discount; + return $this; + } + + /** + * Indicates whether tax is calculated before or after a discount. If set to `false`, the tax is calculated before a discount. If set to `true`, the tax is calculated after a discount. Default is `false`. + * + * @return bool + */ + public function getTaxCalculatedAfterDiscount() + { + return $this->tax_calculated_after_discount; + } + + /** + * Indicates whether the unit price includes tax. Default is `false`. + * + * @param bool $tax_inclusive + * + * @return $this + */ + public function setTaxInclusive($tax_inclusive) + { + $this->tax_inclusive = $tax_inclusive; + return $this; + } + + /** + * Indicates whether the unit price includes tax. Default is `false`. + * + * @return bool + */ + public function getTaxInclusive() + { + return $this->tax_inclusive; + } + + /** + * General terms of the invoice. 4000 characters max. + * + * @param string $terms + * + * @return $this + */ + public function setTerms($terms) + { + $this->terms = $terms; + return $this; + } + + /** + * General terms of the invoice. 4000 characters max. + * + * @return string + */ + public function getTerms() + { + return $this->terms; + } + + /** + * Note to the payer. 4000 characters max. + * + * @param string $note + * + * @return $this + */ + public function setNote($note) + { + $this->note = $note; + return $this; + } + + /** + * Note to the payer. 4000 characters max. + * + * @return string + */ + public function getNote() + { + return $this->note; + } + + /** + * A private bookkeeping memo for the merchant. Maximum length is 150 characters. + * + * @param string $merchant_memo + * + * @return $this + */ + public function setMerchantMemo($merchant_memo) + { + $this->merchant_memo = $merchant_memo; + return $this; + } + + /** + * A private bookkeeping memo for the merchant. Maximum length is 150 characters. + * + * @return string + */ + public function getMerchantMemo() + { + return $this->merchant_memo; + } + + /** + * Full URL of an external image to use as the logo. Maximum length is 4000 characters. + * + * @param string $logo_url + * @throws \InvalidArgumentException + * @return $this + */ + public function setLogoUrl($logo_url) + { + UrlValidator::validate($logo_url, "LogoUrl"); + $this->logo_url = $logo_url; + return $this; + } + + /** + * Full URL of an external image to use as the logo. Maximum length is 4000 characters. + * + * @return string + */ + public function getLogoUrl() + { + return $this->logo_url; + } + + /** + * The total amount of the invoice. + * + * @param \PayPal\Api\Currency $total_amount + * + * @return $this + */ + public function setTotalAmount($total_amount) + { + $this->total_amount = $total_amount; + return $this; + } + + /** + * The total amount of the invoice. + * + * @return \PayPal\Api\Currency + */ + public function getTotalAmount() + { + return $this->total_amount; + } + + /** + * List of payment details for the invoice. + * + * @param \PayPal\Api\PaymentDetail[] $payments + * + * @return $this + */ + public function setPayments($payments) + { + $this->payments = $payments; + return $this; + } + + /** + * List of payment details for the invoice. + * + * @return \PayPal\Api\PaymentDetail[] + */ + public function getPayments() + { + return $this->payments; + } + + /** + * Append Payments to the list. + * + * @param \PayPal\Api\PaymentDetail $paymentDetail + * @return $this + */ + public function addPayment($paymentDetail) + { + if (!$this->getPayments()) { + return $this->setPayments(array($paymentDetail)); + } else { + return $this->setPayments( + array_merge($this->getPayments(), array($paymentDetail)) + ); + } + } + + /** + * Remove Payments from the list. + * + * @param \PayPal\Api\PaymentDetail $paymentDetail + * @return $this + */ + public function removePayment($paymentDetail) + { + return $this->setPayments( + array_diff($this->getPayments(), array($paymentDetail)) + ); + } + + /** + * List of refund details for the invoice. + * + * @param \PayPal\Api\RefundDetail[] $refunds + * + * @return $this + */ + public function setRefunds($refunds) + { + $this->refunds = $refunds; + return $this; + } + + /** + * List of refund details for the invoice. + * + * @return \PayPal\Api\RefundDetail[] + */ + public function getRefunds() + { + return $this->refunds; + } + + /** + * Append Refunds to the list. + * + * @param \PayPal\Api\RefundDetail $refundDetail + * @return $this + */ + public function addRefund($refundDetail) + { + if (!$this->getRefunds()) { + return $this->setRefunds(array($refundDetail)); + } else { + return $this->setRefunds( + array_merge($this->getRefunds(), array($refundDetail)) + ); + } + } + + /** + * Remove Refunds from the list. + * + * @param \PayPal\Api\RefundDetail $refundDetail + * @return $this + */ + public function removeRefund($refundDetail) + { + return $this->setRefunds( + array_diff($this->getRefunds(), array($refundDetail)) + ); + } + + /** + * Audit information for the invoice. + * + * @param \PayPal\Api\Metadata $metadata + * + * @return $this + */ + public function setMetadata($metadata) + { + $this->metadata = $metadata; + return $this; + } + + /** + * Audit information for the invoice. + * + * @return \PayPal\Api\Metadata + */ + public function getMetadata() + { + return $this->metadata; + } + + /** + * Any miscellaneous invoice data. Maximum length is 4000 characters. + * @deprecated Not publicly available + * @param string $additional_data + * + * @return $this + */ + public function setAdditionalData($additional_data) + { + $this->additional_data = $additional_data; + return $this; + } + + /** + * Any miscellaneous invoice data. Maximum length is 4000 characters. + * @deprecated Not publicly available + * @return string + */ + public function getAdditionalData() + { + return $this->additional_data; + } + + /** + * Payment summary of the invoice including amount paid through PayPal and other sources. + * + * @param \PayPal\Api\PaymentSummary $paid_amount + * + * @return $this + */ + public function setPaidAmount($paid_amount) + { + $this->paid_amount = $paid_amount; + return $this; + } + + /** + * Payment summary of the invoice including amount paid through PayPal and other sources. + * + * @return \PayPal\Api\PaymentSummary + */ + public function getPaidAmount() + { + return $this->paid_amount; + } + + /** + * Payment summary of the invoice including amount refunded through PayPal and other sources. + * + * @param \PayPal\Api\PaymentSummary $refunded_amount + * + * @return $this + */ + public function setRefundedAmount($refunded_amount) + { + $this->refunded_amount = $refunded_amount; + return $this; + } + + /** + * Payment summary of the invoice including amount refunded through PayPal and other sources. + * + * @return \PayPal\Api\PaymentSummary + */ + public function getRefundedAmount() + { + return $this->refunded_amount; + } + + /** + * List of files attached to the invoice. + * + * @param \PayPal\Api\FileAttachment[] $attachments + * + * @return $this + */ + public function setAttachments($attachments) + { + $this->attachments = $attachments; + return $this; + } + + /** + * List of files attached to the invoice. + * + * @return \PayPal\Api\FileAttachment[] + */ + public function getAttachments() + { + return $this->attachments; + } + + /** + * Append Attachments to the list. + * + * @param \PayPal\Api\FileAttachment $fileAttachment + * @return $this + */ + public function addAttachment($fileAttachment) + { + if (!$this->getAttachments()) { + return $this->setAttachments(array($fileAttachment)); + } else { + return $this->setAttachments( + array_merge($this->getAttachments(), array($fileAttachment)) + ); + } + } + + /** + * Remove Attachments from the list. + * + * @param \PayPal\Api\FileAttachment $fileAttachment + * @return $this + */ + public function removeAttachment($fileAttachment) + { + return $this->setAttachments( + array_diff($this->getAttachments(), array($fileAttachment)) + ); + } + + /** + * Creates an invoice. Include invoice details including merchant information in the request. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Invoice + */ + public function create($apiContext = null, $restCall = null) + { + $payLoad = $this->toJSON(); + $json = self::executeCall( + "/v1/invoicing/invoices", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $this->fromJson($json); + return $this; + } + + /** + * Searches for an invoice or invoices. Include a search object that specifies your search criteria in the request. + * + * @param Search $search + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return InvoiceSearchResponse + */ + public static function search($search, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($search, 'search'); + $payLoad = $search->toJSON(); + $json = self::executeCall( + "/v1/invoicing/search", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new InvoiceSearchResponse(); + $ret->fromJson($json); + return $ret; + } + + /** + * Sends an invoice, by ID, to a recipient. Optionally, set the `notify_merchant` query parameter to send the merchant an invoice update notification. By default, `notify_merchant` is `true`. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function send($apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + $payLoad = ""; + self::executeCall( + "/v1/invoicing/invoices/{$this->getId()}/send", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * Sends a reminder about a specific invoice, by ID, to a recipient. Include a notification object that defines the reminder subject and other details in the JSON request body. + * + * @param Notification $notification + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function remind($notification, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($notification, 'notification'); + $payLoad = $notification->toJSON(); + self::executeCall( + "/v1/invoicing/invoices/{$this->getId()}/remind", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * Cancels an invoice, by ID. + * + * @param CancelNotification $cancelNotification + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function cancel($cancelNotification, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($cancelNotification, 'cancelNotification'); + $payLoad = $cancelNotification->toJSON(); + self::executeCall( + "/v1/invoicing/invoices/{$this->getId()}/cancel", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * Marks the status of a specified invoice, by ID, as paid. Include a payment detail object that defines the payment method and other details in the JSON request body. + * + * @param PaymentDetail $paymentDetail + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function recordPayment($paymentDetail, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($paymentDetail, 'paymentDetail'); + $payLoad = $paymentDetail->toJSON(); + self::executeCall( + "/v1/invoicing/invoices/{$this->getId()}/record-payment", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * Marks the status of a specified invoice, by ID, as refunded. Include a refund detail object that defines the refund type and other details in the JSON request body. + * + * @param RefundDetail $refundDetail + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function recordRefund($refundDetail, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($refundDetail, 'refundDetail'); + $payLoad = $refundDetail->toJSON(); + self::executeCall( + "/v1/invoicing/invoices/{$this->getId()}/record-refund", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * Gets the details for a specified invoice, by ID. + * + * @param string $invoiceId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Invoice + */ + public static function get($invoiceId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($invoiceId, 'invoiceId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/invoicing/invoices/$invoiceId", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new Invoice(); + $ret->fromJson($json); + return $ret; + } + + /** + * Lists some or all merchant invoices. Filters the response by any specified optional query string parameters. + * + * @param array $params + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return InvoiceSearchResponse + */ + public static function getAll($params = array(), $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($params, 'params'); + + $allowedParams = array( + 'page' => 1, + 'page_size' => 1, + 'total_count_required' => 1 + ); + + $payLoad = ""; + $json = self::executeCall( + "/v1/invoicing/invoices/?" . http_build_query(array_intersect_key($params, $allowedParams)), + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new InvoiceSearchResponse(); + $ret->fromJson($json); + return $ret; + } + + /** + * Fully updates 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. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Invoice + */ + public function update($apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + $payLoad = $this->toJSON(); + $json = self::executeCall( + "/v1/invoicing/invoices/{$this->getId()}", + "PUT", + $payLoad, + null, + $apiContext, + $restCall + ); + $this->fromJson($json); + return $this; + } + + /** + * Delete a particular invoice by passing the invoice ID to the request URI. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function delete($apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + $payLoad = ""; + self::executeCall( + "/v1/invoicing/invoices/{$this->getId()}", + "DELETE", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * Delete external payment. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function deleteExternalPayment($transactionId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($transactionId, "TransactionId"); + $payLoad = ""; + self::executeCall( + "/v1/invoicing/invoices/{$this->getId()}/payment-records/{$transactionId}", + "DELETE", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * Delete external refund. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function deleteExternalRefund($transactionId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($transactionId, "TransactionId"); + $payLoad = ""; + self::executeCall( + "/v1/invoicing/invoices/{$this->getId()}/refund-records/{$transactionId}", + "DELETE", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * 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. + * + * @param array $params + * @param string $invoiceId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Image + */ + public static function qrCode($invoiceId, $params = array(), $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($invoiceId, 'invoiceId'); + ArgumentValidator::validate($params, 'params'); + + $allowedParams = array( + 'width' => 1, + 'height' => 1, + 'action' => 1 + ); + + $payLoad = ""; + $json = self::executeCall( + "/v1/invoicing/invoices/$invoiceId/qr-code?" . http_build_query(array_intersect_key($params, $allowedParams)), + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new Image(); + $ret->fromJson($json); + return $ret; + } + + /** + * Generates the successive invoice number. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return InvoiceNumber + */ + public static function generateNumber($apiContext = null, $restCall = null) + { + $payLoad = ""; + $json = self::executeCall( + "/v1/invoicing/invoices/next-invoice-number", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new InvoiceNumber(); + $ret->fromJson($json); + return $ret; + } + +} diff --git a/paypal/PayPal/Api/InvoiceAddress.php b/paypal/PayPal/Api/InvoiceAddress.php new file mode 100644 index 0000000..8529df9 --- /dev/null +++ b/paypal/PayPal/Api/InvoiceAddress.php @@ -0,0 +1,39 @@ +phone = $phone; + return $this; + } + + /** + * Phone number in E.123 format. + * + * @return \PayPal\Api\Phone + */ + public function getPhone() + { + return $this->phone; + } + +} diff --git a/paypal/PayPal/Api/InvoiceItem.php b/paypal/PayPal/Api/InvoiceItem.php new file mode 100644 index 0000000..ee93e3c --- /dev/null +++ b/paypal/PayPal/Api/InvoiceItem.php @@ -0,0 +1,239 @@ +name = $name; + return $this; + } + + /** + * Name of the item. 200 characters max. + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Description of the item. 1000 characters max. + * + * @param string $description + * + * @return $this + */ + public function setDescription($description) + { + $this->description = $description; + return $this; + } + + /** + * Description of the item. 1000 characters max. + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Quantity of the item. Range of -10000 to 10000. + * + * @param string|double $quantity + * + * @return $this + */ + public function setQuantity($quantity) + { + NumericValidator::validate($quantity, "Quantity"); + $quantity = FormatConverter::formatToPrice($quantity); + $this->quantity = $quantity; + return $this; + } + + /** + * Quantity of the item. Range of -10000 to 10000. + * + * @return string + */ + public function getQuantity() + { + return $this->quantity; + } + + /** + * Unit price of the item. Range of -1,000,000 to 1,000,000. + * + * @param \PayPal\Api\Currency $unit_price + * + * @return $this + */ + public function setUnitPrice($unit_price) + { + $this->unit_price = $unit_price; + return $this; + } + + /** + * Unit price of the item. Range of -1,000,000 to 1,000,000. + * + * @return \PayPal\Api\Currency + */ + public function getUnitPrice() + { + return $this->unit_price; + } + + /** + * Tax associated with the item. + * + * @param \PayPal\Api\Tax $tax + * + * @return $this + */ + public function setTax($tax) + { + $this->tax = $tax; + return $this; + } + + /** + * Tax associated with the item. + * + * @return \PayPal\Api\Tax + */ + public function getTax() + { + return $this->tax; + } + + /** + * The date when the item or service was provided. The date format is *yyyy*-*MM*-*dd* *z* as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @param string $date + * + * @return $this + */ + public function setDate($date) + { + $this->date = $date; + return $this; + } + + /** + * The date when the item or service was provided. The date format is *yyyy*-*MM*-*dd* *z* as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return string + */ + public function getDate() + { + return $this->date; + } + + /** + * The item discount, as a percent or an amount value. + * + * @param \PayPal\Api\Cost $discount + * + * @return $this + */ + public function setDiscount($discount) + { + $this->discount = $discount; + return $this; + } + + /** + * The item discount, as a percent or an amount value. + * + * @return \PayPal\Api\Cost + */ + public function getDiscount() + { + return $this->discount; + } + + /** + * The image URL. Maximum length is 4000 characters. + * @deprecated Not publicly available + * @param string $image_url + * @throws \InvalidArgumentException + * @return $this + */ + public function setImageUrl($image_url) + { + UrlValidator::validate($image_url, "ImageUrl"); + $this->image_url = $image_url; + return $this; + } + + /** + * The image URL. Maximum length is 4000 characters. + * @deprecated Not publicly available + * @return string + */ + public function getImageUrl() + { + return $this->image_url; + } + + /** + * The unit of measure of the item being invoiced. + * Valid Values: ["QUANTITY", "HOURS", "AMOUNT"] + * + * @param string $unit_of_measure + * + * @return $this + */ + public function setUnitOfMeasure($unit_of_measure) + { + $this->unit_of_measure = $unit_of_measure; + return $this; + } + + /** + * The unit of measure of the item being invoiced. + * + * @return string + */ + public function getUnitOfMeasure() + { + return $this->unit_of_measure; + } + +} diff --git a/paypal/PayPal/Api/InvoiceNumber.php b/paypal/PayPal/Api/InvoiceNumber.php new file mode 100644 index 0000000..a3cd2e2 --- /dev/null +++ b/paypal/PayPal/Api/InvoiceNumber.php @@ -0,0 +1,38 @@ +number = $number; + return $this; + } + + /** + * The next invoice number. + * + * @return string + */ + public function getNumber() { + return $this->number; + } +} diff --git a/paypal/PayPal/Api/InvoiceSearchResponse.php b/paypal/PayPal/Api/InvoiceSearchResponse.php new file mode 100644 index 0000000..0634eb6 --- /dev/null +++ b/paypal/PayPal/Api/InvoiceSearchResponse.php @@ -0,0 +1,95 @@ +total_count = $total_count; + return $this; + } + + /** + * Total number of invoices. + * + * @return int + */ + public function getTotalCount() + { + return $this->total_count; + } + + /** + * List of invoices belonging to a merchant. + * + * @param \PayPal\Api\Invoice[] $invoices + * + * @return $this + */ + public function setInvoices($invoices) + { + $this->invoices = $invoices; + return $this; + } + + /** + * List of invoices belonging to a merchant. + * + * @return \PayPal\Api\Invoice[] + */ + public function getInvoices() + { + return $this->invoices; + } + + /** + * Append Invoices to the list. + * + * @param \PayPal\Api\Invoice $invoice + * @return $this + */ + public function addInvoice($invoice) + { + if (!$this->getInvoices()) { + return $this->setInvoices(array($invoice)); + } else { + return $this->setInvoices( + array_merge($this->getInvoices(), array($invoice)) + ); + } + } + + /** + * Remove Invoices from the list. + * + * @param \PayPal\Api\Invoice $invoice + * @return $this + */ + public function removeInvoice($invoice) + { + return $this->setInvoices( + array_diff($this->getInvoices(), array($invoice)) + ); + } + +} diff --git a/paypal/PayPal/Api/Item.php b/paypal/PayPal/Api/Item.php new file mode 100644 index 0000000..75056ba --- /dev/null +++ b/paypal/PayPal/Api/Item.php @@ -0,0 +1,439 @@ +sku = $sku; + return $this; + } + + /** + * Stock keeping unit corresponding (SKU) to item. + * + * @return string + */ + public function getSku() + { + return $this->sku; + } + + /** + * Item name. 127 characters max. + * + * @param string $name + * + * @return $this + */ + public function setName($name) + { + $this->name = $name; + return $this; + } + + /** + * Item name. 127 characters max. + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Description of the item. Only supported when the `payment_method` is set to `paypal`. + * + * @param string $description + * + * @return $this + */ + public function setDescription($description) + { + $this->description = $description; + return $this; + } + + /** + * Description of the item. Only supported when the `payment_method` is set to `paypal`. + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Number of a particular item. 10 characters max. + * + * @param string $quantity + * + * @return $this + */ + public function setQuantity($quantity) + { + $this->quantity = $quantity; + return $this; + } + + /** + * Number of a particular item. 10 characters max. + * + * @return string + */ + public function getQuantity() + { + return $this->quantity; + } + + /** + * Item cost. 10 characters max. + * + * @param string|double $price + * + * @return $this + */ + public function setPrice($price) + { + NumericValidator::validate($price, "Price"); + $price = FormatConverter::formatToPrice($price, $this->getCurrency()); + $this->price = $price; + return $this; + } + + /** + * Item cost. 10 characters max. + * + * @return string + */ + public function getPrice() + { + return $this->price; + } + + /** + * 3-letter [currency code](https://developer.paypal.com/docs/integration/direct/rest_api_payment_country_currency_support/). + * + * @param string $currency + * + * @return $this + */ + public function setCurrency($currency) + { + $this->currency = $currency; + return $this; + } + + /** + * 3-letter [currency code](https://developer.paypal.com/docs/integration/direct/rest_api_payment_country_currency_support/). + * + * @return string + */ + public function getCurrency() + { + return $this->currency; + } + + /** + * Tax of the item. Only supported when the `payment_method` is set to `paypal`. + * + * @param string|double $tax + * + * @return $this + */ + public function setTax($tax) + { + NumericValidator::validate($tax, "Tax"); + $tax = FormatConverter::formatToPrice($tax, $this->getCurrency()); + $this->tax = $tax; + return $this; + } + + /** + * Tax of the item. Only supported when the `payment_method` is set to `paypal`. + * + * @return string + */ + public function getTax() + { + return $this->tax; + } + + /** + * URL linking to item information. Available to payer in transaction history. + * + * @param string $url + * @throws \InvalidArgumentException + * @return $this + */ + public function setUrl($url) + { + UrlValidator::validate($url, "Url"); + $this->url = $url; + return $this; + } + + /** + * URL linking to item information. Available to payer in transaction history. + * + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Category type of the item. + * Valid Values: ["DIGITAL", "PHYSICAL"] + * @deprecated Not publicly available + * @param string $category + * + * @return $this + */ + public function setCategory($category) + { + $this->category = $category; + return $this; + } + + /** + * Category type of the item. + * @deprecated Not publicly available + * @return string + */ + public function getCategory() + { + return $this->category; + } + + /** + * Weight of the item. + * @deprecated Not publicly available + * @param \PayPal\Api\Measurement $weight + * + * @return $this + */ + public function setWeight($weight) + { + $this->weight = $weight; + return $this; + } + + /** + * Weight of the item. + * @deprecated Not publicly available + * @return \PayPal\Api\Measurement + */ + public function getWeight() + { + return $this->weight; + } + + /** + * Length of the item. + * @deprecated Not publicly available + * @param \PayPal\Api\Measurement $length + * + * @return $this + */ + public function setLength($length) + { + $this->length = $length; + return $this; + } + + /** + * Length of the item. + * @deprecated Not publicly available + * @return \PayPal\Api\Measurement + */ + public function getLength() + { + return $this->length; + } + + /** + * Height of the item. + * @deprecated Not publicly available + * @param \PayPal\Api\Measurement $height + * + * @return $this + */ + public function setHeight($height) + { + $this->height = $height; + return $this; + } + + /** + * Height of the item. + * @deprecated Not publicly available + * @return \PayPal\Api\Measurement + */ + public function getHeight() + { + return $this->height; + } + + /** + * Width of the item. + * @deprecated Not publicly available + * @param \PayPal\Api\Measurement $width + * + * @return $this + */ + public function setWidth($width) + { + $this->width = $width; + return $this; + } + + /** + * Width of the item. + * @deprecated Not publicly available + * @return \PayPal\Api\Measurement + */ + public function getWidth() + { + return $this->width; + } + + /** + * Set of optional data used for PayPal risk determination. + * @deprecated Not publicly available + * @param \PayPal\Api\NameValuePair[] $supplementary_data + * + * @return $this + */ + public function setSupplementaryData($supplementary_data) + { + $this->supplementary_data = $supplementary_data; + return $this; + } + + /** + * Set of optional data used for PayPal risk determination. + * @deprecated Not publicly available + * @return \PayPal\Api\NameValuePair[] + */ + public function getSupplementaryData() + { + return $this->supplementary_data; + } + + /** + * Append SupplementaryData to the list. + * @deprecated Not publicly available + * @param \PayPal\Api\NameValuePair $nameValuePair + * @return $this + */ + public function addSupplementaryData($nameValuePair) + { + if (!$this->getSupplementaryData()) { + return $this->setSupplementaryData(array($nameValuePair)); + } else { + return $this->setSupplementaryData( + array_merge($this->getSupplementaryData(), array($nameValuePair)) + ); + } + } + + /** + * Remove SupplementaryData from the list. + * @deprecated Not publicly available + * @param \PayPal\Api\NameValuePair $nameValuePair + * @return $this + */ + public function removeSupplementaryData($nameValuePair) + { + return $this->setSupplementaryData( + array_diff($this->getSupplementaryData(), array($nameValuePair)) + ); + } + + /** + * Set of optional data used for PayPal post-transaction notifications. + * @deprecated Not publicly available + * @param \PayPal\Api\NameValuePair[] $postback_data + * + * @return $this + */ + public function setPostbackData($postback_data) + { + $this->postback_data = $postback_data; + return $this; + } + + /** + * Set of optional data used for PayPal post-transaction notifications. + * @deprecated Not publicly available + * @return \PayPal\Api\NameValuePair[] + */ + public function getPostbackData() + { + return $this->postback_data; + } + + /** + * Append PostbackData to the list. + * @deprecated Not publicly available + * @param \PayPal\Api\NameValuePair $nameValuePair + * @return $this + */ + public function addPostbackData($nameValuePair) + { + if (!$this->getPostbackData()) { + return $this->setPostbackData(array($nameValuePair)); + } else { + return $this->setPostbackData( + array_merge($this->getPostbackData(), array($nameValuePair)) + ); + } + } + + /** + * Remove PostbackData from the list. + * @deprecated Not publicly available + * @param \PayPal\Api\NameValuePair $nameValuePair + * @return $this + */ + public function removePostbackData($nameValuePair) + { + return $this->setPostbackData( + array_diff($this->getPostbackData(), array($nameValuePair)) + ); + } + +} diff --git a/paypal/PayPal/Api/ItemList.php b/paypal/PayPal/Api/ItemList.php new file mode 100644 index 0000000..63ff054 --- /dev/null +++ b/paypal/PayPal/Api/ItemList.php @@ -0,0 +1,143 @@ +items = array_values($items); + return $this; + } + + /** + * List of items. + * + * @return \PayPal\Api\Item[] + */ + public function getItems() + { + return $this->items; + } + + /** + * Append Items to the list. + * + * @param \PayPal\Api\Item $item + * @return $this + */ + public function addItem($item) + { + if (!$this->getItems()) { + return $this->setItems(array($item)); + } else { + return $this->setItems( + array_merge($this->getItems(), array($item)) + ); + } + } + + /** + * Remove Items from the list. + * + * @param \PayPal\Api\Item $item + * @return $this + */ + public function removeItem($item) + { + return $this->setItems( + array_diff($this->getItems(), array($item)) + ); + } + + /** + * Shipping address. + * + * @param \PayPal\Api\ShippingAddress $shipping_address + * + * @return $this + */ + public function setShippingAddress($shipping_address) + { + $this->shipping_address = $shipping_address; + return $this; + } + + /** + * Shipping address. + * + * @return \PayPal\Api\ShippingAddress + */ + public function getShippingAddress() + { + return $this->shipping_address; + } + + /** + * Shipping method used for this payment like USPSParcel etc. + * + * @param string $shipping_method + * + * @return $this + */ + public function setShippingMethod($shipping_method) + { + $this->shipping_method = $shipping_method; + return $this; + } + + /** + * Shipping method used for this payment like USPSParcel etc. + * + * @return string + */ + public function getShippingMethod() + { + return $this->shipping_method; + } + + /** + * 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 + * + * @param string $shipping_phone_number + * + * @return $this + */ + public function setShippingPhoneNumber($shipping_phone_number) + { + $this->shipping_phone_number = $shipping_phone_number; + return $this; + } + + /** + * 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 + * + * @return string + */ + public function getShippingPhoneNumber() + { + return $this->shipping_phone_number; + } + +} diff --git a/paypal/PayPal/Api/Links.php b/paypal/PayPal/Api/Links.php new file mode 100644 index 0000000..7e00880 --- /dev/null +++ b/paypal/PayPal/Api/Links.php @@ -0,0 +1,161 @@ +href = $href; + return $this; + } + + /** + * Gets Href + * + * @return string + */ + public function getHref() + { + return $this->href; + } + + /** + * Sets Rel + * + * @param string $rel + * + * @return $this + */ + public function setRel($rel) + { + $this->rel = $rel; + return $this; + } + + /** + * Gets Rel + * + * @return string + */ + public function getRel() + { + return $this->rel; + } + + /** + * Sets TargetSchema + * + * @param \PayPal\Api\HyperSchema $targetSchema + * + * @return $this + */ + public function setTargetSchema($targetSchema) + { + $this->targetSchema = $targetSchema; + return $this; + } + + /** + * Gets TargetSchema + * + * @return \PayPal\Api\HyperSchema + */ + public function getTargetSchema() + { + return $this->targetSchema; + } + + /** + * Sets Method + * + * @param string $method + * + * @return $this + */ + public function setMethod($method) + { + $this->method = $method; + return $this; + } + + /** + * Gets Method + * + * @return string + */ + public function getMethod() + { + return $this->method; + } + + /** + * Sets Enctype + * + * @param string $enctype + * + * @return $this + */ + public function setEnctype($enctype) + { + $this->enctype = $enctype; + return $this; + } + + /** + * Gets Enctype + * + * @return string + */ + public function getEnctype() + { + return $this->enctype; + } + + /** + * Sets Schema + * + * @param \PayPal\Api\HyperSchema $schema + * + * @return $this + */ + public function setSchema($schema) + { + $this->schema = $schema; + return $this; + } + + /** + * Gets Schema + * + * @return \PayPal\Api\HyperSchema + */ + public function getSchema() + { + return $this->schema; + } + +} diff --git a/paypal/PayPal/Api/Measurement.php b/paypal/PayPal/Api/Measurement.php new file mode 100644 index 0000000..5ae9ace --- /dev/null +++ b/paypal/PayPal/Api/Measurement.php @@ -0,0 +1,65 @@ +value = $value; + return $this; + } + + /** + * Value this measurement represents. + * + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * Unit in which the value is represented. + * + * @param string $unit + * + * @return $this + */ + public function setUnit($unit) + { + $this->unit = $unit; + return $this; + } + + /** + * Unit in which the value is represented. + * + * @return string + */ + public function getUnit() + { + return $this->unit; + } + +} diff --git a/paypal/PayPal/Api/MerchantInfo.php b/paypal/PayPal/Api/MerchantInfo.php new file mode 100644 index 0000000..72c561e --- /dev/null +++ b/paypal/PayPal/Api/MerchantInfo.php @@ -0,0 +1,281 @@ +email = $email; + return $this; + } + + /** + * The merchant email address. Maximum length is 260 characters. + * + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * The merchant first name. Maximum length is 30 characters. + * + * @param string $first_name + * + * @return $this + */ + public function setFirstName($first_name) + { + $this->first_name = $first_name; + return $this; + } + + /** + * The merchant first name. Maximum length is 30 characters. + * + * @return string + */ + public function getFirstName() + { + return $this->first_name; + } + + /** + * The merchant last name. Maximum length is 30 characters. + * + * @param string $last_name + * + * @return $this + */ + public function setLastName($last_name) + { + $this->last_name = $last_name; + return $this; + } + + /** + * The merchant last name. Maximum length is 30 characters. + * + * @return string + */ + public function getLastName() + { + return $this->last_name; + } + + /** + * The merchant address. + * + * @param \PayPal\Api\InvoiceAddress $address + * + * @return $this + */ + public function setAddress($address) + { + $this->address = $address; + return $this; + } + + /** + * The merchant address. + * + * @return \PayPal\Api\InvoiceAddress + */ + public function getAddress() + { + return $this->address; + } + + /** + * The merchant company business name. Maximum length is 100 characters. + * + * @param string $business_name + * + * @return $this + */ + public function setBusinessName($business_name) + { + $this->business_name = $business_name; + return $this; + } + + /** + * The merchant company business name. Maximum length is 100 characters. + * + * @return string + */ + public function getBusinessName() + { + return $this->business_name; + } + + /** + * The merchant phone number. + * + * @param \PayPal\Api\Phone $phone + * + * @return $this + */ + public function setPhone($phone) + { + $this->phone = $phone; + return $this; + } + + /** + * The merchant phone number. + * + * @return \PayPal\Api\Phone + */ + public function getPhone() + { + return $this->phone; + } + + /** + * The merchant fax number. + * + * @param \PayPal\Api\Phone $fax + * + * @return $this + */ + public function setFax($fax) + { + $this->fax = $fax; + return $this; + } + + /** + * The merchant fax number. + * + * @return \PayPal\Api\Phone + */ + public function getFax() + { + return $this->fax; + } + + /** + * The merchant website. Maximum length is 2048 characters. + * + * @param string $website + * + * @return $this + */ + public function setWebsite($website) + { + $this->website = $website; + return $this; + } + + /** + * The merchant website. Maximum length is 2048 characters. + * + * @return string + */ + public function getWebsite() + { + return $this->website; + } + + /** + * The merchant tax ID. Maximum length is 100 characters. + * + * @param string $tax_id + * + * @return $this + */ + public function setTaxId($tax_id) + { + $this->tax_id = $tax_id; + return $this; + } + + /** + * The merchant tax ID. Maximum length is 100 characters. + * + * @return string + */ + public function getTaxId() + { + return $this->tax_id; + } + + /** + * Option to provide a label to the additional_info field. 40 characters max. + * + * @param string $additional_info_label + * + * @return $this + */ + public function setAdditionalInfoLabel($additional_info_label) + { + $this->additional_info_label = $additional_info_label; + return $this; + } + + /** + * Option to provide a label to the additional_info field. 40 characters max. + * + * @return string + */ + public function getAdditionalInfoLabel() + { + return $this->additional_info_label; + } + + /** + * Additional information, such as business hours. Maximum length is 40 characters. + * + * @param string $additional_info + * + * @return $this + */ + public function setAdditionalInfo($additional_info) + { + $this->additional_info = $additional_info; + return $this; + } + + /** + * Additional information, such as business hours. Maximum length is 40 characters. + * + * @return string + */ + public function getAdditionalInfo() + { + return $this->additional_info; + } + +} diff --git a/paypal/PayPal/Api/MerchantPreferences.php b/paypal/PayPal/Api/MerchantPreferences.php new file mode 100644 index 0000000..b51d604 --- /dev/null +++ b/paypal/PayPal/Api/MerchantPreferences.php @@ -0,0 +1,261 @@ +id = $id; + return $this; + } + + /** + * Identifier of the merchant_preferences. 128 characters max. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Setup fee amount. Default is 0. + * + * @param \PayPal\Api\Currency $setup_fee + * + * @return $this + */ + public function setSetupFee($setup_fee) + { + $this->setup_fee = $setup_fee; + return $this; + } + + /** + * Setup fee amount. Default is 0. + * + * @return \PayPal\Api\Currency + */ + public function getSetupFee() + { + return $this->setup_fee; + } + + /** + * Redirect URL on cancellation of agreement request. 1000 characters max. + * + * @param string $cancel_url + * @throws \InvalidArgumentException + * @return $this + */ + public function setCancelUrl($cancel_url) + { + UrlValidator::validate($cancel_url, "CancelUrl"); + $this->cancel_url = $cancel_url; + return $this; + } + + /** + * Redirect URL on cancellation of agreement request. 1000 characters max. + * + * @return string + */ + public function getCancelUrl() + { + return $this->cancel_url; + } + + /** + * Redirect URL on creation of agreement request. 1000 characters max. + * + * @param string $return_url + * @throws \InvalidArgumentException + * @return $this + */ + public function setReturnUrl($return_url) + { + UrlValidator::validate($return_url, "ReturnUrl"); + $this->return_url = $return_url; + return $this; + } + + /** + * Redirect URL on creation of agreement request. 1000 characters max. + * + * @return string + */ + public function getReturnUrl() + { + return $this->return_url; + } + + /** + * Notify URL on agreement creation. 1000 characters max. + * + * @param string $notify_url + * @throws \InvalidArgumentException + * @return $this + */ + public function setNotifyUrl($notify_url) + { + UrlValidator::validate($notify_url, "NotifyUrl"); + $this->notify_url = $notify_url; + return $this; + } + + /** + * Notify URL on agreement creation. 1000 characters max. + * + * @return string + */ + public function getNotifyUrl() + { + return $this->notify_url; + } + + /** + * Total number of failed attempts allowed. Default is 0, representing an infinite number of failed attempts. + * + * @param string $max_fail_attempts + * + * @return $this + */ + public function setMaxFailAttempts($max_fail_attempts) + { + $this->max_fail_attempts = $max_fail_attempts; + return $this; + } + + /** + * Total number of failed attempts allowed. Default is 0, representing an infinite number of failed attempts. + * + * @return string + */ + public function getMaxFailAttempts() + { + return $this->max_fail_attempts; + } + + /** + * Allow auto billing for the outstanding amount of the agreement in the next cycle. Allowed values: `YES`, `NO`. Default is `NO`. + * + * @param string $auto_bill_amount + * + * @return $this + */ + public function setAutoBillAmount($auto_bill_amount) + { + $this->auto_bill_amount = $auto_bill_amount; + return $this; + } + + /** + * Allow auto billing for the outstanding amount of the agreement in the next cycle. Allowed values: `YES`, `NO`. Default is `NO`. + * + * @return string + */ + public function getAutoBillAmount() + { + return $this->auto_bill_amount; + } + + /** + * Action to take if a failure occurs during initial payment. Allowed values: `CONTINUE`, `CANCEL`. Default is continue. + * + * @param string $initial_fail_amount_action + * + * @return $this + */ + public function setInitialFailAmountAction($initial_fail_amount_action) + { + $this->initial_fail_amount_action = $initial_fail_amount_action; + return $this; + } + + /** + * Action to take if a failure occurs during initial payment. Allowed values: `CONTINUE`, `CANCEL`. Default is continue. + * + * @return string + */ + public function getInitialFailAmountAction() + { + return $this->initial_fail_amount_action; + } + + /** + * Payment types that are accepted for this plan. + * + * @param string $accepted_payment_type + * + * @return $this + */ + public function setAcceptedPaymentType($accepted_payment_type) + { + $this->accepted_payment_type = $accepted_payment_type; + return $this; + } + + /** + * Payment types that are accepted for this plan. + * + * @return string + */ + public function getAcceptedPaymentType() + { + return $this->accepted_payment_type; + } + + /** + * char_set for this plan. + * + * @param string $char_set + * + * @return $this + */ + public function setCharSet($char_set) + { + $this->char_set = $char_set; + return $this; + } + + /** + * char_set for this plan. + * + * @return string + */ + public function getCharSet() + { + return $this->char_set; + } + +} diff --git a/paypal/PayPal/Api/Metadata.php b/paypal/PayPal/Api/Metadata.php new file mode 100644 index 0000000..8cddb02 --- /dev/null +++ b/paypal/PayPal/Api/Metadata.php @@ -0,0 +1,259 @@ +created_date = $created_date; + return $this; + } + + /** + * The date and time when the resource was created. + * + * @return string + */ + public function getCreatedDate() + { + return $this->created_date; + } + + /** + * The email address of the account that created the resource. + * + * @param string $created_by + * + * @return $this + */ + public function setCreatedBy($created_by) + { + $this->created_by = $created_by; + return $this; + } + + /** + * The email address of the account that created the resource. + * + * @return string + */ + public function getCreatedBy() + { + return $this->created_by; + } + + /** + * The date and time when the resource was cancelled. + * + * @param string $cancelled_date + * + * @return $this + */ + public function setCancelledDate($cancelled_date) + { + $this->cancelled_date = $cancelled_date; + return $this; + } + + /** + * The date and time when the resource was cancelled. + * + * @return string + */ + public function getCancelledDate() + { + return $this->cancelled_date; + } + + /** + * The actor who cancelled the resource. + * + * @param string $cancelled_by + * + * @return $this + */ + public function setCancelledBy($cancelled_by) + { + $this->cancelled_by = $cancelled_by; + return $this; + } + + /** + * The actor who cancelled the resource. + * + * @return string + */ + public function getCancelledBy() + { + return $this->cancelled_by; + } + + /** + * The date and time when the resource was last edited. + * + * @param string $last_updated_date + * + * @return $this + */ + public function setLastUpdatedDate($last_updated_date) + { + $this->last_updated_date = $last_updated_date; + return $this; + } + + /** + * The date and time when the resource was last edited. + * + * @return string + */ + public function getLastUpdatedDate() + { + return $this->last_updated_date; + } + + /** + * The email address of the account that last edited the resource. + * + * @param string $last_updated_by + * + * @return $this + */ + public function setLastUpdatedBy($last_updated_by) + { + $this->last_updated_by = $last_updated_by; + return $this; + } + + /** + * The email address of the account that last edited the resource. + * + * @return string + */ + public function getLastUpdatedBy() + { + return $this->last_updated_by; + } + + /** + * The date and time when the resource was first sent. + * + * @param string $first_sent_date + * + * @return $this + */ + public function setFirstSentDate($first_sent_date) + { + $this->first_sent_date = $first_sent_date; + return $this; + } + + /** + * The date and time when the resource was first sent. + * + * @return string + */ + public function getFirstSentDate() + { + return $this->first_sent_date; + } + + /** + * The date and time when the resource was last sent. + * + * @param string $last_sent_date + * + * @return $this + */ + public function setLastSentDate($last_sent_date) + { + $this->last_sent_date = $last_sent_date; + return $this; + } + + /** + * The date and time when the resource was last sent. + * + * @return string + */ + public function getLastSentDate() + { + return $this->last_sent_date; + } + + /** + * The email address of the account that last sent the resource. + * + * @param string $last_sent_by + * + * @return $this + */ + public function setLastSentBy($last_sent_by) + { + $this->last_sent_by = $last_sent_by; + return $this; + } + + /** + * The email address of the account that last sent the resource. + * + * @return string + */ + public function getLastSentBy() + { + return $this->last_sent_by; + } + + /** + * URL representing the payer's view of the invoice. + * + * @param string $payer_view_url + * @throws \InvalidArgumentException + * @return $this + */ + public function setPayerViewUrl($payer_view_url) + { + UrlValidator::validate($payer_view_url, "PayerViewUrl"); + $this->payer_view_url = $payer_view_url; + return $this; + } + + /** + * URL representing the payer's view of the invoice. + * + * @return string + */ + public function getPayerViewUrl() + { + return $this->payer_view_url; + } + +} diff --git a/paypal/PayPal/Api/NameValuePair.php b/paypal/PayPal/Api/NameValuePair.php new file mode 100644 index 0000000..4e32720 --- /dev/null +++ b/paypal/PayPal/Api/NameValuePair.php @@ -0,0 +1,65 @@ +name = $name; + return $this; + } + + /** + * Key for the name value pair. The value name types should be correlated + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Value for the name value pair. + * + * @param string $value + * + * @return $this + */ + public function setValue($value) + { + $this->value = $value; + return $this; + } + + /** + * Value for the name value pair. + * + * @return string + */ + public function getValue() + { + return $this->value; + } + +} diff --git a/paypal/PayPal/Api/Notification.php b/paypal/PayPal/Api/Notification.php new file mode 100644 index 0000000..9b5a772 --- /dev/null +++ b/paypal/PayPal/Api/Notification.php @@ -0,0 +1,143 @@ +subject = $subject; + return $this; + } + + /** + * Subject of the notification. + * + * @return string + */ + public function getSubject() + { + return $this->subject; + } + + /** + * Note to the payer. + * + * @param string $note + * + * @return $this + */ + public function setNote($note) + { + $this->note = $note; + return $this; + } + + /** + * Note to the payer. + * + * @return string + */ + public function getNote() + { + return $this->note; + } + + /** + * Indicates whether to send a copy of the email to the merchant. + * + * @param bool $send_to_merchant + * + * @return $this + */ + public function setSendToMerchant($send_to_merchant) + { + $this->send_to_merchant = $send_to_merchant; + return $this; + } + + /** + * Indicates whether to send a copy of the email to the merchant. + * + * @return bool + */ + public function getSendToMerchant() + { + return $this->send_to_merchant; + } + + /** + * Applicable for invoices created with Cc emails. If this field is not in the body, all the cc email addresses added as part of the invoice shall be notified else this field can be used to limit the list of email addresses. Note: additional email addresses are not supported. + * + * @param string[] $cc_emails + * + * @return $this + */ + public function setCcEmails($cc_emails) + { + $this->cc_emails = $cc_emails; + return $this; + } + + /** + * Applicable for invoices created with Cc emails. If this field is not in the body, all the cc email addresses added as part of the invoice shall be notified else this field can be used to limit the list of email addresses. Note: additional email addresses are not supported. + * + * @return string[] + */ + public function getCcEmails() + { + return $this->cc_emails; + } + + /** + * Append CcEmails to the list. + * + * @param string $string + * @return $this + */ + public function addCcEmail($string) + { + if (!$this->getCcEmails()) { + return $this->setCcEmails(array($string)); + } else { + return $this->setCcEmails( + array_merge($this->getCcEmails(), array($string)) + ); + } + } + + /** + * Remove CcEmails from the list. + * + * @param string $string + * @return $this + */ + public function removeCcEmail($string) + { + return $this->setCcEmails( + array_diff($this->getCcEmails(), array($string)) + ); + } + +} diff --git a/paypal/PayPal/Api/OpenIdAddress.php b/paypal/PayPal/Api/OpenIdAddress.php new file mode 100644 index 0000000..306abf6 --- /dev/null +++ b/paypal/PayPal/Api/OpenIdAddress.php @@ -0,0 +1,133 @@ +street_address = $street_address; + return $this; + } + + /** + * Full street address component, which may include house number, street name. + * + * @return string + */ + public function getStreetAddress() + { + return $this->street_address; + } + + /** + * City or locality component. + * + * @param string $locality + * @return self + */ + public function setLocality($locality) + { + $this->locality = $locality; + return $this; + } + + /** + * City or locality component. + * + * @return string + */ + public function getLocality() + { + return $this->locality; + } + + /** + * State, province, prefecture or region component. + * + * @param string $region + * @return self + */ + public function setRegion($region) + { + $this->region = $region; + return $this; + } + + /** + * State, province, prefecture or region component. + * + * @return string + */ + public function getRegion() + { + return $this->region; + } + + /** + * Zip code or postal code component. + * + * @param string $postal_code + * @return self + */ + public function setPostalCode($postal_code) + { + $this->postal_code = $postal_code; + return $this; + } + + /** + * Zip code or postal code component. + * + * @return string + */ + public function getPostalCode() + { + return $this->postal_code; + } + + /** + * Country name component. + * + * @param string $country + * @return self + */ + public function setCountry($country) + { + $this->country = $country; + return $this; + } + + /** + * Country name component. + * + * @return string + */ + public function getCountry() + { + return $this->country; + } + + +} diff --git a/paypal/PayPal/Api/OpenIdError.php b/paypal/PayPal/Api/OpenIdError.php new file mode 100644 index 0000000..4b9b956 --- /dev/null +++ b/paypal/PayPal/Api/OpenIdError.php @@ -0,0 +1,85 @@ +error = $error; + return $this; + } + + /** + * A single ASCII error code from the following enum. + * + * @return string + */ + public function getError() + { + return $this->error; + } + + /** + * A resource ID that indicates the starting resource in the returned results. + * + * @param string $error_description + * @return self + */ + public function setErrorDescription($error_description) + { + $this->error_description = $error_description; + return $this; + } + + /** + * A resource ID that indicates the starting resource in the returned results. + * + * @return string + */ + public function getErrorDescription() + { + return $this->error_description; + } + + /** + * 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. + * + * @param string $error_uri + * @return self + */ + public function setErrorUri($error_uri) + { + $this->error_uri = $error_uri; + return $this; + } + + /** + * 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. + * + * @return string + */ + public function getErrorUri() + { + return $this->error_uri; + } + + +} diff --git a/paypal/PayPal/Api/OpenIdSession.php b/paypal/PayPal/Api/OpenIdSession.php new file mode 100644 index 0000000..ad26af6 --- /dev/null +++ b/paypal/PayPal/Api/OpenIdSession.php @@ -0,0 +1,107 @@ +getConfig(); + + if ($apiContext->get($clientId)) { + $clientId = $apiContext->get($clientId); + } + + $clientId = $clientId ? $clientId : $apiContext->getCredential()->getClientId(); + + $scope = count($scope) != 0 ? $scope : array('openid', 'profile', 'address', 'email', 'phone', + 'https://uri.paypal.com/services/paypalattributes', 'https://uri.paypal.com/services/expresscheckout'); + if (!in_array('openid', $scope)) { + $scope[] = 'openid'; + } + + $params = array( + 'client_id' => $clientId, + 'response_type' => 'code', + 'scope' => implode(" ", $scope), + 'redirect_uri' => $redirectUri + ); + + if ($nonce) { + $params['nonce'] = $nonce; + } + if ($state) { + $params['state'] = $state; + } + return sprintf("%s/signin/authorize?%s", self::getBaseUrl($config), http_build_query($params)); + } + + + /** + * Returns the URL to which the user must be redirected to + * logout from the OpenID provider (i.e. PayPal) + * + * @param string $redirectUri Uri on merchant website to where + * the user must be redirected to post logout + * @param string $idToken id_token from the TokenInfo object + * @param ApiContext $apiContext Optional API Context + * @return string logout URL + */ + public static function getLogoutUrl($redirectUri, $idToken, $apiContext = null) + { + + if (is_null($apiContext)) { + $apiContext = new ApiContext(); + } + $config = $apiContext->getConfig(); + + $params = array( + 'id_token' => $idToken, + 'redirect_uri' => $redirectUri, + 'logout' => 'true' + ); + return sprintf("%s/webapps/auth/protocol/openidconnect/v1/endsession?%s", self::getBaseUrl($config), http_build_query($params)); + } + + /** + * Gets the base URL for the Redirect URI + * + * @param $config + * @return null|string + */ + private static function getBaseUrl($config) + { + + if (array_key_exists('openid.RedirectUri', $config)) { + return $config['openid.RedirectUri']; + } else if (array_key_exists('mode', $config)) { + switch (strtoupper($config['mode'])) { + case 'SANDBOX': + return PayPalConstants::OPENID_REDIRECT_SANDBOX_URL; + case 'LIVE': + return PayPalConstants::OPENID_REDIRECT_LIVE_URL; + } + } + return null; + } +} diff --git a/paypal/PayPal/Api/OpenIdTokeninfo.php b/paypal/PayPal/Api/OpenIdTokeninfo.php new file mode 100644 index 0000000..ccd23da --- /dev/null +++ b/paypal/PayPal/Api/OpenIdTokeninfo.php @@ -0,0 +1,255 @@ +scope = $scope; + return $this; + } + + /** + * OPTIONAL, if identical to the scope requested by the client; otherwise, REQUIRED. + * + * @return string + */ + public function getScope() + { + return $this->scope; + } + + /** + * The access token issued by the authorization server. + * + * @param string $access_token + * @return self + */ + public function setAccessToken($access_token) + { + $this->access_token = $access_token; + return $this; + } + + /** + * The access token issued by the authorization server. + * + * @return string + */ + public function getAccessToken() + { + return $this->access_token; + } + + /** + * 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. + * + * @param string $refresh_token + * @return self + */ + public function setRefreshToken($refresh_token) + { + $this->refresh_token = $refresh_token; + return $this; + } + + /** + * 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. + * + * @return string + */ + public function getRefreshToken() + { + return $this->refresh_token; + } + + /** + * The type of the token issued as described in OAuth2.0 RFC6749 (Section 7.1). Value is case insensitive. + * + * @param string $token_type + * @return self + */ + public function setTokenType($token_type) + { + $this->token_type = $token_type; + return $this; + } + + /** + * The type of the token issued as described in OAuth2.0 RFC6749 (Section 7.1). Value is case insensitive. + * + * @return string + */ + public function getTokenType() + { + return $this->token_type; + } + + /** + * The id_token is a session token assertion that denotes the user's authentication status + * + * @param string $id_token + * @return self + */ + public function setIdToken($id_token) + { + $this->id_token = $id_token; + return $this; + } + + /** + * The id_token is a session token assertion that denotes the user's authentication status + * + * @return string + */ + public function getIdToken() + { + return $this->id_token; + } + + /** + * The lifetime in seconds of the access token. + * + * @param integer $expires_in + * @return self + */ + public function setExpiresIn($expires_in) + { + $this->expires_in = $expires_in; + return $this; + } + + /** + * The lifetime in seconds of the access token. + * + * @return integer + */ + public function getExpiresIn() + { + return $this->expires_in; + } + + + /** + * Creates an Access Token from an Authorization Code. + * + * @path /v1/identity/openidconnect/tokenservice + * @method POST + * @param array $params (allowed values are client_id, client_secret, grant_type, code and redirect_uri) + * (required) client_id from developer portal + * (required) client_secret from developer portal + * (required) code is Authorization code previously received from the authorization server + * (required) redirect_uri Redirection endpoint that must match the one provided during the + * authorization request that ended in receiving the authorization code. + * (optional) grant_type is the Token grant type. Defaults to authorization_code + * @param string $clientId + * @param string $clientSecret + * @param ApiContext $apiContext Optional API Context + * @param PayPalRestCall $restCall + * @return OpenIdTokeninfo + */ + public static function createFromAuthorizationCode($params, $clientId = null, $clientSecret = null, $apiContext = null, $restCall = null) + { + static $allowedParams = array('grant_type' => 1, 'code' => 1, 'redirect_uri' => 1); + + if (!array_key_exists('grant_type', $params)) { + $params['grant_type'] = 'authorization_code'; + } + $apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential); + + if (sizeof($apiContext->get($clientId)) > 0) { + $clientId = $apiContext->get($clientId); + } + + if (sizeof($apiContext->get($clientSecret)) > 0) { + $clientSecret = $apiContext->get($clientSecret); + } + + $clientId = $clientId ? $clientId : $apiContext->getCredential()->getClientId(); + $clientSecret = $clientSecret ? $clientSecret : $apiContext->getCredential()->getClientSecret(); + + $json = self::executeCall( + "/v1/identity/openidconnect/tokenservice", + "POST", + http_build_query(array_intersect_key($params, $allowedParams)), + array( + 'Content-Type' => 'application/x-www-form-urlencoded', + 'Authorization' => 'Basic ' . base64_encode($clientId . ":" . $clientSecret) + ), + $apiContext, + $restCall + ); + $token = new OpenIdTokeninfo(); + $token->fromJson($json); + return $token; + } + + /** + * Creates an Access Token from an Refresh Token. + * + * @path /v1/identity/openidconnect/tokenservice + * @method POST + * @param array $params (allowed values are grant_type and scope) + * (required) client_id from developer portal + * (required) client_secret from developer portal + * (optional) refresh_token refresh token. If one is not passed, refresh token from the current object is used. + * (optional) grant_type is the Token grant type. Defaults to refresh_token + * (optional) scope is an array that either the same or a subset of the scope passed to the authorization request + * @param APIContext $apiContext Optional API Context + * @param PayPalRestCall $restCall + * @return OpenIdTokeninfo + */ + public function createFromRefreshToken($params, $apiContext = null, $restCall = null) + { + static $allowedParams = array('grant_type' => 1, 'refresh_token' => 1, 'scope' => 1); + $apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential); + + if (!array_key_exists('grant_type', $params)) { + $params['grant_type'] = 'refresh_token'; + } + if (!array_key_exists('refresh_token', $params)) { + $params['refresh_token'] = $this->getRefreshToken(); + } + + $clientId = isset($params['client_id']) ? $params['client_id'] : $apiContext->getCredential()->getClientId(); + $clientSecret = isset($params['client_secret']) ? $params['client_secret'] : $apiContext->getCredential()->getClientSecret(); + + $json = self::executeCall( + "/v1/identity/openidconnect/tokenservice", + "POST", + http_build_query(array_intersect_key($params, $allowedParams)), + array( + 'Content-Type' => 'application/x-www-form-urlencoded', + 'Authorization' => 'Basic ' . base64_encode($clientId . ":" . $clientSecret) + ), + $apiContext, + $restCall + ); + + $this->fromJson($json); + return $this; + } +} diff --git a/paypal/PayPal/Api/OpenIdUserinfo.php b/paypal/PayPal/Api/OpenIdUserinfo.php new file mode 100644 index 0000000..b6d1f6e --- /dev/null +++ b/paypal/PayPal/Api/OpenIdUserinfo.php @@ -0,0 +1,540 @@ +user_id = $user_id; + return $this; + } + + /** + * Subject - Identifier for the End-User at the Issuer. + * + * @return string + */ + public function getUserId() + { + return $this->user_id; + } + + /** + * Subject - Identifier for the End-User at the Issuer. + * + * @param string $sub + * @return self + */ + public function setSub($sub) + { + $this->sub = $sub; + return $this; + } + + /** + * Subject - Identifier for the End-User at the Issuer. + * + * @return string + */ + public function getSub() + { + return $this->sub; + } + + /** + * 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. + * + * @param string $name + * @return self + */ + public function setName($name) + { + $this->name = $name; + return $this; + } + + /** + * 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. + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Given name(s) or first name(s) of the End-User + * + * @param string $given_name + * @return self + */ + public function setGivenName($given_name) + { + $this->given_name = $given_name; + return $this; + } + + /** + * Given name(s) or first name(s) of the End-User + * + * @return string + */ + public function getGivenName() + { + return $this->given_name; + } + + /** + * Surname(s) or last name(s) of the End-User. + * + * @param string $family_name + * @return self + */ + public function setFamilyName($family_name) + { + $this->family_name = $family_name; + return $this; + } + + /** + * Surname(s) or last name(s) of the End-User. + * + * @return string + */ + public function getFamilyName() + { + return $this->family_name; + } + + /** + * Middle name(s) of the End-User. + * + * @param string $middle_name + * @return self + */ + public function setMiddleName($middle_name) + { + $this->middle_name = $middle_name; + return $this; + } + + /** + * Middle name(s) of the End-User. + * + * @return string + */ + public function getMiddleName() + { + return $this->middle_name; + } + + /** + * URL of the End-User's profile picture. + * + * @param string $picture + * @return self + */ + public function setPicture($picture) + { + $this->picture = $picture; + return $this; + } + + /** + * URL of the End-User's profile picture. + * + * @return string + */ + public function getPicture() + { + return $this->picture; + } + + /** + * End-User's preferred e-mail address. + * + * @param string $email + * @return self + */ + public function setEmail($email) + { + $this->email = $email; + return $this; + } + + /** + * End-User's preferred e-mail address. + * + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * True if the End-User's e-mail address has been verified; otherwise false. + * + * @param boolean $email_verified + * @return self + */ + public function setEmailVerified($email_verified) + { + $this->email_verified = $email_verified; + return $this; + } + + /** + * True if the End-User's e-mail address has been verified; otherwise false. + * + * @return boolean + */ + public function getEmailVerified() + { + return $this->email_verified; + } + + /** + * End-User's gender. + * + * @param string $gender + * @return self + */ + public function setGender($gender) + { + $this->gender = $gender; + return $this; + } + + /** + * End-User's gender. + * + * @return string + */ + public function getGender() + { + return $this->gender; + } + + /** + * 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. + * + * @param string $birthday + * @return self + */ + public function setBirthday($birthday) + { + $this->birthday = $birthday; + return $this; + } + + /** + * 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. + * + * @return string + */ + public function getBirthday() + { + return $this->birthday; + } + + /** + * Time zone database representing the End-User's time zone + * + * @param string $zoneinfo + * @return self + */ + public function setZoneinfo($zoneinfo) + { + $this->zoneinfo = $zoneinfo; + return $this; + } + + /** + * Time zone database representing the End-User's time zone + * + * @return string + */ + public function getZoneinfo() + { + return $this->zoneinfo; + } + + /** + * End-User's locale. + * + * @param string $locale + * @return self + */ + public function setLocale($locale) + { + $this->locale = $locale; + return $this; + } + + /** + * End-User's locale. + * + * @return string + */ + public function getLocale() + { + return $this->locale; + } + + /** + * End-User's language. + * + * @param string $language + * @return self + */ + public function setLanguage($language) + { + $this->language = $language; + return $this; + } + + /** + * End-User's language. + * + * @return string + */ + public function getLanguage() + { + return $this->language; + } + + /** + * End-User's verified status. + * + * @param boolean $verified + * @return self + */ + public function setVerified($verified) + { + $this->verified = $verified; + return $this; + } + + /** + * End-User's verified status. + * + * @return boolean + */ + public function getVerified() + { + return $this->verified; + } + + /** + * End-User's preferred telephone number. + * + * @param string $phone_number + * @return self + */ + public function setPhoneNumber($phone_number) + { + $this->phone_number = $phone_number; + return $this; + } + + /** + * End-User's preferred telephone number. + * + * @return string + */ + public function getPhoneNumber() + { + return $this->phone_number; + } + + /** + * End-User's preferred address. + * + * @param \PayPal\Api\OpenIdAddress $address + * @return self + */ + public function setAddress($address) + { + $this->address = $address; + return $this; + } + + /** + * End-User's preferred address. + * + * @return \PayPal\Api\OpenIdAddress + */ + public function getAddress() + { + return $this->address; + } + + /** + * Verified account status. + * + * @param boolean $verified_account + * @return self + */ + public function setVerifiedAccount($verified_account) + { + $this->verified_account = $verified_account; + return $this; + } + + /** + * Verified account status. + * + * @return boolean + */ + public function getVerifiedAccount() + { + return $this->verified_account; + } + + /** + * Account type. + * + * @param string $account_type + * @return self + */ + public function setAccountType($account_type) + { + $this->account_type = $account_type; + return $this; + } + + /** + * Account type. + * + * @return string + */ + public function getAccountType() + { + return $this->account_type; + } + + /** + * Account holder age range. + * + * @param string $age_range + * @return self + */ + public function setAgeRange($age_range) + { + $this->age_range = $age_range; + return $this; + } + + /** + * Account holder age range. + * + * @return string + */ + public function getAgeRange() + { + return $this->age_range; + } + + /** + * Account payer identifier. + * + * @param string $payer_id + * @return self + */ + public function setPayerId($payer_id) + { + $this->payer_id = $payer_id; + return $this; + } + + /** + * Account payer identifier. + * + * @return string + */ + public function getPayerId() + { + return $this->payer_id; + } + + + /** + * returns user details + * + * @path /v1/identity/openidconnect/userinfo + * @method GET + * @param array $params (allowed values are access_token) + * access_token - access token from the createFromAuthorizationCode / createFromRefreshToken calls + * @param ApiContext $apiContext Optional API Context + * @param PayPalRestCall $restCall + * @return OpenIdUserinfo + */ + public static function getUserinfo($params, $apiContext = null, $restCall = null) + { + static $allowedParams = array('schema' => 1); + + $params = is_array($params) ? $params : array(); + + if (!array_key_exists('schema', $params)) { + $params['schema'] = 'openid'; + } + $requestUrl = "/v1/identity/openidconnect/userinfo?" + . http_build_query(array_intersect_key($params, $allowedParams)); + + $json = self::executeCall( + $requestUrl, + "GET", + "", + array( + 'Authorization' => "Bearer " . $params['access_token'], + 'Content-Type' => 'x-www-form-urlencoded' + ), + $apiContext, + $restCall + ); + + $ret = new OpenIdUserinfo(); + $ret->fromJson($json); + + return $ret; + } +} diff --git a/paypal/PayPal/Api/Order.php b/paypal/PayPal/Api/Order.php new file mode 100644 index 0000000..13312cc --- /dev/null +++ b/paypal/PayPal/Api/Order.php @@ -0,0 +1,464 @@ +id = $id; + return $this; + } + + /** + * Identifier of the order transaction. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Identifier to the purchase unit associated with this object. Obsolete. Use one in cart_base. + * + * @deprecated Use #setReferenceId instead + * + * @param string $purchase_unit_reference_id + * + * @return $this + */ + public function setPurchaseUnitReferenceId($purchase_unit_reference_id) + { + $this->purchase_unit_reference_id = $purchase_unit_reference_id; + return $this; + } + + /** + * Identifier to the purchase unit associated with this object. Obsolete. Use one in cart_base. + * @deprecated Use #getReferenceId instead + * + * @return string + */ + public function getPurchaseUnitReferenceId() + { + return $this->purchase_unit_reference_id; + } + + /** + * Identifier to the purchase unit associated with this object. Obsolete. Use one in cart_base. + * + * @param string $reference_id + * + * @return $this + */ + public function setReferenceId($reference_id) + { + $this->reference_id = $reference_id; + return $this; + } + + /** + * Identifier to the purchase unit associated with this object. Obsolete. Use one in cart_base. + * + * @return string + */ + public function getReferenceId() + { + return $this->reference_id; + } + + /** + * Amount being collected. + * + * @param \PayPal\Api\Amount $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * Amount being collected. + * + * @return \PayPal\Api\Amount + */ + public function getAmount() + { + return $this->amount; + } + + /** + * specifies payment mode of the transaction + * Valid Values: ["INSTANT_TRANSFER", "MANUAL_BANK_TRANSFER", "DELAYED_TRANSFER", "ECHECK"] + * + * @param string $payment_mode + * + * @return $this + */ + public function setPaymentMode($payment_mode) + { + $this->payment_mode = $payment_mode; + return $this; + } + + /** + * specifies payment mode of the transaction + * + * @return string + */ + public function getPaymentMode() + { + return $this->payment_mode; + } + + /** + * State of the order transaction. + * Valid Values: ["pending", "completed", "voided", "authorized", "captured"] + * + * @param string $state + * + * @return $this + */ + public function setState($state) + { + $this->state = $state; + return $this; + } + + /** + * State of the order transaction. + * + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * Reason code for the transaction state being Pending or Reversed. This field will replace pending_reason field eventually. Only supported when the `payment_method` is set to `paypal`. + * Valid Values: ["PAYER_SHIPPING_UNCONFIRMED", "MULTI_CURRENCY", "RISK_REVIEW", "REGULATORY_REVIEW", "VERIFICATION_REQUIRED", "ORDER", "OTHER"] + * + * @param string $reason_code + * + * @return $this + */ + public function setReasonCode($reason_code) + { + $this->reason_code = $reason_code; + return $this; + } + + /** + * Reason code for the transaction state being Pending or Reversed. This field will replace pending_reason field eventually. Only supported when the `payment_method` is set to `paypal`. + * + * @return string + */ + public function getReasonCode() + { + return $this->reason_code; + } + + /** + * [DEPRECATED] Reason code for the transaction state being Pending. Obsolete. Retained for backward compatability. Use reason_code field above instead. + * Valid Values: ["payer_shipping_unconfirmed", "multi_currency", "risk_review", "regulatory_review", "verification_required", "order", "other"] + * + * @param string $pending_reason + * + * @return $this + */ + public function setPendingReason($pending_reason) + { + $this->pending_reason = $pending_reason; + return $this; + } + + /** + * @deprecated [DEPRECATED] Reason code for the transaction state being Pending. Obsolete. Retained for backward compatability. Use reason_code field above instead. + * + * @return string + */ + public function getPendingReason() + { + return $this->pending_reason; + } + + /** + * The level of seller protection in force for the transaction. + * Valid Values: ["ELIGIBLE", "PARTIALLY_ELIGIBLE", "INELIGIBLE"] + * + * @param string $protection_eligibility + * + * @return $this + */ + public function setProtectionEligibility($protection_eligibility) + { + $this->protection_eligibility = $protection_eligibility; + return $this; + } + + /** + * The level of seller protection in force for the transaction. + * + * @return string + */ + public function getProtectionEligibility() + { + return $this->protection_eligibility; + } + + /** + * 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:
`ITEM_NOT_RECEIVED_ELIGIBLE`- Sellers are protected against claims for items not received.
`UNAUTHORIZED_PAYMENT_ELIGIBLE`- Sellers are protected against claims for unauthorized payments.
One or both of the allowed values can be returned. + * Valid Values: ["ITEM_NOT_RECEIVED_ELIGIBLE", "UNAUTHORIZED_PAYMENT_ELIGIBLE", "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE"] + * + * @param string $protection_eligibility_type + * + * @return $this + */ + public function setProtectionEligibilityType($protection_eligibility_type) + { + $this->protection_eligibility_type = $protection_eligibility_type; + return $this; + } + + /** + * 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:
`ITEM_NOT_RECEIVED_ELIGIBLE`- Sellers are protected against claims for items not received.
`UNAUTHORIZED_PAYMENT_ELIGIBLE`- Sellers are protected against claims for unauthorized payments.
One or both of the allowed values can be returned. + * + * @return string + */ + public function getProtectionEligibilityType() + { + return $this->protection_eligibility_type; + } + + /** + * ID of the Payment resource that this transaction is based on. + * + * @param string $parent_payment + * + * @return $this + */ + public function setParentPayment($parent_payment) + { + $this->parent_payment = $parent_payment; + return $this; + } + + /** + * ID of the Payment resource that this transaction is based on. + * + * @return string + */ + public function getParentPayment() + { + return $this->parent_payment; + } + + /** + * Fraud Management Filter (FMF) details applied for the payment that could result in accept/deny/pending action. + * + * @param \PayPal\Api\FmfDetails $fmf_details + * + * @return $this + */ + public function setFmfDetails($fmf_details) + { + $this->fmf_details = $fmf_details; + return $this; + } + + /** + * Fraud Management Filter (FMF) details applied for the payment that could result in accept/deny/pending action. + * + * @return \PayPal\Api\FmfDetails + */ + public function getFmfDetails() + { + return $this->fmf_details; + } + + /** + * Time the resource was created in UTC ISO8601 format. + * + * @param string $create_time + * + * @return $this + */ + public function setCreateTime($create_time) + { + $this->create_time = $create_time; + return $this; + } + + /** + * Time the resource was created in UTC ISO8601 format. + * + * @return string + */ + public function getCreateTime() + { + return $this->create_time; + } + + /** + * Time the resource was last updated in UTC ISO8601 format. + * + * @param string $update_time + * + * @return $this + */ + public function setUpdateTime($update_time) + { + $this->update_time = $update_time; + return $this; + } + + /** + * Time the resource was last updated in UTC ISO8601 format. + * + * @return string + */ + public function getUpdateTime() + { + return $this->update_time; + } + + /** + * Shows details for an order, by ID. + * + * @param string $orderId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Order + */ + public static function get($orderId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($orderId, 'orderId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/payments/orders/$orderId", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new Order(); + $ret->fromJson($json); + return $ret; + } + + /** + * Captures a payment for an order, by ID. To use this call, the original payment call must specify an intent of `order`. In the JSON request body, include the payment amount and indicate whether this capture is the final capture for the authorization. + * + * @param Capture $capture + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Capture + */ + public function capture($capture, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($capture, 'capture'); + $payLoad = $capture->toJSON(); + $json = self::executeCall( + "/v1/payments/orders/{$this->getId()}/capture", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new Capture(); + $ret->fromJson($json); + return $ret; + } + + /** + * Voids, or cancels, an order, by ID. You cannot void an order if a payment has already been partially or fully captured. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Order + */ + public function void($apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + $payLoad = ""; + $json = self::executeCall( + "/v1/payments/orders/{$this->getId()}/do-void", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $this->fromJson($json); + return $this; + } + + /** + * Authorizes an order, by ID. Include an `amount` object in the JSON request body. + * + * @param Authorization $authorization Authorization Object with Amount value to be authorized + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Authorization + */ + public function authorize($authorization, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($authorization, 'Authorization'); + $payLoad = $authorization->toJSON(); + $json = self::executeCall( + "/v1/payments/orders/{$this->getId()}/authorize", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new Authorization(); + $ret->fromJson($json); + return $ret; + } + +} diff --git a/paypal/PayPal/Api/OverrideChargeModel.php b/paypal/PayPal/Api/OverrideChargeModel.php new file mode 100644 index 0000000..b911c17 --- /dev/null +++ b/paypal/PayPal/Api/OverrideChargeModel.php @@ -0,0 +1,65 @@ +charge_id = $charge_id; + return $this; + } + + /** + * ID of charge model. + * + * @return string + */ + public function getChargeId() + { + return $this->charge_id; + } + + /** + * Updated Amount to be associated with this charge model. + * + * @param \PayPal\Api\Currency $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * Updated Amount to be associated with this charge model. + * + * @return \PayPal\Api\Currency + */ + public function getAmount() + { + return $this->amount; + } + +} diff --git a/paypal/PayPal/Api/Participant.php b/paypal/PayPal/Api/Participant.php new file mode 100644 index 0000000..0f8e6d0 --- /dev/null +++ b/paypal/PayPal/Api/Participant.php @@ -0,0 +1,233 @@ +email = $email; + return $this; + } + + /** + * The participant email address. + * + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * The participant first name. + * + * @param string $first_name + * + * @return $this + */ + public function setFirstName($first_name) + { + $this->first_name = $first_name; + return $this; + } + + /** + * The participant first name. + * + * @return string + */ + public function getFirstName() + { + return $this->first_name; + } + + /** + * The participant last name. + * + * @param string $last_name + * + * @return $this + */ + public function setLastName($last_name) + { + $this->last_name = $last_name; + return $this; + } + + /** + * The participant last name. + * + * @return string + */ + public function getLastName() + { + return $this->last_name; + } + + /** + * The participant company business name. + * + * @param string $business_name + * + * @return $this + */ + public function setBusinessName($business_name) + { + $this->business_name = $business_name; + return $this; + } + + /** + * The participant company business name. + * + * @return string + */ + public function getBusinessName() + { + return $this->business_name; + } + + /** + * The participant phone number. + * + * @param \PayPal\Api\Phone $phone + * + * @return $this + */ + public function setPhone($phone) + { + $this->phone = $phone; + return $this; + } + + /** + * The participant phone number. + * + * @return \PayPal\Api\Phone + */ + public function getPhone() + { + return $this->phone; + } + + /** + * The participant fax number. + * + * @param \PayPal\Api\Phone $fax + * + * @return $this + */ + public function setFax($fax) + { + $this->fax = $fax; + return $this; + } + + /** + * The participant fax number. + * + * @return \PayPal\Api\Phone + */ + public function getFax() + { + return $this->fax; + } + + /** + * The participant website. + * + * @param string $website + * + * @return $this + */ + public function setWebsite($website) + { + $this->website = $website; + return $this; + } + + /** + * The participant website. + * + * @return string + */ + public function getWebsite() + { + return $this->website; + } + + /** + * Additional information, such as business hours. + * + * @param string $additional_info + * + * @return $this + */ + public function setAdditionalInfo($additional_info) + { + $this->additional_info = $additional_info; + return $this; + } + + /** + * Additional information, such as business hours. + * + * @return string + */ + public function getAdditionalInfo() + { + return $this->additional_info; + } + + /** + * The participant address. + * + * @param \PayPal\Api\Address $address + * + * @return $this + */ + public function setAddress($address) + { + $this->address = $address; + return $this; + } + + /** + * The participant address. + * + * @return \PayPal\Api\Address + */ + public function getAddress() + { + return $this->address; + } + +} diff --git a/paypal/PayPal/Api/Patch.php b/paypal/PayPal/Api/Patch.php new file mode 100644 index 0000000..68a6fa8 --- /dev/null +++ b/paypal/PayPal/Api/Patch.php @@ -0,0 +1,114 @@ +op = $op; + return $this; + } + + /** + * The operation to perform. + * + * @return string + */ + public function getOp() + { + return $this->op; + } + + /** + * A JSON pointer that references a location in the target document where the operation is performed. A `string` value. + * + * @param string $path + * + * @return $this + */ + public function setPath($path) + { + $this->path = $path; + return $this; + } + + /** + * A JSON pointer that references a location in the target document where the operation is performed. A `string` value. + * + * @return string + */ + public function getPath() + { + return $this->path; + } + + /** + * New value to apply based on the operation. + * + * @param mixed $value + * + * @return $this + */ + public function setValue($value) + { + $this->value = $value; + return $this; + } + + /** + * New value to apply based on the operation. + * + * @return mixed + */ + public function getValue() + { + return $this->value; + } + + /** + * A string containing a JSON Pointer value that references the location in the target document to move the value from. + * + * @param string $from + * + * @return $this + */ + public function setFrom($from) + { + $this->from = $from; + return $this; + } + + /** + * A string containing a JSON Pointer value that references the location in the target document to move the value from. + * + * @return string + */ + public function getFrom() + { + return $this->from; + } + +} diff --git a/paypal/PayPal/Api/PatchRequest.php b/paypal/PayPal/Api/PatchRequest.php new file mode 100644 index 0000000..2f44686 --- /dev/null +++ b/paypal/PayPal/Api/PatchRequest.php @@ -0,0 +1,86 @@ +patches = $patches; + return $this; + } + + /** + * Placeholder for holding array of patch objects + * + * @return \PayPal\Api\Patch[] + */ + public function getPatches() + { + return $this->patches; + } + + /** + * Append Patches to the list. + * + * @param \PayPal\Api\Patch $patch + * @return $this + */ + public function addPatch($patch) + { + if (!$this->getPatches()) { + return $this->setPatches(array($patch)); + } else { + return $this->setPatches( + array_merge($this->getPatches(), array($patch)) + ); + } + } + + /** + * Remove Patches from the list. + * + * @param \PayPal\Api\Patch $patch + * @return $this + */ + public function removePatch($patch) + { + return $this->setPatches( + array_diff($this->getPatches(), array($patch)) + ); + } + + /** + * As PatchRequest holds the array of Patch object, we would override the json conversion to return + * a json representation of array of Patch objects. + * + * @param int $options + * @return mixed|string + */ + public function toJSON($options = 0) + { + $json = array(); + foreach ($this->getPatches() as $patch) { + $json[] = $patch->toArray(); + } + return str_replace('\\/', '/', json_encode($json, $options)); + } +} diff --git a/paypal/PayPal/Api/Payee.php b/paypal/PayPal/Api/Payee.php new file mode 100644 index 0000000..22594b9 --- /dev/null +++ b/paypal/PayPal/Api/Payee.php @@ -0,0 +1,157 @@ +email = $email; + return $this; + } + + /** + * 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 receive PayPal Wallet Payments. Direct Credit Card Payments will be denied due to card compliance requirements. + * + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * Encrypted PayPal account identifier for the Payee. + * + * @param string $merchant_id + * + * @return $this + */ + public function setMerchantId($merchant_id) + { + $this->merchant_id = $merchant_id; + return $this; + } + + /** + * Encrypted PayPal account identifier for the Payee. + * + * @return string + */ + public function getMerchantId() + { + return $this->merchant_id; + } + + /** + * First Name of the Payee. + * @deprecated Not publicly available + * @param string $first_name + * + * @return $this + */ + public function setFirstName($first_name) + { + $this->first_name = $first_name; + return $this; + } + + /** + * First Name of the Payee. + * @deprecated Not publicly available + * @return string + */ + public function getFirstName() + { + return $this->first_name; + } + + /** + * Last Name of the Payee. + * @deprecated Not publicly available + * @param string $last_name + * + * @return $this + */ + public function setLastName($last_name) + { + $this->last_name = $last_name; + return $this; + } + + /** + * Last Name of the Payee. + * @deprecated Not publicly available + * @return string + */ + public function getLastName() + { + return $this->last_name; + } + + /** + * Unencrypted PayPal account Number of the Payee + * @deprecated Not publicly available + * @param string $account_number + * + * @return $this + */ + public function setAccountNumber($account_number) + { + $this->account_number = $account_number; + return $this; + } + + /** + * Unencrypted PayPal account Number of the Payee + * @deprecated Not publicly available + * @return string + */ + public function getAccountNumber() + { + return $this->account_number; + } + + /** + * Information related to the Payee. + * @deprecated Not publicly available + * @param \PayPal\Api\Phone $phone + * + * @return $this + */ + public function setPhone($phone) + { + $this->phone = $phone; + return $this; + } + + /** + * Information related to the Payee. + * @deprecated Not publicly available + * @return \PayPal\Api\Phone + */ + public function getPhone() + { + return $this->phone; + } + +} diff --git a/paypal/PayPal/Api/Payer.php b/paypal/PayPal/Api/Payer.php new file mode 100644 index 0000000..1b36887 --- /dev/null +++ b/paypal/PayPal/Api/Payer.php @@ -0,0 +1,288 @@ +payment_method = $payment_method; + return $this; + } + + /** + * Payment method being used - PayPal Wallet payment, Bank Direct Debit or Direct Credit card. + * + * @return string + */ + public function getPaymentMethod() + { + return $this->payment_method; + } + + /** + * Status of payer's PayPal Account. + * Valid Values: ["VERIFIED", "UNVERIFIED"] + * + * @param string $status + * + * @return $this + */ + public function setStatus($status) + { + $this->status = $status; + return $this; + } + + /** + * Status of payer's PayPal Account. + * + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * Type of account relationship payer has with PayPal. + * Valid Values: ["BUSINESS", "PERSONAL", "PREMIER"] + * @deprecated Not publicly available + * @param string $account_type + * + * @return $this + */ + public function setAccountType($account_type) + { + $this->account_type = $account_type; + return $this; + } + + /** + * Type of account relationship payer has with PayPal. + * @deprecated Not publicly available + * @return string + */ + public function getAccountType() + { + return $this->account_type; + } + + /** + * Duration since the payer established account relationship with PayPal in days. + * @deprecated Not publicly available + * @param string $account_age + * + * @return $this + */ + public function setAccountAge($account_age) + { + $this->account_age = $account_age; + return $this; + } + + /** + * Duration since the payer established account relationship with PayPal in days. + * @deprecated Not publicly available + * @return string + */ + public function getAccountAge() + { + return $this->account_age; + } + + /** + * 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. + * + * @param \PayPal\Api\FundingInstrument[] $funding_instruments + * + * @return $this + */ + public function setFundingInstruments($funding_instruments) + { + $this->funding_instruments = $funding_instruments; + return $this; + } + + /** + * 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. + * + * @return \PayPal\Api\FundingInstrument[] + */ + public function getFundingInstruments() + { + return $this->funding_instruments; + } + + /** + * Append FundingInstruments to the list. + * + * @param \PayPal\Api\FundingInstrument $fundingInstrument + * @return $this + */ + public function addFundingInstrument($fundingInstrument) + { + if (!$this->getFundingInstruments()) { + return $this->setFundingInstruments(array($fundingInstrument)); + } else { + return $this->setFundingInstruments( + array_merge($this->getFundingInstruments(), array($fundingInstrument)) + ); + } + } + + /** + * Remove FundingInstruments from the list. + * + * @param \PayPal\Api\FundingInstrument $fundingInstrument + * @return $this + */ + public function removeFundingInstrument($fundingInstrument) + { + return $this->setFundingInstruments( + array_diff($this->getFundingInstruments(), array($fundingInstrument)) + ); + } + + /** + * 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. + * @deprecated Not publicly available + * @param string $funding_option_id + * + * @return $this + */ + public function setFundingOptionId($funding_option_id) + { + $this->funding_option_id = $funding_option_id; + return $this; + } + + /** + * 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. + * @deprecated Not publicly available + * @return string + */ + public function getFundingOptionId() + { + return $this->funding_option_id; + } + + /** + * Default funding option available for the payment + * @deprecated Not publicly available + * @param \PayPal\Api\FundingOption $funding_option + * + * @return $this + */ + public function setFundingOption($funding_option) + { + $this->funding_option = $funding_option; + return $this; + } + + /** + * Default funding option available for the payment + * @deprecated Not publicly available + * @return \PayPal\Api\FundingOption + */ + public function getFundingOption() + { + return $this->funding_option; + } + + /** + * Instrument type pre-selected by the user outside of PayPal and passed along the payment creation. This param is used in cases such as PayPal Credit Second Button + * Valid Values: ["CREDIT", "PAY_UPON_INVOICE"] + * + * @param string $external_selected_funding_instrument_type + * + * @return $this + */ + public function setExternalSelectedFundingInstrumentType($external_selected_funding_instrument_type) + { + $this->external_selected_funding_instrument_type = $external_selected_funding_instrument_type; + return $this; + } + + /** + * Instrument type pre-selected by the user outside of PayPal and passed along the payment creation. This param is used in cases such as PayPal Credit Second Button + * + * @return string + */ + public function getExternalSelectedFundingInstrumentType() + { + return $this->external_selected_funding_instrument_type; + } + + /** + * Funding option related to default funding option. + * @deprecated Not publicly available + * @param \PayPal\Api\FundingOption $related_funding_option + * + * @return $this + */ + public function setRelatedFundingOption($related_funding_option) + { + $this->related_funding_option = $related_funding_option; + return $this; + } + + /** + * Funding option related to default funding option. + * @deprecated Not publicly available + * @return \PayPal\Api\FundingOption + */ + public function getRelatedFundingOption() + { + return $this->related_funding_option; + } + + /** + * Information related to the Payer. + * + * @param \PayPal\Api\PayerInfo $payer_info + * + * @return $this + */ + public function setPayerInfo($payer_info) + { + $this->payer_info = $payer_info; + return $this; + } + + /** + * Information related to the Payer. + * + * @return \PayPal\Api\PayerInfo + */ + public function getPayerInfo() + { + return $this->payer_info; + } + +} diff --git a/paypal/PayPal/Api/PayerInfo.php b/paypal/PayPal/Api/PayerInfo.php new file mode 100644 index 0000000..ae70c65 --- /dev/null +++ b/paypal/PayPal/Api/PayerInfo.php @@ -0,0 +1,453 @@ +email = $email; + return $this; + } + + /** + * Email address representing the payer. 127 characters max. + * + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * External Remember Me id representing the payer + * + * @param string $external_remember_me_id + * + * @return $this + */ + public function setExternalRememberMeId($external_remember_me_id) + { + $this->external_remember_me_id = $external_remember_me_id; + return $this; + } + + /** + * External Remember Me id representing the payer + * + * @return string + */ + public function getExternalRememberMeId() + { + return $this->external_remember_me_id; + } + + /** + * Account Number representing the Payer + * + * @deprecated Use #setBuyerAccountNumberInstead + * @param string $account_number + * + * @return $this + */ + public function setAccountNumber($account_number) + { + $this->account_number = $account_number; + return $this; + } + + /** + * Account Number representing the Payer + * + * @deprecated Use #getBuyerAccountNumberInstead + * + * @deprecated Not publicly available + * @return string + */ + public function getAccountNumber() + { + return $this->account_number; + } + + /** + * Account Number representing the Payer + * + * @param string $buyer_account_number + * + * @return $this + */ + public function setBuyerAccountNumber($buyer_account_number) + { + $this->buyer_account_number = $buyer_account_number; + return $this; + } + + /** + * Account Number representing the Payer + * + * @return string + */ + public function getBuyerAccountNumber() + { + return $this->buyer_account_number; + } + + /** + * Salutation of the payer. + * + * @param string $salutation + * + * @return $this + */ + public function setSalutation($salutation) + { + $this->salutation = $salutation; + return $this; + } + + /** + * Salutation of the payer. + * + * @return string + */ + public function getSalutation() + { + return $this->salutation; + } + + /** + * First name of the payer. + * + * @param string $first_name + * + * @return $this + */ + public function setFirstName($first_name) + { + $this->first_name = $first_name; + return $this; + } + + /** + * First name of the payer. + * + * @return string + */ + public function getFirstName() + { + return $this->first_name; + } + + /** + * Middle name of the payer. + * + * @param string $middle_name + * + * @return $this + */ + public function setMiddleName($middle_name) + { + $this->middle_name = $middle_name; + return $this; + } + + /** + * Middle name of the payer. + * + * @return string + */ + public function getMiddleName() + { + return $this->middle_name; + } + + /** + * Last name of the payer. + * + * @param string $last_name + * + * @return $this + */ + public function setLastName($last_name) + { + $this->last_name = $last_name; + return $this; + } + + /** + * Last name of the payer. + * + * @return string + */ + public function getLastName() + { + return $this->last_name; + } + + /** + * Suffix of the payer. + * + * @param string $suffix + * + * @return $this + */ + public function setSuffix($suffix) + { + $this->suffix = $suffix; + return $this; + } + + /** + * Suffix of the payer. + * + * @return string + */ + public function getSuffix() + { + return $this->suffix; + } + + /** + * PayPal assigned encrypted Payer ID. + * + * @param string $payer_id + * + * @return $this + */ + public function setPayerId($payer_id) + { + $this->payer_id = $payer_id; + return $this; + } + + /** + * PayPal assigned encrypted Payer ID. + * + * @return string + */ + public function getPayerId() + { + return $this->payer_id; + } + + /** + * Phone number representing the payer. 20 characters max. + * + * @param string $phone + * + * @return $this + */ + public function setPhone($phone) + { + $this->phone = $phone; + return $this; + } + + /** + * Phone number representing the payer. 20 characters max. + * + * @return string + */ + public function getPhone() + { + return $this->phone; + } + + /** + * Phone type + * Valid Values: ["HOME", "WORK", "MOBILE", "OTHER"] + * + * @param string $phone_type + * + * @return $this + */ + public function setPhoneType($phone_type) + { + $this->phone_type = $phone_type; + return $this; + } + + /** + * Phone type + * + * @return string + */ + public function getPhoneType() + { + return $this->phone_type; + } + + /** + * Birth date of the Payer in ISO8601 format (yyyy-mm-dd). + * + * @param string $birth_date + * + * @return $this + */ + public function setBirthDate($birth_date) + { + $this->birth_date = $birth_date; + return $this; + } + + /** + * Birth date of the Payer in ISO8601 format (yyyy-mm-dd). + * + * @return string + */ + public function getBirthDate() + { + return $this->birth_date; + } + + /** + * Payer’s tax ID. Only supported when the `payment_method` is set to `paypal`. + * + * @param string $tax_id + * + * @return $this + */ + public function setTaxId($tax_id) + { + $this->tax_id = $tax_id; + return $this; + } + + /** + * Payer’s tax ID. Only supported when the `payment_method` is set to `paypal`. + * + * @return string + */ + public function getTaxId() + { + return $this->tax_id; + } + + /** + * Payer’s tax ID type. Allowed values: `BR_CPF` or `BR_CNPJ`. Only supported when the `payment_method` is set to `paypal`. + * Valid Values: ["BR_CPF", "BR_CNPJ"] + * + * @param string $tax_id_type + * + * @return $this + */ + public function setTaxIdType($tax_id_type) + { + $this->tax_id_type = $tax_id_type; + return $this; + } + + /** + * Payer’s tax ID type. Allowed values: `BR_CPF` or `BR_CNPJ`. Only supported when the `payment_method` is set to `paypal`. + * + * @return string + */ + public function getTaxIdType() + { + return $this->tax_id_type; + } + + /** + * Two-letter registered country code of the payer to identify the buyer country. + * + * @param string $country_code + * + * @return $this + */ + public function setCountryCode($country_code) + { + $this->country_code = $country_code; + return $this; + } + + /** + * Two-letter registered country code of the payer to identify the buyer country. + * + * @return string + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * Billing address of the Payer. + * + * @param \PayPal\Api\Address $billing_address + * + * @return $this + */ + public function setBillingAddress($billing_address) + { + $this->billing_address = $billing_address; + return $this; + } + + /** + * Billing address of the Payer. + * + * @return \PayPal\Api\Address + */ + public function getBillingAddress() + { + return $this->billing_address; + } + + /** + * @deprecated [DEPRECATED] Use shipping address present in purchase unit or at root level of checkout Session. + * + * @param \PayPal\Api\ShippingAddress $shipping_address + * + * @return $this + */ + public function setShippingAddress($shipping_address) + { + $this->shipping_address = $shipping_address; + return $this; + } + + /** + * @deprecated [DEPRECATED] Use shipping address present in purchase unit or at root level of checkout Session. + * + * @return \PayPal\Api\ShippingAddress + */ + public function getShippingAddress() + { + return $this->shipping_address; + } + +} diff --git a/paypal/PayPal/Api/Payment.php b/paypal/PayPal/Api/Payment.php new file mode 100644 index 0000000..3197485 --- /dev/null +++ b/paypal/PayPal/Api/Payment.php @@ -0,0 +1,691 @@ +id = $id; + return $this; + } + + /** + * Identifier of the payment resource created. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Payment intent. + * Valid Values: ["sale", "authorize", "order"] + * + * @param string $intent + * + * @return $this + */ + public function setIntent($intent) + { + $this->intent = $intent; + return $this; + } + + /** + * Payment intent. + * + * @return string + */ + public function getIntent() + { + return $this->intent; + } + + /** + * Source of the funds for this payment represented by a PayPal account or a direct credit card. + * + * @param \PayPal\Api\Payer $payer + * + * @return $this + */ + public function setPayer($payer) + { + $this->payer = $payer; + return $this; + } + + /** + * Source of the funds for this payment represented by a PayPal account or a direct credit card. + * + * @return \PayPal\Api\Payer + */ + public function getPayer() + { + return $this->payer; + } + + /** + * 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. + * @deprecated Not publicly available + * @param \PayPal\Api\PotentialPayerInfo $potential_payer_info + * + * @return $this + */ + public function setPotentialPayerInfo($potential_payer_info) + { + $this->potential_payer_info = $potential_payer_info; + return $this; + } + + /** + * 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. + * @deprecated Not publicly available + * @return \PayPal\Api\PotentialPayerInfo + */ + public function getPotentialPayerInfo() + { + return $this->potential_payer_info; + } + + /** + * Receiver of funds for this payment. + * @param \PayPal\Api\Payee $payee + * + * @return $this + */ + public function setPayee($payee) + { + $this->payee = $payee; + return $this; + } + + /** + * Receiver of funds for this payment. + * @return \PayPal\Api\Payee + */ + public function getPayee() + { + return $this->payee; + } + + /** + * ID of the cart to execute the payment. + * @deprecated Not publicly available + * @param string $cart + * + * @return $this + */ + public function setCart($cart) + { + $this->cart = $cart; + return $this; + } + + /** + * ID of the cart to execute the payment. + * @deprecated Not publicly available + * @return string + */ + public function getCart() + { + return $this->cart; + } + + /** + * Transactional details including the amount and item details. + * + * @param \PayPal\Api\Transaction[] $transactions + * + * @return $this + */ + public function setTransactions($transactions) + { + $this->transactions = $transactions; + return $this; + } + + /** + * Transactional details including the amount and item details. + * + * @return \PayPal\Api\Transaction[] + */ + public function getTransactions() + { + return $this->transactions; + } + + /** + * Append Transactions to the list. + * + * @param \PayPal\Api\Transaction $transaction + * @return $this + */ + public function addTransaction($transaction) + { + if (!$this->getTransactions()) { + return $this->setTransactions(array($transaction)); + } else { + return $this->setTransactions( + array_merge($this->getTransactions(), array($transaction)) + ); + } + } + + /** + * Remove Transactions from the list. + * + * @param \PayPal\Api\Transaction $transaction + * @return $this + */ + public function removeTransaction($transaction) + { + return $this->setTransactions( + array_diff($this->getTransactions(), array($transaction)) + ); + } + + /** + * Applicable for advanced payments like multi seller payment (MSP) to support partial failures + * @deprecated Not publicly available + * @param \PayPal\Api\Error[] $failed_transactions + * + * @return $this + */ + public function setFailedTransactions($failed_transactions) + { + $this->failed_transactions = $failed_transactions; + return $this; + } + + /** + * Applicable for advanced payments like multi seller payment (MSP) to support partial failures + * @deprecated Not publicly available + * @return \PayPal\Api\Error[] + */ + public function getFailedTransactions() + { + return $this->failed_transactions; + } + + /** + * Append FailedTransactions to the list. + * @deprecated Not publicly available + * @param \PayPal\Api\Error $error + * @return $this + */ + public function addFailedTransaction($error) + { + if (!$this->getFailedTransactions()) { + return $this->setFailedTransactions(array($error)); + } else { + return $this->setFailedTransactions( + array_merge($this->getFailedTransactions(), array($error)) + ); + } + } + + /** + * Remove FailedTransactions from the list. + * @deprecated Not publicly available + * @param \PayPal\Api\Error $error + * @return $this + */ + public function removeFailedTransaction($error) + { + return $this->setFailedTransactions( + array_diff($this->getFailedTransactions(), array($error)) + ); + } + + /** + * Collection of PayPal generated billing agreement tokens. + * @deprecated Not publicly available + * @param string[] $billing_agreement_tokens + * + * @return $this + */ + public function setBillingAgreementTokens($billing_agreement_tokens) + { + $this->billing_agreement_tokens = $billing_agreement_tokens; + return $this; + } + + /** + * Collection of PayPal generated billing agreement tokens. + * @deprecated Not publicly available + * @return string[] + */ + public function getBillingAgreementTokens() + { + return $this->billing_agreement_tokens; + } + + /** + * Append BillingAgreementTokens to the list. + * @deprecated Not publicly available + * @param string $billingAgreementToken + * @return $this + */ + public function addBillingAgreementToken($billingAgreementToken) + { + if (!$this->getBillingAgreementTokens()) { + return $this->setBillingAgreementTokens(array($billingAgreementToken)); + } else { + return $this->setBillingAgreementTokens( + array_merge($this->getBillingAgreementTokens(), array($billingAgreementToken)) + ); + } + } + + /** + * Remove BillingAgreementTokens from the list. + * @deprecated Not publicly available + * @param string $billingAgreementToken + * @return $this + */ + public function removeBillingAgreementToken($billingAgreementToken) + { + return $this->setBillingAgreementTokens( + array_diff($this->getBillingAgreementTokens(), array($billingAgreementToken)) + ); + } + + /** + * Credit financing offered to payer on PayPal side. Returned in payment after payer opts-in + * @deprecated Not publicly available + * @param \PayPal\Api\CreditFinancingOffered $credit_financing_offered + * + * @return $this + */ + public function setCreditFinancingOffered($credit_financing_offered) + { + $this->credit_financing_offered = $credit_financing_offered; + return $this; + } + + /** + * Credit financing offered to payer on PayPal side. Returned in payment after payer opts-in + * @deprecated Not publicly available + * @return \PayPal\Api\CreditFinancingOffered + */ + public function getCreditFinancingOffered() + { + return $this->credit_financing_offered; + } + + /** + * Instructions for the payer to complete this payment. + * @deprecated Not publicly available + * @param \PayPal\Api\PaymentInstruction $payment_instruction + * + * @return $this + */ + public function setPaymentInstruction($payment_instruction) + { + $this->payment_instruction = $payment_instruction; + return $this; + } + + /** + * Instructions for the payer to complete this payment. + * @deprecated Not publicly available + * @return \PayPal\Api\PaymentInstruction + */ + public function getPaymentInstruction() + { + return $this->payment_instruction; + } + + /** + * The state of the payment, authorization, or order transaction. The value is: + * Valid Values: ["created", "approved", "failed", "partially_completed", "in_progress"] + * + * @param string $state + * + * @return $this + */ + public function setState($state) + { + $this->state = $state; + return $this; + } + + /** + * The state of the payment, authorization, or order transaction. The value is: + * + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * PayPal generated identifier for the merchant's payment experience profile. Refer to [this](https://developer.paypal.com/docs/api/#payment-experience) link to create experience profile ID. + * + * @param string $experience_profile_id + * + * @return $this + */ + public function setExperienceProfileId($experience_profile_id) + { + $this->experience_profile_id = $experience_profile_id; + return $this; + } + + /** + * PayPal generated identifier for the merchant's payment experience profile. Refer to [this](https://developer.paypal.com/docs/api/#payment-experience) link to create experience profile ID. + * + * @return string + */ + public function getExperienceProfileId() + { + return $this->experience_profile_id; + } + + /** + * free-form field for the use of clients to pass in a message to the payer + * + * @param string $note_to_payer + * + * @return $this + */ + public function setNoteToPayer($note_to_payer) + { + $this->note_to_payer = $note_to_payer; + return $this; + } + + /** + * free-form field for the use of clients to pass in a message to the payer + * + * @return string + */ + public function getNoteToPayer() + { + return $this->note_to_payer; + } + + /** + * Set of redirect URLs you provide only for PayPal-based payments. + * + * @param \PayPal\Api\RedirectUrls $redirect_urls + * + * @return $this + */ + public function setRedirectUrls($redirect_urls) + { + $this->redirect_urls = $redirect_urls; + return $this; + } + + /** + * Set of redirect URLs you provide only for PayPal-based payments. + * + * @return \PayPal\Api\RedirectUrls + */ + public function getRedirectUrls() + { + return $this->redirect_urls; + } + + /** + * Failure reason code returned when the payment failed for some valid reasons. + * Valid Values: ["UNABLE_TO_COMPLETE_TRANSACTION", "INVALID_PAYMENT_METHOD", "PAYER_CANNOT_PAY", "CANNOT_PAY_THIS_PAYEE", "REDIRECT_REQUIRED", "PAYEE_FILTER_RESTRICTIONS"] + * + * @param string $failure_reason + * + * @return $this + */ + public function setFailureReason($failure_reason) + { + $this->failure_reason = $failure_reason; + return $this; + } + + /** + * Failure reason code returned when the payment failed for some valid reasons. + * + * @return string + */ + public function getFailureReason() + { + return $this->failure_reason; + } + + /** + * Payment creation time as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @param string $create_time + * + * @return $this + */ + public function setCreateTime($create_time) + { + $this->create_time = $create_time; + return $this; + } + + /** + * Payment creation time as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return string + */ + public function getCreateTime() + { + return $this->create_time; + } + + /** + * Payment update time as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @param string $update_time + * + * @return $this + */ + public function setUpdateTime($update_time) + { + $this->update_time = $update_time; + return $this; + } + + /** + * Payment update time as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return string + */ + public function getUpdateTime() + { + return $this->update_time; + } + + /** + * Get Approval Link + * + * @return null|string + */ + public function getApprovalLink() + { + return $this->getLink(PayPalConstants::APPROVAL_URL); + } + + /** + * Get token from Approval Link + * + * @return null|string + */ + public function getToken() + { + $parameter_name = "token"; + parse_str(parse_url($this->getApprovalLink(), PHP_URL_QUERY), $query); + return !isset($query[$parameter_name]) ? null : $query[$parameter_name]; + } + + /** + * Creates and processes a payment. In the JSON request body, include a `payment` object with the intent, payer, and transactions. For PayPal payments, include redirect URLs in the `payment` object. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Payment + */ + public function create($apiContext = null, $restCall = null) + { + $payLoad = $this->toJSON(); + $json = self::executeCall( + "/v1/payments/payment", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $this->fromJson($json); + return $this; + } + + /** + * Shows details for a payment, by ID. + * + * @param string $paymentId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Payment + */ + public static function get($paymentId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($paymentId, 'paymentId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/payments/payment/$paymentId", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new Payment(); + $ret->fromJson($json); + return $ret; + } + + /** + * Partially updates a payment, by ID. You can update the amount, shipping address, invoice ID, and custom data. You cannot use patch after execute has been called. + * + * @param PatchRequest $patchRequest + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return boolean + */ + public function update($patchRequest, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($patchRequest, 'patchRequest'); + $payLoad = $patchRequest->toJSON(); + self::executeCall( + "/v1/payments/payment/{$this->getId()}", + "PATCH", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * Executes, or completes, a PayPal payment that the payer has approved. You can optionally update selective payment information when you execute a payment. + * + * @param PaymentExecution $paymentExecution + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Payment + */ + public function execute($paymentExecution, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($paymentExecution, 'paymentExecution'); + $payLoad = $paymentExecution->toJSON(); + $json = self::executeCall( + "/v1/payments/payment/{$this->getId()}/execute", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $this->fromJson($json); + return $this; + } + + /** + * List payments that were made to the merchant who issues the request. Payments can be in any state. + * + * @param array $params + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return PaymentHistory + */ + public static function all($params, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($params, 'params'); + $payLoad = ""; + $allowedParams = array( + 'count' => 1, + 'start_id' => 1, + 'start_index' => 1, + 'start_time' => 1, + 'end_time' => 1, + 'payee_id' => 1, + 'sort_by' => 1, + 'sort_order' => 1, + ); + $json = self::executeCall( + "/v1/payments/payment?" . http_build_query(array_intersect_key($params, $allowedParams)), + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new PaymentHistory(); + $ret->fromJson($json); + return $ret; + } + +} diff --git a/paypal/PayPal/Api/PaymentCard.php b/paypal/PayPal/Api/PaymentCard.php new file mode 100644 index 0000000..c070462 --- /dev/null +++ b/paypal/PayPal/Api/PaymentCard.php @@ -0,0 +1,482 @@ +id = $id; + return $this; + } + + /** + * The ID of a credit card to save for later use. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * The card number. + * + * @param string $number + * + * @return $this + */ + public function setNumber($number) + { + $this->number = $number; + return $this; + } + + /** + * The card number. + * + * @return string + */ + public function getNumber() + { + return $this->number; + } + + /** + * The card type. + * Valid Values: ["VISA", "AMEX", "SOLO", "JCB", "STAR", "DELTA", "DISCOVER", "SWITCH", "MAESTRO", "CB_NATIONALE", "CONFINOGA", "COFIDIS", "ELECTRON", "CETELEM", "CHINA_UNION_PAY", "MASTERCARD"] + * + * @param string $type + * + * @return $this + */ + public function setType($type) + { + $this->type = $type; + return $this; + } + + /** + * The card type. + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * The two-digit expiry month for the card. + * + * @param string $expire_month + * + * @return $this + */ + public function setExpireMonth($expire_month) + { + $this->expire_month = $expire_month; + return $this; + } + + /** + * The two-digit expiry month for the card. + * + * @return string + */ + public function getExpireMonth() + { + return $this->expire_month; + } + + /** + * The four-digit expiry year for the card. + * + * @param string $expire_year + * + * @return $this + */ + public function setExpireYear($expire_year) + { + $this->expire_year = $expire_year; + return $this; + } + + /** + * The four-digit expiry year for the card. + * + * @return string + */ + public function getExpireYear() + { + return $this->expire_year; + } + + /** + * The two-digit start month for the card. Required for UK Maestro cards. + * + * @param string $start_month + * + * @return $this + */ + public function setStartMonth($start_month) + { + $this->start_month = $start_month; + return $this; + } + + /** + * The two-digit start month for the card. Required for UK Maestro cards. + * + * @return string + */ + public function getStartMonth() + { + return $this->start_month; + } + + /** + * The four-digit start year for the card. Required for UK Maestro cards. + * + * @param string $start_year + * + * @return $this + */ + public function setStartYear($start_year) + { + $this->start_year = $start_year; + return $this; + } + + /** + * The four-digit start year for the card. Required for UK Maestro cards. + * + * @return string + */ + public function getStartYear() + { + return $this->start_year; + } + + /** + * The validation code for the card. Supported for payments but not for saving payment cards for future use. + * + * @param string $cvv2 + * + * @return $this + */ + public function setCvv2($cvv2) + { + $this->cvv2 = $cvv2; + return $this; + } + + /** + * The validation code for the card. Supported for payments but not for saving payment cards for future use. + * + * @return string + */ + public function getCvv2() + { + return $this->cvv2; + } + + /** + * The first name of the card holder. + * + * @param string $first_name + * + * @return $this + */ + public function setFirstName($first_name) + { + $this->first_name = $first_name; + return $this; + } + + /** + * The first name of the card holder. + * + * @return string + */ + public function getFirstName() + { + return $this->first_name; + } + + /** + * The last name of the card holder. + * + * @param string $last_name + * + * @return $this + */ + public function setLastName($last_name) + { + $this->last_name = $last_name; + return $this; + } + + /** + * The last name of the card holder. + * + * @return string + */ + public function getLastName() + { + return $this->last_name; + } + + /** + * The two-letter country code. + * + * @param string $billing_country + * + * @return $this + */ + public function setBillingCountry($billing_country) + { + $this->billing_country = $billing_country; + return $this; + } + + /** + * The two-letter country code. + * + * @return string + */ + public function getBillingCountry() + { + return $this->billing_country; + } + + /** + * The billing address for the card. + * + * @param \PayPal\Api\Address $billing_address + * + * @return $this + */ + public function setBillingAddress($billing_address) + { + $this->billing_address = $billing_address; + return $this; + } + + /** + * The billing address for the card. + * + * @return \PayPal\Api\Address + */ + public function getBillingAddress() + { + return $this->billing_address; + } + + /** + * The ID of the customer who owns this card account. The facilitator generates and provides this ID. Required when you create or use a stored funding instrument in the PayPal vault. + * + * @param string $external_customer_id + * + * @return $this + */ + public function setExternalCustomerId($external_customer_id) + { + $this->external_customer_id = $external_customer_id; + return $this; + } + + /** + * The ID of the customer who owns this card account. The facilitator generates and provides this ID. Required when you create or use a stored funding instrument in the PayPal vault. + * + * @return string + */ + public function getExternalCustomerId() + { + return $this->external_customer_id; + } + + /** + * The state of the funding instrument. + * Valid Values: ["EXPIRED", "ACTIVE"] + * + * @param string $status + * + * @return $this + */ + public function setStatus($status) + { + $this->status = $status; + return $this; + } + + /** + * The state of the funding instrument. + * + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * The product class of the financial instrument issuer. + * Valid Values: ["CREDIT", "DEBIT", "GIFT", "PAYPAL_PREPAID", "PREPAID", "UNKNOWN"] + * + * @param string $card_product_class + * + * @return $this + */ + public function setCardProductClass($card_product_class) + { + $this->card_product_class = $card_product_class; + return $this; + } + + /** + * The product class of the financial instrument issuer. + * + * @return string + */ + public function getCardProductClass() + { + return $this->card_product_class; + } + + /** + * The date and time until when this instrument can be used fund a payment. + * + * @param string $valid_until + * + * @return $this + */ + public function setValidUntil($valid_until) + { + $this->valid_until = $valid_until; + return $this; + } + + /** + * The date and time until when this instrument can be used fund a payment. + * + * @return string + */ + public function getValidUntil() + { + return $this->valid_until; + } + + /** + * The one- to two-digit card issue number. Required for UK Maestro cards. + * + * @param string $issue_number + * + * @return $this + */ + public function setIssueNumber($issue_number) + { + $this->issue_number = $issue_number; + return $this; + } + + /** + * The one- to two-digit card issue number. Required for UK Maestro cards. + * + * @return string + */ + public function getIssueNumber() + { + return $this->issue_number; + } + + /** + * Sets Links + * + * @param \PayPal\Api\Links[] $links + * + * @return $this + */ + public function setLinks($links) + { + $this->links = $links; + return $this; + } + + /** + * Gets Links + * + * @return \PayPal\Api\Links[] + */ + public function getLinks() + { + return $this->links; + } + + /** + * Append Links to the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function addLink($links) + { + if (!$this->getLinks()) { + return $this->setLinks(array($links)); + } else { + return $this->setLinks( + array_merge($this->getLinks(), array($links)) + ); + } + } + + /** + * Remove Links from the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function removeLink($links) + { + return $this->setLinks( + array_diff($this->getLinks(), array($links)) + ); + } + +} diff --git a/paypal/PayPal/Api/PaymentCardToken.php b/paypal/PayPal/Api/PaymentCardToken.php new file mode 100644 index 0000000..d5fbe6c --- /dev/null +++ b/paypal/PayPal/Api/PaymentCardToken.php @@ -0,0 +1,162 @@ +payment_card_id = $payment_card_id; + return $this; + } + + /** + * ID of a previously saved Payment Card resource. + * + * @return string + */ + public function getPaymentCardId() + { + return $this->payment_card_id; + } + + /** + * The unique identifier of the payer used when saving this payment card. + * + * @param string $external_customer_id + * + * @return $this + */ + public function setExternalCustomerId($external_customer_id) + { + $this->external_customer_id = $external_customer_id; + return $this; + } + + /** + * The unique identifier of the payer used when saving this payment card. + * + * @return string + */ + public function getExternalCustomerId() + { + return $this->external_customer_id; + } + + /** + * Last 4 digits of the card number from the saved card. + * + * @param string $last4 + * + * @return $this + */ + public function setLast4($last4) + { + $this->last4 = $last4; + return $this; + } + + /** + * Last 4 digits of the card number from the saved card. + * + * @return string + */ + public function getLast4() + { + return $this->last4; + } + + /** + * Type of the Card. + * Valid Values: ["VISA", "AMEX", "SOLO", "JCB", "STAR", "DELTA", "DISCOVER", "SWITCH", "MAESTRO", "CB_NATIONALE", "CONFINOGA", "COFIDIS", "ELECTRON", "CETELEM", "CHINA_UNION_PAY", "MASTERCARD"] + * + * @param string $type + * + * @return $this + */ + public function setType($type) + { + $this->type = $type; + return $this; + } + + /** + * Type of the Card. + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Expiry month from the saved card with value 1 - 12. + * + * @param int $expire_month + * + * @return $this + */ + public function setExpireMonth($expire_month) + { + $this->expire_month = $expire_month; + return $this; + } + + /** + * Expiry month from the saved card with value 1 - 12. + * + * @return int + */ + public function getExpireMonth() + { + return $this->expire_month; + } + + /** + * Four digit expiry year from the saved card, represented as YYYY format. + * + * @param int $expire_year + * + * @return $this + */ + public function setExpireYear($expire_year) + { + $this->expire_year = $expire_year; + return $this; + } + + /** + * Four digit expiry year from the saved card, represented as YYYY format. + * + * @return int + */ + public function getExpireYear() + { + return $this->expire_year; + } + +} diff --git a/paypal/PayPal/Api/PaymentDefinition.php b/paypal/PayPal/Api/PaymentDefinition.php new file mode 100644 index 0000000..36cb799 --- /dev/null +++ b/paypal/PayPal/Api/PaymentDefinition.php @@ -0,0 +1,239 @@ +id = $id; + return $this; + } + + /** + * Identifier of the payment_definition. 128 characters max. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Name of the payment definition. 128 characters max. + * + * @param string $name + * + * @return $this + */ + public function setName($name) + { + $this->name = $name; + return $this; + } + + /** + * Name of the payment definition. 128 characters max. + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Type of the payment definition. Allowed values: `TRIAL`, `REGULAR`. + * + * @param string $type + * + * @return $this + */ + public function setType($type) + { + $this->type = $type; + return $this; + } + + /** + * Type of the payment definition. Allowed values: `TRIAL`, `REGULAR`. + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * How frequently the customer should be charged. + * + * @param string $frequency_interval + * + * @return $this + */ + public function setFrequencyInterval($frequency_interval) + { + $this->frequency_interval = $frequency_interval; + return $this; + } + + /** + * How frequently the customer should be charged. + * + * @return string + */ + public function getFrequencyInterval() + { + return $this->frequency_interval; + } + + /** + * Frequency of the payment definition offered. Allowed values: `WEEK`, `DAY`, `YEAR`, `MONTH`. + * + * @param string $frequency + * + * @return $this + */ + public function setFrequency($frequency) + { + $this->frequency = $frequency; + return $this; + } + + /** + * Frequency of the payment definition offered. Allowed values: `WEEK`, `DAY`, `YEAR`, `MONTH`. + * + * @return string + */ + public function getFrequency() + { + return $this->frequency; + } + + /** + * Number of cycles in this payment definition. + * + * @param string $cycles + * + * @return $this + */ + public function setCycles($cycles) + { + $this->cycles = $cycles; + return $this; + } + + /** + * Number of cycles in this payment definition. + * + * @return string + */ + public function getCycles() + { + return $this->cycles; + } + + /** + * Amount that will be charged at the end of each cycle for this payment definition. + * + * @param \PayPal\Api\Currency $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * Amount that will be charged at the end of each cycle for this payment definition. + * + * @return \PayPal\Api\Currency + */ + public function getAmount() + { + return $this->amount; + } + + /** + * Array of charge_models for this payment definition. + * + * @param \PayPal\Api\ChargeModel[] $charge_models + * + * @return $this + */ + public function setChargeModels($charge_models) + { + $this->charge_models = $charge_models; + return $this; + } + + /** + * Array of charge_models for this payment definition. + * + * @return \PayPal\Api\ChargeModel[] + */ + public function getChargeModels() + { + return $this->charge_models; + } + + /** + * Append ChargeModels to the list. + * + * @param \PayPal\Api\ChargeModel $chargeModel + * @return $this + */ + public function addChargeModel($chargeModel) + { + if (!$this->getChargeModels()) { + return $this->setChargeModels(array($chargeModel)); + } else { + return $this->setChargeModels( + array_merge($this->getChargeModels(), array($chargeModel)) + ); + } + } + + /** + * Remove ChargeModels from the list. + * + * @param \PayPal\Api\ChargeModel $chargeModel + * @return $this + */ + public function removeChargeModel($chargeModel) + { + return $this->setChargeModels( + array_diff($this->getChargeModels(), array($chargeModel)) + ); + } + +} diff --git a/paypal/PayPal/Api/PaymentDetail.php b/paypal/PayPal/Api/PaymentDetail.php new file mode 100644 index 0000000..59305a7 --- /dev/null +++ b/paypal/PayPal/Api/PaymentDetail.php @@ -0,0 +1,188 @@ +type = $type; + return $this; + } + + /** + * The PayPal payment detail. Indicates whether payment was made in an invoicing flow through PayPal or externally. In the case of the mark-as-paid API, the supported payment type is `EXTERNAL`. For backward compatibility, the `PAYPAL` payment type is still supported. + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * The PayPal payment transaction ID. Required with the `PAYPAL` payment type. + * + * @param string $transaction_id + * + * @return $this + */ + public function setTransactionId($transaction_id) + { + $this->transaction_id = $transaction_id; + return $this; + } + + /** + * The PayPal payment transaction ID. Required with the `PAYPAL` payment type. + * + * @return string + */ + public function getTransactionId() + { + return $this->transaction_id; + } + + /** + * Type of the transaction. + * Valid Values: ["SALE", "AUTHORIZATION", "CAPTURE"] + * + * @param string $transaction_type + * + * @return $this + */ + public function setTransactionType($transaction_type) + { + $this->transaction_type = $transaction_type; + return $this; + } + + /** + * Type of the transaction. + * + * @return string + */ + public function getTransactionType() + { + return $this->transaction_type; + } + + /** + * The date when the invoice was paid. The date format is *yyyy*-*MM*-*dd* *z* as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @param string $date + * + * @return $this + */ + public function setDate($date) + { + $this->date = $date; + return $this; + } + + /** + * The date when the invoice was paid. The date format is *yyyy*-*MM*-*dd* *z* as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return string + */ + public function getDate() + { + return $this->date; + } + + /** + * The payment mode or method. Required with the `EXTERNAL` payment type. + * Valid Values: ["BANK_TRANSFER", "CASH", "CHECK", "CREDIT_CARD", "DEBIT_CARD", "PAYPAL", "WIRE_TRANSFER", "OTHER"] + * + * @param string $method + * + * @return $this + */ + public function setMethod($method) + { + $this->method = $method; + return $this; + } + + /** + * The payment mode or method. Required with the `EXTERNAL` payment type. + * + * @return string + */ + public function getMethod() + { + return $this->method; + } + + /** + * Optional. A note associated with the payment. + * + * @param string $note + * + * @return $this + */ + public function setNote($note) + { + $this->note = $note; + return $this; + } + + /** + * Optional. A note associated with the payment. + * + * @return string + */ + public function getNote() + { + return $this->note; + } + + /** + * The amount to record as payment against invoice. If you omit this parameter, the total invoice amount is recorded as payment. + * + * @param \PayPal\Api\Currency $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * The amount to record as payment against invoice. If you omit this parameter, the total invoice amount is recorded as payment. + * + * @return \PayPal\Api\Currency + */ + public function getAmount() + { + return $this->amount; + } + +} diff --git a/paypal/PayPal/Api/PaymentExecution.php b/paypal/PayPal/Api/PaymentExecution.php new file mode 100644 index 0000000..4783037 --- /dev/null +++ b/paypal/PayPal/Api/PaymentExecution.php @@ -0,0 +1,118 @@ +payer_id = $payer_id; + return $this; + } + + /** + * The ID of the Payer, passed in the `return_url` by PayPal. + * + * @return string + */ + public function getPayerId() + { + return $this->payer_id; + } + + /** + * Carrier account id for a carrier billing payment. For a carrier billing payment, payer_id is not applicable. + * @deprecated Not publicly available + * @param string $carrier_account_id + * + * @return $this + */ + public function setCarrierAccountId($carrier_account_id) + { + $this->carrier_account_id = $carrier_account_id; + return $this; + } + + /** + * Carrier account id for a carrier billing payment. For a carrier billing payment, payer_id is not applicable. + * @deprecated Not publicly available + * @return string + */ + public function getCarrierAccountId() + { + return $this->carrier_account_id; + } + + /** + * Transactional details including the amount and item details. + * + * @param \PayPal\Api\Transaction[] $transactions + * + * @return $this + */ + public function setTransactions($transactions) + { + $this->transactions = $transactions; + return $this; + } + + /** + * Transactional details including the amount and item details. + * + * @return \PayPal\Api\Transaction[] + */ + public function getTransactions() + { + return $this->transactions; + } + + /** + * Append Transactions to the list. + * + * @param \PayPal\Api\Transaction $transaction + * @return $this + */ + public function addTransaction($transaction) + { + if (!$this->getTransactions()) { + return $this->setTransactions(array($transaction)); + } else { + return $this->setTransactions( + array_merge($this->getTransactions(), array($transaction)) + ); + } + } + + /** + * Remove Transactions from the list. + * + * @param \PayPal\Api\Transaction $transaction + * @return $this + */ + public function removeTransaction($transaction) + { + return $this->setTransactions( + array_diff($this->getTransactions(), array($transaction)) + ); + } + +} diff --git a/paypal/PayPal/Api/PaymentHistory.php b/paypal/PayPal/Api/PaymentHistory.php new file mode 100644 index 0000000..eb4e611 --- /dev/null +++ b/paypal/PayPal/Api/PaymentHistory.php @@ -0,0 +1,119 @@ +payments = $payments; + return $this; + } + + /** + * A list of Payment resources + * + * @return \PayPal\Api\Payment[] + */ + public function getPayments() + { + return $this->payments; + } + + /** + * Append Payments to the list. + * + * @param \PayPal\Api\Payment $payment + * @return $this + */ + public function addPayment($payment) + { + if (!$this->getPayments()) { + return $this->setPayments(array($payment)); + } else { + return $this->setPayments( + array_merge($this->getPayments(), array($payment)) + ); + } + } + + /** + * Remove Payments from the list. + * + * @param \PayPal\Api\Payment $payment + * @return $this + */ + public function removePayment($payment) + { + return $this->setPayments( + array_diff($this->getPayments(), array($payment)) + ); + } + + /** + * 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. Maximum value: 20. + * + * @param int $count + * + * @return $this + */ + public function setCount($count) + { + $this->count = $count; + return $this; + } + + /** + * 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. Maximum value: 20. + * + * @return int + */ + public function getCount() + { + return $this->count; + } + + /** + * Identifier of the next element to get the next range of results. + * + * @param string $next_id + * + * @return $this + */ + public function setNextId($next_id) + { + $this->next_id = $next_id; + return $this; + } + + /** + * Identifier of the next element to get the next range of results. + * + * @return string + */ + public function getNextId() + { + return $this->next_id; + } + +} diff --git a/paypal/PayPal/Api/PaymentInstruction.php b/paypal/PayPal/Api/PaymentInstruction.php new file mode 100644 index 0000000..152d83f --- /dev/null +++ b/paypal/PayPal/Api/PaymentInstruction.php @@ -0,0 +1,190 @@ +reference_number = $reference_number; + return $this; + } + + /** + * ID of payment instruction + * + * @return string + */ + public function getReferenceNumber() + { + return $this->reference_number; + } + + /** + * Type of payment instruction + * Valid Values: ["MANUAL_BANK_TRANSFER", "PAY_UPON_INVOICE"] + * + * @param string $instruction_type + * + * @return $this + */ + public function setInstructionType($instruction_type) + { + $this->instruction_type = $instruction_type; + return $this; + } + + /** + * Type of payment instruction + * + * @return string + */ + public function getInstructionType() + { + return $this->instruction_type; + } + + /** + * Recipient bank Details. + * + * @param \PayPal\Api\RecipientBankingInstruction $recipient_banking_instruction + * + * @return $this + */ + public function setRecipientBankingInstruction($recipient_banking_instruction) + { + $this->recipient_banking_instruction = $recipient_banking_instruction; + return $this; + } + + /** + * Recipient bank Details. + * + * @return \PayPal\Api\RecipientBankingInstruction + */ + public function getRecipientBankingInstruction() + { + return $this->recipient_banking_instruction; + } + + /** + * Amount to be transferred + * + * @param \PayPal\Api\Currency $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * Amount to be transferred + * + * @return \PayPal\Api\Currency + */ + public function getAmount() + { + return $this->amount; + } + + /** + * Date by which payment should be received + * + * @param string $payment_due_date + * + * @return $this + */ + public function setPaymentDueDate($payment_due_date) + { + $this->payment_due_date = $payment_due_date; + return $this; + } + + /** + * Date by which payment should be received + * + * @return string + */ + public function getPaymentDueDate() + { + return $this->payment_due_date; + } + + /** + * Additional text regarding payment handling + * + * @param string $note + * + * @return $this + */ + public function setNote($note) + { + $this->note = $note; + return $this; + } + + /** + * Additional text regarding payment handling + * + * @return string + */ + public function getNote() + { + return $this->note; + } + + /** + * 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). + * + * @param string $paymentId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return PaymentInstruction + */ + public static function get($paymentId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($paymentId, 'paymentId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/payments/payment/$paymentId/payment-instruction", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new PaymentInstruction(); + $ret->fromJson($json); + return $ret; + } + +} diff --git a/paypal/PayPal/Api/PaymentOptions.php b/paypal/PayPal/Api/PaymentOptions.php new file mode 100644 index 0000000..90b24a2 --- /dev/null +++ b/paypal/PayPal/Api/PaymentOptions.php @@ -0,0 +1,88 @@ +allowed_payment_method = $allowed_payment_method; + return $this; + } + + /** + * Payment method requested for this purchase unit + * + * @return string + */ + public function getAllowedPaymentMethod() + { + return $this->allowed_payment_method; + } + + /** + * Indicator if this payment request is a recurring payment. Only supported when the `payment_method` is set to `credit_card` + * @deprecated Not publicly available + * @param bool $recurring_flag + * + * @return $this + */ + public function setRecurringFlag($recurring_flag) + { + $this->recurring_flag = $recurring_flag; + return $this; + } + + /** + * Indicator if this payment request is a recurring payment. Only supported when the `payment_method` is set to `credit_card` + * @deprecated Not publicly available + * @return bool + */ + public function getRecurringFlag() + { + return $this->recurring_flag; + } + + /** + * Indicator if fraud management filters (fmf) should be skipped for this transaction. Only supported when the `payment_method` is set to `credit_card` + * @deprecated Not publicly available + * @param bool $skip_fmf + * + * @return $this + */ + public function setSkipFmf($skip_fmf) + { + $this->skip_fmf = $skip_fmf; + return $this; + } + + /** + * Indicator if fraud management filters (fmf) should be skipped for this transaction. Only supported when the `payment_method` is set to `credit_card` + * @deprecated Not publicly available + * @return bool + */ + public function getSkipFmf() + { + return $this->skip_fmf; + } + +} diff --git a/paypal/PayPal/Api/PaymentSummary.php b/paypal/PayPal/Api/PaymentSummary.php new file mode 100644 index 0000000..3fcc5d6 --- /dev/null +++ b/paypal/PayPal/Api/PaymentSummary.php @@ -0,0 +1,65 @@ +paypal = $paypal; + return $this; + } + + /** + * Total Amount paid/refunded via PayPal. + * + * @return \PayPal\Api\Currency + */ + public function getPaypal() + { + return $this->paypal; + } + + /** + * Total Amount paid/refunded via other sources. + * + * @param \PayPal\Api\Currency $other + * + * @return $this + */ + public function setOther($other) + { + $this->other = $other; + return $this; + } + + /** + * Total Amount paid/refunded via other sources. + * + * @return \PayPal\Api\Currency + */ + public function getOther() + { + return $this->other; + } + +} diff --git a/paypal/PayPal/Api/PaymentTerm.php b/paypal/PayPal/Api/PaymentTerm.php new file mode 100644 index 0000000..ee62f6d --- /dev/null +++ b/paypal/PayPal/Api/PaymentTerm.php @@ -0,0 +1,66 @@ +term_type = $term_type; + return $this; + } + + /** + * The terms by which the invoice payment is due. + * + * @return string + */ + public function getTermType() + { + return $this->term_type; + } + + /** + * The date when the invoice payment is due. This date must be a future date. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @param string $due_date + * + * @return $this + */ + public function setDueDate($due_date) + { + $this->due_date = $due_date; + return $this; + } + + /** + * The date when the invoice payment is due. This date must be a future date. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return string + */ + public function getDueDate() + { + return $this->due_date; + } + +} diff --git a/paypal/PayPal/Api/Payout.php b/paypal/PayPal/Api/Payout.php new file mode 100644 index 0000000..b97b515 --- /dev/null +++ b/paypal/PayPal/Api/Payout.php @@ -0,0 +1,166 @@ +sender_batch_header = $sender_batch_header; + return $this; + } + + /** + * The original batch header as provided by the payment sender. + * + * @return \PayPal\Api\PayoutSenderBatchHeader + */ + public function getSenderBatchHeader() + { + return $this->sender_batch_header; + } + + /** + * An array of payout items (that is, a set of individual payouts). + * + * @param \PayPal\Api\PayoutItem[] $items + * + * @return $this + */ + public function setItems($items) + { + $this->items = $items; + return $this; + } + + /** + * An array of payout items (that is, a set of individual payouts). + * + * @return \PayPal\Api\PayoutItem[] + */ + public function getItems() + { + return $this->items; + } + + /** + * Append Items to the list. + * + * @param \PayPal\Api\PayoutItem $payoutItem + * @return $this + */ + public function addItem($payoutItem) + { + if (!$this->getItems()) { + return $this->setItems(array($payoutItem)); + } else { + return $this->setItems( + array_merge($this->getItems(), array($payoutItem)) + ); + } + } + + /** + * Remove Items from the list. + * + * @param \PayPal\Api\PayoutItem $payoutItem + * @return $this + */ + public function removeItem($payoutItem) + { + return $this->setItems( + array_diff($this->getItems(), array($payoutItem)) + ); + } + + /** + * 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. + * + * @param array $params + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return PayoutBatch + */ + public function create($params = array(), $apiContext = null, $restCall = null) + { + $params = $params ? $params : array(); + ArgumentValidator::validate($params, 'params'); + $payLoad = $this->toJSON(); + $allowedParams = array( + 'sync_mode' => 1, + ); + $json = self::executeCall( + "/v1/payments/payouts" . "?" . http_build_query(array_intersect_key($params, $allowedParams)), + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new PayoutBatch(); + $ret->fromJson($json); + return $ret; + } + + /** + * You can submit a payout with a synchronous API call, which immediately returns the results of a PayPal payment. + * + * @param ApiContext $apiContext + * @param PayPalRestCall $restCall + * @return PayoutBatch + */ + public function createSynchronous($apiContext = null, $restCall = null) + { + $params = array('sync_mode' => 'true'); + return $this->create($params, $apiContext, $restCall); + } + + /** + * 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. + * + * @param string $payoutBatchId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return PayoutBatch + */ + public static function get($payoutBatchId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($payoutBatchId, 'payoutBatchId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/payments/payouts/$payoutBatchId", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new PayoutBatch(); + $ret->fromJson($json); + return $ret; + } + +} diff --git a/paypal/PayPal/Api/PayoutBatch.php b/paypal/PayPal/Api/PayoutBatch.php new file mode 100644 index 0000000..2b5e367 --- /dev/null +++ b/paypal/PayPal/Api/PayoutBatch.php @@ -0,0 +1,120 @@ +batch_header = $batch_header; + return $this; + } + + /** + * A batch header. Includes the generated batch status. + * + * @return \PayPal\Api\PayoutBatchHeader + */ + public function getBatchHeader() + { + return $this->batch_header; + } + + /** + * An array of items in a batch payout. + * + * @param \PayPal\Api\PayoutItemDetails[] $items + * + * @return $this + */ + public function setItems($items) + { + $this->items = $items; + return $this; + } + + /** + * An array of items in a batch payout. + * + * @return \PayPal\Api\PayoutItemDetails[] + */ + public function getItems() + { + return $this->items; + } + + /** + * Append Items to the list. + * + * @param \PayPal\Api\PayoutItemDetails $payoutItemDetails + * @return $this + */ + public function addItem($payoutItemDetails) + { + if (!$this->getItems()) { + return $this->setItems(array($payoutItemDetails)); + } else { + return $this->setItems( + array_merge($this->getItems(), array($payoutItemDetails)) + ); + } + } + + /** + * Remove Items from the list. + * + * @param \PayPal\Api\PayoutItemDetails $payoutItemDetails + * @return $this + */ + public function removeItem($payoutItemDetails) + { + return $this->setItems( + array_diff($this->getItems(), array($payoutItemDetails)) + ); + } + + + /** + * Sets Links + * + * @param \PayPal\Api\Links[] $links + * + * @return $this + */ + public function setLinks($links) + { + $this->links = $links; + return $this; + } + + /** + * Gets Links + * + * @return \PayPal\Api\Links[] + */ + public function getLinks() + { + return $this->links; + } + +} diff --git a/paypal/PayPal/Api/PayoutBatchHeader.php b/paypal/PayPal/Api/PayoutBatchHeader.php new file mode 100644 index 0000000..88a834b --- /dev/null +++ b/paypal/PayPal/Api/PayoutBatchHeader.php @@ -0,0 +1,263 @@ +payout_batch_id = $payout_batch_id; + return $this; + } + + /** + * The PayPal-generated ID for a batch payout. + * + * @return string + */ + public function getPayoutBatchId() + { + return $this->payout_batch_id; + } + + /** + * The PayPal-generated batch payout status. If the batch payout passes the preliminary checks, the status is `PENDING`. + * + * @param string $batch_status + * + * @return $this + */ + public function setBatchStatus($batch_status) + { + $this->batch_status = $batch_status; + return $this; + } + + /** + * The PayPal-generated batch payout status. If the batch payout passes the preliminary checks, the status is `PENDING`. + * + * @return string + */ + public function getBatchStatus() + { + return $this->batch_status; + } + + /** + * The time the batch entered processing. + * + * @param string $time_created + * + * @return $this + */ + public function setTimeCreated($time_created) + { + $this->time_created = $time_created; + return $this; + } + + /** + * The time the batch entered processing. + * + * @return string + */ + public function getTimeCreated() + { + return $this->time_created; + } + + /** + * The time that processing for the batch was completed. + * + * @param string $time_completed + * + * @return $this + */ + public function setTimeCompleted($time_completed) + { + $this->time_completed = $time_completed; + return $this; + } + + /** + * The time that processing for the batch was completed. + * + * @return string + */ + public function getTimeCompleted() + { + return $this->time_completed; + } + + /** + * The original batch header as provided by the payment sender. + * + * @param \PayPal\Api\PayoutSenderBatchHeader $sender_batch_header + * + * @return $this + */ + public function setSenderBatchHeader($sender_batch_header) + { + $this->sender_batch_header = $sender_batch_header; + return $this; + } + + /** + * The sender-provided batch payout header. + * + * @return \PayPal\Api\PayoutSenderBatchHeader + */ + public function getSenderBatchHeader() + { + return $this->sender_batch_header; + } + + /** + * Total amount, in U.S. dollars, requested for the applicable payouts. + * + * @param \PayPal\Api\Currency $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * Total amount, in U.S. dollars, requested for the applicable payouts. + * + * @return \PayPal\Api\Currency + */ + public function getAmount() + { + return $this->amount; + } + + /** + * Total estimate in U.S. dollars for the applicable payouts fees. + * + * @param \PayPal\Api\Currency $fees + * + * @return $this + */ + public function setFees($fees) + { + $this->fees = $fees; + return $this; + } + + /** + * Total estimate in U.S. dollars for the applicable payouts fees. + * + * @return \PayPal\Api\Currency + */ + public function getFees() + { + return $this->fees; + } + + /** + * Sets Errors + * + * @param \PayPal\Api\Error $errors + * + * @return $this + */ + public function setErrors($errors) + { + $this->errors = $errors; + return $this; + } + + /** + * Gets Errors + * + * @return \PayPal\Api\Error + */ + public function getErrors() + { + return $this->errors; + } + + /** + * Sets Links + * + * @param \PayPal\Api\Links[] $links + * + * @return $this + */ + public function setLinks($links) + { + $this->links = $links; + return $this; + } + + /** + * Gets Links + * + * @return \PayPal\Api\Links[] + */ + public function getLinks() + { + return $this->links; + } + + /** + * Append Links to the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function addLink($links) + { + if (!$this->getLinks()) { + return $this->setLinks(array($links)); + } else { + return $this->setLinks( + array_merge($this->getLinks(), array($links)) + ); + } + } + + /** + * Remove Links from the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function removeLink($links) + { + return $this->setLinks( + array_diff($this->getLinks(), array($links)) + ); + } + +} diff --git a/paypal/PayPal/Api/PayoutItem.php b/paypal/PayPal/Api/PayoutItem.php new file mode 100644 index 0000000..b8e628b --- /dev/null +++ b/paypal/PayPal/Api/PayoutItem.php @@ -0,0 +1,189 @@ +EMAIL. Unencrypted email. Value is a string of up to 127 single-byte characters.
  • PHONE. Unencrypted phone number.
    Note: The PayPal sandbox does not support the PHONE recipient type.
  • PAYPAL_ID. Encrypted PayPal account number.
  • If the sender_batch_header includes the recipient_type attribute, any payout item without its own recipient_type attribute uses the recipient_type value from sender_batch_header. If the sender_batch_header omits the recipient_type attribute, each payout item must include its own recipient_type value. + * + * @param string $recipient_type + * + * @return $this + */ + public function setRecipientType($recipient_type) + { + $this->recipient_type = $recipient_type; + return $this; + } + + /** + * The type of ID that identifies the payment receiver. Value is:If the sender_batch_header includes the recipient_type attribute, any payout item without its own recipient_type attribute uses the recipient_type value from sender_batch_header. If the sender_batch_header omits the recipient_type attribute, each payout item must include its own recipient_type value. + * + * @return string + */ + public function getRecipientType() + { + return $this->recipient_type; + } + + /** + * The amount of money to pay the receiver. + * + * @param \PayPal\Api\Currency $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * The amount of money to pay the receiver. + * + * @return \PayPal\Api\Currency + */ + public function getAmount() + { + return $this->amount; + } + + /** + * Optional. A sender-specified note for notifications. Value is any string value. + * + * @param string $note + * + * @return $this + */ + public function setNote($note) + { + $this->note = $note; + return $this; + } + + /** + * Optional. A sender-specified note for notifications. Value is any string value. + * + * @return string + */ + public function getNote() + { + return $this->note; + } + + /** + * The receiver of the payment. Corresponds to the `recipient_type` value in the request. + * + * @param string $receiver + * + * @return $this + */ + public function setReceiver($receiver) + { + $this->receiver = $receiver; + return $this; + } + + /** + * The receiver of the payment. Corresponds to the `recipient_type` value in the request. + * + * @return string + */ + public function getReceiver() + { + return $this->receiver; + } + + /** + * A sender-specified ID number. Tracks the batch payout in an accounting system. + * + * @param string $sender_item_id + * + * @return $this + */ + public function setSenderItemId($sender_item_id) + { + $this->sender_item_id = $sender_item_id; + return $this; + } + + /** + * A sender-specified ID number. Tracks the batch payout in an accounting system. + * + * @return string + */ + public function getSenderItemId() + { + return $this->sender_item_id; + } + + /** + * Obtain the status of a payout item by passing the item ID to the request URI. + * + * @param string $payoutItemId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return PayoutItemDetails + */ + public static function get($payoutItemId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($payoutItemId, 'payoutItemId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/payments/payouts-item/$payoutItemId", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new PayoutItemDetails(); + $ret->fromJson($json); + return $ret; + } + + /** + * 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. + * + * @param string $payoutItemId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return PayoutItemDetails + */ + public static function cancel($payoutItemId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($payoutItemId, 'payoutItemId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/payments/payouts-item/$payoutItemId/cancel", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new PayoutItemDetails(); + $ret->fromJson($json); + return $ret; + } +} diff --git a/paypal/PayPal/Api/PayoutItemDetails.php b/paypal/PayPal/Api/PayoutItemDetails.php new file mode 100644 index 0000000..147b99e --- /dev/null +++ b/paypal/PayPal/Api/PayoutItemDetails.php @@ -0,0 +1,287 @@ +payout_item_id = $payout_item_id; + return $this; + } + + /** + * The ID for the payout item. Viewable when you show details for a batch payout. + * + * @return string + */ + public function getPayoutItemId() + { + return $this->payout_item_id; + } + + /** + * The PayPal-generated ID for the transaction. + * + * @param string $transaction_id + * + * @return $this + */ + public function setTransactionId($transaction_id) + { + $this->transaction_id = $transaction_id; + return $this; + } + + /** + * The PayPal-generated ID for the transaction. + * + * @return string + */ + public function getTransactionId() + { + return $this->transaction_id; + } + + /** + * The transaction status. + * + * @param string $transaction_status + * + * @return $this + */ + public function setTransactionStatus($transaction_status) + { + $this->transaction_status = $transaction_status; + return $this; + } + + /** + * The transaction status. + * + * @return string + */ + public function getTransactionStatus() + { + return $this->transaction_status; + } + + /** + * The amount of money, in U.S. dollars, for fees. + * + * @param \PayPal\Api\Currency $payout_item_fee + * + * @return $this + */ + public function setPayoutItemFee($payout_item_fee) + { + $this->payout_item_fee = $payout_item_fee; + return $this; + } + + /** + * The amount of money, in U.S. dollars, for fees. + * + * @return \PayPal\Api\Currency + */ + public function getPayoutItemFee() + { + return $this->payout_item_fee; + } + + /** + * The PayPal-generated ID for the batch payout. + * + * @param string $payout_batch_id + * + * @return $this + */ + public function setPayoutBatchId($payout_batch_id) + { + $this->payout_batch_id = $payout_batch_id; + return $this; + } + + /** + * The PayPal-generated ID for the batch payout. + * + * @return string + */ + public function getPayoutBatchId() + { + return $this->payout_batch_id; + } + + /** + * A sender-specified ID number. Tracks the batch payout in an accounting system. + * + * @param string $sender_batch_id + * + * @return $this + */ + public function setSenderBatchId($sender_batch_id) + { + $this->sender_batch_id = $sender_batch_id; + return $this; + } + + /** + * A sender-specified ID number. Tracks the batch payout in an accounting system. + * + * @return string + */ + public function getSenderBatchId() + { + return $this->sender_batch_id; + } + + /** + * The sender-provided information for the payout item. + * + * @param \PayPal\Api\PayoutItem $payout_item + * + * @return $this + */ + public function setPayoutItem($payout_item) + { + $this->payout_item = $payout_item; + return $this; + } + + /** + * The sender-provided information for the payout item. + * + * @return \PayPal\Api\PayoutItem + */ + public function getPayoutItem() + { + return $this->payout_item; + } + + /** + * The date and time when this item was last processed. + * + * @param string $time_processed + * + * @return $this + */ + public function setTimeProcessed($time_processed) + { + $this->time_processed = $time_processed; + return $this; + } + + /** + * The date and time when this item was last processed. + * + * @return string + */ + public function getTimeProcessed() + { + return $this->time_processed; + } + + /** + * Sets Errors + * + * @param \PayPal\Api\Error $errors + * + * @return $this + */ + public function setErrors($errors) + { + $this->errors = $errors; + return $this; + } + + /** + * Gets Errors + * + * @return \PayPal\Api\Error + */ + public function getErrors() + { + return $this->errors; + } + + /** + * Sets Links + * + * @param \PayPal\Api\Links[] $links + * + * @return $this + */ + public function setLinks($links) + { + $this->links = $links; + return $this; + } + + /** + * Gets Links + * + * @return \PayPal\Api\Links[] + */ + public function getLinks() + { + return $this->links; + } + + /** + * Append Links to the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function addLink($links) + { + if (!$this->getLinks()) { + return $this->setLinks(array($links)); + } else { + return $this->setLinks( + array_merge($this->getLinks(), array($links)) + ); + } + } + + /** + * Remove Links from the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function removeLink($links) + { + return $this->setLinks( + array_diff($this->getLinks(), array($links)) + ); + } + +} diff --git a/paypal/PayPal/Api/PayoutSenderBatchHeader.php b/paypal/PayPal/Api/PayoutSenderBatchHeader.php new file mode 100644 index 0000000..3ea59c9 --- /dev/null +++ b/paypal/PayPal/Api/PayoutSenderBatchHeader.php @@ -0,0 +1,107 @@ +Note: PayPal prevents duplicate batches from being processed. If you specify a `sender_batch_id` that was used in the last 30 days, the API rejects the request and returns an error message that indicates the duplicate `sender_batch_id` and includes a HATEOAS link to the original batch payout with the same `sender_batch_id`. If you receive a HTTP `5nn` status code, you can safely retry the request with the same `sender_batch_id`. In any case, the API completes a payment only once for a specific `sender_batch_id` that is used within 30 days. + * + * @param string $sender_batch_id + * + * @return $this + */ + public function setSenderBatchId($sender_batch_id) + { + $this->sender_batch_id = $sender_batch_id; + return $this; + } + + /** + * A sender-specified ID number. Tracks the batch payout in an accounting system.
    Note: PayPal prevents duplicate batches from being processed. If you specify a `sender_batch_id` that was used in the last 30 days, the API rejects the request and returns an error message that indicates the duplicate `sender_batch_id` and includes a HATEOAS link to the original batch payout with the same `sender_batch_id`. If you receive a HTTP `5nn` status code, you can safely retry the request with the same `sender_batch_id`. In any case, the API completes a payment only once for a specific `sender_batch_id` that is used within 30 days.
    + * + * @return string + */ + public function getSenderBatchId() + { + return $this->sender_batch_id; + } + + /** + * The subject line text for the email that PayPal sends when a payout item completes. The subject line is the same for all recipients. Value is an alphanumeric string with a maximum length of 255 single-byte characters. + * + * @param string $email_subject + * + * @return $this + */ + public function setEmailSubject($email_subject) + { + $this->email_subject = $email_subject; + return $this; + } + + /** + * The subject line text for the email that PayPal sends when a payout item completes. The subject line is the same for all recipients. Value is an alphanumeric string with a maximum length of 255 single-byte characters. + * + * @return string + */ + public function getEmailSubject() + { + return $this->email_subject; + } + + /** + * The type of ID that identifies the payment receiver. Value is:If the sender_batch_header includes the recipient_type attribute, any payout item without its own recipient_type attribute uses the recipient_type value from sender_batch_header. If the sender_batch_header omits the recipient_type attribute, each payout item must include its own recipient_type value. + * + * @param string $recipient_type + * + * @return $this + */ + public function setRecipientType($recipient_type) + { + $this->recipient_type = $recipient_type; + return $this; + } + + /** + * The type of ID that identifies the payment receiver. Value is:If the sender_batch_header includes the recipient_type attribute, any payout item without its own recipient_type attribute uses the recipient_type value from sender_batch_header. If the sender_batch_header omits the recipient_type attribute, each payout item must include its own recipient_type value. + * + * @return string + */ + public function getRecipientType() + { + return $this->recipient_type; + } + + /** + * @deprecated This property is unused + */ + public function setBatchStatus($batch_status) + { + $this->batch_status = $batch_status; + return $this; + } + + /** + * @deprecated This property is unused + */ + public function getBatchStatus() + { + return $this->batch_status; + } + +} diff --git a/paypal/PayPal/Api/Phone.php b/paypal/PayPal/Api/Phone.php new file mode 100644 index 0000000..b93a09e --- /dev/null +++ b/paypal/PayPal/Api/Phone.php @@ -0,0 +1,89 @@ +country_code = $country_code; + return $this; + } + + /** + * Country code (from in E.164 format) + * + * @return string + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * In-country phone number (from in E.164 format) + * + * @param string $national_number + * + * @return $this + */ + public function setNationalNumber($national_number) + { + $this->national_number = $national_number; + return $this; + } + + /** + * In-country phone number (from in E.164 format) + * + * @return string + */ + public function getNationalNumber() + { + return $this->national_number; + } + + /** + * Phone extension + * + * @param string $extension + * + * @return $this + */ + public function setExtension($extension) + { + $this->extension = $extension; + return $this; + } + + /** + * Phone extension + * + * @return string + */ + public function getExtension() + { + return $this->extension; + } + +} diff --git a/paypal/PayPal/Api/Plan.php b/paypal/PayPal/Api/Plan.php new file mode 100644 index 0000000..630a9dc --- /dev/null +++ b/paypal/PayPal/Api/Plan.php @@ -0,0 +1,445 @@ +id = $id; + return $this; + } + + /** + * Identifier of the billing plan. 128 characters max. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Name of the billing plan. 128 characters max. + * + * @param string $name + * + * @return $this + */ + public function setName($name) + { + $this->name = $name; + return $this; + } + + /** + * Name of the billing plan. 128 characters max. + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Description of the billing plan. 128 characters max. + * + * @param string $description + * + * @return $this + */ + public function setDescription($description) + { + $this->description = $description; + return $this; + } + + /** + * Description of the billing plan. 128 characters max. + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Type of the billing plan. Allowed values: `FIXED`, `INFINITE`. + * + * @param string $type + * + * @return $this + */ + public function setType($type) + { + $this->type = $type; + return $this; + } + + /** + * Type of the billing plan. Allowed values: `FIXED`, `INFINITE`. + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Status of the billing plan. Allowed values: `CREATED`, `ACTIVE`, `INACTIVE`, and `DELETED`. + * + * @param string $state + * + * @return $this + */ + public function setState($state) + { + $this->state = $state; + return $this; + } + + /** + * Status of the billing plan. Allowed values: `CREATED`, `ACTIVE`, `INACTIVE`, and `DELETED`. + * + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * Time when the billing plan was created. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @param string $create_time + * + * @return $this + */ + public function setCreateTime($create_time) + { + $this->create_time = $create_time; + return $this; + } + + /** + * Time when the billing plan was created. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return string + */ + public function getCreateTime() + { + return $this->create_time; + } + + /** + * Time when this billing plan was updated. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @param string $update_time + * + * @return $this + */ + public function setUpdateTime($update_time) + { + $this->update_time = $update_time; + return $this; + } + + /** + * Time when this billing plan was updated. Format YYYY-MM-DDTimeTimezone, as defined in [ISO8601](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return string + */ + public function getUpdateTime() + { + return $this->update_time; + } + + /** + * Array of payment definitions for this billing plan. + * + * @param \PayPal\Api\PaymentDefinition[] $payment_definitions + * + * @return $this + */ + public function setPaymentDefinitions($payment_definitions) + { + $this->payment_definitions = $payment_definitions; + return $this; + } + + /** + * Array of payment definitions for this billing plan. + * + * @return \PayPal\Api\PaymentDefinition[] + */ + public function getPaymentDefinitions() + { + return $this->payment_definitions; + } + + /** + * Append PaymentDefinitions to the list. + * + * @param \PayPal\Api\PaymentDefinition $paymentDefinition + * @return $this + */ + public function addPaymentDefinition($paymentDefinition) + { + if (!$this->getPaymentDefinitions()) { + return $this->setPaymentDefinitions(array($paymentDefinition)); + } else { + return $this->setPaymentDefinitions( + array_merge($this->getPaymentDefinitions(), array($paymentDefinition)) + ); + } + } + + /** + * Remove PaymentDefinitions from the list. + * + * @param \PayPal\Api\PaymentDefinition $paymentDefinition + * @return $this + */ + public function removePaymentDefinition($paymentDefinition) + { + return $this->setPaymentDefinitions( + array_diff($this->getPaymentDefinitions(), array($paymentDefinition)) + ); + } + + /** + * Array of terms for this billing plan. + * + * @param \PayPal\Api\Terms[] $terms + * + * @return $this + */ + public function setTerms($terms) + { + $this->terms = $terms; + return $this; + } + + /** + * Array of terms for this billing plan. + * + * @return \PayPal\Api\Terms[] + */ + public function getTerms() + { + return $this->terms; + } + + /** + * Append Terms to the list. + * + * @param \PayPal\Api\Terms $terms + * @return $this + */ + public function addTerm($terms) + { + if (!$this->getTerms()) { + return $this->setTerms(array($terms)); + } else { + return $this->setTerms( + array_merge($this->getTerms(), array($terms)) + ); + } + } + + /** + * Remove Terms from the list. + * + * @param \PayPal\Api\Terms $terms + * @return $this + */ + public function removeTerm($terms) + { + return $this->setTerms( + array_diff($this->getTerms(), array($terms)) + ); + } + + /** + * Specific preferences such as: set up fee, max fail attempts, autobill amount, and others that are configured for this billing plan. + * + * @param \PayPal\Api\MerchantPreferences $merchant_preferences + * + * @return $this + */ + public function setMerchantPreferences($merchant_preferences) + { + $this->merchant_preferences = $merchant_preferences; + return $this; + } + + /** + * Specific preferences such as: set up fee, max fail attempts, autobill amount, and others that are configured for this billing plan. + * + * @return \PayPal\Api\MerchantPreferences + */ + public function getMerchantPreferences() + { + return $this->merchant_preferences; + } + + /** + * Retrieve the details for a particular billing plan by passing the billing plan ID to the request URI. + * + * @param string $planId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Plan + */ + public static function get($planId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($planId, 'planId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/payments/billing-plans/$planId", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new Plan(); + $ret->fromJson($json); + return $ret; + } + + /** + * Create a new billing plan by passing the details for the plan, including the plan name, description, and type, to the request URI. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Plan + */ + public function create($apiContext = null, $restCall = null) + { + $payLoad = $this->toJSON(); + $json = self::executeCall( + "/v1/payments/billing-plans/", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $this->fromJson($json); + return $this; + } + + /** + * 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. + * + * @param PatchRequest $patchRequest + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function update($patchRequest, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($patchRequest, 'patchRequest'); + $payLoad = $patchRequest->toJSON(); + self::executeCall( + "/v1/payments/billing-plans/{$this->getId()}", + "PATCH", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * Delete a billing plan by passing the ID of the billing plan to the request URI. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function delete($apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + $patchRequest = new PatchRequest(); + $patch = new Patch(); + $value = new PayPalModel('{ + "state":"DELETED" + }'); + $patch->setOp('replace') + ->setPath('/') + ->setValue($value); + $patchRequest->addPatch($patch); + return $this->update($patchRequest, $apiContext, $restCall); + } + + /** + * List billing plans according to optional query string parameters specified. + * + * @param array $params + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return PlanList + */ + public static function all($params, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($params, 'params'); + $payLoad = ""; + $allowedParams = array( + 'page_size' => 1, + 'status' => 1, + 'page' => 1, + 'total_required' => 1 + ); + $json = self::executeCall( + "/v1/payments/billing-plans/" . "?" . http_build_query(array_intersect_key($params, $allowedParams)), + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new PlanList(); + $ret->fromJson($json); + return $ret; + } + +} diff --git a/paypal/PayPal/Api/PlanList.php b/paypal/PayPal/Api/PlanList.php new file mode 100644 index 0000000..495599b --- /dev/null +++ b/paypal/PayPal/Api/PlanList.php @@ -0,0 +1,173 @@ +plans = $plans; + return $this; + } + + /** + * Array of billing plans. + * + * @return \PayPal\Api\Plan[] + */ + public function getPlans() + { + return $this->plans; + } + + /** + * Append Plans to the list. + * + * @param \PayPal\Api\Plan $plan + * @return $this + */ + public function addPlan($plan) + { + if (!$this->getPlans()) { + return $this->setPlans(array($plan)); + } else { + return $this->setPlans( + array_merge($this->getPlans(), array($plan)) + ); + } + } + + /** + * Remove Plans from the list. + * + * @param \PayPal\Api\Plan $plan + * @return $this + */ + public function removePlan($plan) + { + return $this->setPlans( + array_diff($this->getPlans(), array($plan)) + ); + } + + /** + * Total number of items. + * + * @param string $total_items + * + * @return $this + */ + public function setTotalItems($total_items) + { + $this->total_items = $total_items; + return $this; + } + + /** + * Total number of items. + * + * @return string + */ + public function getTotalItems() + { + return $this->total_items; + } + + /** + * Total number of pages. + * + * @param string $total_pages + * + * @return $this + */ + public function setTotalPages($total_pages) + { + $this->total_pages = $total_pages; + return $this; + } + + /** + * Total number of pages. + * + * @return string + */ + public function getTotalPages() + { + return $this->total_pages; + } + + /** + * Sets Links + * + * @param \PayPal\Api\Links[] $links + * + * @return $this + */ + public function setLinks($links) + { + $this->links = $links; + return $this; + } + + /** + * Gets Links + * + * @return \PayPal\Api\Links[] + */ + public function getLinks() + { + return $this->links; + } + + /** + * Append Links to the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function addLink($links) + { + if (!$this->getLinks()) { + return $this->setLinks(array($links)); + } else { + return $this->setLinks( + array_merge($this->getLinks(), array($links)) + ); + } + } + + /** + * Remove Links from the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function removeLink($links) + { + return $this->setLinks( + array_diff($this->getLinks(), array($links)) + ); + } + +} diff --git a/paypal/PayPal/Api/PotentialPayerInfo.php b/paypal/PayPal/Api/PotentialPayerInfo.php new file mode 100644 index 0000000..63254cf --- /dev/null +++ b/paypal/PayPal/Api/PotentialPayerInfo.php @@ -0,0 +1,109 @@ +email = $email; + return $this; + } + + /** + * Email address representing the potential payer. + * @deprecated Not publicly available + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * ExternalRememberMe id representing the potential payer + * @deprecated Not publicly available + * @param string $external_remember_me_id + * + * @return $this + */ + public function setExternalRememberMeId($external_remember_me_id) + { + $this->external_remember_me_id = $external_remember_me_id; + return $this; + } + + /** + * ExternalRememberMe id representing the potential payer + * @deprecated Not publicly available + * @return string + */ + public function getExternalRememberMeId() + { + return $this->external_remember_me_id; + } + + /** + * Account Number representing the potential payer + * @deprecated Not publicly available + * @param string $account_number + * + * @return $this + */ + public function setAccountNumber($account_number) + { + $this->account_number = $account_number; + return $this; + } + + /** + * Account Number representing the potential payer + * @deprecated Not publicly available + * @return string + */ + public function getAccountNumber() + { + return $this->account_number; + } + + /** + * Billing address of the potential payer. + * @deprecated Not publicly available + * @param \PayPal\Api\Address $billing_address + * + * @return $this + */ + public function setBillingAddress($billing_address) + { + $this->billing_address = $billing_address; + return $this; + } + + /** + * Billing address of the potential payer. + * @deprecated Not publicly available + * @return \PayPal\Api\Address + */ + public function getBillingAddress() + { + return $this->billing_address; + } + +} diff --git a/paypal/PayPal/Api/Presentation.php b/paypal/PayPal/Api/Presentation.php new file mode 100644 index 0000000..95c13a3 --- /dev/null +++ b/paypal/PayPal/Api/Presentation.php @@ -0,0 +1,137 @@ +brand_name = $brand_name; + return $this; + } + + /** + * A label that overrides the business name in the PayPal account on the PayPal pages. Character length and limitations: 127 single-byte alphanumeric characters. + * + * @return string + */ + public function getBrandName() + { + return $this->brand_name; + } + + /** + * A URL to the logo image. A valid media type is `.gif`, `.jpg`, or `.png`. The maximum width of the image is 190 pixels. The maximum height of the image is 60 pixels. PayPal crops images that are larger. PayPal places your logo image at the top of the cart review area. PayPal recommends that you store the image on a secure (HTTPS) server. Otherwise, web browsers display a message that checkout pages contain non-secure items. Character length and limit: 127 single-byte alphanumeric characters. + * + * @param string $logo_image + * + * @return $this + */ + public function setLogoImage($logo_image) + { + $this->logo_image = $logo_image; + return $this; + } + + /** + * A URL to the logo image. A valid media type is `.gif`, `.jpg`, or `.png`. The maximum width of the image is 190 pixels. The maximum height of the image is 60 pixels. PayPal crops images that are larger. PayPal places your logo image at the top of the cart review area. PayPal recommends that you store the image on a secure (HTTPS) server. Otherwise, web browsers display a message that checkout pages contain non-secure items. Character length and limit: 127 single-byte alphanumeric characters. + * + * @return string + */ + public function getLogoImage() + { + return $this->logo_image; + } + + /** + * The locale of pages displayed by PayPal payment experience. A valid value is `AU`, `AT`, `BE`, `BR`, `CA`, `CH`, `CN`, `DE`, `ES`, `GB`, `FR`, `IT`, `NL`, `PL`, `PT`, `RU`, or `US`. A 5-character code is also valid for languages in specific countries: `da_DK`, `he_IL`, `id_ID`, `ja_JP`, `no_NO`, `pt_BR`, `ru_RU`, `sv_SE`, `th_TH`, `zh_CN`, `zh_HK`, or `zh_TW`. + * + * @param string $locale_code + * + * @return $this + */ + public function setLocaleCode($locale_code) + { + $this->locale_code = $locale_code; + return $this; + } + + /** + * The locale of pages displayed by PayPal payment experience. A valid value is `AU`, `AT`, `BE`, `BR`, `CA`, `CH`, `CN`, `DE`, `ES`, `GB`, `FR`, `IT`, `NL`, `PL`, `PT`, `RU`, or `US`. A 5-character code is also valid for languages in specific countries: `da_DK`, `he_IL`, `id_ID`, `ja_JP`, `no_NO`, `pt_BR`, `ru_RU`, `sv_SE`, `th_TH`, `zh_CN`, `zh_HK`, or `zh_TW`. + * + * @return string + */ + public function getLocaleCode() + { + return $this->locale_code; + } + + /** + * A label to use as hypertext for the return to merchant link. + * + * @param string $return_url_label + * + * @return $this + */ + public function setReturnUrlLabel($return_url_label) + { + $this->return_url_label = $return_url_label; + return $this; + } + + /** + * A label to use as hypertext for the return to merchant link. + * + * @return string + */ + public function getReturnUrlLabel() + { + return $this->return_url_label; + } + + /** + * A label to use as the title for the note to seller field. Used only when `allow_note` is `1`. + * + * @param string $note_to_seller_label + * + * @return $this + */ + public function setNoteToSellerLabel($note_to_seller_label) + { + $this->note_to_seller_label = $note_to_seller_label; + return $this; + } + + /** + * A label to use as the title for the note to seller field. Used only when `allow_note` is `1`. + * + * @return string + */ + public function getNoteToSellerLabel() + { + return $this->note_to_seller_label; + } + +} diff --git a/paypal/PayPal/Api/PrivateLabelCard.php b/paypal/PayPal/Api/PrivateLabelCard.php new file mode 100644 index 0000000..385a1cc --- /dev/null +++ b/paypal/PayPal/Api/PrivateLabelCard.php @@ -0,0 +1,137 @@ +id = $id; + return $this; + } + + /** + * encrypted identifier of the private label card instrument. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * last 4 digits of the card number. + * + * @param string $card_number + * + * @return $this + */ + public function setCardNumber($card_number) + { + $this->card_number = $card_number; + return $this; + } + + /** + * last 4 digits of the card number. + * + * @return string + */ + public function getCardNumber() + { + return $this->card_number; + } + + /** + * Merchants providing private label store cards have associated issuer account. This value indicates encrypted account number of the associated issuer account. + * + * @param string $issuer_id + * + * @return $this + */ + public function setIssuerId($issuer_id) + { + $this->issuer_id = $issuer_id; + return $this; + } + + /** + * Merchants providing private label store cards have associated issuer account. This value indicates encrypted account number of the associated issuer account. + * + * @return string + */ + public function getIssuerId() + { + return $this->issuer_id; + } + + /** + * Merchants providing private label store cards have associated issuer account. This value indicates name on the issuer account. + * + * @param string $issuer_name + * + * @return $this + */ + public function setIssuerName($issuer_name) + { + $this->issuer_name = $issuer_name; + return $this; + } + + /** + * Merchants providing private label store cards have associated issuer account. This value indicates name on the issuer account. + * + * @return string + */ + public function getIssuerName() + { + return $this->issuer_name; + } + + /** + * This value indicates URL to access PLCC program logo image + * + * @param string $image_key + * + * @return $this + */ + public function setImageKey($image_key) + { + $this->image_key = $image_key; + return $this; + } + + /** + * This value indicates URL to access PLCC program logo image + * + * @return string + */ + public function getImageKey() + { + return $this->image_key; + } + +} diff --git a/paypal/PayPal/Api/ProcessorResponse.php b/paypal/PayPal/Api/ProcessorResponse.php new file mode 100644 index 0000000..9b903dc --- /dev/null +++ b/paypal/PayPal/Api/ProcessorResponse.php @@ -0,0 +1,162 @@ +response_code = $response_code; + return $this; + } + + /** + * Paypal normalized response code, generated from the processor's specific response code + * + * @return string + */ + public function getResponseCode() + { + return $this->response_code; + } + + /** + * Address Verification System response code. https://developer.paypal.com/docs/classic/api/AVSResponseCodes/ + * + * @param string $avs_code + * + * @return $this + */ + public function setAvsCode($avs_code) + { + $this->avs_code = $avs_code; + return $this; + } + + /** + * Address Verification System response code. https://developer.paypal.com/docs/classic/api/AVSResponseCodes/ + * + * @return string + */ + public function getAvsCode() + { + return $this->avs_code; + } + + /** + * CVV System response code. https://developer.paypal.com/docs/classic/api/AVSResponseCodes/ + * + * @param string $cvv_code + * + * @return $this + */ + public function setCvvCode($cvv_code) + { + $this->cvv_code = $cvv_code; + return $this; + } + + /** + * CVV System response code. https://developer.paypal.com/docs/classic/api/AVSResponseCodes/ + * + * @return string + */ + public function getCvvCode() + { + return $this->cvv_code; + } + + /** + * Provides merchant advice on how to handle declines related to recurring payments + * 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"] + * + * @param string $advice_code + * + * @return $this + */ + public function setAdviceCode($advice_code) + { + $this->advice_code = $advice_code; + return $this; + } + + /** + * Provides merchant advice on how to handle declines related to recurring payments + * + * @return string + */ + public function getAdviceCode() + { + return $this->advice_code; + } + + /** + * Response back from the authorization. Provided by the processor + * + * @param string $eci_submitted + * + * @return $this + */ + public function setEciSubmitted($eci_submitted) + { + $this->eci_submitted = $eci_submitted; + return $this; + } + + /** + * Response back from the authorization. Provided by the processor + * + * @return string + */ + public function getEciSubmitted() + { + return $this->eci_submitted; + } + + /** + * Visa Payer Authentication Service status. Will be return from processor + * + * @param string $vpas + * + * @return $this + */ + public function setVpas($vpas) + { + $this->vpas = $vpas; + return $this; + } + + /** + * Visa Payer Authentication Service status. Will be return from processor + * + * @return string + */ + public function getVpas() + { + return $this->vpas; + } + +} diff --git a/paypal/PayPal/Api/RecipientBankingInstruction.php b/paypal/PayPal/Api/RecipientBankingInstruction.php new file mode 100644 index 0000000..9c2fd0d --- /dev/null +++ b/paypal/PayPal/Api/RecipientBankingInstruction.php @@ -0,0 +1,161 @@ +bank_name = $bank_name; + return $this; + } + + /** + * Name of the financial institution. + * + * @return string + */ + public function getBankName() + { + return $this->bank_name; + } + + /** + * Name of the account holder + * + * @param string $account_holder_name + * + * @return $this + */ + public function setAccountHolderName($account_holder_name) + { + $this->account_holder_name = $account_holder_name; + return $this; + } + + /** + * Name of the account holder + * + * @return string + */ + public function getAccountHolderName() + { + return $this->account_holder_name; + } + + /** + * bank account number + * + * @param string $account_number + * + * @return $this + */ + public function setAccountNumber($account_number) + { + $this->account_number = $account_number; + return $this; + } + + /** + * bank account number + * + * @return string + */ + public function getAccountNumber() + { + return $this->account_number; + } + + /** + * bank routing number + * + * @param string $routing_number + * + * @return $this + */ + public function setRoutingNumber($routing_number) + { + $this->routing_number = $routing_number; + return $this; + } + + /** + * bank routing number + * + * @return string + */ + public function getRoutingNumber() + { + return $this->routing_number; + } + + /** + * IBAN equivalent of the bank + * + * @param string $international_bank_account_number + * + * @return $this + */ + public function setInternationalBankAccountNumber($international_bank_account_number) + { + $this->international_bank_account_number = $international_bank_account_number; + return $this; + } + + /** + * IBAN equivalent of the bank + * + * @return string + */ + public function getInternationalBankAccountNumber() + { + return $this->international_bank_account_number; + } + + /** + * BIC identifier of the financial institution + * + * @param string $bank_identifier_code + * + * @return $this + */ + public function setBankIdentifierCode($bank_identifier_code) + { + $this->bank_identifier_code = $bank_identifier_code; + return $this; + } + + /** + * BIC identifier of the financial institution + * + * @return string + */ + public function getBankIdentifierCode() + { + return $this->bank_identifier_code; + } + +} diff --git a/paypal/PayPal/Api/RedirectUrls.php b/paypal/PayPal/Api/RedirectUrls.php new file mode 100644 index 0000000..5c97ba4 --- /dev/null +++ b/paypal/PayPal/Api/RedirectUrls.php @@ -0,0 +1,68 @@ +return_url = $return_url; + return $this; + } + + /** + * Url where the payer would be redirected to after approving the payment. **Required for PayPal account payments.** + * + * @return string + */ + public function getReturnUrl() + { + return $this->return_url; + } + + /** + * Url where the payer would be redirected to after canceling the payment. **Required for PayPal account payments.** + * + * @param string $cancel_url + * @throws \InvalidArgumentException + * @return $this + */ + public function setCancelUrl($cancel_url) + { + UrlValidator::validate($cancel_url, "CancelUrl"); + $this->cancel_url = $cancel_url; + return $this; + } + + /** + * Url where the payer would be redirected to after canceling the payment. **Required for PayPal account payments.** + * + * @return string + */ + public function getCancelUrl() + { + return $this->cancel_url; + } + +} diff --git a/paypal/PayPal/Api/Refund.php b/paypal/PayPal/Api/Refund.php new file mode 100644 index 0000000..c008f17 --- /dev/null +++ b/paypal/PayPal/Api/Refund.php @@ -0,0 +1,335 @@ +id = $id; + return $this; + } + + /** + * ID of the refund transaction. 17 characters max. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Details including both refunded amount (to payer) and refunded fee (to payee). 10 characters max. + * + * @param \PayPal\Api\Amount $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * Details including both refunded amount (to payer) and refunded fee (to payee). 10 characters max. + * + * @return \PayPal\Api\Amount + */ + public function getAmount() + { + return $this->amount; + } + + /** + * State of the refund. + * Valid Values: ["pending", "completed", "failed"] + * + * @param string $state + * + * @return $this + */ + public function setState($state) + { + $this->state = $state; + return $this; + } + + /** + * State of the refund. + * + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * Reason description for the Sale transaction being refunded. + * + * @param string $reason + * + * @return $this + */ + public function setReason($reason) + { + $this->reason = $reason; + return $this; + } + + /** + * Reason description for the Sale transaction being refunded. + * + * @return string + */ + public function getReason() + { + return $this->reason; + } + + /** + * Your own invoice or tracking ID number. Character length and limitations: 127 single-byte alphanumeric characters. + * + * @param string $invoice_number + * + * @return $this + */ + public function setInvoiceNumber($invoice_number) + { + $this->invoice_number = $invoice_number; + return $this; + } + + /** + * Your own invoice or tracking ID number. Character length and limitations: 127 single-byte alphanumeric characters. + * + * @return string + */ + public function getInvoiceNumber() + { + return $this->invoice_number; + } + + /** + * ID of the Sale transaction being refunded. + * + * @param string $sale_id + * + * @return $this + */ + public function setSaleId($sale_id) + { + $this->sale_id = $sale_id; + return $this; + } + + /** + * ID of the Sale transaction being refunded. + * + * @return string + */ + public function getSaleId() + { + return $this->sale_id; + } + + /** + * ID of the sale transaction being refunded. + * + * @param string $capture_id + * + * @return $this + */ + public function setCaptureId($capture_id) + { + $this->capture_id = $capture_id; + return $this; + } + + /** + * ID of the sale transaction being refunded. + * + * @return string + */ + public function getCaptureId() + { + return $this->capture_id; + } + + /** + * ID of the payment resource on which this transaction is based. + * + * @param string $parent_payment + * + * @return $this + */ + public function setParentPayment($parent_payment) + { + $this->parent_payment = $parent_payment; + return $this; + } + + /** + * ID of the payment resource on which this transaction is based. + * + * @return string + */ + public function getParentPayment() + { + return $this->parent_payment; + } + + /** + * Description of what is being refunded for. + * + * @param string $description + * + * @return $this + */ + public function setDescription($description) + { + $this->description = $description; + return $this; + } + + /** + * Description of what is being refunded for. + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Time of refund as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @param string $create_time + * + * @return $this + */ + public function setCreateTime($create_time) + { + $this->create_time = $create_time; + return $this; + } + + /** + * Time of refund as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return string + */ + public function getCreateTime() + { + return $this->create_time; + } + + /** + * Time that the resource was last updated. + * + * @param string $update_time + * + * @return $this + */ + public function setUpdateTime($update_time) + { + $this->update_time = $update_time; + return $this; + } + + /** + * Time that the resource was last updated. + * + * @return string + */ + public function getUpdateTime() + { + return $this->update_time; + } + + /** + * The reason code for the refund state being pending + * Valid Values: ["ECHECK"] + * + * @param string $reason_code + * + * @return $this + */ + public function setReasonCode($reason_code) + { + $this->reason_code = $reason_code; + return $this; + } + + /** + * The reason code for the refund state being pending + * + * @return string + */ + public function getReasonCode() + { + return $this->reason_code; + } + + /** + * Shows details for a refund, by ID. + * + * @param string $refundId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Refund + */ + public static function get($refundId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($refundId, 'refundId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/payments/refund/$refundId", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new Refund(); + $ret->fromJson($json); + return $ret; + } + +} diff --git a/paypal/PayPal/Api/RefundDetail.php b/paypal/PayPal/Api/RefundDetail.php new file mode 100644 index 0000000..7674ec1 --- /dev/null +++ b/paypal/PayPal/Api/RefundDetail.php @@ -0,0 +1,138 @@ +type = $type; + return $this; + } + + /** + * The PayPal refund type. Indicates whether refund was paid in invoicing flow through PayPal or externally. In the case of mark-as-refunded API, the supported refund type is `EXTERNAL`. For backward compatability, the `PAYPAL` refund type is still supported. + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * The PayPal refund transaction ID. Required with the `PAYPAL` refund type. + * + * @param string $transaction_id + * + * @return $this + */ + public function setTransactionId($transaction_id) + { + $this->transaction_id = $transaction_id; + return $this; + } + + /** + * The PayPal refund transaction ID. Required with the `PAYPAL` refund type. + * + * @return string + */ + public function getTransactionId() + { + return $this->transaction_id; + } + + /** + * Date on which the invoice was refunded. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST. + * + * @param string $date + * + * @return $this + */ + public function setDate($date) + { + $this->date = $date; + return $this; + } + + /** + * Date on which the invoice was refunded. Date format: yyyy-MM-dd z. For example, 2014-02-27 PST. + * + * @return string + */ + public function getDate() + { + return $this->date; + } + + /** + * Optional note associated with the refund. + * + * @param string $note + * + * @return $this + */ + public function setNote($note) + { + $this->note = $note; + return $this; + } + + /** + * Optional note associated with the refund. + * + * @return string + */ + public function getNote() + { + return $this->note; + } + + /** + * Amount to be recorded as refund against invoice. If this field is not passed, the total invoice paid amount is recorded as refund. + * + * @param \PayPal\Api\Currency $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * Amount to be recorded as refund against invoice. If this field is not passed, the total invoice paid amount is recorded as refund. + * + * @return \PayPal\Api\Currency + */ + public function getAmount() + { + return $this->amount; + } + +} diff --git a/paypal/PayPal/Api/RefundRequest.php b/paypal/PayPal/Api/RefundRequest.php new file mode 100644 index 0000000..1fdaa95 --- /dev/null +++ b/paypal/PayPal/Api/RefundRequest.php @@ -0,0 +1,162 @@ +amount = $amount; + return $this; + } + + /** + * Details including both refunded amount (to payer) and refunded fee (to payee). + * + * @return \PayPal\Api\Amount + */ + public function getAmount() + { + return $this->amount; + } + + /** + * Description of what is being refunded for. Character length and limitations: 255 single-byte alphanumeric characters. + * + * @param string $description + * + * @return $this + */ + public function setDescription($description) + { + $this->description = $description; + return $this; + } + + /** + * Description of what is being refunded for. Character length and limitations: 255 single-byte alphanumeric characters. + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Type of PayPal funding source (balance or eCheck) that can be used for auto refund. + * Valid Values: ["INSTANT_FUNDING_SOURCE", "ECHECK", "UNRESTRICTED"] + * + * @param string $refund_source + * + * @return $this + */ + public function setRefundSource($refund_source) + { + $this->refund_source = $refund_source; + return $this; + } + + /** + * Type of PayPal funding source (balance or eCheck) that can be used for auto refund. + * + * @return string + */ + public function getRefundSource() + { + return $this->refund_source; + } + + /** + * Reason description for the Sale transaction being refunded. + * + * @param string $reason + * + * @return $this + */ + public function setReason($reason) + { + $this->reason = $reason; + return $this; + } + + /** + * Reason description for the Sale transaction being refunded. + * + * @return string + */ + public function getReason() + { + return $this->reason; + } + + /** + * The invoice number that is used to track this payment. Character length and limitations: 127 single-byte alphanumeric characters. + * + * @param string $invoice_number + * + * @return $this + */ + public function setInvoiceNumber($invoice_number) + { + $this->invoice_number = $invoice_number; + return $this; + } + + /** + * The invoice number that is used to track this payment. Character length and limitations: 127 single-byte alphanumeric characters. + * + * @return string + */ + public function getInvoiceNumber() + { + return $this->invoice_number; + } + + /** + * Flag to indicate that the buyer was already given store credit for a given transaction. + * + * @param bool $refund_advice + * + * @return $this + */ + public function setRefundAdvice($refund_advice) + { + $this->refund_advice = $refund_advice; + return $this; + } + + /** + * Flag to indicate that the buyer was already given store credit for a given transaction. + * + * @return bool + */ + public function getRefundAdvice() + { + return $this->refund_advice; + } + +} diff --git a/paypal/PayPal/Api/RelatedResources.php b/paypal/PayPal/Api/RelatedResources.php new file mode 100644 index 0000000..d324841 --- /dev/null +++ b/paypal/PayPal/Api/RelatedResources.php @@ -0,0 +1,137 @@ +sale = $sale; + return $this; + } + + /** + * Sale transaction + * + * @return \PayPal\Api\Sale + */ + public function getSale() + { + return $this->sale; + } + + /** + * Authorization transaction + * + * @param \PayPal\Api\Authorization $authorization + * + * @return $this + */ + public function setAuthorization($authorization) + { + $this->authorization = $authorization; + return $this; + } + + /** + * Authorization transaction + * + * @return \PayPal\Api\Authorization + */ + public function getAuthorization() + { + return $this->authorization; + } + + /** + * Order transaction + * + * @param \PayPal\Api\Order $order + * + * @return $this + */ + public function setOrder($order) + { + $this->order = $order; + return $this; + } + + /** + * Order transaction + * + * @return \PayPal\Api\Order + */ + public function getOrder() + { + return $this->order; + } + + /** + * Capture transaction + * + * @param \PayPal\Api\Capture $capture + * + * @return $this + */ + public function setCapture($capture) + { + $this->capture = $capture; + return $this; + } + + /** + * Capture transaction + * + * @return \PayPal\Api\Capture + */ + public function getCapture() + { + return $this->capture; + } + + /** + * Refund transaction + * + * @param \PayPal\Api\Refund $refund + * + * @return $this + */ + public function setRefund($refund) + { + $this->refund = $refund; + return $this; + } + + /** + * Refund transaction + * + * @return \PayPal\Api\Refund + */ + public function getRefund() + { + return $this->refund; + } + +} diff --git a/paypal/PayPal/Api/Sale.php b/paypal/PayPal/Api/Sale.php new file mode 100644 index 0000000..1c4cb28 --- /dev/null +++ b/paypal/PayPal/Api/Sale.php @@ -0,0 +1,637 @@ +id = $id; + return $this; + } + + /** + * Identifier of the sale transaction. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Identifier to the purchase or transaction unit corresponding to this sale transaction. + * + * @param string $purchase_unit_reference_id + * + * @return $this + */ + public function setPurchaseUnitReferenceId($purchase_unit_reference_id) + { + $this->purchase_unit_reference_id = $purchase_unit_reference_id; + return $this; + } + + /** + * Identifier to the purchase or transaction unit corresponding to this sale transaction. + * + * @return string + */ + public function getPurchaseUnitReferenceId() + { + return $this->purchase_unit_reference_id; + } + + /** + * Amount being collected. + * + * @param \PayPal\Api\Amount $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * Amount being collected. + * + * @return \PayPal\Api\Amount + */ + public function getAmount() + { + return $this->amount; + } + + /** + * Specifies payment mode of the transaction. Only supported when the `payment_method` is set to `paypal`. + * Valid Values: ["INSTANT_TRANSFER", "MANUAL_BANK_TRANSFER", "DELAYED_TRANSFER", "ECHECK"] + * + * @param string $payment_mode + * + * @return $this + */ + public function setPaymentMode($payment_mode) + { + $this->payment_mode = $payment_mode; + return $this; + } + + /** + * Specifies payment mode of the transaction. Only supported when the `payment_method` is set to `paypal`. + * + * @return string + */ + public function getPaymentMode() + { + return $this->payment_mode; + } + + /** + * State of the sale transaction. + * Valid Values: ["completed", "partially_refunded", "pending", "refunded", "denied"] + * + * @param string $state + * + * @return $this + */ + public function setState($state) + { + $this->state = $state; + return $this; + } + + /** + * State of the sale transaction. + * + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * Reason code for the transaction state being Pending or Reversed. Only supported when the `payment_method` is set to `paypal`. + * 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", "TRANSACTION_APPROVED_AWAITING_FUNDING"] + * + * @param string $reason_code + * + * @return $this + */ + public function setReasonCode($reason_code) + { + $this->reason_code = $reason_code; + return $this; + } + + /** + * Reason code for the transaction state being Pending or Reversed. Only supported when the `payment_method` is set to `paypal`. + * + * @return string + */ + public function getReasonCode() + { + return $this->reason_code; + } + + /** + * The level of seller protection in force for the transaction. Only supported when the `payment_method` is set to `paypal`. + * Valid Values: ["ELIGIBLE", "PARTIALLY_ELIGIBLE", "INELIGIBLE"] + * + * @param string $protection_eligibility + * + * @return $this + */ + public function setProtectionEligibility($protection_eligibility) + { + $this->protection_eligibility = $protection_eligibility; + return $this; + } + + /** + * The level of seller protection in force for the transaction. Only supported when the `payment_method` is set to `paypal`. + * + * @return string + */ + public function getProtectionEligibility() + { + return $this->protection_eligibility; + } + + /** + * 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`. + * Valid Values: ["ITEM_NOT_RECEIVED_ELIGIBLE", "UNAUTHORIZED_PAYMENT_ELIGIBLE", "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE"] + * + * @param string $protection_eligibility_type + * + * @return $this + */ + public function setProtectionEligibilityType($protection_eligibility_type) + { + $this->protection_eligibility_type = $protection_eligibility_type; + return $this; + } + + /** + * 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`. + * + * @return string + */ + public function getProtectionEligibilityType() + { + return $this->protection_eligibility_type; + } + + /** + * Expected clearing time for eCheck Transactions. Returned when payment is made with eCheck. Only supported when the `payment_method` is set to `paypal`. + * + * @param string $clearing_time + * + * @return $this + */ + public function setClearingTime($clearing_time) + { + $this->clearing_time = $clearing_time; + return $this; + } + + /** + * Expected clearing time for eCheck Transactions. Returned when payment is made with eCheck. Only supported when the `payment_method` is set to `paypal`. + * + * @return string + */ + public function getClearingTime() + { + return $this->clearing_time; + } + + /** + * Status of the Recipient Fund. For now, it will be returned only when fund status is held + * Valid Values: ["HELD"] + * + * @param string $payment_hold_status + * + * @return $this + */ + public function setPaymentHoldStatus($payment_hold_status) + { + $this->payment_hold_status = $payment_hold_status; + return $this; + } + + /** + * Status of the Recipient Fund. For now, it will be returned only when fund status is held + * + * @return string + */ + public function getPaymentHoldStatus() + { + return $this->payment_hold_status; + } + + /** + * Reasons for PayPal holding recipient fund. It is set only if payment hold status is held + * + * @param string[] $payment_hold_reasons + * + * @return $this + */ + public function setPaymentHoldReasons($payment_hold_reasons) + { + $this->payment_hold_reasons = $payment_hold_reasons; + return $this; + } + + /** + * Reasons for PayPal holding recipient fund. It is set only if payment hold status is held + * + * @return string[] + */ + public function getPaymentHoldReasons() + { + return $this->payment_hold_reasons; + } + + /** + * Append PaymentHoldReasons to the list. + * + * @param string $string + * @return $this + */ + public function addPaymentHoldReason($string) + { + if (!$this->getPaymentHoldReasons()) { + return $this->setPaymentHoldReasons(array($string)); + } else { + return $this->setPaymentHoldReasons( + array_merge($this->getPaymentHoldReasons(), array($string)) + ); + } + } + + /** + * Remove PaymentHoldReasons from the list. + * + * @param string $string + * @return $this + */ + public function removePaymentHoldReason($string) + { + return $this->setPaymentHoldReasons( + array_diff($this->getPaymentHoldReasons(), array($string)) + ); + } + + /** + * Transaction fee applicable for this payment. + * + * @param \PayPal\Api\Currency $transaction_fee + * + * @return $this + */ + public function setTransactionFee($transaction_fee) + { + $this->transaction_fee = $transaction_fee; + return $this; + } + + /** + * Transaction fee applicable for this payment. + * + * @return \PayPal\Api\Currency + */ + public function getTransactionFee() + { + return $this->transaction_fee; + } + + /** + * 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. + * + * @param \PayPal\Api\Currency $receivable_amount + * + * @return $this + */ + public function setReceivableAmount($receivable_amount) + { + $this->receivable_amount = $receivable_amount; + return $this; + } + + /** + * 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. + * + * @return \PayPal\Api\Currency + */ + public function getReceivableAmount() + { + return $this->receivable_amount; + } + + /** + * 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. + * + * @param string $exchange_rate + * + * @return $this + */ + public function setExchangeRate($exchange_rate) + { + $this->exchange_rate = $exchange_rate; + return $this; + } + + /** + * 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. + * + * @return string + */ + public function getExchangeRate() + { + return $this->exchange_rate; + } + + /** + * 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. + * + * @param \PayPal\Api\FmfDetails $fmf_details + * + * @return $this + */ + public function setFmfDetails($fmf_details) + { + $this->fmf_details = $fmf_details; + return $this; + } + + /** + * 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. + * + * @return \PayPal\Api\FmfDetails + */ + public function getFmfDetails() + { + return $this->fmf_details; + } + + /** + * Receipt id is a payment identification number returned for guest users to identify the payment. + * + * @param string $receipt_id + * + * @return $this + */ + public function setReceiptId($receipt_id) + { + $this->receipt_id = $receipt_id; + return $this; + } + + /** + * Receipt id is a payment identification number returned for guest users to identify the payment. + * + * @return string + */ + public function getReceiptId() + { + return $this->receipt_id; + } + + /** + * ID of the payment resource on which this transaction is based. + * + * @param string $parent_payment + * + * @return $this + */ + public function setParentPayment($parent_payment) + { + $this->parent_payment = $parent_payment; + return $this; + } + + /** + * ID of the payment resource on which this transaction is based. + * + * @return string + */ + public function getParentPayment() + { + return $this->parent_payment; + } + + /** + * Response codes returned by the processor concerning the submitted payment. Only supported when the `payment_method` is set to `credit_card`. + * + * @param \PayPal\Api\ProcessorResponse $processor_response + * + * @return $this + */ + public function setProcessorResponse($processor_response) + { + $this->processor_response = $processor_response; + return $this; + } + + /** + * Response codes returned by the processor concerning the submitted payment. Only supported when the `payment_method` is set to `credit_card`. + * + * @return \PayPal\Api\ProcessorResponse + */ + public function getProcessorResponse() + { + return $this->processor_response; + } + + /** + * ID of the billing agreement used as reference to execute this transaction. + * + * @param string $billing_agreement_id + * + * @return $this + */ + public function setBillingAgreementId($billing_agreement_id) + { + $this->billing_agreement_id = $billing_agreement_id; + return $this; + } + + /** + * ID of the billing agreement used as reference to execute this transaction. + * + * @return string + */ + public function getBillingAgreementId() + { + return $this->billing_agreement_id; + } + + /** + * Time of sale as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6) + * + * @param string $create_time + * + * @return $this + */ + public function setCreateTime($create_time) + { + $this->create_time = $create_time; + return $this; + } + + /** + * Time of sale as defined in [RFC 3339 Section 5.6](http://tools.ietf.org/html/rfc3339#section-5.6) + * + * @return string + */ + public function getCreateTime() + { + return $this->create_time; + } + + /** + * Time the resource was last updated in UTC ISO8601 format. + * + * @param string $update_time + * + * @return $this + */ + public function setUpdateTime($update_time) + { + $this->update_time = $update_time; + return $this; + } + + /** + * Time the resource was last updated in UTC ISO8601 format. + * + * @return string + */ + public function getUpdateTime() + { + return $this->update_time; + } + + /** + * Shows details for a sale, by ID. Returns only sales that were created through the REST API. + * + * @param string $saleId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Sale + */ + public static function get($saleId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($saleId, 'saleId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/payments/sale/$saleId", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new Sale(); + $ret->fromJson($json); + return $ret; + } + + /** + * 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. + * + * @deprecated Please use #refundSale instead. + * @param Refund $refund + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Refund + */ + public function refund($refund, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($refund, 'refund'); + $payLoad = $refund->toJSON(); + $json = self::executeCall( + "/v1/payments/sale/{$this->getId()}/refund", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new Refund(); + $ret->fromJson($json); + return $ret; + } + + /** + * Refunds a sale, by ID. For a full refund, include an empty payload in the JSON request body. For a partial refund, include an `amount` object in the JSON request body. + * + * @param RefundRequest $refundRequest + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return DetailedRefund + */ + public function refundSale($refundRequest, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($refundRequest, 'refundRequest'); + $payLoad = $refundRequest->toJSON(); + $json = self::executeCall( + "/v1/payments/sale/{$this->getId()}/refund", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new DetailedRefund(); + $ret->fromJson($json); + return $ret; + } +} diff --git a/paypal/PayPal/Api/Search.php b/paypal/PayPal/Api/Search.php new file mode 100644 index 0000000..333d99d --- /dev/null +++ b/paypal/PayPal/Api/Search.php @@ -0,0 +1,498 @@ +email = $email; + return $this; + } + + /** + * The initial letters of the email address. + * + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * The initial letters of the recipient's first name. + * + * @param string $recipient_first_name + * + * @return $this + */ + public function setRecipientFirstName($recipient_first_name) + { + $this->recipient_first_name = $recipient_first_name; + return $this; + } + + /** + * The initial letters of the recipient's first name. + * + * @return string + */ + public function getRecipientFirstName() + { + return $this->recipient_first_name; + } + + /** + * The initial letters of the recipient's last name. + * + * @param string $recipient_last_name + * + * @return $this + */ + public function setRecipientLastName($recipient_last_name) + { + $this->recipient_last_name = $recipient_last_name; + return $this; + } + + /** + * The initial letters of the recipient's last name. + * + * @return string + */ + public function getRecipientLastName() + { + return $this->recipient_last_name; + } + + /** + * The initial letters of the recipient's business name. + * + * @param string $recipient_business_name + * + * @return $this + */ + public function setRecipientBusinessName($recipient_business_name) + { + $this->recipient_business_name = $recipient_business_name; + return $this; + } + + /** + * The initial letters of the recipient's business name. + * + * @return string + */ + public function getRecipientBusinessName() + { + return $this->recipient_business_name; + } + + /** + * The invoice number. + * + * @param string $number + * + * @return $this + */ + public function setNumber($number) + { + $this->number = $number; + return $this; + } + + /** + * The invoice number. + * + * @return string + */ + public function getNumber() + { + return $this->number; + } + + /** + * The invoice status. + * Valid Values: ["DRAFT", "SENT", "PAID", "MARKED_AS_PAID", "CANCELLED", "REFUNDED", "PARTIALLY_REFUNDED", "MARKED_AS_REFUNDED"] + * + * @param string $status + * + * @return $this + */ + public function setStatus($status) + { + $this->status = $status; + return $this; + } + + /** + * The invoice status. + * + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * The lower limit of the total amount. + * + * @param \PayPal\Api\Currency $lower_total_amount + * + * @return $this + */ + public function setLowerTotalAmount($lower_total_amount) + { + $this->lower_total_amount = $lower_total_amount; + return $this; + } + + /** + * The lower limit of the total amount. + * + * @return \PayPal\Api\Currency + */ + public function getLowerTotalAmount() + { + return $this->lower_total_amount; + } + + /** + * The upper limit of total amount. + * + * @param \PayPal\Api\Currency $upper_total_amount + * + * @return $this + */ + public function setUpperTotalAmount($upper_total_amount) + { + $this->upper_total_amount = $upper_total_amount; + return $this; + } + + /** + * The upper limit of total amount. + * + * @return \PayPal\Api\Currency + */ + public function getUpperTotalAmount() + { + return $this->upper_total_amount; + } + + /** + * The start date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @param string $start_invoice_date + * + * @return $this + */ + public function setStartInvoiceDate($start_invoice_date) + { + $this->start_invoice_date = $start_invoice_date; + return $this; + } + + /** + * The start date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return string + */ + public function getStartInvoiceDate() + { + return $this->start_invoice_date; + } + + /** + * The end date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @param string $end_invoice_date + * + * @return $this + */ + public function setEndInvoiceDate($end_invoice_date) + { + $this->end_invoice_date = $end_invoice_date; + return $this; + } + + /** + * The end date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return string + */ + public function getEndInvoiceDate() + { + return $this->end_invoice_date; + } + + /** + * The start due date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @param string $start_due_date + * + * @return $this + */ + public function setStartDueDate($start_due_date) + { + $this->start_due_date = $start_due_date; + return $this; + } + + /** + * The start due date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return string + */ + public function getStartDueDate() + { + return $this->start_due_date; + } + + /** + * The end due date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @param string $end_due_date + * + * @return $this + */ + public function setEndDueDate($end_due_date) + { + $this->end_due_date = $end_due_date; + return $this; + } + + /** + * The end due date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return string + */ + public function getEndDueDate() + { + return $this->end_due_date; + } + + /** + * The start payment date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @param string $start_payment_date + * + * @return $this + */ + public function setStartPaymentDate($start_payment_date) + { + $this->start_payment_date = $start_payment_date; + return $this; + } + + /** + * The start payment date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return string + */ + public function getStartPaymentDate() + { + return $this->start_payment_date; + } + + /** + * The end payment date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @param string $end_payment_date + * + * @return $this + */ + public function setEndPaymentDate($end_payment_date) + { + $this->end_payment_date = $end_payment_date; + return $this; + } + + /** + * The end payment date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return string + */ + public function getEndPaymentDate() + { + return $this->end_payment_date; + } + + /** + * The start creation date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @param string $start_creation_date + * + * @return $this + */ + public function setStartCreationDate($start_creation_date) + { + $this->start_creation_date = $start_creation_date; + return $this; + } + + /** + * The start creation date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return string + */ + public function getStartCreationDate() + { + return $this->start_creation_date; + } + + /** + * The end creation date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @param string $end_creation_date + * + * @return $this + */ + public function setEndCreationDate($end_creation_date) + { + $this->end_creation_date = $end_creation_date; + return $this; + } + + /** + * The end creation date for the invoice. Date format is *yyyy*-*MM*-*dd* *z*, as defined in [Internet Date/Time Format](http://tools.ietf.org/html/rfc3339#section-5.6). + * + * @return string + */ + public function getEndCreationDate() + { + return $this->end_creation_date; + } + + /** + * The offset for the search results. + * + * @param \PayPal\Api\number $page + * + * @return $this + */ + public function setPage($page) + { + $this->page = $page; + return $this; + } + + /** + * The offset for the search results. + * + * @return \PayPal\Api\number + */ + public function getPage() + { + return $this->page; + } + + /** + * The page size for the search results. + * + * @param \PayPal\Api\number $page_size + * + * @return $this + */ + public function setPageSize($page_size) + { + $this->page_size = $page_size; + return $this; + } + + /** + * The page size for the search results. + * + * @return \PayPal\Api\number + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Indicates whether the total count appears in the response. Default is `false`. + * + * @param bool $total_count_required + * + * @return $this + */ + public function setTotalCountRequired($total_count_required) + { + $this->total_count_required = $total_count_required; + return $this; + } + + /** + * Indicates whether the total count appears in the response. Default is `false`. + * + * @return bool + */ + public function getTotalCountRequired() + { + return $this->total_count_required; + } + + /** + * A flag indicating whether search is on invoices archived by merchant. true - returns archived / false returns unarchived / null returns all. + * + * @param bool $archived + * + * @return $this + */ + public function setArchived($archived) + { + $this->archived = $archived; + return $this; + } + + /** + * A flag indicating whether search is on invoices archived by merchant. true - returns archived / false returns unarchived / null returns all. + * + * @return bool + */ + public function getArchived() + { + return $this->archived; + } + +} diff --git a/paypal/PayPal/Api/ShippingAddress.php b/paypal/PayPal/Api/ShippingAddress.php new file mode 100644 index 0000000..c7d29f7 --- /dev/null +++ b/paypal/PayPal/Api/ShippingAddress.php @@ -0,0 +1,108 @@ +id = $id; + return $this; + } + + /** + * Address ID assigned in PayPal system. + * @deprecated Not publicly available + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Name of the recipient at this address. + * + * @param string $recipient_name + * + * @return $this + */ + public function setRecipientName($recipient_name) + { + $this->recipient_name = $recipient_name; + return $this; + } + + /** + * Name of the recipient at this address. + * + * @return string + */ + public function getRecipientName() + { + return $this->recipient_name; + } + + /** + * Default shipping address of the Payer. + * @deprecated Not publicly available + * @param bool $default_address + * + * @return $this + */ + public function setDefaultAddress($default_address) + { + $this->default_address = $default_address; + return $this; + } + + /** + * Default shipping address of the Payer. + * @deprecated Not publicly available + * @return bool + */ + public function getDefaultAddress() + { + return $this->default_address; + } + + /** + * Shipping Address marked as preferred by Payer. + * @deprecated Not publicly available + * @param bool $preferred_address + * + * @return $this + */ + public function setPreferredAddress($preferred_address) + { + $this->preferred_address = $preferred_address; + return $this; + } + + /** + * Shipping Address marked as preferred by Payer. + * @deprecated Not publicly available + * @return bool + */ + public function getPreferredAddress() + { + return $this->preferred_address; + } + +} diff --git a/paypal/PayPal/Api/ShippingCost.php b/paypal/PayPal/Api/ShippingCost.php new file mode 100644 index 0000000..96694c4 --- /dev/null +++ b/paypal/PayPal/Api/ShippingCost.php @@ -0,0 +1,65 @@ +amount = $amount; + return $this; + } + + /** + * The shipping cost, as an amount. Valid range is from 0 to 999999.99. + * + * @return \PayPal\Api\Currency + */ + public function getAmount() + { + return $this->amount; + } + + /** + * The tax percentage on the shipping amount. + * + * @param \PayPal\Api\Tax $tax + * + * @return $this + */ + public function setTax($tax) + { + $this->tax = $tax; + return $this; + } + + /** + * The tax percentage on the shipping amount. + * + * @return \PayPal\Api\Tax + */ + public function getTax() + { + return $this->tax; + } + +} diff --git a/paypal/PayPal/Api/ShippingInfo.php b/paypal/PayPal/Api/ShippingInfo.php new file mode 100644 index 0000000..f851e67 --- /dev/null +++ b/paypal/PayPal/Api/ShippingInfo.php @@ -0,0 +1,158 @@ +first_name = $first_name; + return $this; + } + + /** + * The invoice recipient first name. Maximum length is 30 characters. + * + * @return string + */ + public function getFirstName() + { + return $this->first_name; + } + + /** + * The invoice recipient last name. Maximum length is 30 characters. + * + * @param string $last_name + * + * @return $this + */ + public function setLastName($last_name) + { + $this->last_name = $last_name; + return $this; + } + + /** + * The invoice recipient last name. Maximum length is 30 characters. + * + * @return string + */ + public function getLastName() + { + return $this->last_name; + } + + /** + * The invoice recipient company business name. Maximum length is 100 characters. + * + * @param string $business_name + * + * @return $this + */ + public function setBusinessName($business_name) + { + $this->business_name = $business_name; + return $this; + } + + /** + * The invoice recipient company business name. Maximum length is 100 characters. + * + * @return string + */ + public function getBusinessName() + { + return $this->business_name; + } + + /** + * + * + * @param \PayPal\Api\Phone $phone + * @return $this + */ + public function setPhone($phone) + { + $this->phone = $phone; + return $this; + } + + /** + * + * + * @return \PayPal\Api\Phone + */ + public function getPhone() + { + return $this->phone; + } + + /** + * @deprecated Not used anymore + * + * @param string $email + * @return $this + */ + public function setEmail($email) + { + $this->email = $email; + return $this; + } + + /** + * @deprecated Not used anymore + * + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * Address of the invoice recipient. + * + * @param \PayPal\Api\InvoiceAddress $address + * + * @return $this + */ + public function setAddress($address) + { + $this->address = $address; + return $this; + } + + /** + * The invoice recipient address. + * + * @return \PayPal\Api\InvoiceAddress + */ + public function getAddress() + { + return $this->address; + } + +} diff --git a/paypal/PayPal/Api/Tax.php b/paypal/PayPal/Api/Tax.php new file mode 100644 index 0000000..e83192c --- /dev/null +++ b/paypal/PayPal/Api/Tax.php @@ -0,0 +1,117 @@ +id = $id; + return $this; + } + + /** + * The resource ID. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * The tax name. Maximum length is 20 characters. + * + * @param string $name + * + * @return $this + */ + public function setName($name) + { + $this->name = $name; + return $this; + } + + /** + * The tax name. Maximum length is 20 characters. + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * The rate of the specified tax. Valid range is from 0.001 to 99.999. + * + * @param string|double $percent + * + * @return $this + */ + public function setPercent($percent) + { + NumericValidator::validate($percent, "Percent"); + $percent = FormatConverter::formatToPrice($percent); + $this->percent = $percent; + return $this; + } + + /** + * The rate of the specified tax. Valid range is from 0.001 to 99.999. + * + * @return string + */ + public function getPercent() + { + return $this->percent; + } + + /** + * The tax as a monetary amount. Cannot be specified in a request. + * + * @param \PayPal\Api\Currency $amount + * + * @return $this + */ + public function setAmount($amount) + { + $this->amount = $amount; + return $this; + } + + /** + * The tax as a monetary amount. Cannot be specified in a request. + * + * @return \PayPal\Api\Currency + */ + public function getAmount() + { + return $this->amount; + } + +} diff --git a/paypal/PayPal/Api/Template.php b/paypal/PayPal/Api/Template.php new file mode 100644 index 0000000..4602e9b --- /dev/null +++ b/paypal/PayPal/Api/Template.php @@ -0,0 +1,309 @@ +template_id = $template_id; + return $this; + } + + /** + * Unique identifier id of the template. + * + * @return string + */ + public function getTemplateId() + { + return $this->template_id; + } + + /** + * Name of the template. + * + * @param string $name + * + * @return $this + */ + public function setName($name) + { + $this->name = $name; + return $this; + } + + /** + * Name of the template. + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Indicates that this template is merchant's default. There can be only one template which can be a default. + * + * @param bool $default + * + * @return $this + */ + public function setDefault($default) + { + $this->default = $default; + return $this; + } + + /** + * Indicates that this template is merchant's default. There can be only one template which can be a default. + * + * @return bool + */ + public function getDefault() + { + return $this->default; + } + + /** + * Customized invoice data which is saved as template + * + * @param \PayPal\Api\TemplateData $template_data + * + * @return $this + */ + public function setTemplateData($template_data) + { + $this->template_data = $template_data; + return $this; + } + + /** + * Customized invoice data which is saved as template + * + * @return \PayPal\Api\TemplateData + */ + public function getTemplateData() + { + return $this->template_data; + } + + /** + * Settings for each template + * + * @param \PayPal\Api\TemplateSettings[] $settings + * + * @return $this + */ + public function setSettings($settings) + { + $this->settings = $settings; + return $this; + } + + /** + * Settings for each template + * + * @return \PayPal\Api\TemplateSettings[] + */ + public function getSettings() + { + return $this->settings; + } + + /** + * Append Settings to the list. + * + * @param \PayPal\Api\TemplateSettings $templateSettings + * @return $this + */ + public function addSetting($templateSettings) + { + if (!$this->getSettings()) { + return $this->setSettings(array($templateSettings)); + } else { + return $this->setSettings( + array_merge($this->getSettings(), array($templateSettings)) + ); + } + } + + /** + * Remove Settings from the list. + * + * @param \PayPal\Api\TemplateSettings $templateSettings + * @return $this + */ + public function removeSetting($templateSettings) + { + return $this->setSettings( + array_diff($this->getSettings(), array($templateSettings)) + ); + } + + /** + * Unit of measure for the template, possible values are Quantity, Hours, Amount. + * + * @param string $unit_of_measure + * + * @return $this + */ + public function setUnitOfMeasure($unit_of_measure) + { + $this->unit_of_measure = $unit_of_measure; + return $this; + } + + /** + * Unit of measure for the template, possible values are Quantity, Hours, Amount. + * + * @return string + */ + public function getUnitOfMeasure() + { + return $this->unit_of_measure; + } + + /** + * Indicates whether this is a custom template created by the merchant. Non custom templates are system generated + * + * @param bool $custom + * + * @return $this + */ + public function setCustom($custom) + { + $this->custom = $custom; + return $this; + } + + /** + * Indicates whether this is a custom template created by the merchant. Non custom templates are system generated + * + * @return bool + */ + public function getCustom() + { + return $this->custom; + } + + /** + * Retrieve the details for a particular template by passing the template ID to the request URI. + * + * @param string $templateId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Template + */ + public static function get($templateId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($templateId, 'templateId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/invoicing/templates/$templateId", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new Template(); + $ret->fromJson($json); + return $ret; + } + + /** + * Delete a particular template by passing the template ID to the request URI. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function delete($apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getTemplateId(), "Id"); + $payLoad = ""; + self::executeCall( + "/v1/invoicing/templates/{$this->getTemplateId()}", + "DELETE", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * Creates a template. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Template + */ + public function create($apiContext = null, $restCall = null) + { + $json = self::executeCall( + "/v1/invoicing/templates", + "POST", + $this->toJSON(), + null, + $apiContext, + $restCall + ); + $this->fromJson($json); + return $this; + } + + /** + * Update an existing template by passing the template ID to the request URI. In addition, pass a complete template object in the request JSON. Partial updates are not supported. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Template + */ + public function update($apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getTemplateId(), "Id"); + $payLoad = $this->toJSON(); + $json = self::executeCall( + "/v1/invoicing/templates/{$this->getTemplateId()}", + "PUT", + $payLoad, + null, + $apiContext, + $restCall + ); + $this->fromJson($json); + return $this; + } + +} diff --git a/paypal/PayPal/Api/TemplateData.php b/paypal/PayPal/Api/TemplateData.php new file mode 100644 index 0000000..64d56c1 --- /dev/null +++ b/paypal/PayPal/Api/TemplateData.php @@ -0,0 +1,619 @@ +merchant_info = $merchant_info; + return $this; + } + + /** + * Information about the merchant who is sending the invoice. + * + * @return \PayPal\Api\MerchantInfo + */ + public function getMerchantInfo() + { + return $this->merchant_info; + } + + /** + * The required invoice recipient email address and any optional billing information. One recipient is supported. + * + * @param \PayPal\Api\BillingInfo[] $billing_info + * + * @return $this + */ + public function setBillingInfo($billing_info) + { + $this->billing_info = $billing_info; + return $this; + } + + /** + * The required invoice recipient email address and any optional billing information. One recipient is supported. + * + * @return \PayPal\Api\BillingInfo[] + */ + public function getBillingInfo() + { + return $this->billing_info; + } + + /** + * Append BillingInfo to the list. + * + * @param \PayPal\Api\BillingInfo $billingInfo + * @return $this + */ + public function addBillingInfo($billingInfo) + { + if (!$this->getBillingInfo()) { + return $this->setBillingInfo(array($billingInfo)); + } else { + return $this->setBillingInfo( + array_merge($this->getBillingInfo(), array($billingInfo)) + ); + } + } + + /** + * Remove BillingInfo from the list. + * + * @param \PayPal\Api\BillingInfo $billingInfo + * @return $this + */ + public function removeBillingInfo($billingInfo) + { + return $this->setBillingInfo( + array_diff($this->getBillingInfo(), array($billingInfo)) + ); + } + + /** + * For invoices sent by email, one or more email addresses to which to send a Cc: copy of the notification. Supports only email addresses under participant. + * + * @param string[] $cc_info + * + * @return $this + */ + public function setCcInfo($cc_info) + { + $this->cc_info = $cc_info; + return $this; + } + + /** + * For invoices sent by email, one or more email addresses to which to send a Cc: copy of the notification. Supports only email addresses under participant. + * + * @return string[] + */ + public function getCcInfo() + { + return $this->cc_info; + } + + /** + * Append CcInfo to the list. + * + * @param string $email + * @return $this + */ + public function addCcInfo($email) + { + if (!$this->getCcInfo()) { + return $this->setCcInfo(array($email)); + } else { + return $this->setCcInfo( + array_merge($this->getCcInfo(), array($email)) + ); + } + } + + /** + * Remove CcInfo from the list. + * + * @param string $email + * @return $this + */ + public function removeCcInfo($email) + { + return $this->setCcInfo( + array_diff($this->getCcInfo(), array($email)) + ); + } + + /** + * The shipping information for entities to whom items are being shipped. + * + * @param \PayPal\Api\ShippingInfo $shipping_info + * + * @return $this + */ + public function setShippingInfo($shipping_info) + { + $this->shipping_info = $shipping_info; + return $this; + } + + /** + * The shipping information for entities to whom items are being shipped. + * + * @return \PayPal\Api\ShippingInfo + */ + public function getShippingInfo() + { + return $this->shipping_info; + } + + /** + * The list of items to include in the invoice. Maximum value is 100 items per invoice. + * + * @param \PayPal\Api\InvoiceItem[] $items + * + * @return $this + */ + public function setItems($items) + { + $this->items = $items; + return $this; + } + + /** + * The list of items to include in the invoice. Maximum value is 100 items per invoice. + * + * @return \PayPal\Api\InvoiceItem[] + */ + public function getItems() + { + return $this->items; + } + + /** + * Append Items to the list. + * + * @param \PayPal\Api\InvoiceItem $invoiceItem + * @return $this + */ + public function addItem($invoiceItem) + { + if (!$this->getItems()) { + return $this->setItems(array($invoiceItem)); + } else { + return $this->setItems( + array_merge($this->getItems(), array($invoiceItem)) + ); + } + } + + /** + * Remove Items from the list. + * + * @param \PayPal\Api\InvoiceItem $invoiceItem + * @return $this + */ + public function removeItem($invoiceItem) + { + return $this->setItems( + array_diff($this->getItems(), array($invoiceItem)) + ); + } + + /** + * Optional. The payment deadline for the invoice. Value is either `term_type` or `due_date` but not both. + * + * @param \PayPal\Api\PaymentTerm $payment_term + * + * @return $this + */ + public function setPaymentTerm($payment_term) + { + $this->payment_term = $payment_term; + return $this; + } + + /** + * Optional. The payment deadline for the invoice. Value is either `term_type` or `due_date` but not both. + * + * @return \PayPal\Api\PaymentTerm + */ + public function getPaymentTerm() + { + return $this->payment_term; + } + + /** + * Reference data, such as PO number, to add to the invoice. Maximum length is 60 characters. + * + * @param string $reference + * + * @return $this + */ + public function setReference($reference) + { + $this->reference = $reference; + return $this; + } + + /** + * Reference data, such as PO number, to add to the invoice. Maximum length is 60 characters. + * + * @return string + */ + public function getReference() + { + return $this->reference; + } + + /** + * The invoice level discount, as a percent or an amount value. + * + * @param \PayPal\Api\Cost $discount + * + * @return $this + */ + public function setDiscount($discount) + { + $this->discount = $discount; + return $this; + } + + /** + * The invoice level discount, as a percent or an amount value. + * + * @return \PayPal\Api\Cost + */ + public function getDiscount() + { + return $this->discount; + } + + /** + * The shipping cost, as a percent or an amount value. + * + * @param \PayPal\Api\ShippingCost $shipping_cost + * + * @return $this + */ + public function setShippingCost($shipping_cost) + { + $this->shipping_cost = $shipping_cost; + return $this; + } + + /** + * The shipping cost, as a percent or an amount value. + * + * @return \PayPal\Api\ShippingCost + */ + public function getShippingCost() + { + return $this->shipping_cost; + } + + /** + * The custom amount to apply on an invoice. If you include a label, the amount cannot be empty. + * + * @param \PayPal\Api\CustomAmount $custom + * + * @return $this + */ + public function setCustom($custom) + { + $this->custom = $custom; + return $this; + } + + /** + * The custom amount to apply on an invoice. If you include a label, the amount cannot be empty. + * + * @return \PayPal\Api\CustomAmount + */ + public function getCustom() + { + return $this->custom; + } + + /** + * Indicates whether the invoice allows a partial payment. If set to `false`, invoice must be paid in full. If set to `true`, the invoice allows partial payments. Default is `false`. + * + * @param bool $allow_partial_payment + * + * @return $this + */ + public function setAllowPartialPayment($allow_partial_payment) + { + $this->allow_partial_payment = $allow_partial_payment; + return $this; + } + + /** + * Indicates whether the invoice allows a partial payment. If set to `false`, invoice must be paid in full. If set to `true`, the invoice allows partial payments. Default is `false`. + * + * @return bool + */ + public function getAllowPartialPayment() + { + return $this->allow_partial_payment; + } + + /** + * If `allow_partial_payment` is set to `true`, the minimum amount allowed for a partial payment. + * + * @param \PayPal\Api\Currency $minimum_amount_due + * + * @return $this + */ + public function setMinimumAmountDue($minimum_amount_due) + { + $this->minimum_amount_due = $minimum_amount_due; + return $this; + } + + /** + * If `allow_partial_payment` is set to `true`, the minimum amount allowed for a partial payment. + * + * @return \PayPal\Api\Currency + */ + public function getMinimumAmountDue() + { + return $this->minimum_amount_due; + } + + /** + * Indicates whether tax is calculated before or after a discount. If set to `false`, the tax is calculated before a discount. If set to `true`, the tax is calculated after a discount. Default is `false`. + * + * @param bool $tax_calculated_after_discount + * + * @return $this + */ + public function setTaxCalculatedAfterDiscount($tax_calculated_after_discount) + { + $this->tax_calculated_after_discount = $tax_calculated_after_discount; + return $this; + } + + /** + * Indicates whether tax is calculated before or after a discount. If set to `false`, the tax is calculated before a discount. If set to `true`, the tax is calculated after a discount. Default is `false`. + * + * @return bool + */ + public function getTaxCalculatedAfterDiscount() + { + return $this->tax_calculated_after_discount; + } + + /** + * Indicates whether the unit price includes tax. Default is `false`. + * + * @param bool $tax_inclusive + * + * @return $this + */ + public function setTaxInclusive($tax_inclusive) + { + $this->tax_inclusive = $tax_inclusive; + return $this; + } + + /** + * Indicates whether the unit price includes tax. Default is `false`. + * + * @return bool + */ + public function getTaxInclusive() + { + return $this->tax_inclusive; + } + + /** + * General terms of the invoice. 4000 characters max. + * + * @param string $terms + * + * @return $this + */ + public function setTerms($terms) + { + $this->terms = $terms; + return $this; + } + + /** + * General terms of the invoice. 4000 characters max. + * + * @return string + */ + public function getTerms() + { + return $this->terms; + } + + /** + * Note to the payer. 4000 characters max. + * + * @param string $note + * + * @return $this + */ + public function setNote($note) + { + $this->note = $note; + return $this; + } + + /** + * Note to the payer. 4000 characters max. + * + * @return string + */ + public function getNote() + { + return $this->note; + } + + /** + * A private bookkeeping memo for the merchant. Maximum length is 150 characters. + * + * @param string $merchant_memo + * + * @return $this + */ + public function setMerchantMemo($merchant_memo) + { + $this->merchant_memo = $merchant_memo; + return $this; + } + + /** + * A private bookkeeping memo for the merchant. Maximum length is 150 characters. + * + * @return string + */ + public function getMerchantMemo() + { + return $this->merchant_memo; + } + + /** + * Full URL of an external image to use as the logo. Maximum length is 4000 characters. + * + * @param string $logo_url + * @throws \InvalidArgumentException + * @return $this + */ + public function setLogoUrl($logo_url) + { + UrlValidator::validate($logo_url, "LogoUrl"); + $this->logo_url = $logo_url; + return $this; + } + + /** + * Full URL of an external image to use as the logo. Maximum length is 4000 characters. + * + * @return string + */ + public function getLogoUrl() + { + return $this->logo_url; + } + + /** + * The total amount of the invoice. + * + * @param \PayPal\Api\Currency $total_amount + * + * @return $this + */ + public function setTotalAmount($total_amount) + { + $this->total_amount = $total_amount; + return $this; + } + + /** + * The total amount of the invoice. + * + * @return \PayPal\Api\Currency + */ + public function getTotalAmount() + { + return $this->total_amount; + } + + /** + * List of files attached to the invoice. + * + * @param \PayPal\Api\FileAttachment[] $attachments + * + * @return $this + */ + public function setAttachments($attachments) + { + $this->attachments = $attachments; + return $this; + } + + /** + * List of files attached to the invoice. + * + * @return \PayPal\Api\FileAttachment[] + */ + public function getAttachments() + { + return $this->attachments; + } + + /** + * Append Attachments to the list. + * + * @param \PayPal\Api\FileAttachment $fileAttachment + * @return $this + */ + public function addAttachment($fileAttachment) + { + if (!$this->getAttachments()) { + return $this->setAttachments(array($fileAttachment)); + } else { + return $this->setAttachments( + array_merge($this->getAttachments(), array($fileAttachment)) + ); + } + } + + /** + * Remove Attachments from the list. + * + * @param \PayPal\Api\FileAttachment $fileAttachment + * @return $this + */ + public function removeAttachment($fileAttachment) + { + return $this->setAttachments( + array_diff($this->getAttachments(), array($fileAttachment)) + ); + } + +} diff --git a/paypal/PayPal/Api/TemplateSettings.php b/paypal/PayPal/Api/TemplateSettings.php new file mode 100644 index 0000000..60be389 --- /dev/null +++ b/paypal/PayPal/Api/TemplateSettings.php @@ -0,0 +1,65 @@ +field_name = $field_name; + return $this; + } + + /** + * The field name (for any field in template_data) for which the corresponding display preferences will be mapped to. + * + * @return string + */ + public function getFieldName() + { + return $this->field_name; + } + + /** + * Settings metadata for each field. + * + * @param \PayPal\Api\TemplateSettingsMetadata $display_preference + * + * @return $this + */ + public function setDisplayPreference($display_preference) + { + $this->display_preference = $display_preference; + return $this; + } + + /** + * Settings metadata for each field. + * + * @return \PayPal\Api\TemplateSettingsMetadata + */ + public function getDisplayPreference() + { + return $this->display_preference; + } + +} diff --git a/paypal/PayPal/Api/TemplateSettingsMetadata.php b/paypal/PayPal/Api/TemplateSettingsMetadata.php new file mode 100644 index 0000000..7084a04 --- /dev/null +++ b/paypal/PayPal/Api/TemplateSettingsMetadata.php @@ -0,0 +1,41 @@ +hidden = $hidden; + return $this; + } + + /** + * Indicates whether this field should be hidden. default is false + * + * @return bool + */ + public function getHidden() + { + return $this->hidden; + } + +} diff --git a/paypal/PayPal/Api/Templates.php b/paypal/PayPal/Api/Templates.php new file mode 100644 index 0000000..c9b0ad0 --- /dev/null +++ b/paypal/PayPal/Api/Templates.php @@ -0,0 +1,292 @@ +addresses = $addresses; + return $this; + } + + /** + * List of addresses in merchant's profile. + * + * @return \PayPal\Api\Address[] + */ + public function getAddresses() + { + return $this->addresses; + } + + /** + * Append Addresses to the list. + * + * @param \PayPal\Api\Address $address + * @return $this + */ + public function addAddress($address) + { + if (!$this->getAddresses()) { + return $this->setAddresses(array($address)); + } else { + return $this->setAddresses( + array_merge($this->getAddresses(), array($address)) + ); + } + } + + /** + * Remove Addresses from the list. + * + * @param \PayPal\Api\Address $address + * @return $this + */ + public function removeAddress($address) + { + return $this->setAddresses( + array_diff($this->getAddresses(), array($address)) + ); + } + + /** + * List of emails in merchant's profile. + * + * @param string[] $emails + * + * @return $this + */ + public function setEmails($emails) + { + $this->emails = $emails; + return $this; + } + + /** + * List of emails in merchant's profile. + * + * @return string[] + */ + public function getEmails() + { + return $this->emails; + } + + /** + * Append Emails to the list. + * + * @param string $string + * @return $this + */ + public function addEmail($string) + { + if (!$this->getEmails()) { + return $this->setEmails(array($string)); + } else { + return $this->setEmails( + array_merge($this->getEmails(), array($string)) + ); + } + } + + /** + * Remove Emails from the list. + * + * @param string $string + * @return $this + */ + public function removeEmail($string) + { + return $this->setEmails( + array_diff($this->getEmails(), array($string)) + ); + } + + /** + * List of phone numbers in merchant's profile. + * + * @param \PayPal\Api\Phone[] $phones + * + * @return $this + */ + public function setPhones($phones) + { + $this->phones = $phones; + return $this; + } + + /** + * List of phone numbers in merchant's profile. + * + * @return \PayPal\Api\Phone[] + */ + public function getPhones() + { + return $this->phones; + } + + /** + * Append Phones to the list. + * + * @param \PayPal\Api\Phone $phone + * @return $this + */ + public function addPhone($phone) + { + if (!$this->getPhones()) { + return $this->setPhones(array($phone)); + } else { + return $this->setPhones( + array_merge($this->getPhones(), array($phone)) + ); + } + } + + /** + * Remove Phones from the list. + * + * @param \PayPal\Api\Phone $phone + * @return $this + */ + public function removePhone($phone) + { + return $this->setPhones( + array_diff($this->getPhones(), array($phone)) + ); + } + + /** + * Array of templates. + * + * @param \PayPal\Api\Template[] $templates + * + * @return $this + */ + public function setTemplates($templates) + { + $this->templates = $templates; + return $this; + } + + /** + * Array of templates. + * + * @return \PayPal\Api\Template[] + */ + public function getTemplates() + { + return $this->templates; + } + + /** + * Append Templates to the list. + * + * @param \PayPal\Api\Template $template + * @return $this + */ + public function addTemplate($template) + { + if (!$this->getTemplates()) { + return $this->setTemplates(array($template)); + } else { + return $this->setTemplates( + array_merge($this->getTemplates(), array($template)) + ); + } + } + + /** + * Remove Templates from the list. + * + * @param \PayPal\Api\Template $template + * @return $this + */ + public function removeTemplate($template) + { + return $this->setTemplates( + array_diff($this->getTemplates(), array($template)) + ); + } + + /** + * Retrieve the details for a particular template by passing the template ID to the request URI. + * + * @deprecated Please use `Template::get()` instead. + * @see Template::get + * @param string $templateId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Template + */ + public static function get($templateId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($templateId, 'templateId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/invoicing/templates/$templateId", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new Template(); + $ret->fromJson($json); + return $ret; + } + + /** + * Retrieves the template information of the merchant. + * + * @param array $params + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Templates + */ + public static function getAll($params = array(), $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($params, 'params'); + $payLoad = ""; + $allowedParams = array( + 'fields' => 1, + ); + $json = self::executeCall( + "/v1/invoicing/templates/" . "?" . http_build_query(array_intersect_key($params, $allowedParams)), + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new Templates(); + $ret->fromJson($json); + return $ret; + } +} diff --git a/paypal/PayPal/Api/Terms.php b/paypal/PayPal/Api/Terms.php new file mode 100644 index 0000000..8bc1c84 --- /dev/null +++ b/paypal/PayPal/Api/Terms.php @@ -0,0 +1,161 @@ +id = $id; + return $this; + } + + /** + * Identifier of the terms. 128 characters max. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * Term type. Allowed values: `MONTHLY`, `WEEKLY`, `YEARLY`. + * + * @param string $type + * + * @return $this + */ + public function setType($type) + { + $this->type = $type; + return $this; + } + + /** + * Term type. Allowed values: `MONTHLY`, `WEEKLY`, `YEARLY`. + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Max Amount associated with this term. + * + * @param \PayPal\Api\Currency $max_billing_amount + * + * @return $this + */ + public function setMaxBillingAmount($max_billing_amount) + { + $this->max_billing_amount = $max_billing_amount; + return $this; + } + + /** + * Max Amount associated with this term. + * + * @return \PayPal\Api\Currency + */ + public function getMaxBillingAmount() + { + return $this->max_billing_amount; + } + + /** + * How many times money can be pulled during this term. + * + * @param string $occurrences + * + * @return $this + */ + public function setOccurrences($occurrences) + { + $this->occurrences = $occurrences; + return $this; + } + + /** + * How many times money can be pulled during this term. + * + * @return string + */ + public function getOccurrences() + { + return $this->occurrences; + } + + /** + * Amount_range associated with this term. + * + * @param \PayPal\Api\Currency $amount_range + * + * @return $this + */ + public function setAmountRange($amount_range) + { + $this->amount_range = $amount_range; + return $this; + } + + /** + * Amount_range associated with this term. + * + * @return \PayPal\Api\Currency + */ + public function getAmountRange() + { + return $this->amount_range; + } + + /** + * Buyer's ability to edit the amount in this term. + * + * @param string $buyer_editable + * + * @return $this + */ + public function setBuyerEditable($buyer_editable) + { + $this->buyer_editable = $buyer_editable; + return $this; + } + + /** + * Buyer's ability to edit the amount in this term. + * + * @return string + */ + public function getBuyerEditable() + { + return $this->buyer_editable; + } + +} diff --git a/paypal/PayPal/Api/Transaction.php b/paypal/PayPal/Api/Transaction.php new file mode 100644 index 0000000..8520e63 --- /dev/null +++ b/paypal/PayPal/Api/Transaction.php @@ -0,0 +1,63 @@ +transactions = $transactions; + return $this; + } + + /** + * Additional transactions for complex payment scenarios. + * + * @return self[] + */ + public function getTransactions() + { + return $this->transactions; + } + + /** + * Identifier to the purchase unit corresponding to this sale transaction + * + * @param string $purchase_unit_reference_id + * @deprecated Use #setReferenceId instead + * @return $this + */ + public function setPurchaseUnitReferenceId($purchase_unit_reference_id) + { + $this->purchase_unit_reference_id = $purchase_unit_reference_id; + return $this; + } + + /** + * Identifier to the purchase unit corresponding to this sale transaction + * + * @deprecated Use #getReferenceId instead + * @return string + */ + public function getPurchaseUnitReferenceId() + { + return $this->purchase_unit_reference_id; + } + +} diff --git a/paypal/PayPal/Api/TransactionBase.php b/paypal/PayPal/Api/TransactionBase.php new file mode 100644 index 0000000..0fcbc70 --- /dev/null +++ b/paypal/PayPal/Api/TransactionBase.php @@ -0,0 +1,40 @@ +related_resources = $related_resources; + return $this; + } + + /** + * List of financial transactions (Sale, Authorization, Capture, Refund) related to the payment. + * + * @return \PayPal\Api\RelatedResources[] + */ + public function getRelatedResources() + { + return $this->related_resources; + } + +} diff --git a/paypal/PayPal/Api/Transactions.php b/paypal/PayPal/Api/Transactions.php new file mode 100644 index 0000000..f7a09c1 --- /dev/null +++ b/paypal/PayPal/Api/Transactions.php @@ -0,0 +1,42 @@ +amount = $amount; + return $this; + } + + /** + * Amount being collected. + * + * @return \PayPal\Api\Amount + */ + public function getAmount() + { + return $this->amount; + } + +} diff --git a/paypal/PayPal/Api/VerifyWebhookSignature.php b/paypal/PayPal/Api/VerifyWebhookSignature.php new file mode 100644 index 0000000..edb4bbd --- /dev/null +++ b/paypal/PayPal/Api/VerifyWebhookSignature.php @@ -0,0 +1,256 @@ +auth_algo = $auth_algo; + return $this; + } + + /** + * The algorithm that PayPal uses to generate the signature and that you can use to verify the signature. Extract this value from the `PAYPAL-AUTH-ALGO` response header, which is received with the webhook notification. + * + * @return string + */ + public function getAuthAlgo() + { + return $this->auth_algo; + } + + /** + * The X.509 public key certificate. Download the certificate from this URL and use it to verify the signature. Extract this value from the `PAYPAL-CERT-URL` response header, which is received with the webhook notification. + * + * @param string $cert_url + * @throws \InvalidArgumentException + * @return $this + */ + public function setCertUrl($cert_url) + { + UrlValidator::validate($cert_url, "CertUrl"); + $this->cert_url = $cert_url; + return $this; + } + + /** + * The X.509 public key certificate. Download the certificate from this URL and use it to verify the signature. Extract this value from the `PAYPAL-CERT-URL` response header, which is received with the webhook notification. + * + * @return string + */ + public function getCertUrl() + { + return $this->cert_url; + } + + /** + * The ID of the HTTP transmission. Contained in the `PAYPAL-TRANSMISSION-ID` header of the notification message. + * + * @param string $transmission_id + * + * @return $this + */ + public function setTransmissionId($transmission_id) + { + $this->transmission_id = $transmission_id; + return $this; + } + + /** + * The ID of the HTTP transmission. Contained in the `PAYPAL-TRANSMISSION-ID` header of the notification message. + * + * @return string + */ + public function getTransmissionId() + { + return $this->transmission_id; + } + + /** + * The PayPal-generated asymmetric signature. Extract this value from the `PAYPAL-TRANSMISSION-SIG` response header, which is received with the webhook notification. + * + * @param string $transmission_sig + * + * @return $this + */ + public function setTransmissionSig($transmission_sig) + { + $this->transmission_sig = $transmission_sig; + return $this; + } + + /** + * The PayPal-generated asymmetric signature. Extract this value from the `PAYPAL-TRANSMISSION-SIG` response header, which is received with the webhook notification. + * + * @return string + */ + public function getTransmissionSig() + { + return $this->transmission_sig; + } + + /** + * The date and time of the HTTP transmission. Contained in the `PAYPAL-TRANSMISSION-TIME` header of the notification message. + * + * @param string $transmission_time + * + * @return $this + */ + public function setTransmissionTime($transmission_time) + { + $this->transmission_time = $transmission_time; + return $this; + } + + /** + * The date and time of the HTTP transmission. Contained in the `PAYPAL-TRANSMISSION-TIME` header of the notification message. + * + * @return string + */ + public function getTransmissionTime() + { + return $this->transmission_time; + } + + /** + * The ID of the webhook as configured in your Developer Portal account. + * + * @param string $webhook_id + * + * @return $this + */ + public function setWebhookId($webhook_id) + { + $this->webhook_id = $webhook_id; + return $this; + } + + /** + * The ID of the webhook as configured in your Developer Portal account. + * + * @return string + */ + public function getWebhookId() + { + return $this->webhook_id; + } + + /** + * The webhook notification, which is the content of the HTTP `POST` request body. + * @deprecated Please use setRequestBody($request_body) instead. + * @param \PayPal\Api\WebhookEvent $webhook_event + * + * @return $this + */ + public function setWebhookEvent($webhook_event) + { + $this->webhook_event = $webhook_event; + return $this; + } + + /** + * The webhook notification, which is the content of the HTTP `POST` request body. + * + * @return \PayPal\Api\WebhookEvent + */ + public function getWebhookEvent() + { + return $this->webhook_event; + } + + /** + * The content of the HTTP `POST` request body of the webhook notification you received as a string. + * + * @param string $request_body + * + * @return $this + */ + public function setRequestBody($request_body) + { + $this->request_body = $request_body; + return $this; + } + + /** + * The content of the HTTP `POST` request body of the webhook notification you received as a string. + * + * @return string + */ + public function getRequestBody() + { + return $this->request_body; + } + + /** + * Verifies a webhook signature. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return VerifyWebhookSignatureResponse + */ + public function post($apiContext = null, $restCall = null) + { + $payLoad = $this->toJSON(); + + $json = self::executeCall( + "/v1/notifications/verify-webhook-signature", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new VerifyWebhookSignatureResponse(); + $ret->fromJson($json); + return $ret; + } + + public function toJSON($options = 0) + { + if (!is_null($this->request_body)) { + $valuesToEncode = $this->toArray(); + unset($valuesToEncode['webhook_event']); + unset($valuesToEncode['request_body']); + + $payLoad = "{"; + foreach ($valuesToEncode as $field => $value) { + $payLoad .= "\"$field\": \"$value\","; + } + $payLoad .= "\"webhook_event\": $this->request_body"; + $payLoad .= "}"; + return $payLoad; + } else { + $payLoad = parent::toJSON($options); + return $payLoad; + } + } +} diff --git a/paypal/PayPal/Api/VerifyWebhookSignatureResponse.php b/paypal/PayPal/Api/VerifyWebhookSignatureResponse.php new file mode 100644 index 0000000..75b0845 --- /dev/null +++ b/paypal/PayPal/Api/VerifyWebhookSignatureResponse.php @@ -0,0 +1,42 @@ +verification_status = $verification_status; + return $this; + } + + /** + * The status of the signature verification. Value is `SUCCESS` or `FAILURE`. + * + * @return string + */ + public function getVerificationStatus() + { + return $this->verification_status; + } + +} diff --git a/paypal/PayPal/Api/WebProfile.php b/paypal/PayPal/Api/WebProfile.php new file mode 100644 index 0000000..4ff1a80 --- /dev/null +++ b/paypal/PayPal/Api/WebProfile.php @@ -0,0 +1,305 @@ +id = $id; + return $this; + } + + /** + * The unique ID of the web experience profile. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * The web experience profile name. Unique for a specified merchant's profiles. + * + * @param string $name + * + * @return $this + */ + public function setName($name) + { + $this->name = $name; + return $this; + } + + /** + * The web experience profile name. Unique for a specified merchant's profiles. + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Indicates whether the profile persists for three hours or permanently. Set to `false` to persist the profile permanently. Set to `true` to persist the profile for three hours. + * + * @param bool $temporary + * + * @return $this + */ + public function setTemporary($temporary) + { + $this->temporary = $temporary; + return $this; + } + + /** + * Indicates whether the profile persists for three hours or permanently. Set to `false` to persist the profile permanently. Set to `true` to persist the profile for three hours. + * + * @return bool + */ + public function getTemporary() + { + return $this->temporary; + } + + /** + * Parameters for flow configuration. + * + * @param \PayPal\Api\FlowConfig $flow_config + * + * @return $this + */ + public function setFlowConfig($flow_config) + { + $this->flow_config = $flow_config; + return $this; + } + + /** + * Parameters for flow configuration. + * + * @return \PayPal\Api\FlowConfig + */ + public function getFlowConfig() + { + return $this->flow_config; + } + + /** + * Parameters for input fields customization. + * + * @param \PayPal\Api\InputFields $input_fields + * + * @return $this + */ + public function setInputFields($input_fields) + { + $this->input_fields = $input_fields; + return $this; + } + + /** + * Parameters for input fields customization. + * + * @return \PayPal\Api\InputFields + */ + public function getInputFields() + { + return $this->input_fields; + } + + /** + * Parameters for style and presentation. + * + * @param \PayPal\Api\Presentation $presentation + * + * @return $this + */ + public function setPresentation($presentation) + { + $this->presentation = $presentation; + return $this; + } + + /** + * Parameters for style and presentation. + * + * @return \PayPal\Api\Presentation + */ + public function getPresentation() + { + return $this->presentation; + } + + /** + * Creates a web experience profile. Pass the profile name and details in the JSON request body. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return CreateProfileResponse + */ + public function create($apiContext = null, $restCall = null) + { + $payLoad = $this->toJSON(); + $json = self::executeCall( + "/v1/payment-experience/web-profiles/", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new CreateProfileResponse(); + $ret->fromJson($json); + return $ret; + } + + /** + * Updates a web experience profile. Pass the ID of the profile to the request URI and pass the profile details in the JSON request body. If your request omits any profile detail fields, the operation removes the previously set values for those fields. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function update($apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + $payLoad = $this->toJSON(); + self::executeCall( + "/v1/payment-experience/web-profiles/{$this->getId()}", + "PUT", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * Partially-updates a web experience profile. Pass the profile ID to the request URI. Pass a patch object with the operation, path of the profile location to update, and, if needed, a new value to complete the operation in the JSON request body. + * + * @param Patch[] $patch + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function partial_update($patch, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($patch, 'patch'); + $payload = array(); + foreach ($patch as $patchObject) { + $payload[] = $patchObject->toArray(); + } + $payLoad = json_encode($payload); + self::executeCall( + "/v1/payment-experience/web-profiles/{$this->getId()}", + "PATCH", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + + /** + * Shows details for a web experience profile, by ID. + * + * @param string $profileId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return WebProfile + */ + public static function get($profileId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($profileId, 'profileId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/payment-experience/web-profiles/$profileId", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new WebProfile(); + $ret->fromJson($json); + return $ret; + } + + /** + * Lists all web experience profiles for a merchant or subject. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return WebProfile[] + */ + public static function get_list($apiContext = null, $restCall = null) + { + $payLoad = ""; + $json = self::executeCall( + "/v1/payment-experience/web-profiles/", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + return WebProfile::getList($json); + } + + /** + * Deletes a web experience profile, by ID. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function delete($apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + $payLoad = ""; + self::executeCall( + "/v1/payment-experience/web-profiles/{$this->getId()}", + "DELETE", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + +} diff --git a/paypal/PayPal/Api/Webhook.php b/paypal/PayPal/Api/Webhook.php new file mode 100644 index 0000000..549b588 --- /dev/null +++ b/paypal/PayPal/Api/Webhook.php @@ -0,0 +1,260 @@ +id = $id; + return $this; + } + + /** + * The ID of the webhook. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * The URL that is configured to listen on `localhost` for incoming `POST` notification messages that contain event information. + * + * @param string $url + * @throws \InvalidArgumentException + * @return $this + */ + public function setUrl($url) + { + UrlValidator::validate($url, "Url"); + $this->url = $url; + return $this; + } + + /** + * The URL that is configured to listen on `localhost` for incoming `POST` notification messages that contain event information. + * + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * A list of up to ten events to which to subscribe your webhook. To subscribe to all events including new events as they are added, specify the asterisk (`*`) wildcard. To replace the `event_types` array, specify the `*` wildcard. To see all supported events, [list available events](#available-event-type.list). + * + * @param \PayPal\Api\WebhookEventType[] $event_types + * + * @return $this + */ + public function setEventTypes($event_types) + { + $this->event_types = $event_types; + return $this; + } + + /** + * A list of up to ten events to which to subscribe your webhook. To subscribe to all events including new events as they are added, specify the asterisk (`*`) wildcard. To replace the `event_types` array, specify the `*` wildcard. To see all supported events, [list available events](#available-event-type.list). + * + * @return \PayPal\Api\WebhookEventType[] + */ + public function getEventTypes() + { + return $this->event_types; + } + + /** + * Append EventTypes to the list. + * + * @param \PayPal\Api\WebhookEventType $webhookEventType + * @return $this + */ + public function addEventType($webhookEventType) + { + if (!$this->getEventTypes()) { + return $this->setEventTypes(array($webhookEventType)); + } else { + return $this->setEventTypes( + array_merge($this->getEventTypes(), array($webhookEventType)) + ); + } + } + + /** + * Remove EventTypes from the list. + * + * @param \PayPal\Api\WebhookEventType $webhookEventType + * @return $this + */ + public function removeEventType($webhookEventType) + { + return $this->setEventTypes( + array_diff($this->getEventTypes(), array($webhookEventType)) + ); + } + + /** + * Subscribes your webhook listener to events. A successful call returns a [`webhook`](/docs/api/webhooks/#definition-webhook) object, which includes the webhook ID for later use. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Webhook + */ + public function create($apiContext = null, $restCall = null) + { + $payLoad = $this->toJSON(); + $json = self::executeCall( + "/v1/notifications/webhooks", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $this->fromJson($json); + return $this; + } + + /** + * Shows details for a webhook, by ID. + * + * @param string $webhookId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Webhook + */ + public static function get($webhookId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($webhookId, 'webhookId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/notifications/webhooks/$webhookId", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new Webhook(); + $ret->fromJson($json); + return $ret; + } + + /** + * Retrieves all Webhooks for the application associated with access token. + * + * @deprecated Please use Webhook#getAllWithParams instead. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return WebhookList + */ + public static function getAll($apiContext = null, $restCall = null) + { + return self::getAllWithParams(array(), $apiContext, $restCall); + } + + /** + * Lists all webhooks for an app. + * + * @param array $params + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return WebhookList + */ + public static function getAllWithParams($params = array(), $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($params, 'params'); + $payLoad = ""; + $allowedParams = array( + 'anchor_type' => 1, + ); + $json = self::executeCall( + "/v1/notifications/webhooks?" . http_build_query(array_intersect_key($params, $allowedParams)), + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new WebhookList(); + $ret->fromJson($json); + return $ret; + } + + /** + * Replaces webhook fields with new values. Pass a `json_patch` object with `replace` operation and `path`, which is `/url` for a URL or `/event_types` for events. The `value` is either the URL or a list of events. + * + * @param PatchRequest $patchRequest + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return Webhook + */ + public function update($patchRequest, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + ArgumentValidator::validate($patchRequest, 'patchRequest'); + $payLoad = $patchRequest->toJSON(); + $json = self::executeCall( + "/v1/notifications/webhooks/{$this->getId()}", + "PATCH", + $payLoad, + null, + $apiContext, + $restCall + ); + $this->fromJson($json); + return $this; + } + + /** + * Deletes a webhook, by ID. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return bool + */ + public function delete($apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + $payLoad = ""; + self::executeCall( + "/v1/notifications/webhooks/{$this->getId()}", + "DELETE", + $payLoad, + null, + $apiContext, + $restCall + ); + return true; + } + +} diff --git a/paypal/PayPal/Api/WebhookEvent.php b/paypal/PayPal/Api/WebhookEvent.php new file mode 100644 index 0000000..f222b27 --- /dev/null +++ b/paypal/PayPal/Api/WebhookEvent.php @@ -0,0 +1,312 @@ +id = $id; + return $this; + } + + /** + * The ID of the webhook event notification. + * + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * The date and time when the webhook event notification was created. + * + * @param string $create_time + * + * @return $this + */ + public function setCreateTime($create_time) + { + $this->create_time = $create_time; + return $this; + } + + /** + * The date and time when the webhook event notification was created. + * + * @return string + */ + public function getCreateTime() + { + return $this->create_time; + } + + /** + * The name of the resource related to the webhook notification event. + * + * @param string $resource_type + * + * @return $this + */ + public function setResourceType($resource_type) + { + $this->resource_type = $resource_type; + return $this; + } + + /** + * The name of the resource related to the webhook notification event. + * + * @return string + */ + public function getResourceType() + { + return $this->resource_type; + } + + /** + * The version of the event. + * + * @param string $event_version + * + * @return $this + */ + public function setEventVersion($event_version) + { + $this->event_version = $event_version; + return $this; + } + + /** + * The version of the event. + * + * @return string + */ + public function getEventVersion() + { + return $this->event_version; + } + + /** + * The event that triggered the webhook event notification. + * + * @param string $event_type + * + * @return $this + */ + public function setEventType($event_type) + { + $this->event_type = $event_type; + return $this; + } + + /** + * The event that triggered the webhook event notification. + * + * @return string + */ + public function getEventType() + { + return $this->event_type; + } + + /** + * A summary description for the event notification. For example, `A payment authorization was created.` + * + * @param string $summary + * + * @return $this + */ + public function setSummary($summary) + { + $this->summary = $summary; + return $this; + } + + /** + * A summary description for the event notification. For example, `A payment authorization was created.` + * + * @return string + */ + public function getSummary() + { + return $this->summary; + } + + /** + * The resource that triggered the webhook event notification. + * + * @param \PayPal\Common\PayPalModel $resource + * + * @return $this + */ + public function setResource($resource) + { + $this->resource = $resource; + return $this; + } + + /** + * The resource that triggered the webhook event notification. + * + * @return \PayPal\Common\PayPalModel + */ + public function getResource() + { + return $this->resource; + } + + /** + * Validates Received Event from Webhook, and returns the webhook event object. Because security verifications by verifying certificate chain is not enabled in PHP yet, + * 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. + * 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 + * 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. + * + * 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. + * + * @deprecated Please use `VerifyWebhookSignature->post()` instead. + * + * @param string $body + * @param ApiContext $apiContext + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return WebhookEvent + * @throws \InvalidArgumentException if input arguments are incorrect, or Id is not found. + * @throws PayPalConnectionException if any exception from PayPal APIs other than not found is sent. + */ + public static function validateAndGetReceivedEvent($body, $apiContext = null, $restCall = null) + { + if ($body == null | empty($body)){ + throw new \InvalidArgumentException("Body cannot be null or empty"); + } + if (!JsonValidator::validate($body, true)) { + throw new \InvalidArgumentException("Request Body is not a valid JSON."); + } + $object = new WebhookEvent($body); + if ($object->getId() == null) { + throw new \InvalidArgumentException("Id attribute not found in JSON. Possible reason could be invalid JSON Object"); + } + try { + return self::get($object->getId(), $apiContext, $restCall); + } catch(PayPalConnectionException $ex) { + if ($ex->getCode() == 404) { + // It means that the given webhook event Id is not found for this merchant. + 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."); + } + throw $ex; + } + } + + /** + * Retrieves the Webhooks event resource identified by event_id. Can be used to retrieve the payload for an event. + * + * @param string $eventId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return WebhookEvent + */ + public static function get($eventId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($eventId, 'eventId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/notifications/webhooks-events/$eventId", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new WebhookEvent(); + $ret->fromJson($json); + return $ret; + } + + /** + * Resends a webhook event notification, by ID. Any pending notifications are not resent. + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return WebhookEvent + */ + public function resend($apiContext = null, $restCall = null) + { + ArgumentValidator::validate($this->getId(), "Id"); + $payLoad = ""; + $json = self::executeCall( + "/v1/notifications/webhooks-events/{$this->getId()}/resend", + "POST", + $payLoad, + null, + $apiContext, + $restCall + ); + $this->fromJson($json); + return $this; + } + + /** + * Lists webhook event notifications. Use query parameters to filter the response. + * + * @param array $params + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return WebhookEventList + */ + public static function all($params, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($params, 'params'); + $payLoad = ""; + $allowedParams = array( + 'page_size' => 1, + 'start_time' => 1, + 'end_time' => 1, + 'transaction_id' => 1, + 'event_type' => 1, + ); + $json = self::executeCall( + "/v1/notifications/webhooks-events" . "?" . http_build_query(array_intersect_key($params, $allowedParams)), + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new WebhookEventList(); + $ret->fromJson($json); + return $ret; + } + +} diff --git a/paypal/PayPal/Api/WebhookEventList.php b/paypal/PayPal/Api/WebhookEventList.php new file mode 100644 index 0000000..8c8c7ed --- /dev/null +++ b/paypal/PayPal/Api/WebhookEventList.php @@ -0,0 +1,149 @@ +events = $events; + return $this; + } + + /** + * A list of webhooks events. + * + * @return \PayPal\Api\WebhookEvent[] + */ + public function getEvents() + { + return $this->events; + } + + /** + * Append Events to the list. + * + * @param \PayPal\Api\WebhookEvent $webhookEvent + * @return $this + */ + public function addEvent($webhookEvent) + { + if (!$this->getEvents()) { + return $this->setEvents(array($webhookEvent)); + } else { + return $this->setEvents( + array_merge($this->getEvents(), array($webhookEvent)) + ); + } + } + + /** + * Remove Events from the list. + * + * @param \PayPal\Api\WebhookEvent $webhookEvent + * @return $this + */ + public function removeEvent($webhookEvent) + { + return $this->setEvents( + array_diff($this->getEvents(), array($webhookEvent)) + ); + } + + /** + * The number of items in each range of results. Note that the response might have fewer items than the requested `page_size` value. + * + * @param int $count + * + * @return $this + */ + public function setCount($count) + { + $this->count = $count; + return $this; + } + + /** + * The number of items in each range of results. Note that the response might have fewer items than the requested `page_size` value. + * + * @return int + */ + public function getCount() + { + return $this->count; + } + + /** + * Sets Links + * + * @param \PayPal\Api\Links[] $links + * + * @return $this + */ + public function setLinks($links) + { + $this->links = $links; + return $this; + } + + /** + * Gets Links + * + * @return \PayPal\Api\Links[] + */ + public function getLinks() + { + return $this->links; + } + + /** + * Append Links to the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function addLink($links) + { + if (!$this->getLinks()) { + return $this->setLinks(array($links)); + } else { + return $this->setLinks( + array_merge($this->getLinks(), array($links)) + ); + } + } + + /** + * Remove Links from the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function removeLink($links) + { + return $this->setLinks( + array_diff($this->getLinks(), array($links)) + ); + } + +} diff --git a/paypal/PayPal/Api/WebhookEventType.php b/paypal/PayPal/Api/WebhookEventType.php new file mode 100644 index 0000000..2aedc60 --- /dev/null +++ b/paypal/PayPal/Api/WebhookEventType.php @@ -0,0 +1,140 @@ +name = $name; + return $this; + } + + /** + * The unique event name. + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * A human-readable description of the event. + * + * @param string $description + * + * @return $this + */ + public function setDescription($description) + { + $this->description = $description; + return $this; + } + + /** + * A human-readable description of the event. + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * The status of a webhook event. + * + * @param string $status + * + * @return $this + */ + public function setStatus($status) + { + $this->status = $status; + return $this; + } + + /** + * The status of a webhook event. + * + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * Lists event subscriptions for a webhook, by ID. + * + * @param string $webhookId + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return WebhookEventTypeList + */ + public static function subscribedEventTypes($webhookId, $apiContext = null, $restCall = null) + { + ArgumentValidator::validate($webhookId, 'webhookId'); + $payLoad = ""; + $json = self::executeCall( + "/v1/notifications/webhooks/$webhookId/event-types", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new WebhookEventTypeList(); + $ret->fromJson($json); + return $ret; + } + + /** + * Lists available events to which any webhook can subscribe. For a list of supported events, see [Webhook events](/docs/integration/direct/rest/webhooks/webhook-events/). + * + * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. + * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls + * @return WebhookEventTypeList + */ + public static function availableEventTypes($apiContext = null, $restCall = null) + { + $payLoad = ""; + $json = self::executeCall( + "/v1/notifications/webhooks-event-types", + "GET", + $payLoad, + null, + $apiContext, + $restCall + ); + $ret = new WebhookEventTypeList(); + $ret->fromJson($json); + return $ret; + } + +} diff --git a/paypal/PayPal/Api/WebhookEventTypeList.php b/paypal/PayPal/Api/WebhookEventTypeList.php new file mode 100644 index 0000000..63fa2c4 --- /dev/null +++ b/paypal/PayPal/Api/WebhookEventTypeList.php @@ -0,0 +1,71 @@ +event_types = $event_types; + return $this; + } + + /** + * A list of webhook events. + * + * @return \PayPal\Api\WebhookEventType[] + */ + public function getEventTypes() + { + return $this->event_types; + } + + /** + * Append EventTypes to the list. + * + * @param \PayPal\Api\WebhookEventType $webhookEventType + * @return $this + */ + public function addEventType($webhookEventType) + { + if (!$this->getEventTypes()) { + return $this->setEventTypes(array($webhookEventType)); + } else { + return $this->setEventTypes( + array_merge($this->getEventTypes(), array($webhookEventType)) + ); + } + } + + /** + * Remove EventTypes from the list. + * + * @param \PayPal\Api\WebhookEventType $webhookEventType + * @return $this + */ + public function removeEventType($webhookEventType) + { + return $this->setEventTypes( + array_diff($this->getEventTypes(), array($webhookEventType)) + ); + } + +} diff --git a/paypal/PayPal/Api/WebhookList.php b/paypal/PayPal/Api/WebhookList.php new file mode 100644 index 0000000..9ccbb36 --- /dev/null +++ b/paypal/PayPal/Api/WebhookList.php @@ -0,0 +1,71 @@ +webhooks = $webhooks; + return $this; + } + + /** + * A list of webhooks. + * + * @return \PayPal\Api\Webhook[] + */ + public function getWebhooks() + { + return $this->webhooks; + } + + /** + * Append Webhooks to the list. + * + * @param \PayPal\Api\Webhook $webhook + * @return $this + */ + public function addWebhook($webhook) + { + if (!$this->getWebhooks()) { + return $this->setWebhooks(array($webhook)); + } else { + return $this->setWebhooks( + array_merge($this->getWebhooks(), array($webhook)) + ); + } + } + + /** + * Remove Webhooks from the list. + * + * @param \PayPal\Api\Webhook $webhook + * @return $this + */ + public function removeWebhook($webhook) + { + return $this->setWebhooks( + array_diff($this->getWebhooks(), array($webhook)) + ); + } + +} diff --git a/paypal/PayPal/Auth/OAuthTokenCredential.php b/paypal/PayPal/Auth/OAuthTokenCredential.php new file mode 100644 index 0000000..91e4a02 --- /dev/null +++ b/paypal/PayPal/Auth/OAuthTokenCredential.php @@ -0,0 +1,317 @@ +clientId = $clientId; + $this->clientSecret = $clientSecret; + $this->cipher = new Cipher($this->clientSecret); + $this->targetSubject = $targetSubject; + } + + /** + * Get Client ID + * + * @return string + */ + public function getClientId() + { + return $this->clientId; + } + + /** + * Get Client Secret + * + * @return string + */ + public function getClientSecret() + { + return $this->clientSecret; + } + + /** + * Get AccessToken + * + * @param $config + * + * @return null|string + */ + public function getAccessToken($config) + { + // Check if we already have accessToken in Cache + if ($this->accessToken && (time() - $this->tokenCreateTime) < ($this->tokenExpiresIn - self::$expiryBufferTime)) { + return $this->accessToken; + } + // Check for persisted data first + $token = AuthorizationCache::pull($config, $this->clientId); + if ($token) { + // We found it + // This code block is for backward compatibility only. + if (array_key_exists('accessToken', $token)) { + $this->accessToken = $token['accessToken']; + } + + $this->tokenCreateTime = $token['tokenCreateTime']; + $this->tokenExpiresIn = $token['tokenExpiresIn']; + + // Case where we have an old unencrypted cache file + if (!array_key_exists('accessTokenEncrypted', $token)) { + AuthorizationCache::push($config, $this->clientId, $this->encrypt($this->accessToken), $this->tokenCreateTime, $this->tokenExpiresIn); + } else { + $this->accessToken = $this->decrypt($token['accessTokenEncrypted']); + } + } + + // Check if Access Token is not null and has not expired. + // The API returns expiry time as a relative time unit + // We use a buffer time when checking for token expiry to account + // for API call delays and any delay between the time the token is + // retrieved and subsequently used + if ( + $this->accessToken != null && + (time() - $this->tokenCreateTime) > ($this->tokenExpiresIn - self::$expiryBufferTime) + ) { + $this->accessToken = null; + } + + + // If accessToken is Null, obtain a new token + if ($this->accessToken == null) { + // Get a new one by making calls to API + $this->updateAccessToken($config); + AuthorizationCache::push($config, $this->clientId, $this->encrypt($this->accessToken), $this->tokenCreateTime, $this->tokenExpiresIn); + } + + return $this->accessToken; + } + + + /** + * Get a Refresh Token from Authorization Code + * + * @param $config + * @param $authorizationCode + * @param array $params optional arrays to override defaults + * @return string|null + */ + public function getRefreshToken($config, $authorizationCode = null, $params = array()) + { + static $allowedParams = array( + 'grant_type' => 'authorization_code', + 'code' => 1, + 'redirect_uri' => 'urn:ietf:wg:oauth:2.0:oob', + 'response_type' => 'token' + ); + + $params = is_array($params) ? $params : array(); + if ($authorizationCode) { + //Override the authorizationCode if value is explicitly set + $params['code'] = $authorizationCode; + } + $payload = http_build_query(array_merge($allowedParams, array_intersect_key($params, $allowedParams))); + + $response = $this->getToken($config, $this->clientId, $this->clientSecret, $payload); + + if ($response != null && isset($response["refresh_token"])) { + return $response['refresh_token']; + } + + return null; + } + + /** + * Updates Access Token based on given input + * + * @param array $config + * @param string|null $refreshToken + * @return string + */ + public function updateAccessToken($config, $refreshToken = null) + { + $this->generateAccessToken($config, $refreshToken); + return $this->accessToken; + } + + /** + * Retrieves the token based on the input configuration + * + * @param array $config + * @param string $clientId + * @param string $clientSecret + * @param string $payload + * @return mixed + * @throws PayPalConfigurationException + * @throws \PayPal\Exception\PayPalConnectionException + */ + protected function getToken($config, $clientId, $clientSecret, $payload) + { + $httpConfig = new PayPalHttpConfig(null, 'POST', $config); + + // if proxy set via config, add it + if (!empty($config['http.Proxy'])) { + $httpConfig->setHttpProxy($config['http.Proxy']); + } + + $handlers = array(self::$AUTH_HANDLER); + + /** @var IPayPalHandler $handler */ + foreach ($handlers as $handler) { + if (!is_object($handler)) { + $fullHandler = "\\" . (string)$handler; + $handler = new $fullHandler(new ApiContext($this)); + } + $handler->handle($httpConfig, $payload, array('clientId' => $clientId, 'clientSecret' => $clientSecret)); + } + + $connection = new PayPalHttpConnection($httpConfig, $config); + $res = $connection->execute($payload); + $response = json_decode($res, true); + + return $response; + } + + + /** + * Generates a new access token + * + * @param array $config + * @param null|string $refreshToken + * @return null + * @throws PayPalConnectionException + */ + private function generateAccessToken($config, $refreshToken = null) + { + $params = array('grant_type' => 'client_credentials'); + if ($refreshToken != null) { + // If the refresh token is provided, it would get access token using refresh token + // Used for Future Payments + $params['grant_type'] = 'refresh_token'; + $params['refresh_token'] = $refreshToken; + } + if ($this->targetSubject != null) { + $params['target_subject'] = $this->targetSubject; + } + $payload = http_build_query($params); + $response = $this->getToken($config, $this->clientId, $this->clientSecret, $payload); + + if ($response == null || !isset($response["access_token"]) || !isset($response["expires_in"])) { + $this->accessToken = null; + $this->tokenExpiresIn = null; + PayPalLoggingManager::getInstance(__CLASS__)->warning("Could not generate new Access token. Invalid response from server: "); + throw new PayPalConnectionException(null, "Could not generate new Access token. Invalid response from server: "); + } else { + $this->accessToken = $response["access_token"]; + $this->tokenExpiresIn = $response["expires_in"]; + } + $this->tokenCreateTime = time(); + + return $this->accessToken; + } + + /** + * Helper method to encrypt data using clientSecret as key + * + * @param $data + * @return string + */ + public function encrypt($data) + { + return $this->cipher->encrypt($data); + } + + /** + * Helper method to decrypt data using clientSecret as key + * + * @param $data + * @return string + */ + public function decrypt($data) + { + return $this->cipher->decrypt($data); + } +} diff --git a/paypal/PayPal/Cache/AuthorizationCache.php b/paypal/PayPal/Cache/AuthorizationCache.php new file mode 100644 index 0000000..83910d3 --- /dev/null +++ b/paypal/PayPal/Cache/AuthorizationCache.php @@ -0,0 +1,123 @@ + $clientId, + 'accessTokenEncrypted' => $accessToken, + 'tokenCreateTime' => $tokenCreateTime, + 'tokenExpiresIn' => $tokenExpiresIn + ); + } + if (!file_put_contents($cachePath, json_encode($tokens))) { + throw new \Exception("Failed to write cache"); + }; + } + + /** + * Determines from the Configuration if caching is currently enabled/disabled + * + * @param $config + * @return bool + */ + public static function isEnabled($config) + { + $value = self::getConfigValue('cache.enabled', $config); + return empty($value) ? false : ((trim($value) == true || trim($value) == 'true')); + } + + /** + * Returns the cache file path + * + * @param $config + * @return string + */ + public static function cachePath($config) + { + $cachePath = self::getConfigValue('cache.FileName', $config); + return empty($cachePath) ? __DIR__ . self::$CACHE_PATH : $cachePath; + } + + /** + * Returns the Value of the key if found in given config, or from PayPal Config Manager + * Returns null if not found + * + * @param $key + * @param $config + * @return null|string + */ + private static function getConfigValue($key, $config) + { + $config = ($config && is_array($config)) ? $config : PayPalConfigManager::getInstance()->getConfigHashmap(); + return (array_key_exists($key, $config)) ? trim($config[$key]) : null; + } +} diff --git a/paypal/PayPal/Common/ArrayUtil.php b/paypal/PayPal/Common/ArrayUtil.php new file mode 100644 index 0000000..4b4ffaf --- /dev/null +++ b/paypal/PayPal/Common/ArrayUtil.php @@ -0,0 +1,27 @@ + $v) { + if (is_int($k)) { + return false; + } + } + return true; + } +} diff --git a/paypal/PayPal/Common/PayPalModel.php b/paypal/PayPal/Common/PayPalModel.php new file mode 100644 index 0000000..2cab284 --- /dev/null +++ b/paypal/PayPal/Common/PayPalModel.php @@ -0,0 +1,309 @@ +fromJson($data) later after creating the object. + * + * @param array|string|null $data + * @throws \InvalidArgumentException + */ + public function __construct($data = null) + { + switch (gettype($data)) { + case "NULL": + break; + case "string": + JsonValidator::validate($data); + $this->fromJson($data); + break; + case "array": + $this->fromArray($data); + break; + default: + } + } + + /** + * Returns a list of Object from Array or Json String. It is generally used when your json + * contains an array of this object + * + * @param mixed $data Array object or json string representation + * @return array + */ + public static function getList($data) + { + // Return Null if Null + if ($data === null) { + return null; + } + + if (is_a($data, get_class(new \stdClass()))) { + //This means, root element is object + return new static(json_encode($data)); + } + + $list = array(); + + if (is_array($data)) { + $data = json_encode($data); + } + + if (JsonValidator::validate($data)) { + // It is valid JSON + $decoded = json_decode($data); + if ($decoded === null) { + return $list; + } + if (is_array($decoded)) { + foreach ($decoded as $k => $v) { + $list[] = self::getList($v); + } + } + if (is_a($decoded, get_class(new \stdClass()))) { + //This means, root element is object + $list[] = new static(json_encode($decoded)); + } + } + + return $list; + } + + /** + * Magic Get Method + * + * @param $key + * @return mixed + */ + public function __get($key) + { + if ($this->__isset($key)) { + return $this->_propMap[$key]; + } + return null; + } + + /** + * Magic Set Method + * + * @param $key + * @param $value + */ + public function __set($key, $value) + { + if (!is_array($value) && $value === null) { + $this->__unset($key); + } else { + $this->_propMap[$key] = $value; + } + } + + /** + * Converts the input key into a valid Setter Method Name + * + * @param $key + * @return mixed + */ + private function convertToCamelCase($key) + { + return str_replace(' ', '', ucwords(str_replace(array('_', '-'), ' ', $key))); + } + + /** + * Magic isSet Method + * + * @param $key + * @return bool + */ + public function __isset($key) + { + return isset($this->_propMap[$key]); + } + + /** + * Magic Unset Method + * + * @param $key + */ + public function __unset($key) + { + unset($this->_propMap[$key]); + } + + /** + * Converts Params to Array + * + * @param $param + * @return array + */ + private function _convertToArray($param) + { + $ret = array(); + foreach ($param as $k => $v) { + if ($v instanceof PayPalModel) { + $ret[$k] = $v->toArray(); + } elseif (is_array($v) && sizeof($v) <= 0) { + $ret[$k] = array(); + } elseif (is_array($v)) { + $ret[$k] = $this->_convertToArray($v); + } else { + $ret[$k] = $v; + } + } + // If the array is empty, which means an empty object, + // we need to convert array to StdClass object to properly + // represent JSON String + if (sizeof($ret) <= 0) { + $ret = new PayPalModel(); + } + return $ret; + } + + /** + * Fills object value from Array list + * + * @param $arr + * @return $this + */ + public function fromArray($arr) + { + if (!empty($arr)) { + // Iterate over each element in array + foreach ($arr as $k => $v) { + // If the value is an array, it means, it is an object after conversion + if (is_array($v)) { + // Determine the class of the object + if (($clazz = ReflectionUtil::getPropertyClass(get_class($this), $k)) != null) { + // If the value is an associative array, it means, its an object. Just make recursive call to it. + if (empty($v)) { + if (ReflectionUtil::isPropertyClassArray(get_class($this), $k)) { + // It means, it is an array of objects. + $this->assignValue($k, array()); + continue; + } + $o = new $clazz(); + //$arr = array(); + $this->assignValue($k, $o); + } elseif (ArrayUtil::isAssocArray($v)) { + /** @var self $o */ + $o = new $clazz(); + $o->fromArray($v); + $this->assignValue($k, $o); + } else { + // Else, value is an array of object/data + $arr = array(); + // Iterate through each element in that array. + foreach ($v as $nk => $nv) { + if (is_array($nv)) { + $o = new $clazz(); + $o->fromArray($nv); + $arr[$nk] = $o; + } else { + $arr[$nk] = $nv; + } + } + $this->assignValue($k, $arr); + } + } else { + $this->assignValue($k, $v); + } + } else { + $this->assignValue($k, $v); + } + } + } + return $this; + } + + private function assignValue($key, $value) + { + $setter = 'set'. $this->convertToCamelCase($key); + // If we find the setter, use that, otherwise use magic method. + if (method_exists($this, $setter)) { + $this->$setter($value); + } else { + $this->__set($key, $value); + } + } + + /** + * Fills object value from Json string + * + * @param $json + * @return $this + */ + public function fromJson($json) + { + return $this->fromArray(json_decode($json, true)); + } + + /** + * Returns array representation of object + * + * @return array + */ + public function toArray() + { + return $this->_convertToArray($this->_propMap); + } + + /** + * Returns object JSON representation + * + * @param int $options http://php.net/manual/en/json.constants.php + * @return string + */ + public function toJSON($options = 0) + { + // Because of PHP Version 5.3, we cannot use JSON_UNESCAPED_SLASHES option + // Instead we would use the str_replace command for now. + // TODO: Replace this code with return json_encode($this->toArray(), $options | 64); once we support PHP >= 5.4 + if (version_compare(phpversion(), '5.4.0', '>=') === true) { + return json_encode($this->toArray(), $options | 64); + } + return str_replace('\\/', '/', json_encode($this->toArray(), $options)); + } + + /** + * Magic Method for toString + * + * @return string + */ + public function __toString() + { + return $this->toJSON(128); + } +} diff --git a/paypal/PayPal/Common/PayPalResourceModel.php b/paypal/PayPal/Common/PayPalResourceModel.php new file mode 100644 index 0000000..d1ba0f8 --- /dev/null +++ b/paypal/PayPal/Common/PayPalResourceModel.php @@ -0,0 +1,120 @@ +links = $links; + return $this; + } + + /** + * Gets Links + * + * @return \PayPal\Api\Links[] + */ + public function getLinks() + { + return $this->links; + } + + public function getLink($rel) + { + if (is_array($this->links)) { + foreach ($this->links as $link) { + if ($link->getRel() == $rel) { + return $link->getHref(); + } + } + } + return null; + } + + /** + * Append Links to the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function addLink($links) + { + if (!$this->getLinks()) { + return $this->setLinks(array($links)); + } else { + return $this->setLinks( + array_merge($this->getLinks(), array($links)) + ); + } + } + + /** + * Remove Links from the list. + * + * @param \PayPal\Api\Links $links + * @return $this + */ + public function removeLink($links) + { + return $this->setLinks( + array_diff($this->getLinks(), array($links)) + ); + } + + + /** + * Execute SDK Call to Paypal services + * + * @param string $url + * @param string $method + * @param string $payLoad + * @param array $headers + * @param ApiContext $apiContext + * @param PayPalRestCall $restCall + * @param array $handlers + * @return string json response of the object + */ + protected static function executeCall($url, $method, $payLoad, $headers = array(), $apiContext = null, $restCall = null, $handlers = array('PayPal\Handler\RestHandler')) + { + //Initialize the context and rest call object if not provided explicitly + $apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential); + $restCall = $restCall ? $restCall : new PayPalRestCall($apiContext); + + //Make the execution call + $json = $restCall->execute($handlers, $url, $method, $payLoad, $headers); + return $json; + } + + /** + * Updates Access Token using long lived refresh token + * + * @param string|null $refreshToken + * @param ApiContext $apiContext + * @return void + */ + public function updateAccessToken($refreshToken, $apiContext) + { + $apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential); + $apiContext->getCredential()->updateAccessToken($apiContext->getConfig(), $refreshToken); + } +} diff --git a/paypal/PayPal/Common/PayPalUserAgent.php b/paypal/PayPal/Common/PayPalUserAgent.php new file mode 100644 index 0000000..c3131ed --- /dev/null +++ b/paypal/PayPal/Common/PayPalUserAgent.php @@ -0,0 +1,57 @@ +getDocComment(), + $annots, + PREG_PATTERN_ORDER)) { + return null; + } + foreach ($annots[1] as $i => $annot) { + $annotations[strtolower($annot)] = empty($annots[2][$i]) ? true : rtrim($annots[2][$i], " \t\n\r)"); + } + + return $annotations; + } + + /** + * preg_replace_callback callback function + * + * @param $match + * @return string + */ + private static function replace_callback($match) + { + return ucwords($match[2]); + } + + /** + * Returns the properly formatted getter function name based on class name and property + * Formats the property name to a standard getter function + * + * @param string $class + * @param string $propertyName + * @return string getter function name + */ + public static function getter($class, $propertyName) + { + return method_exists($class, "get" . ucfirst($propertyName)) ? + "get" . ucfirst($propertyName) : + "get" . preg_replace_callback("/([_\-\s]?([a-z0-9]+))/", "self::replace_callback", $propertyName); + } +} diff --git a/paypal/PayPal/Converter/FormatConverter.php b/paypal/PayPal/Converter/FormatConverter.php new file mode 100644 index 0000000..82c1be5 --- /dev/null +++ b/paypal/PayPal/Converter/FormatConverter.php @@ -0,0 +1,62 @@ + 0, 'TWD' => 0, 'HUF' => 0); + if ($currency && array_key_exists($currency, $currencyDecimals)) { + if (strpos($value, ".") !== false && (floor($value) != $value)) { + //throw exception if it has decimal values for JPY, TWD and HUF which does not ends with .00 + throw new \InvalidArgumentException("value cannot have decimals for $currency currency"); + } + $decimals = $currencyDecimals[$currency]; + } elseif (strpos($value, ".") === false) { + // Check if value has decimal values. If not no need to assign 2 decimals with .00 at the end + $decimals = 0; + } + return self::formatToNumber($value, $decimals); + } +} diff --git a/paypal/PayPal/Core/PayPalConfigManager.php b/paypal/PayPal/Core/PayPalConfigManager.php new file mode 100644 index 0000000..c341bb1 --- /dev/null +++ b/paypal/PayPal/Core/PayPalConfigManager.php @@ -0,0 +1,159 @@ +addConfigFromIni($configFile); + } + } + + /** + * Returns the singleton object + * + * @return $this + */ + public static function getInstance() + { + if (!isset(self::$instance)) { + self::$instance = new self(); + } + return self::$instance; + } + + /** + * Add Configuration from configuration.ini files + * + * @param string $fileName + * @return $this + */ + public function addConfigFromIni($fileName) + { + if ($configs = parse_ini_file($fileName)) { + $this->addConfigs($configs); + } + return $this; + } + + /** + * If a configuration exists in both arrays, + * then the element from the first array will be used and + * the matching key's element from the second array will be ignored. + * + * @param array $configs + * @return $this + */ + public function addConfigs($configs = array()) + { + $this->configs = $configs + $this->configs; + return $this; + } + + /** + * Simple getter for configuration params + * If an exact match for key is not found, + * does a "contains" search on the key + * + * @param string $searchKey + * @return array + */ + public function get($searchKey) + { + if (array_key_exists($searchKey, $this->configs)) { + return $this->configs[$searchKey]; + } else { + $arr = array(); + if ($searchKey !== '') { + foreach ($this->configs as $k => $v) { + if (strstr($k, $searchKey)) { + $arr[$k] = $v; + } + } + } + + return $arr; + } + } + + /** + * Utility method for handling account configuration + * return config key corresponding to the API userId passed in + * + * If $userId is null, returns config keys corresponding to + * all configured accounts + * + * @param string|null $userId + * @return array|string + */ + public function getIniPrefix($userId = null) + { + if ($userId == null) { + $arr = array(); + foreach ($this->configs as $key => $value) { + $pos = strpos($key, '.'); + if (strstr($key, "acct")) { + $arr[] = substr($key, 0, $pos); + } + } + return array_unique($arr); + } else { + $iniPrefix = array_search($userId, $this->configs); + $pos = strpos($iniPrefix, '.'); + $acct = substr($iniPrefix, 0, $pos); + + return $acct; + } + } + + /** + * returns the config file hashmap + */ + public function getConfigHashmap() + { + return $this->configs; + } + + /** + * Disabling __clone call + */ + public function __clone() + { + trigger_error('Clone is not allowed.', E_USER_ERROR); + } +} diff --git a/paypal/PayPal/Core/PayPalConstants.php b/paypal/PayPal/Core/PayPalConstants.php new file mode 100644 index 0000000..942b86a --- /dev/null +++ b/paypal/PayPal/Core/PayPalConstants.php @@ -0,0 +1,27 @@ +initCredential($config); + } catch (\Exception $e) { + $this->credentialHashmap = array(); + throw $e; + } + } + + /** + * Create singleton instance for this class. + * + * @param array|null $config + * @return PayPalCredentialManager + */ + public static function getInstance($config = null) + { + if (!self::$instance) { + self::$instance = new self($config == null ? PayPalConfigManager::getInstance()->getConfigHashmap() : $config); + } + return self::$instance; + } + + /** + * Load credentials for multiple accounts, with priority given to Signature credential. + * + * @param array $config + */ + private function initCredential($config) + { + $suffix = 1; + $prefix = "acct"; + + $arr = array(); + foreach ($config as $k => $v) { + if (strstr($k, $prefix)) { + $arr[$k] = $v; + } + } + $credArr = $arr; + + $arr = array(); + foreach ($config as $key => $value) { + $pos = strpos($key, '.'); + if (strstr($key, "acct")) { + $arr[] = substr($key, 0, $pos); + } + } + $arrayPartKeys = array_unique($arr); + + $key = $prefix . $suffix; + $userName = null; + while (in_array($key, $arrayPartKeys)) { + if (isset($credArr[$key . ".ClientId"]) && isset($credArr[$key . ".ClientSecret"])) { + $userName = $key; + $this->credentialHashmap[$userName] = new OAuthTokenCredential( + $credArr[$key . ".ClientId"], + $credArr[$key . ".ClientSecret"] + ); + } + if ($userName && $this->defaultAccountName == null) { + if (array_key_exists($key . '.UserName', $credArr)) { + $this->defaultAccountName = $credArr[$key . '.UserName']; + } else { + $this->defaultAccountName = $key; + } + } + $suffix++; + $key = $prefix . $suffix; + } + } + + /** + * Sets credential object for users + * + * @param \PayPal\Auth\OAuthTokenCredential $credential + * @param string|null $userId User Id associated with the account + * @param bool $default If set, it would make it as a default credential for all requests + * + * @return $this + */ + public function setCredentialObject(OAuthTokenCredential $credential, $userId = null, $default = true) + { + $key = $userId == null ? 'default' : $userId; + $this->credentialHashmap[$key] = $credential; + if ($default) { + $this->defaultAccountName = $key; + } + return $this; + } + + /** + * Obtain Credential Object based on UserId provided. + * + * @param null $userId + * @return OAuthTokenCredential + * @throws PayPalInvalidCredentialException + */ + public function getCredentialObject($userId = null) + { + if ($userId == null && array_key_exists($this->defaultAccountName, $this->credentialHashmap)) { + $credObj = $this->credentialHashmap[$this->defaultAccountName]; + } elseif (array_key_exists($userId, $this->credentialHashmap)) { + $credObj = $this->credentialHashmap[$userId]; + } + + if (empty($credObj)) { + throw new PayPalInvalidCredentialException("Credential not found for " . ($userId ? $userId : " default user") . + ". Please make sure your configuration/APIContext has credential information"); + } + return $credObj; + } + + /** + * Disabling __clone call + */ + public function __clone() + { + trigger_error('Clone is not allowed.', E_USER_ERROR); + } +} diff --git a/paypal/PayPal/Core/PayPalHttpConfig.php b/paypal/PayPal/Core/PayPalHttpConfig.php new file mode 100644 index 0000000..8e431b3 --- /dev/null +++ b/paypal/PayPal/Core/PayPalHttpConfig.php @@ -0,0 +1,302 @@ + 6, + CURLOPT_CONNECTTIMEOUT => 10, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_TIMEOUT => 60, // maximum number of seconds to allow cURL functions to execute + CURLOPT_USERAGENT => 'PayPal-PHP-SDK', + CURLOPT_HTTPHEADER => array(), + CURLOPT_SSL_VERIFYHOST => 2, + CURLOPT_SSL_VERIFYPEER => 1, + CURLOPT_SSL_CIPHER_LIST => 'TLSv1:TLSv1.2' + //Allowing TLSv1 cipher list. + //Adding it like this for backward compatibility with older versions of curl + ); + + const HEADER_SEPARATOR = ';'; + const HTTP_GET = 'GET'; + const HTTP_POST = 'POST'; + + private $headers = array(); + + private $curlOptions; + + private $url; + + private $method; + + /*** + * Number of times to retry a failed HTTP call + */ + private $retryCount = 0; + + /** + * Default Constructor + * + * @param string $url + * @param string $method HTTP method (GET, POST etc) defaults to POST + * @param array $configs All Configurations + */ + public function __construct($url = null, $method = self::HTTP_POST, $configs = array()) + { + $this->url = $url; + $this->method = $method; + $this->curlOptions = $this->getHttpConstantsFromConfigs($configs, 'http.') + self::$defaultCurlOptions; + // Update the Cipher List based on OpenSSL or NSS settings + $curl = curl_version(); + $sslVersion = isset($curl['ssl_version']) ? $curl['ssl_version'] : ''; + if($sslVersion && substr_compare($sslVersion, "NSS/", 0, strlen("NSS/")) === 0) { + //Remove the Cipher List for NSS + $this->removeCurlOption(CURLOPT_SSL_CIPHER_LIST); + } + } + + /** + * Gets Url + * + * @return null|string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Gets Method + * + * @return string + */ + public function getMethod() + { + return $this->method; + } + + /** + * Gets all Headers + * + * @return array + */ + public function getHeaders() + { + return $this->headers; + } + + /** + * Get Header by Name + * + * @param $name + * @return string|null + */ + public function getHeader($name) + { + if (array_key_exists($name, $this->headers)) { + return $this->headers[$name]; + } + return null; + } + + /** + * Sets Url + * + * @param $url + */ + public function setUrl($url) + { + $this->url = $url; + } + + /** + * Set Headers + * + * @param array $headers + */ + public function setHeaders(array $headers = array()) + { + $this->headers = $headers; + } + + /** + * Adds a Header + * + * @param $name + * @param $value + * @param bool $overWrite allows you to override header value + */ + public function addHeader($name, $value, $overWrite = true) + { + if (!array_key_exists($name, $this->headers) || $overWrite) { + $this->headers[$name] = $value; + } else { + $this->headers[$name] = $this->headers[$name] . self::HEADER_SEPARATOR . $value; + } + } + + /** + * Removes a Header + * + * @param $name + */ + public function removeHeader($name) + { + unset($this->headers[$name]); + } + + /** + * Gets all curl options + * + * @return array + */ + public function getCurlOptions() + { + return $this->curlOptions; + } + + /** + * Add Curl Option + * + * @param string $name + * @param mixed $value + */ + public function addCurlOption($name, $value) + { + $this->curlOptions[$name] = $value; + } + + /** + * Removes a curl option from the list + * + * @param $name + */ + public function removeCurlOption($name) + { + unset($this->curlOptions[$name]); + } + + /** + * Set Curl Options. Overrides all curl options + * + * @param $options + */ + public function setCurlOptions($options) + { + $this->curlOptions = $options; + } + + /** + * Set ssl parameters for certificate based client authentication + * + * @param $certPath + * @param null $passPhrase + */ + public function setSSLCert($certPath, $passPhrase = null) + { + $this->curlOptions[CURLOPT_SSLCERT] = realpath($certPath); + if (isset($passPhrase) && trim($passPhrase) != "") { + $this->curlOptions[CURLOPT_SSLCERTPASSWD] = $passPhrase; + } + } + + /** + * Set connection timeout in seconds + * + * @param integer $timeout + */ + public function setHttpTimeout($timeout) + { + $this->curlOptions[CURLOPT_CONNECTTIMEOUT] = $timeout; + } + + /** + * Set HTTP proxy information + * + * @param string $proxy + * @throws PayPalConfigurationException + */ + public function setHttpProxy($proxy) + { + $urlParts = parse_url($proxy); + if ($urlParts == false || !array_key_exists("host", $urlParts)) { + throw new PayPalConfigurationException("Invalid proxy configuration " . $proxy); + } + $this->curlOptions[CURLOPT_PROXY] = $urlParts["host"]; + if (isset($urlParts["port"])) { + $this->curlOptions[CURLOPT_PROXY] .= ":" . $urlParts["port"]; + } + if (isset($urlParts["user"])) { + $this->curlOptions[CURLOPT_PROXYUSERPWD] = $urlParts["user"] . ":" . $urlParts["pass"]; + } + } + + /** + * Set Http Retry Counts + * + * @param int $retryCount + */ + public function setHttpRetryCount($retryCount) + { + $this->retryCount = $retryCount; + } + + /** + * Get Http Retry Counts + * + * @return int + */ + public function getHttpRetryCount() + { + return $this->retryCount; + } + + /** + * Sets the User-Agent string on the HTTP request + * + * @param string $userAgentString + */ + public function setUserAgent($userAgentString) + { + $this->curlOptions[CURLOPT_USERAGENT] = $userAgentString; + } + + /** + * Retrieves an array of constant key, and value based on Prefix + * + * @param array $configs + * @param $prefix + * @return array + */ + public function getHttpConstantsFromConfigs($configs = array(), $prefix) + { + $arr = array(); + if ($prefix != null && is_array($configs)) { + foreach ($configs as $k => $v) { + // Check if it startsWith + if (substr($k, 0, strlen($prefix)) === $prefix) { + $newKey = ltrim($k, $prefix); + if (defined($newKey)) { + $arr[constant($newKey)] = $v; + } + } + } + } + return $arr; + } +} diff --git a/paypal/PayPal/Core/PayPalHttpConnection.php b/paypal/PayPal/Core/PayPalHttpConnection.php new file mode 100644 index 0000000..cf5253c --- /dev/null +++ b/paypal/PayPal/Core/PayPalHttpConnection.php @@ -0,0 +1,223 @@ +httpConfig = $httpConfig; + $this->logger = PayPalLoggingManager::getInstance(__CLASS__); + } + + /** + * Gets all Http Headers + * + * @return array + */ + private function getHttpHeaders() + { + $ret = array(); + foreach ($this->httpConfig->getHeaders() as $k => $v) { + $ret[] = "$k: $v"; + } + return $ret; + } + + /** + * Parses the response headers for debugging. + * + * @param resource $ch + * @param string $data + * @return int + */ + protected function parseResponseHeaders($ch, $data) { + if (!$this->skippedHttpStatusLine) { + $this->skippedHttpStatusLine = true; + return strlen($data); + } + + $trimmedData = trim($data); + if (strlen($trimmedData) == 0) { + return strlen($data); + } + + // Added condition to ignore extra header which dont have colon ( : ) + if (strpos($trimmedData, ":") == false) { + return strlen($data); + } + + list($key, $value) = explode(":", $trimmedData, 2); + + $key = trim($key); + $value = trim($value); + + // This will skip over the HTTP Status Line and any other lines + // that don't look like header lines with values + if (strlen($key) > 0 && strlen($value) > 0) { + // This is actually a very basic way of looking at response headers + // and may miss a few repeated headers with different (appended) + // values but this should work for debugging purposes. + $this->responseHeaders[$key] = $value; + } + + return strlen($data); + } + + + /** + * Implodes a key/value array for printing. + * + * @param array $arr + * @return string + */ + protected function implodeArray($arr) { + $retStr = ''; + foreach($arr as $key => $value) { + $retStr .= $key . ': ' . $value . ', '; + } + rtrim($retStr, ', '); + return $retStr; + } + + /** + * Executes an HTTP request + * + * @param string $data query string OR POST content as a string + * @return mixed + * @throws PayPalConnectionException + */ + public function execute($data) + { + //Initialize the logger + $this->logger->info($this->httpConfig->getMethod() . ' ' . $this->httpConfig->getUrl()); + + //Initialize Curl Options + $ch = curl_init($this->httpConfig->getUrl()); + $options = $this->httpConfig->getCurlOptions(); + if (empty($options[CURLOPT_HTTPHEADER])) { + unset($options[CURLOPT_HTTPHEADER]); + } + curl_setopt_array($ch, $options); + curl_setopt($ch, CURLOPT_URL, $this->httpConfig->getUrl()); + curl_setopt($ch, CURLOPT_HEADER, false); + curl_setopt($ch, CURLINFO_HEADER_OUT, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, $this->getHttpHeaders()); + + //Determine Curl Options based on Method + switch ($this->httpConfig->getMethod()) { + case 'POST': + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $data); + break; + case 'PUT': + case 'PATCH': + case 'DELETE': + curl_setopt($ch, CURLOPT_POSTFIELDS, $data); + break; + } + + //Default Option if Method not of given types in switch case + if ($this->httpConfig->getMethod() != null) { + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->httpConfig->getMethod()); + } + + $this->responseHeaders = array(); + $this->skippedHttpStatusLine = false; + curl_setopt($ch, CURLOPT_HEADERFUNCTION, array($this, 'parseResponseHeaders')); + + //Execute Curl Request + $result = curl_exec($ch); + //Retrieve Response Status + $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); + + //Retry if Certificate Exception + if (curl_errno($ch) == 60) { + $this->logger->info("Invalid or no certificate authority found - Retrying using bundled CA certs file"); + curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem'); + $result = curl_exec($ch); + //Retrieve Response Status + $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); + } + + //Throw Exception if Retries and Certificates doenst work + if (curl_errno($ch)) { + $ex = new PayPalConnectionException( + $this->httpConfig->getUrl(), + curl_error($ch), + curl_errno($ch) + ); + curl_close($ch); + throw $ex; + } + + // Get Request and Response Headers + $requestHeaders = curl_getinfo($ch, CURLINFO_HEADER_OUT); + $this->logger->debug("Request Headers \t: " . str_replace("\r\n", ", ", $requestHeaders)); + $this->logger->debug(($data && $data != '' ? "Request Data\t\t: " . $data : "No Request Payload") . "\n" . str_repeat('-', 128) . "\n"); + $this->logger->info("Response Status \t: " . $httpStatus); + $this->logger->debug("Response Headers\t: " . $this->implodeArray($this->responseHeaders)); + + //Close the curl request + curl_close($ch); + + //More Exceptions based on HttpStatus Code + if ($httpStatus < 200 || $httpStatus >= 300) { + $ex = new PayPalConnectionException( + $this->httpConfig->getUrl(), + "Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}.", + $httpStatus + ); + $ex->setData($result); + $this->logger->error("Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}. " . $result); + $this->logger->debug("\n\n" . str_repeat('=', 128) . "\n"); + throw $ex; + } + + $this->logger->debug(($result && $result != '' ? "Response Data \t: " . $result : "No Response Body") . "\n\n" . str_repeat('=', 128) . "\n"); + + //Return result object + return $result; + } +} diff --git a/paypal/PayPal/Core/PayPalLoggingManager.php b/paypal/PayPal/Core/PayPalLoggingManager.php new file mode 100644 index 0000000..90521a8 --- /dev/null +++ b/paypal/PayPal/Core/PayPalLoggingManager.php @@ -0,0 +1,119 @@ +getConfigHashmap(); + // Checks if custom factory defined, and is it an implementation of @PayPalLogFactory + $factory = array_key_exists('log.AdapterFactory', $config) && in_array('PayPal\Log\PayPalLogFactory', class_implements($config['log.AdapterFactory'])) ? $config['log.AdapterFactory'] : '\PayPal\Log\PayPalDefaultLogFactory'; + /** @var PayPalLogFactory $factoryInstance */ + $factoryInstance = new $factory(); + $this->logger = $factoryInstance->getLogger($loggerName); + $this->loggerName = $loggerName; + } + + /** + * Log Error + * + * @param string $message + */ + public function error($message) + { + $this->logger->error($message); + } + + /** + * Log Warning + * + * @param string $message + */ + public function warning($message) + { + $this->logger->warning($message); + } + + /** + * Log Info + * + * @param string $message + */ + public function info($message) + { + $this->logger->info($message); + } + + /** + * Log Fine + * + * @param string $message + */ + public function fine($message) + { + $this->info($message); + } + + /** + * Log Debug + * + * @param string $message + */ + public function debug($message) + { + $config = PayPalConfigManager::getInstance()->getConfigHashmap(); + // Disable debug in live mode. + if (array_key_exists('mode', $config) && $config['mode'] != 'live') { + $this->logger->debug($message); + } + } +} diff --git a/paypal/PayPal/Core/cacert.pem b/paypal/PayPal/Core/cacert.pem new file mode 100644 index 0000000..1202c20 --- /dev/null +++ b/paypal/PayPal/Core/cacert.pem @@ -0,0 +1,171 @@ +Verisign Class 3 Public Primary Certification Authority +======================================================= +-----BEGIN CERTIFICATE----- +MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkGA1UEBhMCVVMx +FzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmltYXJ5 +IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVow +XzELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAz +IFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUA +A4GNADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhEBarsAx94 +f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/isI19wKTakyYbnsZogy1Ol +hec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0GCSqGSIb3DQEBAgUAA4GBALtMEivPLCYA +TxQT3ab7/AoRhIzzKBxnki98tsX63/Dolbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59Ah +WM1pF+NEHJwZRDmJXNycAA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2Omuf +Tqj/ZA1k +-----END CERTIFICATE----- + +Verisign Class 3 Public Primary Certification Authority - G2 +============================================================ +-----BEGIN CERTIFICATE----- +MIIDAjCCAmsCEH3Z/gfPqB63EHln+6eJNMYwDQYJKoZIhvcNAQEFBQAwgcExCzAJBgNVBAYTAlVT +MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFy +eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2ln +biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVz +dCBOZXR3b3JrMB4XDTk4MDUxODAwMDAwMFoXDTI4MDgwMTIzNTk1OVowgcExCzAJBgNVBAYTAlVT +MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMgUHJpbWFy +eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2ln +biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVz +dCBOZXR3b3JrMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDMXtERXVxp0KvTuWpMmR9ZmDCO +FoUgRm1HP9SFIIThbbP4pO0M8RcPO/mn+SXXwc+EY/J8Y8+iR/LGWzOOZEAEaMGAuWQcRXfH2G71 +lSk8UOg013gfqLptQ5GVj0VXXn7F+8qkBOvqlzdUMG+7AUcyM83cV5tkaWH4mx0ciU9cZwIDAQAB +MA0GCSqGSIb3DQEBBQUAA4GBAFFNzb5cy5gZnBWyATl4Lk0PZ3BwmcYQWpSkU01UbSuvDV1Ai2TT +1+7eVmGSX6bEHRBhNtMsJzzoKQm5EWR0zLVznxxIqbxhAe7iF6YM40AIOw7n60RzKprxaZLvcRTD +Oaxxp5EJb+RxBrO6WVcmeQD2+A2iMzAo1KpYoJ2daZH9 +-----END CERTIFICATE----- + + +Verisign Class 3 Public Primary Certification Authority - G3 +============================================================ +-----BEGIN CERTIFICATE----- +MIIEGjCCAwICEQCbfgZJoz5iudXukEhxKe9XMA0GCSqGSIb3DQEBBQUAMIHKMQswCQYDVQQGEwJV +UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv +cmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl +IG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQsw +CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRy +dXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhv +cml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDMgUHVibGljIFByaW1hcnkg +Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC +ggEBAMu6nFL8eB8aHm8bN3O9+MlrlBIwT/A2R/XQkQr1F8ilYcEWQE37imGQ5XYgwREGfassbqb1 +EUGO+i2tKmFZpGcmTNDovFJbcCAEWNF6yaRpvIMXZK0Fi7zQWM6NjPXr8EJJC52XJ2cybuGukxUc +cLwgTS8Y3pKI6GyFVxEa6X7jJhFUokWWVYPKMIno3Nij7SqAP395ZVc+FSBmCC+Vk7+qRy+oRpfw +EuL+wgorUeZ25rdGt+INpsyow0xZVYnm6FNcHOqd8GIWC6fJXwzw3sJ2zq/3avL6QaaiMxTJ5Xpj +055iN9WFZZ4O5lMkdBteHRJTW8cs54NJOxWuimi5V5cCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA +ERSWwauSCPc/L8my/uRan2Te2yFPhpk0djZX3dAVL8WtfxUfN2JzPtTnX84XA9s1+ivbrmAJXx5f +j267Cz3qWhMeDGBvtcC1IyIuBwvLqXTLR7sdwdela8wv0kL9Sd2nic9TutoAWii/gt/4uhMdUIaC +/Y4wjylGsB49Ndo4YhYYSq3mtlFs3q9i6wHQHiT+eo8SGhJouPtmmRQURVyu565pF4ErWjfJXir0 +xuKhXFSbplQAz/DxwceYMBo7Nhbbo27q/a2ywtrvAkcTisDxszGtTxzhT5yvDwyd93gN2PQ1VoDa +t20Xj50egWTh/sVFuq1ruQp6Tk9LhO5L8X3dEQ== +-----END CERTIFICATE----- + +Verisign Class 4 Public Primary Certification Authority - G3 +============================================================ +-----BEGIN CERTIFICATE----- +MIIEGjCCAwICEQDsoKeLbnVqAc/EfMwvlF7XMA0GCSqGSIb3DQEBBQUAMIHKMQswCQYDVQQGEwJV +UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv +cmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl +IG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDQgUHVibGljIFByaW1hcnkgQ2VydGlmaWNh +dGlvbiBBdXRob3JpdHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQsw +CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRy +dXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhv +cml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDQgUHVibGljIFByaW1hcnkg +Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC +ggEBAK3LpRFpxlmr8Y+1GQ9Wzsy1HyDkniYlS+BzZYlZ3tCD5PUPtbut8XzoIfzk6AzufEUiGXaS +tBO3IFsJ+mGuqPKljYXCKtbeZjbSmwL0qJJgfJxptI8kHtCGUvYynEFYHiK9zUVilQhu0GbdU6LM +8BDcVHOLBKFGMzNcF0C5nk3T875Vg+ixiY5afJqWIpA7iCXy0lOIAgwLePLmNxdLMEYH5IBtptiW +Lugs+BGzOA1mppvqySNb247i8xOOGlktqgLw7KSHZtzBP/XYufTsgsbSPZUd5cBPhMnZo0QoBmrX +Razwa2rvTl/4EYIeOGM0ZlDUPpNz+jDDZq3/ky2X7wMCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA +j/ola09b5KROJ1WrIhVZPMq1CtRK26vdoV9TxaBXOcLORyu+OshWv8LZJxA6sQU8wHcxuzrTBXtt +mhwwjIDLk5Mqg6sFUYICABFna/OIYUdfA5PVWw3g8dShMjWFsjrbsIKr0csKvE+MW8VLADsfKoKm +fjaF3H48ZwC15DtS4KjrXRX5xm3wrR0OhbepmnMUWluPQSjA1egtTaRezarZ7c7c2NU8Qh0XwRJd +RTjDOPP8hS6DRkiy1yBfkjaP53kPmF6Z6PDQpLv1U70qzlmwr25/bLvSHgCwIe34QWKCudiyxLtG +UPMxxY8BqHTr9Xgn2uf3ZkPznoM+IKrDNWCRzg== +-----END CERTIFICATE----- +VeriSign Class 3 Public Primary Certification Authority - G5 +============================================================ +-----BEGIN CERTIFICATE----- +MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCByjELMAkGA1UE +BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO +ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk +IHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRp +ZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCB +yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2ln +biBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBh +dXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmlt +YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw +ggEKAoIBAQCvJAgIKXo1nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKz +j/i5Vbext0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIzSdhD +Y2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQGBO+QueQA5N06tRn/ +Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+rCpSx4/VBEnkjWNHiDxpg8v+R70r +fk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/ +BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2Uv +Z2lmMCEwHzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy +aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKvMzEzMA0GCSqG +SIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzEp6B4Eq1iDkVwZMXnl2YtmAl+ +X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKE +KQsTb47bDN0lAtukixlE0kF6BWlKWE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiC +Km0oHw0LxOXnGiYZ4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vE +ZV8NhnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq +-----END CERTIFICATE----- +VeriSign Universal Root Certification Authority +=============================================== +-----BEGIN CERTIFICATE----- +MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCBvTELMAkGA1UE +BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO +ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwOCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk +IHVzZSBvbmx5MTgwNgYDVQQDEy9WZXJpU2lnbiBVbml2ZXJzYWwgUm9vdCBDZXJ0aWZpY2F0aW9u +IEF1dGhvcml0eTAeFw0wODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIG9MQswCQYDVQQGEwJV +UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv +cmsxOjA4BgNVBAsTMShjKSAyMDA4IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl +IG9ubHkxODA2BgNVBAMTL1ZlcmlTaWduIFVuaXZlcnNhbCBSb290IENlcnRpZmljYXRpb24gQXV0 +aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx2E3XrEBNNti1xWb/1hajCMj +1mCOkdeQmIN65lgZOIzF9uVkhbSicfvtvbnazU0AtMgtc6XHaXGVHzk8skQHnOgO+k1KxCHfKWGP +MiJhgsWHH26MfF8WIFFE0XBPV+rjHOPMee5Y2A7Cs0WTwCznmhcrewA3ekEzeOEz4vMQGn+HLL72 +9fdC4uW/h2KJXwBL38Xd5HVEMkE6HnFuacsLdUYI0crSK5XQz/u5QGtkjFdN/BMReYTtXlT2NJ8I +AfMQJQYXStrxHXpma5hgZqTZ79IugvHw7wnqRMkVauIDbjPTrJ9VAMf2CGqUuV/c4DPxhGD5WycR +tPwW8rtWaoAljQIDAQABo4GyMIGvMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMG0G +CCsGAQUFBwEMBGEwX6FdoFswWTBXMFUWCWltYWdlL2dpZjAhMB8wBwYFKw4DAhoEFI/l0xqGrI2O +a8PPgGrUSBgsexkuMCUWI2h0dHA6Ly9sb2dvLnZlcmlzaWduLmNvbS92c2xvZ28uZ2lmMB0GA1Ud +DgQWBBS2d/ppSEefUxLVwuoHMnYH0ZcHGTANBgkqhkiG9w0BAQsFAAOCAQEASvj4sAPmLGd75JR3 +Y8xuTPl9Dg3cyLk1uXBPY/ok+myDjEedO2Pzmvl2MpWRsXe8rJq+seQxIcaBlVZaDrHC1LGmWazx +Y8u4TB1ZkErvkBYoH1quEPuBUDgMbMzxPcP1Y+Oz4yHJJDnp/RVmRvQbEdBNc6N9Rvk97ahfYtTx +P/jgdFcrGJ2BtMQo2pSXpXDrrB2+BxHw1dvd5Yzw1TKwg+ZX4o+/vqGqvz0dtdQ46tewXDpPaj+P +wGZsY6rp2aQW9IHRlRQOfc2VNNnSj3BzgXucfr2YYdhFh5iQxeuGMMY1v/D/w1WIg0vvBZIGcfK4 +mJO37M2CYfE45k+XmCpajQ== +-----END CERTIFICATE----- + +VeriSign Class 3 Public Primary Certification Authority - G4 +============================================================ +-----BEGIN CERTIFICATE----- +MIIDhDCCAwqgAwIBAgIQL4D+I4wOIg9IZxIokYesszAKBggqhkjOPQQDAzCByjELMAkGA1UEBhMC +VVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3 +b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVz +ZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmlj +YXRpb24gQXV0aG9yaXR5IC0gRzQwHhcNMDcxMTA1MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCByjEL +MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBU +cnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRo +b3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5 +IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASnVnp8 +Utpkmw4tXNherJI9/gHmGUo9FANL+mAnINmDiWn6VMaaGF5VKmTeBvaNSjutEDxlPZCIBIngMGGz +rl0Bp3vefLK+ymVhAIau2o970ImtTR1ZmkGxvEeA3J5iw/mjgbIwga8wDwYDVR0TAQH/BAUwAwEB +/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEw +HzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVyaXNpZ24u +Y29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFLMWkf3upm7ktS5Jj4d4gYDs5bG1MAoGCCqGSM49BAMD +A2gAMGUCMGYhDBgmYFo4e1ZC4Kf8NoRRkSAsdk1DPcQdhCPQrNZ8NQbOzWm9kA3bbEhCHQ6qQgIx +AJw9SDkjOVgaFRJZap7v1VmyHVIsmXHNxynfGyphe3HR3vPA5Q06Sqotp9iGKt0uEA== +-----END CERTIFICATE----- +Verisign Class 3 Public Primary Certification Authority +======================================================= +-----BEGIN CERTIFICATE----- +MIICPDCCAaUCEDyRMcsf9tAbDpq40ES/Er4wDQYJKoZIhvcNAQEFBQAwXzELMAkGA1UEBhMCVVMx +FzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmltYXJ5 +IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2MDEyOTAwMDAwMFoXDTI4MDgwMjIzNTk1OVow +XzELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAz +IFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUA +A4GNADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhEBarsAx94 +f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/isI19wKTakyYbnsZogy1Ol +hec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0GCSqGSIb3DQEBBQUAA4GBABByUqkFFBky +CEHwxWsKzH4PIRnN5GfcX6kb5sroc50i2JhucwNhkcV8sEVAbkSdjbCxlnRhLQ2pRdKkkirWmnWX +bj9T/UWZYB2oK0z5XqcJ2HUw19JlYD1n1khVdWk/kfVIC0dpImmClr7JyDiGSnoscxlIaU5rfGW/ +D/xwzoiQ +-----END CERTIFICATE----- diff --git a/paypal/PayPal/Exception/PayPalConfigurationException.php b/paypal/PayPal/Exception/PayPalConfigurationException.php new file mode 100644 index 0000000..5105747 --- /dev/null +++ b/paypal/PayPal/Exception/PayPalConfigurationException.php @@ -0,0 +1,23 @@ +url = $url; + } + + /** + * Sets Data + * + * @param $data + */ + public function setData($data) + { + $this->data = $data; + } + + /** + * Gets Data + * + * @return string + */ + public function getData() + { + return $this->data; + } + + /** + * Gets Url + * + * @return string + */ + public function getUrl() + { + return $this->url; + } +} diff --git a/paypal/PayPal/Exception/PayPalInvalidCredentialException.php b/paypal/PayPal/Exception/PayPalInvalidCredentialException.php new file mode 100644 index 0000000..09ad27a --- /dev/null +++ b/paypal/PayPal/Exception/PayPalInvalidCredentialException.php @@ -0,0 +1,35 @@ +getLine() . ' in ' . $this->getFile() + . ': ' . $this->getMessage() . ''; + return $errorMsg; + } +} diff --git a/paypal/PayPal/Exception/PayPalMissingCredentialException.php b/paypal/PayPal/Exception/PayPalMissingCredentialException.php new file mode 100644 index 0000000..6ace3b4 --- /dev/null +++ b/paypal/PayPal/Exception/PayPalMissingCredentialException.php @@ -0,0 +1,36 @@ +getLine() . ' in ' . $this->getFile() + . ': ' . $this->getMessage() . ''; + + return $errorMsg; + } +} diff --git a/paypal/PayPal/Handler/IPayPalHandler.php b/paypal/PayPal/Handler/IPayPalHandler.php new file mode 100644 index 0000000..0d1c8ff --- /dev/null +++ b/paypal/PayPal/Handler/IPayPalHandler.php @@ -0,0 +1,20 @@ +apiContext = $apiContext; + } + + /** + * @param PayPalHttpConfig $httpConfig + * @param string $request + * @param mixed $options + * @return mixed|void + * @throws PayPalConfigurationException + * @throws PayPalInvalidCredentialException + * @throws PayPalMissingCredentialException + */ + public function handle($httpConfig, $request, $options) + { + $config = $this->apiContext->getConfig(); + + $httpConfig->setUrl( + rtrim(trim($this->_getEndpoint($config)), '/') . + (isset($options['path']) ? $options['path'] : '') + ); + + $headers = array( + "User-Agent" => PayPalUserAgent::getValue(PayPalConstants::SDK_NAME, PayPalConstants::SDK_VERSION), + "Authorization" => "Basic " . base64_encode($options['clientId'] . ":" . $options['clientSecret']), + "Accept" => "*/*" + ); + $httpConfig->setHeaders($headers); + + // Add any additional Headers that they may have provided + $headers = $this->apiContext->getRequestHeaders(); + foreach ($headers as $key => $value) { + $httpConfig->addHeader($key, $value); + } + } + + /** + * Get HttpConfiguration object for OAuth API + * + * @param array $config + * + * @return PayPalHttpConfig + * @throws \PayPal\Exception\PayPalConfigurationException + */ + private static function _getEndpoint($config) + { + if (isset($config['oauth.EndPoint'])) { + $baseEndpoint = $config['oauth.EndPoint']; + } elseif (isset($config['service.EndPoint'])) { + $baseEndpoint = $config['service.EndPoint']; + } elseif (isset($config['mode'])) { + switch (strtoupper($config['mode'])) { + case 'SANDBOX': + $baseEndpoint = PayPalConstants::REST_SANDBOX_ENDPOINT; + break; + case 'LIVE': + $baseEndpoint = PayPalConstants::REST_LIVE_ENDPOINT; + break; + default: + throw new PayPalConfigurationException('The mode config parameter must be set to either sandbox/live'); + } + } else { + // Defaulting to Sandbox + $baseEndpoint = PayPalConstants::REST_SANDBOX_ENDPOINT; + } + + $baseEndpoint = rtrim(trim($baseEndpoint), '/') . "/v1/oauth2/token"; + + return $baseEndpoint; + } +} diff --git a/paypal/PayPal/Handler/RestHandler.php b/paypal/PayPal/Handler/RestHandler.php new file mode 100644 index 0000000..6bc55ae --- /dev/null +++ b/paypal/PayPal/Handler/RestHandler.php @@ -0,0 +1,124 @@ +apiContext = $apiContext; + } + + /** + * @param PayPalHttpConfig $httpConfig + * @param string $request + * @param mixed $options + * @return mixed|void + * @throws PayPalConfigurationException + * @throws PayPalInvalidCredentialException + * @throws PayPalMissingCredentialException + */ + public function handle($httpConfig, $request, $options) + { + $credential = $this->apiContext->getCredential(); + $config = $this->apiContext->getConfig(); + + if ($credential == null) { + // Try picking credentials from the config file + $credMgr = PayPalCredentialManager::getInstance($config); + $credValues = $credMgr->getCredentialObject(); + + if (!is_array($credValues)) { + throw new PayPalMissingCredentialException("Empty or invalid credentials passed"); + } + + $credential = new OAuthTokenCredential($credValues['clientId'], $credValues['clientSecret']); + } + + if ($credential == null || !($credential instanceof OAuthTokenCredential)) { + throw new PayPalInvalidCredentialException("Invalid credentials passed"); + } + + $httpConfig->setUrl( + rtrim(trim($this->_getEndpoint($config)), '/') . + (isset($options['path']) ? $options['path'] : '') + ); + + // Overwrite Expect Header to disable 100 Continue Issue + $httpConfig->addHeader("Expect", null); + + if (!array_key_exists("User-Agent", $httpConfig->getHeaders())) { + $httpConfig->addHeader("User-Agent", PayPalUserAgent::getValue(PayPalConstants::SDK_NAME, PayPalConstants::SDK_VERSION)); + } + + if (!is_null($credential) && $credential instanceof OAuthTokenCredential && is_null($httpConfig->getHeader('Authorization'))) { + $httpConfig->addHeader('Authorization', "Bearer " . $credential->getAccessToken($config), false); + } + + if (($httpConfig->getMethod() == 'POST' || $httpConfig->getMethod() == 'PUT') && !is_null($this->apiContext->getRequestId())) { + $httpConfig->addHeader('PayPal-Request-Id', $this->apiContext->getRequestId()); + } + // Add any additional Headers that they may have provided + $headers = $this->apiContext->getRequestHeaders(); + foreach ($headers as $key => $value) { + $httpConfig->addHeader($key, $value); + } + } + + /** + * End Point + * + * @param array $config + * + * @return string + * @throws \PayPal\Exception\PayPalConfigurationException + */ + private function _getEndpoint($config) + { + if (isset($config['service.EndPoint'])) { + return $config['service.EndPoint']; + } elseif (isset($config['mode'])) { + switch (strtoupper($config['mode'])) { + case 'SANDBOX': + return PayPalConstants::REST_SANDBOX_ENDPOINT; + break; + case 'LIVE': + return PayPalConstants::REST_LIVE_ENDPOINT; + break; + default: + throw new PayPalConfigurationException('The mode config parameter must be set to either sandbox/live'); + break; + } + } else { + // Defaulting to Sandbox + return PayPalConstants::REST_SANDBOX_ENDPOINT; + } + } +} diff --git a/paypal/PayPal/LICENSE b/paypal/PayPal/LICENSE new file mode 100644 index 0000000..967c3e9 --- /dev/null +++ b/paypal/PayPal/LICENSE @@ -0,0 +1,171 @@ +The PayPal PHP SDK is released under the following license: + + Copyright (c) 2013-2016 PAYPAL, INC. + + SDK LICENSE + + NOTICE TO USER: PayPal, Inc. is providing the Software and Documentation for use under the terms of + this Agreement. Any use, reproduction, modification or distribution of the Software or Documentation, + or any derivatives or portions hereof, constitutes your acceptance of this Agreement. + + As used in this Agreement, "PayPal" means PayPal, Inc. "Software" means the software code accompanying + this agreement. "Documentation" means the documents, specifications and all other items accompanying + this Agreement other than the Software. + + 1. LICENSE GRANT Subject to the terms of this Agreement, PayPal hereby grants you a non-exclusive, + worldwide, royalty free license to use, reproduce, prepare derivative works from, publicly display, + publicly perform, distribute and sublicense the Software for any purpose, provided the copyright notice + below appears in a conspicuous location within the source code of the distributed Software and this + license is distributed in the supporting documentation of the Software you distribute. Furthermore, + you must comply with all third party licenses in order to use the third party software contained in the + Software. + + Subject to the terms of this Agreement, PayPal hereby grants you a non-exclusive, worldwide, royalty free + license to use, reproduce, publicly display, publicly perform, distribute and sublicense the Documentation + for any purpose. You may not modify the Documentation. + + No title to the intellectual property in the Software or Documentation is transferred to you under the + terms of this Agreement. You do not acquire any rights to the Software or the Documentation except as + expressly set forth in this Agreement. + + If you choose to distribute the Software in a commercial product, you do so with the understanding that + you agree to defend, indemnify and hold harmless PayPal and its suppliers against any losses, damages and + costs arising from the claims, lawsuits or other legal actions arising out of such distribution. You may + distribute the Software in object code form under your own license, provided that your license agreement: + + (a) complies with the terms and conditions of this license agreement; + + (b) effectively disclaims all warranties and conditions, express or implied, on behalf of PayPal; + + (c) effectively excludes all liability for damages on behalf of PayPal; + + (d) states that any provisions that differ from this Agreement are offered by you alone and not PayPal; and + + (e) states that the Software is available from you or PayPal and informs licensees how to obtain it in a + reasonable manner on or through a medium customarily used for software exchange. + + 2. DISCLAIMER OF WARRANTY + PAYPAL LICENSES THE SOFTWARE AND DOCUMENTATION TO YOU ONLY ON AN "AS IS" BASIS WITHOUT WARRANTIES OR CONDITIONS + OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY WARRANTIES OR CONDITIONS OF TITLE, + NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. PAYPAL MAKES NO WARRANTY THAT THE + SOFTWARE OR DOCUMENTATION WILL BE ERROR-FREE. Each user of the Software or Documentation is solely responsible + for determining the appropriateness of using and distributing the Software and Documentation and assumes all + risks associated with its exercise of rights under this Agreement, including but not limited to the risks and + costs of program errors, compliance with applicable laws, damage to or loss of data, programs, or equipment, + and unavailability or interruption of operations. Use of the Software and Documentation is made with the + understanding that PayPal will not provide you with any technical or customer support or maintenance. Some + states or jurisdictions do not allow the exclusion of implied warranties or limitations on how long an implied + warranty may last, so the above limitations may not apply to you. To the extent permissible, any implied + warranties are limited to ninety (90) days. + + + 3. LIMITATION OF LIABILITY + PAYPAL AND ITS SUPPLIERS SHALL NOT BE LIABLE FOR LOSS OR DAMAGE ARISING OUT OF THIS AGREEMENT OR FROM THE USE + OF THE SOFTWARE OR DOCUMENTATION. IN NO EVENT WILL PAYPAL OR ITS SUPPLIERS BE LIABLE TO YOU OR ANY THIRD PARTY + FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, INCIDENTAL, OR SPECIAL DAMAGES INCLUDING LOST PROFITS, LOST SAVINGS, + COSTS, FEES, OR EXPENSES OF ANY KIND ARISING OUT OF ANY PROVISION OF THIS AGREEMENT OR THE USE OR THE INABILITY + TO USE THE SOFTWARE OR DOCUMENTATION, HOWEVER CAUSED AND UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY OR TORT INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + PAYPAL'S AGGREGATE LIABILITY AND THAT OF ITS SUPPLIERS UNDER OR IN CONNECTION WITH THIS AGREEMENT SHALL BE + LIMITED TO THE AMOUNT PAID BY YOU FOR THE SOFTWARE AND DOCUMENTATION. + + 4. TRADEMARK USAGE + PayPal is a trademark PayPal, Inc. in the United States and other countries. Such trademarks may not be used + to endorse or promote any product unless expressly permitted under separate agreement with PayPal. + + 5. TERM + Your rights under this Agreement shall terminate if you fail to comply with any of the material terms or + conditions of this Agreement and do not cure such failure in a reasonable period of time after becoming + aware of such noncompliance. If all your rights under this Agreement terminate, you agree to cease use + and distribution of the Software and Documentation as soon as reasonably practicable. + + 6. GOVERNING LAW AND JURISDICTION. This Agreement is governed by the statutes and laws of the State of + California, without regard to the conflicts of law principles thereof. If any part of this Agreement is + found void and unenforceable, it will not affect the validity of the balance of the Agreement, which shall + remain valid and enforceable according to its terms. Any dispute arising out of or related to this Agreement + shall be brought in the courts of Santa Clara County, California, USA. The PayPal PHP SDK is released under the following license: + + Copyright (c) 2013-2016 PAYPAL, INC. + + SDK LICENSE + + NOTICE TO USER: PayPal, Inc. is providing the Software and Documentation for use under the terms of + this Agreement. Any use, reproduction, modification or distribution of the Software or Documentation, + or any derivatives or portions hereof, constitutes your acceptance of this Agreement. + + As used in this Agreement, "PayPal" means PayPal, Inc. "Software" means the software code accompanying + this agreement. "Documentation" means the documents, specifications and all other items accompanying + this Agreement other than the Software. + + 1. LICENSE GRANT Subject to the terms of this Agreement, PayPal hereby grants you a non-exclusive, + worldwide, royalty free license to use, reproduce, prepare derivative works from, publicly display, + publicly perform, distribute and sublicense the Software for any purpose, provided the copyright notice + below appears in a conspicuous location within the source code of the distributed Software and this + license is distributed in the supporting documentation of the Software you distribute. Furthermore, + you must comply with all third party licenses in order to use the third party software contained in the + Software. + + Subject to the terms of this Agreement, PayPal hereby grants you a non-exclusive, worldwide, royalty free + license to use, reproduce, publicly display, publicly perform, distribute and sublicense the Documentation + for any purpose. You may not modify the Documentation. + + No title to the intellectual property in the Software or Documentation is transferred to you under the + terms of this Agreement. You do not acquire any rights to the Software or the Documentation except as + expressly set forth in this Agreement. + + If you choose to distribute the Software in a commercial product, you do so with the understanding that + you agree to defend, indemnify and hold harmless PayPal and its suppliers against any losses, damages and + costs arising from the claims, lawsuits or other legal actions arising out of such distribution. You may + distribute the Software in object code form under your own license, provided that your license agreement: + + (a) complies with the terms and conditions of this license agreement; + + (b) effectively disclaims all warranties and conditions, express or implied, on behalf of PayPal; + + (c) effectively excludes all liability for damages on behalf of PayPal; + + (d) states that any provisions that differ from this Agreement are offered by you alone and not PayPal; and + + (e) states that the Software is available from you or PayPal and informs licensees how to obtain it in a + reasonable manner on or through a medium customarily used for software exchange. + + 2. DISCLAIMER OF WARRANTY + PAYPAL LICENSES THE SOFTWARE AND DOCUMENTATION TO YOU ONLY ON AN "AS IS" BASIS WITHOUT WARRANTIES OR CONDITIONS + OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY WARRANTIES OR CONDITIONS OF TITLE, + NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. PAYPAL MAKES NO WARRANTY THAT THE + SOFTWARE OR DOCUMENTATION WILL BE ERROR-FREE. Each user of the Software or Documentation is solely responsible + for determining the appropriateness of using and distributing the Software and Documentation and assumes all + risks associated with its exercise of rights under this Agreement, including but not limited to the risks and + costs of program errors, compliance with applicable laws, damage to or loss of data, programs, or equipment, + and unavailability or interruption of operations. Use of the Software and Documentation is made with the + understanding that PayPal will not provide you with any technical or customer support or maintenance. Some + states or jurisdictions do not allow the exclusion of implied warranties or limitations on how long an implied + warranty may last, so the above limitations may not apply to you. To the extent permissible, any implied + warranties are limited to ninety (90) days. + + + 3. LIMITATION OF LIABILITY + PAYPAL AND ITS SUPPLIERS SHALL NOT BE LIABLE FOR LOSS OR DAMAGE ARISING OUT OF THIS AGREEMENT OR FROM THE USE + OF THE SOFTWARE OR DOCUMENTATION. IN NO EVENT WILL PAYPAL OR ITS SUPPLIERS BE LIABLE TO YOU OR ANY THIRD PARTY + FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, INCIDENTAL, OR SPECIAL DAMAGES INCLUDING LOST PROFITS, LOST SAVINGS, + COSTS, FEES, OR EXPENSES OF ANY KIND ARISING OUT OF ANY PROVISION OF THIS AGREEMENT OR THE USE OR THE INABILITY + TO USE THE SOFTWARE OR DOCUMENTATION, HOWEVER CAUSED AND UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY OR TORT INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + PAYPAL'S AGGREGATE LIABILITY AND THAT OF ITS SUPPLIERS UNDER OR IN CONNECTION WITH THIS AGREEMENT SHALL BE + LIMITED TO THE AMOUNT PAID BY YOU FOR THE SOFTWARE AND DOCUMENTATION. + + 4. TRADEMARK USAGE + PayPal is a trademark PayPal, Inc. in the United States and other countries. Such trademarks may not be used + to endorse or promote any product unless expressly permitted under separate agreement with PayPal. + + 5. TERM + Your rights under this Agreement shall terminate if you fail to comply with any of the material terms or + conditions of this Agreement and do not cure such failure in a reasonable period of time after becoming + aware of such noncompliance. If all your rights under this Agreement terminate, you agree to cease use + and distribution of the Software and Documentation as soon as reasonably practicable. + + 6. GOVERNING LAW AND JURISDICTION. This Agreement is governed by the statutes and laws of the State of + California, without regard to the conflicts of law principles thereof. If any part of this Agreement is + found void and unenforceable, it will not affect the validity of the balance of the Agreement, which shall + remain valid and enforceable according to its terms. Any dispute arising out of or related to this Agreement + shall be brought in the courts of Santa Clara County, California, USA. diff --git a/paypal/PayPal/Log/PayPalDefaultLogFactory.php b/paypal/PayPal/Log/PayPalDefaultLogFactory.php new file mode 100644 index 0000000..3066810 --- /dev/null +++ b/paypal/PayPal/Log/PayPalDefaultLogFactory.php @@ -0,0 +1,26 @@ +loggerName = $className; + $this->initialize(); + } + + public function initialize() + { + $config = PayPalConfigManager::getInstance()->getConfigHashmap(); + if (!empty($config)) { + $this->isLoggingEnabled = (array_key_exists('log.LogEnabled', $config) && $config['log.LogEnabled'] == '1'); + if ($this->isLoggingEnabled) { + $this->loggerFile = ($config['log.FileName']) ? $config['log.FileName'] : ini_get('error_log'); + $loggingLevel = strtoupper($config['log.LogLevel']); + $this->loggingLevel = (isset($loggingLevel) && defined("\\Psr\\Log\\LogLevel::$loggingLevel")) ? + constant("\\Psr\\Log\\LogLevel::$loggingLevel") : + LogLevel::INFO; + } + } + } + + public function log($level, $message, array $context = array()) + { + if ($this->isLoggingEnabled) { + // Checks if the message is at level below configured logging level + if (array_search($level, $this->loggingLevels) <= array_search($this->loggingLevel, $this->loggingLevels)) { + error_log("[" . date('d-m-Y H:i:s') . "] " . $this->loggerName . " : " . strtoupper($level) . ": $message\n", 3, $this->loggerFile); + } + } + } +} diff --git a/paypal/PayPal/Rest/ApiContext.php b/paypal/PayPal/Rest/ApiContext.php new file mode 100644 index 0000000..bbe3752 --- /dev/null +++ b/paypal/PayPal/Rest/ApiContext.php @@ -0,0 +1,173 @@ +requestId = $requestId; + $this->credential = $credential; + } + + /** + * Get Credential + * + * @return \PayPal\Auth\OAuthTokenCredential + */ + public function getCredential() + { + if ($this->credential == null) { + return PayPalCredentialManager::getInstance()->getCredentialObject(); + } + return $this->credential; + } + + public function getRequestHeaders() + { + $result = PayPalConfigManager::getInstance()->get('http.headers'); + $headers = array(); + foreach ($result as $header => $value) { + $headerName = ltrim($header, 'http.headers'); + $headers[$headerName] = $value; + } + return $headers; + } + + public function addRequestHeader($name, $value) + { + // Determine if the name already has a 'http.headers' prefix. If not, add one. + if (!(substr($name, 0, strlen('http.headers')) === 'http.headers')) { + $name = 'http.headers.' . $name; + } + PayPalConfigManager::getInstance()->addConfigs(array($name => $value)); + } + + /** + * Get Request ID + * + * @return string + */ + public function getRequestId() + { + return $this->requestId; + } + + /** + * Sets the request ID + * + * @param string $requestId the PayPal-Request-Id value to use + */ + public function setRequestId($requestId) + { + $this->requestId = $requestId; + } + + /** + * Resets the requestId that can be used to set the PayPal-request-id + * header used for idempotency. In cases where you need to make multiple create calls + * using the same ApiContext object, you need to reset request Id. + * @deprecated Call setRequestId with a unique value. + * + * @return string + */ + public function resetRequestId() + { + $this->requestId = $this->generateRequestId(); + return $this->getRequestId(); + } + + /** + * Sets Config + * + * @param array $config SDK configuration parameters + */ + public function setConfig(array $config) + { + PayPalConfigManager::getInstance()->addConfigs($config); + } + + /** + * Gets Configurations + * + * @return array + */ + public function getConfig() + { + return PayPalConfigManager::getInstance()->getConfigHashmap(); + } + + /** + * Gets a specific configuration from key + * + * @param $searchKey + * @return mixed + */ + public function get($searchKey) + { + return PayPalConfigManager::getInstance()->get($searchKey); + } + + /** + * Generates a unique per request id that + * can be used to set the PayPal-Request-Id header + * that is used for idempotency + * @deprecated + * + * @return string + */ + private function generateRequestId() + { + static $pid = -1; + static $addr = -1; + + if ($pid == -1) { + $pid = getmypid(); + } + + if ($addr == -1) { + if (array_key_exists('SERVER_ADDR', $_SERVER)) { + $addr = ip2long($_SERVER['SERVER_ADDR']); + } else { + $addr = php_uname('n'); + } + } + + return $addr . $pid . $_SERVER['REQUEST_TIME'] . mt_rand(0, 0xffff); + } +} diff --git a/paypal/PayPal/Rest/IResource.php b/paypal/PayPal/Rest/IResource.php new file mode 100644 index 0000000..281ac47 --- /dev/null +++ b/paypal/PayPal/Rest/IResource.php @@ -0,0 +1,12 @@ +secretKey = $secretKey; + } + + /** + * Encrypts the input text using the cipher key + * + * @param $input + * @return string + */ + public function encrypt($input) + { + // Create a random IV. Not using mcrypt to generate one, as to not have a dependency on it. + $iv = substr(uniqid("", true), 0, Cipher::IV_SIZE); + // Encrypt the data + $encrypted = openssl_encrypt($input, "AES-256-CBC", $this->secretKey, 0, $iv); + // Encode the data with IV as prefix + return base64_encode($iv . $encrypted); + } + + /** + * Decrypts the input text from the cipher key + * + * @param $input + * @return string + */ + public function decrypt($input) + { + // Decode the IV + data + $input = base64_decode($input); + // Remove the IV + $iv = substr($input, 0, Cipher::IV_SIZE); + // Return Decrypted Data + return openssl_decrypt(substr($input, Cipher::IV_SIZE), "AES-256-CBC", $this->secretKey, 0, $iv); + } +} diff --git a/paypal/PayPal/Transport/PayPalRestCall.php b/paypal/PayPal/Transport/PayPalRestCall.php new file mode 100644 index 0000000..a505959 --- /dev/null +++ b/paypal/PayPal/Transport/PayPalRestCall.php @@ -0,0 +1,82 @@ +apiContext = $apiContext; + $this->logger = PayPalLoggingManager::getInstance(__CLASS__); + } + + /** + * @param array $handlers Array of handlers + * @param string $path Resource path relative to base service endpoint + * @param string $method HTTP method - one of GET, POST, PUT, DELETE, PATCH etc + * @param string $data Request payload + * @param array $headers HTTP headers + * @return mixed + * @throws \PayPal\Exception\PayPalConnectionException + */ + public function execute($handlers = array(), $path, $method, $data = '', $headers = array()) + { + $config = $this->apiContext->getConfig(); + $httpConfig = new PayPalHttpConfig(null, $method, $config); + $headers = $headers ? $headers : array(); + $httpConfig->setHeaders($headers + + array( + 'Content-Type' => 'application/json' + ) + ); + + // if proxy set via config, add it + if (!empty($config['http.Proxy'])) { + $httpConfig->setHttpProxy($config['http.Proxy']); + } + + /** @var \Paypal\Handler\IPayPalHandler $handler */ + foreach ($handlers as $handler) { + if (!is_object($handler)) { + $fullHandler = "\\" . (string)$handler; + $handler = new $fullHandler($this->apiContext); + } + $handler->handle($httpConfig, $data, array('path' => $path, 'apiContext' => $this->apiContext)); + } + $connection = new PayPalHttpConnection($httpConfig, $config); + $response = $connection->execute($data); + + return $response; + } +} diff --git a/paypal/PayPal/Validation/ArgumentValidator.php b/paypal/PayPal/Validation/ArgumentValidator.php new file mode 100644 index 0000000..29e7fa3 --- /dev/null +++ b/paypal/PayPal/Validation/ArgumentValidator.php @@ -0,0 +1,32 @@ +