PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / DonationForms / DataTransferObjects / DonateRouteData.php

DonateRouteData.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/DonationForms/DataTransferObjects/DonateRouteData.php

70 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\DonationForms\DataTransferObjects;
4
5 use Give\DonationForms\Routes\DonateRouteSignature;
6 use Give\Framework\PaymentGateways\Log\PaymentGatewayLog;
7
8 /**
9 * @since 3.0.0
10 */
11 class DonateRouteData
12 {
13 /**
14 * @var string
15 */
16 public $routeSignature;
17 /**
18 * @var string
19 */
20 public $routeSignatureId;
21 /**
22 * @var string
23 */
24 public $routeSignatureExpiration;
25
26 /**
27 * Convert data from request into DTO
28 *
29 * @since 3.0.0
30 */
31 public static function fromRequest(array $request): self
32 {
33 $self = new self();
34
35 $self->routeSignature = $request['givewp-route-signature'];
36 $self->routeSignatureId = $request['givewp-route-signature-id'];
37 $self->routeSignatureExpiration = $request['givewp-route-signature-expiration'];
38
39 return $self;
40 }
41
42 /**
43 * @since 3.0.0
44 *
45 * @return void
46 */
47 public function validateSignature()
48 {
49 $signature = new DonateRouteSignature(
50 $this->routeSignatureId,
51 $this->routeSignatureExpiration
52 );
53
54 if (!$signature->isValid($this->routeSignature)) {
55 PaymentGatewayLog::error(
56 'Invalid Secure Route',
57 [
58 'routeSignature' => $this->routeSignature,
59 'signature' => $signature,
60 'signatureString' => $signature->toString(),
61 'signatureHash' => $signature->toHash(),
62 'signatureExpiration' => $signature->expiration,
63 ]
64 );
65
66 wp_die('Forbidden', 403);
67 }
68 }
69 }
70