Overview
  • Namespace
  • Class

Namespaces

  • PayPal
    • Api
    • Auth
    • Cache
    • Common
    • Converter
    • Core
    • Exception
    • Handler
    • Log
    • Rest
    • Security
    • Transport
    • Validation

Classes

  • PayPal\Api\Address
  • PayPal\Api\Agreement
  • PayPal\Api\AgreementDetails
  • PayPal\Api\AgreementStateDescriptor
  • PayPal\Api\AgreementTransaction
  • PayPal\Api\AgreementTransactions
  • PayPal\Api\AlternatePayment
  • PayPal\Api\Amount
  • PayPal\Api\Authorization
  • PayPal\Api\BankAccount
  • PayPal\Api\BankAccountsList
  • PayPal\Api\BankToken
  • PayPal\Api\BaseAddress
  • PayPal\Api\Billing
  • PayPal\Api\BillingAgreementToken
  • PayPal\Api\BillingInfo
  • PayPal\Api\CancelNotification
  • PayPal\Api\Capture
  • PayPal\Api\CarrierAccount
  • PayPal\Api\CarrierAccountToken
  • PayPal\Api\CartBase
  • PayPal\Api\ChargeModel
  • PayPal\Api\Cost
  • PayPal\Api\CountryCode
  • PayPal\Api\CreateProfileResponse
  • PayPal\Api\Credit
  • PayPal\Api\CreditCard
  • PayPal\Api\CreditCardHistory
  • PayPal\Api\CreditCardList
  • PayPal\Api\CreditCardToken
  • PayPal\Api\CreditFinancingOffered
  • PayPal\Api\Currency
  • PayPal\Api\CurrencyConversion
  • PayPal\Api\CustomAmount
  • PayPal\Api\DetailedRefund
  • PayPal\Api\Details
  • PayPal\Api\Error
  • PayPal\Api\ErrorDetails
  • PayPal\Api\ExtendedBankAccount
  • PayPal\Api\ExternalFunding
  • PayPal\Api\FileAttachment
  • PayPal\Api\FlowConfig
  • PayPal\Api\FmfDetails
  • PayPal\Api\FundingDetail
  • PayPal\Api\FundingInstrument
  • PayPal\Api\FundingOption
  • PayPal\Api\FundingSource
  • PayPal\Api\FuturePayment
  • PayPal\Api\HyperSchema
  • PayPal\Api\Image
  • PayPal\Api\Incentive
  • PayPal\Api\InputFields
  • PayPal\Api\InstallmentInfo
  • PayPal\Api\InstallmentOption
  • PayPal\Api\Invoice
  • PayPal\Api\InvoiceAddress
  • PayPal\Api\InvoiceItem
  • PayPal\Api\InvoiceNumber
  • PayPal\Api\InvoiceSearchResponse
  • PayPal\Api\Item
  • PayPal\Api\ItemList
  • PayPal\Api\Links
  • PayPal\Api\Measurement
  • PayPal\Api\MerchantInfo
  • PayPal\Api\MerchantPreferences
  • PayPal\Api\Metadata
  • PayPal\Api\NameValuePair
  • PayPal\Api\Notification
  • PayPal\Api\OpenIdAddress
  • PayPal\Api\OpenIdError
  • PayPal\Api\OpenIdSession
  • PayPal\Api\OpenIdTokeninfo
  • PayPal\Api\OpenIdUserinfo
  • PayPal\Api\Order
  • PayPal\Api\OverrideChargeModel
  • PayPal\Api\Participant
  • PayPal\Api\Patch
  • PayPal\Api\PatchRequest
  • PayPal\Api\Payee
  • PayPal\Api\Payer
  • PayPal\Api\PayerInfo
  • PayPal\Api\Payment
  • PayPal\Api\PaymentCard
  • PayPal\Api\PaymentCardToken
  • PayPal\Api\PaymentDefinition
  • PayPal\Api\PaymentDetail
  • PayPal\Api\PaymentExecution
  • PayPal\Api\PaymentHistory
  • PayPal\Api\PaymentInstruction
  • PayPal\Api\PaymentOptions
  • PayPal\Api\PaymentSummary
  • PayPal\Api\PaymentTerm
  • PayPal\Api\Payout
  • PayPal\Api\PayoutBatch
  • PayPal\Api\PayoutBatchHeader
  • PayPal\Api\PayoutItem
  • PayPal\Api\PayoutItemDetails
  • PayPal\Api\PayoutSenderBatchHeader
  • PayPal\Api\Phone
  • PayPal\Api\Plan
  • PayPal\Api\PlanList
  • PayPal\Api\PotentialPayerInfo
  • PayPal\Api\Presentation
  • PayPal\Api\PrivateLabelCard
  • PayPal\Api\ProcessorResponse
  • PayPal\Api\RecipientBankingInstruction
  • PayPal\Api\RedirectUrls
  • PayPal\Api\Refund
  • PayPal\Api\RefundDetail
  • PayPal\Api\RefundRequest
  • PayPal\Api\RelatedResources
  • PayPal\Api\Sale
  • PayPal\Api\Search
  • PayPal\Api\ShippingAddress
  • PayPal\Api\ShippingCost
  • PayPal\Api\ShippingInfo
  • PayPal\Api\Tax
  • PayPal\Api\Template
  • PayPal\Api\TemplateData
  • PayPal\Api\Templates
  • PayPal\Api\TemplateSettings
  • PayPal\Api\TemplateSettingsMetadata
  • PayPal\Api\Terms
  • PayPal\Api\Transaction
  • PayPal\Api\TransactionBase
  • PayPal\Api\Transactions
  • PayPal\Api\VerifyWebhookSignature
  • PayPal\Api\VerifyWebhookSignatureResponse
  • PayPal\Api\Webhook
  • PayPal\Api\WebhookEvent
  • PayPal\Api\WebhookEventList
  • PayPal\Api\WebhookEventType
  • PayPal\Api\WebhookEventTypeList
  • PayPal\Api\WebhookList
  • PayPal\Api\WebProfile
  • PayPal\Auth\OAuthTokenCredential
  • PayPal\Cache\AuthorizationCache
  • PayPal\Common\ArrayUtil
  • PayPal\Common\PayPalModel
  • PayPal\Common\PayPalResourceModel
  • PayPal\Common\PayPalUserAgent
  • PayPal\Common\ReflectionUtil
  • PayPal\Converter\FormatConverter
  • PayPal\Core\PayPalConfigManager
  • PayPal\Core\PayPalConstants
  • PayPal\Core\PayPalCredentialManager
  • PayPal\Core\PayPalHttpConfig
  • PayPal\Core\PayPalHttpConnection
  • PayPal\Core\PayPalLoggingManager
  • PayPal\Handler\OauthHandler
  • PayPal\Handler\RestHandler
  • PayPal\Log\PayPalDefaultLogFactory
  • PayPal\Log\PayPalLogger
  • PayPal\Rest\ApiContext
  • PayPal\Security\Cipher
  • PayPal\Transport\PayPalRestCall
  • PayPal\Validation\ArgumentValidator
  • PayPal\Validation\JsonValidator
  • PayPal\Validation\NumericValidator
  • PayPal\Validation\UrlValidator

Interfaces

  • PayPal\Handler\IPayPalHandler
  • PayPal\Log\PayPalLogFactory
  • PayPal\Rest\IResource

Exceptions

  • PayPal\Exception\PayPalConfigurationException
  • PayPal\Exception\PayPalConnectionException
  • PayPal\Exception\PayPalInvalidCredentialException
  • PayPal\Exception\PayPalMissingCredentialException
  1 <?php
  2 
  3 namespace PayPal\Api;
  4 
  5 use PayPal\Common\PayPalResourceModel;
  6 use PayPal\Validation\ArgumentValidator;
  7 use PayPal\Api\VerifyWebhookSignatureResponse;
  8 use PayPal\Rest\ApiContext;
  9 use PayPal\Validation\UrlValidator;
 10 
 11 /**
 12  * Class VerifyWebhookSignature
 13  *
 14  * Verify webhook signature.
 15  *
 16  * @package PayPal\Api
 17  *
 18  * @property string auth_algo
 19  * @property string cert_url
 20  * @property string transmission_id
 21  * @property string transmission_sig
 22  * @property string transmission_time
 23  * @property string webhook_id
 24  * @property \PayPal\Api\WebhookEvent webhook_event
 25  */
 26 class VerifyWebhookSignature extends PayPalResourceModel
 27 {
 28     /**
 29      * 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.
 30      *
 31      * @param string $auth_algo
 32      *
 33      * @return $this
 34      */
 35     public function setAuthAlgo($auth_algo)
 36     {
 37         $this->auth_algo = $auth_algo;
 38         return $this;
 39     }
 40 
 41     /**
 42      * 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.
 43      *
 44      * @return string
 45      */
 46     public function getAuthAlgo()
 47     {
 48         return $this->auth_algo;
 49     }
 50 
 51     /**
 52      * 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.
 53      *
 54      * @param string $cert_url
 55      * @throws \InvalidArgumentException
 56      * @return $this
 57      */
 58     public function setCertUrl($cert_url)
 59     {
 60         UrlValidator::validate($cert_url, "CertUrl");
 61         $this->cert_url = $cert_url;
 62         return $this;
 63     }
 64 
 65     /**
 66      * 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.
 67      *
 68      * @return string
 69      */
 70     public function getCertUrl()
 71     {
 72         return $this->cert_url;
 73     }
 74 
 75     /**
 76      * The ID of the HTTP transmission. Contained in the `PAYPAL-TRANSMISSION-ID` header of the notification message.
 77      *
 78      * @param string $transmission_id
 79      *
 80      * @return $this
 81      */
 82     public function setTransmissionId($transmission_id)
 83     {
 84         $this->transmission_id = $transmission_id;
 85         return $this;
 86     }
 87 
 88     /**
 89      * The ID of the HTTP transmission. Contained in the `PAYPAL-TRANSMISSION-ID` header of the notification message.
 90      *
 91      * @return string
 92      */
 93     public function getTransmissionId()
 94     {
 95         return $this->transmission_id;
 96     }
 97 
 98     /**
 99      * The PayPal-generated asymmetric signature. Extract this value from the `PAYPAL-TRANSMISSION-SIG` response header, which is received with the webhook notification.
100      *
101      * @param string $transmission_sig
102      *
103      * @return $this
104      */
105     public function setTransmissionSig($transmission_sig)
106     {
107         $this->transmission_sig = $transmission_sig;
108         return $this;
109     }
110 
111     /**
112      * The PayPal-generated asymmetric signature. Extract this value from the `PAYPAL-TRANSMISSION-SIG` response header, which is received with the webhook notification.
113      *
114      * @return string
115      */
116     public function getTransmissionSig()
117     {
118         return $this->transmission_sig;
119     }
120 
121     /**
122      * The date and time of the HTTP transmission. Contained in the `PAYPAL-TRANSMISSION-TIME` header of the notification message.
123      *
124      * @param string $transmission_time
125      *
126      * @return $this
127      */
128     public function setTransmissionTime($transmission_time)
129     {
130         $this->transmission_time = $transmission_time;
131         return $this;
132     }
133 
134     /**
135      * The date and time of the HTTP transmission. Contained in the `PAYPAL-TRANSMISSION-TIME` header of the notification message.
136      *
137      * @return string
138      */
139     public function getTransmissionTime()
140     {
141         return $this->transmission_time;
142     }
143 
144     /**
145      * The ID of the webhook as configured in your Developer Portal account.
146      *
147      * @param string $webhook_id
148      *
149      * @return $this
150      */
151     public function setWebhookId($webhook_id)
152     {
153         $this->webhook_id = $webhook_id;
154         return $this;
155     }
156 
157     /**
158      * The ID of the webhook as configured in your Developer Portal account.
159      *
160      * @return string
161      */
162     public function getWebhookId()
163     {
164         return $this->webhook_id;
165     }
166 
167     /**
168      * The webhook notification, which is the content of the HTTP `POST` request body.
169      * @deprecated Please use setRequestBody($request_body) instead.
170      * @param \PayPal\Api\WebhookEvent $webhook_event
171      *
172      * @return $this
173      */
174     public function setWebhookEvent($webhook_event)
175     {
176         $this->webhook_event = $webhook_event;
177         return $this;
178     }
179 
180     /**
181      * The webhook notification, which is the content of the HTTP `POST` request body.
182      *
183      * @return \PayPal\Api\WebhookEvent
184      */
185     public function getWebhookEvent()
186     {
187         return $this->webhook_event;
188     }
189 
190     /**
191      * The content of the HTTP `POST` request body of the webhook notification you received as a string.
192      *
193      * @param string $request_body
194      *
195      * @return $this
196      */
197     public function setRequestBody($request_body)
198     {
199         $this->request_body = $request_body;
200         return $this;
201     }
202 
203     /**
204      * The content of the HTTP `POST` request body of the webhook notification you received as a string.
205      *
206      * @return string
207      */
208     public function getRequestBody()
209     {
210         return $this->request_body;
211     }
212 
213     /**
214      * Verifies a webhook signature.
215      *
216      * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
217      * @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
218      * @return VerifyWebhookSignatureResponse
219      */
220     public function post($apiContext = null, $restCall = null)
221     {
222         $payLoad = $this->toJSON();
223 
224         $json = self::executeCall(
225             "/v1/notifications/verify-webhook-signature",
226             "POST",
227             $payLoad,
228             null,
229             $apiContext,
230             $restCall
231         );
232         $ret = new VerifyWebhookSignatureResponse();
233         $ret->fromJson($json);
234         return $ret;
235     }
236 
237     public function toJSON($options = 0)
238     {
239         if (!is_null($this->request_body)) {
240             $valuesToEncode = $this->toArray();
241             unset($valuesToEncode['webhook_event']);
242             unset($valuesToEncode['request_body']);
243 
244             $payLoad = "{";
245             foreach ($valuesToEncode as $field => $value) {
246                 $payLoad .= "\"$field\": \"$value\",";
247             }
248             $payLoad .= "\"webhook_event\": $this->request_body";
249             $payLoad .= "}";
250             return $payLoad;
251         } else {
252             $payLoad = parent::toJSON($options);
253             return $payLoad;
254         }
255     }
256 }
257 
API documentation generated by ApiGen