PluginProbe
The Innovative Form Builder – IvyForms / 1.5.1
The Innovative Form Builder – IvyForms v1.5.1
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Services / Payment / WebhookEventDedupeStore.php

WebhookEventDedupeStore.php in The Innovative Form Builder – IvyForms 1.5.1, at backend/src/Services/Payment/WebhookEventDedupeStore.php

33 lines 784 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IvyForms\Services\Payment;
4
5 /**
6 * Deduplicates inbound payment webhooks by provider event id.
7 */
8 class WebhookEventDedupeStore
9 {
10 private const TTL = DAY_IN_SECONDS;
11
12 /**
13 * Returns true when this event should be processed (first sighting, or no id to key on).
14 */
15 public static function claim(string $provider, string $eventId): bool
16 {
17 $provider = sanitize_key($provider);
18 $eventId = sanitize_text_field($eventId);
19 if ($provider === '' || $eventId === '') {
20 return true;
21 }
22
23 $name = 'ivyforms_wh_' . $provider . '_' . md5($eventId);
24 if (get_transient($name) !== false) {
25 return false;
26 }
27
28 set_transient($name, 1, self::TTL);
29
30 return true;
31 }
32 }
33