Plugin Directory

Changeset 3804971


Ignore:
Timestamp:
11/16/2026 11:28:53 AM (10 days ago)
Author:
paymos
Message:

Publish Paymos for Easy Digital Downloads 1.7.8: unified native refund adapters, Connect network resilience, PHP 8.5 compat, and PHP SDK 1.10.2

Location:
paymos-easy-digital-downloads
Files:
116 added
22 edited

Legend:

Unmodified
Added
Removed
  • paymos-easy-digital-downloads/trunk/CHANGELOG.md

    r3787430 r3804971  
    88
    99## [Unreleased]
     10
     11## [1.7.8] - 2026-11-15
     12
     13- chore: rebuild canonical CMS package
     14
     15## [1.7.7] - 2026-11-15
     16
     17- fix(plugins): guard PHP 8.5 setAccessible deprecations and Drupal SDK path in tests
     18- fix(refunds): decouple refund RBAC from Withdraw and unify 12 CMS refund adapters
     19- chore: rebuild canonical CMS package
     20
     21## [1.7.6] - 2026-11-14
     22
     23- fix(woocommerce,edd): a network error during Connect keeps the flow alive
     24
     25## [1.7.5] - 2026-11-14
     26
     27- chore: rebuild canonical CMS package
     28
     29## [1.7.4] - 2026-11-14
     30
     31- chore: rebuild canonical CMS package
     32
     33## [1.7.3] - 2026-11-13
     34
     35- merge: integrate Windows WIP onto origin/main (CMS binding, SDK preview, dashboard, plugins, specs)
     36- chore: bundle Paymos PHP SDK v1.10.2
     37
     38## [1.7.2] - 2026-11-13
     39
     40- chore: rebuild canonical CMS package
     41
     42## [1.7.1] - 2026-11-13
     43
     44- chore: bundle Paymos PHP SDK v1.10.1
     45- chore: rebuild canonical CMS package
     46
     47## [1.7.0] - 2026-11-13
     48
     49- fix(plugins): unblock WordPress checks and align native recovery tests
     50- feat(notifications): rewrite all 71 email and 52 Telegram RU templates, lifecycle series, and R01-R34 audit fixes
     51- chore: bundle Paymos PHP SDK v1.10.0
     52- chore: rebuild canonical CMS package
     53
     54## [1.6.5] - 2026-11-08
     55
     56- chore: rebuild canonical CMS package
     57
     58## [1.6.4] - 2026-11-08
     59
     60- chore: rebuild canonical CMS package
     61
     62## [1.6.3] - 2026-11-07
     63
     64- chore: rebuild canonical CMS package
    1065
    1166## [1.6.2] - 2026-11-06
  • paymos-easy-digital-downloads/trunk/assets/js/connect.js

    r3787430 r3804971  
    33  var config = window.PaymosEddConnect;
    44  if (!config) return;
     5  var labels = config.labels;
    56
    67  // Set when the browser refused the approval tab and the merchant has to open it
    … …  
    910  var awaitingManualApproval = false;
    1011
    11   function post(action) {
     12  function post(action, flowId) {
    1213    var body = new URLSearchParams({ action: action, nonce: config.nonce });
     14    if (flowId) body.set('flow_id', flowId);
    1315    return fetch(config.ajaxUrl, { method: 'POST', credentials: 'same-origin', headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' }, body: body.toString() })
    1416      .then(function (response) { return response.json(); });
    … …  
    3234    link.target = '_blank';
    3335    link.rel = 'noopener noreferrer';
    34     link.textContent = 'Open the approval page';
    35     node.appendChild(document.createTextNode('Your browser blocked the approval tab. '));
     36    link.textContent = labels.approval_link;
     37    node.appendChild(document.createTextNode(labels.blocked_tab + ' '));
    3638    node.appendChild(link);
    37     node.appendChild(document.createTextNode(' Code: ' + userCode));
     39    node.appendChild(document.createTextNode(' ' + labels.code + ' ' + userCode));
    3840  }
    39   function poll(interval) {
     41  function terminalError(message) {
     42    awaitingManualApproval = false;
     43    status(message, true, true);
     44    var button = document.getElementById('paymos-edd-connect-button');
     45    if (button) button.disabled = false;
     46  }
     47
     48  function poll(interval, flowId) {
    4049    window.setTimeout(function check() {
    41       post(config.pollAction).then(function (response) {
    42         if (!response.success) { status((response.data && response.data.message) || 'Paymos connection failed.', true); return; }
     50      post(config.pollAction, flowId).then(function (response) {
     51        if (!response.success) { terminalError((response.data && response.data.message) || labels.failed); return; }
    4352        if (response.data.status === 'connected') {
    4453          awaitingManualApproval = false;
    45           status('Paymos connected. Reloading…', false, true);
     54          status(labels.connected, false, true);
    4655          window.setTimeout(function () { window.location.reload(); }, 700);
    4756          return;
    4857        }
    49         status('Waiting for approval in Paymos…', false);
    50         window.setTimeout(check, response.data.status === 'slow_down' ? interval + 5000 : interval);
    51       }).catch(function () { status('Paymos connection failed.', true); });
     58        // retry: Paymos could not be reached this time. The request is kept, so back off like slow_down.
     59        var retry = response.data.status === 'retry';
     60        status((retry && response.data.message) || labels.waiting, false);
     61        window.setTimeout(check, retry || response.data.status === 'slow_down' ? interval + 5000 : interval);
     62      }).catch(function () { terminalError(labels.failed); });
    5263    }, interval);
    5364  }
    … …  
    5869    button.disabled = true;
    5970    awaitingManualApproval = false;
    60     status('Starting secure connection…', false, true);
     71    status(labels.starting, false, true);
    6172
    6273    // Open the tab now, while the click is still a trusted user activation. Browsers
    … …  
    6980
    7081    post(config.startAction).then(function (response) {
    71       if (!response.success) throw new Error((response.data && response.data.message) || 'Paymos connection failed.');
     82      if (!response.success) throw new Error((response.data && response.data.message) || labels.failed);
    7283      if (tab && !tab.closed) {
    7384        tab.location = response.data.verification_url;
    74         status('Waiting for approval. Code: ' + response.data.user_code, false, true);
     85        status(labels.waiting + ' ' + labels.code + ' ' + response.data.user_code, false, true);
    7586      } else {
    7687        manualApproval(response.data.verification_url, response.data.user_code);
    … …  
    7889      // Polling starts either way: a merchant who opens the link manually must still
    7990      // have their approval picked up.
    80       poll(Math.max(1, Number(response.data.interval || 5)) * 1000);
     91      poll(Math.max(1, Number(response.data.interval || 5)) * 1000, response.data.flow_id);
    8192    }).catch(function (error) {
    8293      if (tab && !tab.closed) tab.close();
    83       status(error.message || 'Paymos connection failed.', true, true);
    84       button.disabled = false;
     94      terminalError(error.message || labels.failed);
    8595    });
    8696  });
  • paymos-easy-digital-downloads/trunk/assets/js/refunds.js

    r3787430 r3804971  
    1515                    if (response.data && response.data.paymos_refund) { window.location.reload(); return; }
    1616                    status.text(response.data && response.data.message ? response.data.message : labels.request_failed); refresh();
    17                 }).fail(function () { status.text(labels.unknown || ''); });
     17                }).fail(function (xhr) {
     18                    var data = xhr.responseJSON && xhr.responseJSON.data;
     19                    status.text(data && data.message ? data.message : (labels.unknown || ''));
     20                    // Recover only an existing intent before permitting another attempt.
     21                    $.post(ajaxurl, {action: 'paymos_edd_refund', order_id: state.order_id, security: state.security,
     22                        mode: 'recover', paymos_refund_token: state.tokens[mode]})
     23                        .done(function (response) {
     24                            if (response.data && response.data.paymos_refund) { window.location.reload(); return; }
     25                            refresh();
     26                        }).fail(function () { refresh(); });
     27                });
    1828                // Keep the same token after a timeout. A new click recovers this exact intent.
    1929            });
    … …  
    2232            $.post(ajaxurl, {action: 'paymos_edd_refund', order_id: state.order_id, security: state.security, mode: 'summary'})
    2333                .done(function (response) {
    24                     if (!response.success) { status.text(labels.request_failed); return; }
     34                    if (!response.success) { status.text(response.data && response.data.message ? response.data.message : labels.request_failed); return; }
    2535                    var value = response.data, asset = value.refund_asset || {};
    26                     summary.text((labels.full) + ': ' + (value.full_refund_amount || '0') + ' / '
    27                         + (labels.overpayment) + ': ' + (value.overpayment_refund_amount || '0')
     36                    var amountsKnown = value.full_refund_amount != null && value.overpayment_refund_amount != null;
     37                    summary.text((amountsKnown ? (labels.full) + ': ' + value.full_refund_amount + ' / '
     38                        + (labels.overpayment) + ': ' + value.overpayment_refund_amount : labels.server_calculates)
    2839                        + ' ' + (asset.currency || '') + '/' + (asset.network || '')
    2940                        + (value.sender_address ? ' → ' + value.sender_address : ''));
    3041                    buttons.full.prop('disabled', value.can_refund_full !== true);
    3142                    buttons.overpayment.prop('disabled', value.can_refund_overpayment !== true);
     43                }).fail(function (xhr) {
     44                    var data = xhr.responseJSON && xhr.responseJSON.data;
     45                    if (!status.text()) { status.text(data && data.message ? data.message : labels.request_failed); }
    3246                });
    3347        }
  • paymos-easy-digital-downloads/trunk/composer.json

    r3787430 r3804971  
    66  "require": {
    77    "php": ">=7.4",
    8     "paymos/php-sdk": "^1.9.1"
     8    "paymos/php-sdk": "^1.10.0"
    99  },
    1010  "autoload": {
  • paymos-easy-digital-downloads/trunk/includes/ConnectController.php

    r3787430 r3804971  
    4040            'startAction' => self::START_ACTION,
    4141            'pollAction' => self::POLL_ACTION,
     42            'labels' => array(
     43                'approval_link' => __('Open the approval page', 'paymos-easy-digital-downloads'),
     44                'blocked_tab' => __('Your browser blocked the approval tab.', 'paymos-easy-digital-downloads'),
     45                'code' => __('Code:', 'paymos-easy-digital-downloads'),
     46                'failed' => __('Paymos connection failed.', 'paymos-easy-digital-downloads'),
     47                'connected' => __('Paymos connected. Reloading…', 'paymos-easy-digital-downloads'),
     48                'waiting' => __('Waiting for approval in Paymos…', 'paymos-easy-digital-downloads'),
     49                'starting' => __('Starting secure connection…', 'paymos-easy-digital-downloads'),
     50            ),
    4251        ));
    4352    }
    … …  
    4554    public static function start()
    4655    {
     56        check_ajax_referer(self::NONCE_ACTION, 'nonce');
    4757        self::authorize();
    4858        try {
    4959            $state = self::client()->start('easy-digital-downloads', self::sourceUrl(), self::settingsUrl());
    50             ConnectStateStore::save($state);
     60            $flowId = ConnectStateStore::save($state);
    5161            wp_send_json_success(array(
    5262                'verification_url' => $state['verification_url'],
    5363                'user_code' => $state['user_code'],
    5464                'interval' => $state['interval'],
     65                'flow_id' => $flowId,
    5566            ));
    5667        } catch (\Throwable $exception) {
    57             wp_send_json_error(array('message' => $exception->getMessage()), 400);
     68            Logger::error('Paymos connection failed: ' . $exception->getMessage());
     69            wp_send_json_error(array('message' => __('Paymos connection failed.', 'paymos-easy-digital-downloads')), 400);
    5870        }
    5971    }
    … …  
    6173    public static function poll()
    6274    {
     75        check_ajax_referer(self::NONCE_ACTION, 'nonce');
    6376        self::authorize();
     77        $flowId = isset($_POST['flow_id']) && is_string($_POST['flow_id'])
     78            ? sanitize_text_field(wp_unslash($_POST['flow_id'])) : '';
     79        // A generated hex token needs no normalization: never accept a different raw value.
     80        if ($flowId !== '' && ($_POST['flow_id'] !== $flowId || preg_match('/\A[a-f0-9]{32}\z/', $flowId) !== 1)) {
     81            $flowId = '';
     82        }
    6483        try {
    6584            $state = ConnectStateStore::load();
    66             if (!isset($state['device_code'])) {
     85            if (!isset($state['device_code'], $state['flow_id']) || $flowId === ''
     86                || !hash_equals($state['flow_id'], $flowId)) {
    6787                throw new \RuntimeException('No active Paymos connection request.');
    6888            }
    69             $result = self::client()->poll((string) $state['device_code']);
     89            try {
     90                $result = self::client()->poll((string) $state['device_code']);
     91            } catch (\Throwable $exception) {
     92                // A network or server failure says nothing about the device code: keep the request
     93                // and let the page poll again until Paymos answers or the request expires locally.
     94                Logger::error('Paymos connection poll failed, retrying: ' . $exception->getMessage());
     95                wp_send_json_success(array('status' => 'retry', 'message' => $exception->getMessage()));
     96                return;
     97            }
    7098            if ($result['status'] === 'connected') {
    7199                if ($result['plugin'] !== 'edd'
    … …  
    76104                    throw new \RuntimeException('Paymos connection response does not match this store.');
    77105                }
    78                 CredentialStore::save($result['credentials']);
    79                 ConnectStateStore::clear();
     106                if (!ConnectStateStore::complete($flowId, $result['credentials'])) {
     107                    throw new \RuntimeException('Paymos connection request was replaced.');
     108                }
    80109                Config::reset_for_tests();
    81110                wp_send_json_success(array('status' => 'connected'));
     111                return;
    82112            }
    83113            if (in_array($result['status'], array('authorization_pending', 'slow_down'), true)) {
    84114                wp_send_json_success(array('status' => $result['status']));
     115                return;
    85116            }
    86             ConnectStateStore::clear();
    87             wp_send_json_error(array('message' => 'Paymos connection was denied or expired.'), 409);
     117            ConnectStateStore::clear($flowId);
     118            wp_send_json_error(array('message' => __('Paymos connection was denied or expired.', 'paymos-easy-digital-downloads')), 409);
    88119        } catch (\Throwable $exception) {
    89             ConnectStateStore::clear();
    90             wp_send_json_error(array('message' => $exception->getMessage()), 400);
     120            try { ConnectStateStore::clear($flowId); } catch (\Throwable $cleanupError) { /* Preserve the original failure. */ }
     121            Logger::error('Paymos connection failed: ' . $exception->getMessage());
     122            wp_send_json_error(array('message' => __('Paymos connection failed.', 'paymos-easy-digital-downloads')), 400);
    91123        }
    92124    }
    … …  
    94126    private static function authorize()
    95127    {
    96         check_ajax_referer(self::NONCE_ACTION, 'nonce');
    97128        if (!current_user_can('manage_shop_settings')) {
    98             wp_send_json_error(array('message' => 'Access denied.'), 403);
     129            wp_send_json_error(array('message' => __('Access denied.', 'paymos-easy-digital-downloads')), 403);
    99130        }
    100131    }
  • paymos-easy-digital-downloads/trunk/includes/ConnectStateStore.php

    r3787430 r3804971  
    66
    77use Paymos\Plugin\WordPressEncryptedOption;
     8use Paymos\Plugin\WordPressOrderLock;
    89
    910defined('ABSPATH') || exit;
    … …  
    2021        }
    2122        $state['expires_at'] = (int) $state['started_at'] + (int) $state['expires_in'];
    22         WordPressEncryptedOption::save(self::OPTION_KEY, self::AAD, array(
    23             'schema' => 1,
    24             'state' => $state,
    25         ));
     23        $state['flow_id'] = bin2hex(random_bytes(16));
     24        return self::locked(static function () use ($state) {
     25            WordPressEncryptedOption::save(self::OPTION_KEY, self::AAD, array('schema' => 1, 'state' => $state));
     26            return $state['flow_id'];
     27        });
    2628    }
    2729
    2830    public static function load()
     31    {
     32        return self::locked(static function () { return self::read(); });
     33    }
     34
     35    private static function read()
    2936    {
    3037        $payload = WordPressEncryptedOption::load(self::OPTION_KEY, self::AAD);
    … …  
    3845        }
    3946        if (!isset($payload['state']['expires_at']) || time() >= (int) $payload['state']['expires_at']) {
    40             self::clear();
     47            WordPressEncryptedOption::delete(self::OPTION_KEY);
    4148            return array();
    4249        }
    … …  
    4451    }
    4552
    46     public static function clear()
     53    public static function clear($flowId)
    4754    {
    48         WordPressEncryptedOption::delete(self::OPTION_KEY);
     55        return self::finish($flowId, null);
     56    }
     57
     58    public static function complete($flowId, array $credentials)
     59    {
     60        return self::finish($flowId, $credentials);
     61    }
     62
     63    private static function finish($flowId, $credentials)
     64    {
     65        return self::locked(static function () use ($flowId, $credentials) {
     66            $state = self::read();
     67            if (!is_string($flowId) || $flowId === '' || !isset($state['flow_id'])
     68                || !hash_equals($state['flow_id'], $flowId)) {
     69                return false;
     70            }
     71            if ($credentials !== null) {
     72                CredentialStore::save($credentials);
     73            }
     74            WordPressEncryptedOption::delete(self::OPTION_KEY);
     75            return true;
     76        });
     77    }
     78
     79    private static function locked(callable $operation)
     80    {
     81        $lock = new WordPressOrderLock('edd-connect', self::OPTION_KEY);
     82        if (!$lock->acquire()) {
     83            throw new \RuntimeException('Paymos connection state is busy.');
     84        }
     85        try {
     86            // A previous poll may have cached the old option before a new start.
     87            wp_cache_delete(self::OPTION_KEY, 'options');
     88            wp_cache_delete('alloptions', 'options');
     89            wp_cache_delete('notoptions', 'options');
     90            $lock->assertOwned();
     91            return $operation();
     92        } finally {
     93            $lock->release();
     94        }
    4995    }
    5096}
  • paymos-easy-digital-downloads/trunk/includes/EventStore.php

    r3787430 r3804971  
    8080        // phpcs:enable WordPress.DB.DirectDatabaseQuery, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
    8181        if ($created === false) {
    82             throw new \RuntimeException('Paymos event storage is unavailable.');
     82            throw new EventStorageException('Paymos event storage is unavailable.');
    8383        }
    8484        // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- Uncached native schema inspection during the versioned upgrade.
    8585        $column = $wpdb->get_row($wpdb->prepare('SHOW COLUMNS FROM %i LIKE %s', $table, 'owner_token'), ARRAY_A);
     86        self::assertReadSucceeded();
    8687        // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- Versioned owner-token migration in the integration-owned table.
    8788        if (!is_array($column) && $wpdb->query($wpdb->prepare("ALTER TABLE %i ADD owner_token char(32) NOT NULL DEFAULT ''", $table)) === false) {
    88             throw new \RuntimeException('Paymos event storage upgrade failed.');
     89            throw new EventStorageException('Paymos event storage upgrade failed.');
    8990        }
    9091        update_option(self::SCHEMA_OPTION, self::SCHEMA_VERSION, false);
    … …  
    9697        self::ensureTable();
    9798        if ($this->pendingHash !== '') {
    98             throw new \RuntimeException('Paymos event reservation is already owned.');
     99            throw new EventStorageException('Paymos event reservation is already owned.');
    99100        }
    100101        self::purgeExpired();
    … …  
    108109        ));
    109110        if ($inserted === false) {
    110             throw new \RuntimeException('Paymos event reservation failed.');
     111            throw new EventStorageException('Paymos event reservation failed.');
    111112        }
    112113        if ($inserted !== 1) {
    113114            // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- Read the current owner for a fenced compare-and-swap, never a cached lease.
    114115            $row = $wpdb->get_row($wpdb->prepare('SELECT owner_token,status,expires_at FROM %i WHERE event_hash=%s', self::tableName(), $hash), ARRAY_A);
     116            self::assertReadSucceeded();
    115117            if (!is_array($row) || (int) $row['expires_at'] > $now) {
    116118                return false;
    … …  
    123125            ));
    124126            if ($inserted === false) {
    125                 throw new \RuntimeException('Paymos event reservation failed.');
     127                throw new EventStorageException('Paymos event reservation failed.');
    126128            }
    127129            if ($inserted !== 1) {
    … …  
    141143        // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- Deduplication requires current committed state from SQL.
    142144        $row = $wpdb->get_row($wpdb->prepare('SELECT status,expires_at FROM %i WHERE event_hash=%s', self::tableName(), md5((string) $eventId)), ARRAY_A);
     145        self::assertReadSucceeded();
    143146        return is_array($row) && $row['status'] === 'committed' && (int) $row['expires_at'] > time();
    144147    }
    … …  
    159162        ));
    160163        if ($updated !== 1) {
    161             throw new \RuntimeException('Paymos event reservation ownership was lost.');
     164            throw new EventStorageException('Paymos event reservation ownership was lost.');
    162165        }
    163166        $this->clearPending();
    … …  
    175178        $this->clearPending();
    176179        if ($deleted === false) {
    177             throw new \RuntimeException('Paymos event reservation release failed.');
     180            throw new EventStorageException('Paymos event reservation release failed.');
    178181        }
    179182    }
    … …  
    186189        // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- Prepared indexed cleanup removes at most 100 expired rows.
    187190        if ($wpdb->query($wpdb->prepare('DELETE FROM %i WHERE expires_at<=%d ORDER BY expires_at ASC LIMIT 100', self::tableName(), time())) === false) {
    188             throw new \RuntimeException('Paymos expired event cleanup failed.');
     191            throw new EventStorageException('Paymos expired event cleanup failed.');
    189192        }
    190193    }
    … …  
    210213        foreach (array('query', 'prepare', 'get_row') as $method) {
    211214            if (!is_object($wpdb) || !method_exists($wpdb, $method)) {
    212                 throw new \RuntimeException('Paymos requires durable database event storage.');
    213             }
     215                throw new EventStorageException('Paymos requires durable database event storage.');
     216            }
     217        }
     218    }
     219
     220    private static function assertReadSucceeded()
     221    {
     222        global $wpdb;
     223        if (!empty($wpdb->last_error)) {
     224            throw new EventStorageException('Paymos event storage read failed.');
    214225        }
    215226    }
  • paymos-easy-digital-downloads/trunk/includes/Gateway.php

    r3787430 r3804971  
    285285            $lock->assertOwned();
    286286            self::assertCreatedInvoice($invoice, PaymentRepository::getMeta($paymentId, '_paymos_invoice_id'));
     287            // Bind a recovered response before renewal archives this generation.
     288            PaymentRepository::updateMeta($paymentId, '_paymos_invoice_id', $invoice['invoice_id']);
    287289            if (InvoiceRenewal::isRequired($invoice)) {
    288290                // An idempotent create can return the same closed invoice on a
    … …  
    446448                throw new \RuntimeException('Paymos previous invoice needs manual review.');
    447449            }
     450            PaymentRepository::updateMeta($paymentId, '_paymos_invoice_id', $oldInvoiceId);
    448451        }
    449452        return self::storeNewIntent($paymentId, $environment, $config, $amount, $currency, $clientId, $lock);
    … …  
    452455    private static function storeNewIntent($paymentId, $environment, array $config, $amount, $currency, $clientId, WordPressOrderLock $lock)
    453456    {
     457        $lock->assertOwned();
     458        PaymentRepository::archiveInvoiceBinding($paymentId);
    454459        $external = 'edd_' . (int) $paymentId . '_' . bin2hex(random_bytes(16));
    455460        $lock->assertOwned();
  • paymos-easy-digital-downloads/trunk/includes/PaymentMapper.php

    r3787430 r3804971  
    5151            $previousStatus = in_array($legacyStatus, array('underpaid', 'expired', 'cancelled'), true) ? $legacyStatus : '';
    5252        }
    53         $this->recordEvent($paymentId, $event, $eventType);
     53        if ($action !== StatusMapper::ACTION_NOTE_PAID_LATE) {
     54            $this->recordEvent($paymentId, $event, $eventType);
     55        }
    5456
    5557        if (PaymentRepository::isProtected($paymentId) && $action !== StatusMapper::ACTION_NOTE_PAID_LATE) {
  • paymos-easy-digital-downloads/trunk/includes/PaymentRepository.php

    r3787430 r3804971  
    4444        $value = get_post_meta((int) $paymentId, (string) $key, true);
    4545        return is_scalar($value) ? (string) $value : '';
     46    }
     47
     48    /** Save the exact old identity before clearing the current invoice generation. */
     49    public static function archiveInvoiceBinding($paymentId)
     50    {
     51        $invoiceId = self::getMeta($paymentId, '_paymos_invoice_id');
     52        if ($invoiceId === '') {
     53            return;
     54        }
     55        $binding = array('invoice_id' => $invoiceId);
     56        foreach (array('external_order_id', 'project_id', 'environment', 'invoice_amount', 'invoice_currency') as $field) {
     57            $value = self::getMeta($paymentId, '_paymos_' . $field);
     58            if ($value === '') {
     59                throw new \RuntimeException('Paymos previous invoice binding is incomplete.');
     60            }
     61            $binding[str_replace('invoice_', '', $field)] = $value;
     62        }
     63        $stored = self::getMeta($paymentId, '_paymos_invoice_history');
     64        $history = $stored === '' ? array() : json_decode($stored, true);
     65        if (!is_array($history)) {
     66            throw new \RuntimeException('Paymos invoice binding history is invalid.');
     67        }
     68        $history[$invoiceId] = $binding;
     69        self::updateMeta($paymentId, '_paymos_invoice_history', json_encode($history, JSON_THROW_ON_ERROR));
     70    }
     71
     72    public static function historicalInvoiceBinding($paymentId, $invoiceId)
     73    {
     74        $history = json_decode(self::getMeta($paymentId, '_paymos_invoice_history'), true);
     75        return is_array($history) && isset($history[$invoiceId]) && is_array($history[$invoiceId])
     76            ? $history[$invoiceId] : array();
    4677    }
    4778
  • paymos-easy-digital-downloads/trunk/includes/RefundAdapter.php

    r3787430 r3804971  
    127127                'mode' => $mode, 'full_draft' => $draft,
    128128            ));
    129             if (($reason = $this->preflight($intent)) !== null) { throw new \RuntimeException(esc_html($reason)); }
     129            if (($reason = $this->preflight($intent)) !== null) {
     130                $message = $reason === \Paymos\Plugin\NativeRefundProjectorInterface::PREFLIGHT_RETRY
     131                    ? 'refund_preflight_unavailable'
     132                    : $reason;
     133                throw new \RuntimeException(esc_html($message));
     134            }
    130135            $intent = $this->store->createIntent($intent); // Commits before coordinator HTTP.
    131136            $this->coordinator($intent)->submit($intent->operationId());
    132137            $this->reconcile($intent->operationId());
    133138            return $this->store->getIntent($intent->operationId());
     139        });
     140    }
     141
     142    /** Recover a saved AJAX request without creating another intent. */
     143    public function recover(string $paymentKey, string $token): ?array
     144    {
     145        if (!preg_match('/^[a-zA-Z0-9_-]{16,64}$/D', $token)) { throw new \RuntimeException('refund_request_invalid'); }
     146        return $this->store->withPaymentLock($paymentKey, function () use ($paymentKey, $token) {
     147            $intent = $this->store->findByRequestToken($this->installationId(), $token);
     148            if ($intent === null) { return null; }
     149            if ($intent->paymentKey() !== $paymentKey) { throw new \RuntimeException('refund_request_conflict'); }
     150            $this->assertMapping($this->store->loadOrder(), $intent);
     151            $this->reconcile($intent->operationId());
     152            return $this->view($this->store->getIntent($intent->operationId()));
    134153        });
    135154    }
    … …  
    145164            $this->assertOriginalPaid($order);
    146165            if ($intent->fullDraft() !== null) { $this->assertDraft($order, $intent->fullDraft()); }
    147             $invoice = $this->client($intent->environment())->invoices()->get($intent->invoiceId());
     166            try {
     167                $invoice = $this->client($intent->environment())->invoices()->get($intent->invoiceId());
     168            } catch (\Paymos\Exception\ApiException $error) {
     169                if ($error->statusCode() === 429 || $error->statusCode() >= 500) {
     170                    return \Paymos\Plugin\NativeRefundProjectorInterface::PREFLIGHT_RETRY;
     171                }
     172                return $error->errorCode() !== '' ? $error->errorCode() : $error->getMessage();
     173            } catch (\RuntimeException $error) {
     174                return \Paymos\Plugin\NativeRefundProjectorInterface::PREFLIGHT_RETRY;
     175            }
    148176            $this->store->assertOwned();
    149177            $this->assertInvoice($invoice, $order);
    … …  
    153181            if ($intent->fullDraft() !== null) { $this->assertDraft($fresh, $intent->fullDraft()); }
    154182            $summary = $this->invoiceSummary($invoice);
     183            if (!array_key_exists('refund_summary', $invoice)) {
     184                $summary = $this->suppressCompletedOverpayment($summary, $intent->paymentKey());
     185            }
    155186            $flag = $intent->mode() === RefundStates::FULL ? 'can_refund_full' : 'can_refund_overpayment';
    156187            if (!isset($summary[$flag]) || $summary[$flag] !== true) {
    … …  
    407438                    if ($external['review_reason'] !== null || $external['observation']['mode'] === RefundStates::FULL) { throw new \RuntimeException('refund_external_requires_review'); }
    408439                }
     440                if (!array_key_exists('refund_summary', $invoice)) {
     441                    $summary = $this->suppressCompletedOverpayment($summary, $this->store->paymentKey());
     442                }
    409443            } catch (\Throwable $error) { $summary['can_refund_full'] = false; $summary['can_refund_overpayment'] = false; $summary['local_unavailable_reason'] = $error->getMessage(); }
    410444            return $summary;
    411445        });
     446    }
     447
     448    private function suppressCompletedOverpayment(array $summary, string $paymentKey): array
     449    {
     450        foreach ($this->store->forPayment($paymentKey) as $intent) {
     451            if ($intent->mode() === RefundStates::OVERPAYMENT && $intent->cashState() === RefundStates::COMPLETED) {
     452                $summary['can_refund_overpayment'] = false;
     453            }
     454        }
     455        foreach ($this->store->externalForPayment($paymentKey) as $external) {
     456            if ($external['observation']['mode'] === RefundStates::OVERPAYMENT
     457                && $external['observation']['status'] === RefundStates::COMPLETED) {
     458                $summary['can_refund_overpayment'] = false;
     459            }
     460        }
     461        return $summary;
    412462    }
    413463
    … …  
    424474            'can_refund_full' => $paid,
    425475            'can_refund_overpayment' => $overpaid,
    426             'full_refund_amount' => isset($payment['paid']) && is_string($payment['paid']) ? $payment['paid'] : ($paid ? (string) ($invoice['order']['amount'] ?? '0') : '0'),
    427             'overpayment_refund_amount' => $overpaid && isset($payment['paid']) && is_string($payment['paid']) ? $payment['paid'] : '0',
     476            // Gross does not establish the remaining cash after earlier refunds.
     477            'full_refund_amount' => null,
     478            'overpayment_refund_amount' => null,
    428479            'refund_asset' => isset($payment['currency'], $payment['network'])
    429480                ? array('currency' => $payment['currency'], 'network' => $payment['network']) : null,
    … …  
    737788            $adapter = $adapter ?: new self();
    738789            if ($mode === 'summary') { wp_send_json_success($adapter->summary((string) $id)); return; }
     790            if ($mode === 'recover' && !$native) {
     791                wp_send_json_success(array('paymos_refund' => $adapter->recover((string) $id, $token))); return;
     792            }
    739793            $intent = $adapter->request((string) $id, $mode, $token, $input);
    740794            if ($native) { wp_send_json_error(array('message' => RefundCopy::message($adapter->view($intent)), 'paymos_refund' => $adapter->view($intent))); return; }
    … …  
    754808        $settings = array('order_id' => $id, 'security' => wp_create_nonce('paymos_edd_refund_' . $id),
    755809            'labels' => array_merge(RefundCopy::labels(), array('full' => RefundCopy::text('full_action'),
    756                 'overpayment' => RefundCopy::text('overpayment_action'))),
     810                'overpayment' => RefundCopy::text('overpayment_action'),
     811                'server_calculates' => __('Paymos calculates the available refund amount when you submit the request.', 'paymos-easy-digital-downloads'))),
    757812            'tokens' => array('full' => wp_generate_uuid4(), 'overpayment' => wp_generate_uuid4()));
    758813        try {
  • paymos-easy-digital-downloads/trunk/includes/WebhookController.php

    r3787430 r3804971  
    7979            Logger::error('Paymos webhook timestamp skew.');
    8080            return new \WP_REST_Response(array('error' => 'bad_timestamp'), 401);
     81        } catch (EventStorageException $e) {
     82            try { $eventStore->release(); } catch (\Throwable $releaseError) { /* Preserve the storage failure. */ }
     83            Logger::error('Paymos event storage failed: ' . $e->getMessage());
     84            return new \WP_REST_Response(array('error' => 'storage_failed'), 500);
    8185        } catch (\Throwable $e) {
    8286            try {
    … …  
    107111            PaymentRepository::refresh($paymentId);
    108112            PaymentRepository::assertPaymosPayment($paymentId);
     113            // Current pending intents recover by exact POST below; a missing invoice ID
     114            // does not make their late-payment event a historical generation.
     115            if ($event->type() === 'invoice.paid_late'
     116                && PaymentRepository::getMeta($paymentId, '_paymos_external_order_id') !== $event->externalOrderId()) {
     117                $binding = PaymentRepository::historicalInvoiceBinding($paymentId, $event->invoiceId());
     118                if (($binding['environment'] ?? '') !== $environment
     119                    || ($binding['external_order_id'] ?? '') !== $event->externalOrderId()
     120                    || !(new InvoiceReverseVerifier(self::client($environment)))->verify($event, $binding)->isVerified()) {
     121                    throw new \RuntimeException('Paymos historical invoice verification failed.');
     122                }
     123                $lock->assertOwned();
     124                (new PaymentMapper())->apply($paymentId, $event->toArray(), $lock);
     125                return;
     126            }
    109127            self::assertPaymentMatchesEvent($paymentId, $event, $environment, $lock);
    110128            self::reverseVerifyTerminalEvent($event, $paymentId, $environment);
    … …  
    216234            if (!isset($config[$required]) || !is_scalar($config[$required]) || trim((string) $config[$required]) === '') {
    217235                // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Diagnostic exception is caught and logged, never rendered as HTML.
    218                 throw new \RuntimeException('Paymos connected credentials are missing ' . $required . ' for ' . (string) $environment . '.');
     236                throw new EventStorageException('Paymos connected credentials are missing ' . $required . ' for ' . (string) $environment . '.');
    219237            }
    220238        }
  • paymos-easy-digital-downloads/trunk/paymos-easy-digital-downloads.php

    r3787430 r3804971  
    44 * Plugin URI: https://paymos.io/docs/cms-easy-digital-downloads
    55 * Description: Accept stablecoin payments in Easy Digital Downloads through Paymos.
    6  * Version: 1.6.2
     6 * Version: 1.7.8
    77 * Author: Paymos
    88 * Author URI: https://paymos.io
    … …  
    1818define('PAYMOS_EDD_PLUGIN_FILE', __FILE__);
    1919define('PAYMOS_EDD_PLUGIN_DIR', plugin_dir_path(__FILE__));
    20 define('PAYMOS_EDD_PLUGIN_VERSION', '1.6.2');
     20define('PAYMOS_EDD_PLUGIN_VERSION', '1.7.8');
    2121
    2222require_once PAYMOS_EDD_PLUGIN_DIR . 'includes/Autoloader.php';
  • paymos-easy-digital-downloads/trunk/readme.txt

    r3787430 r3804971  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.6.2
     7Stable tag: 1.7.8
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    4747== Changelog ==
    4848
    49 = 1.6.2 =
    50 * fix(cms): align marketplace manifests, refund copy, store links, and release guards
    51 * chore: bundle Paymos PHP SDK v1.9.1
     49= 1.7.8 =
    5250* chore: rebuild canonical CMS package
    5351
    54 = 1.6.1 =
    55 * fix(plugins): use wp_add_inline_script, sanitize nonces before wp_verify_nonce, and guard curl_close on PHP 8+
    56 * chore: bundle Paymos PHP SDK v1.9.1
    57 
    58 * Moved optional Paymos diagnostics from PHP error_log to the EDD debug log, with masking for supported key patterns. Logging remains off by default.
    59 
    60 * Compare amounts as exact decimals and require complete invoice snapshots plus API confirmation before changing payment state.
    61 * Serialize order updates and recover when native payment completion returns `false` from save or status updates.
    62 * Check ownership when updating event reservations, and purge at most 100 expired records per reservation.
    63 
    64 Fixed:
    65 * Entries that were present, non-empty and still English — `Connect Paymos` in
    66   German and Spanish, the plugin name in Turkish and Chinese, `Webhook URL` in
    67   Chinese — and one string missing from every catalogue
    68   (`in the invoice currency`, the fallback in the underpayment notice).
    69 * A late non-final webhook could reopen a finished order. Webhooks are
    70   delivered at least once and in no particular order, and only paid orders were
    71   guarded: an `invoice.underpaid_waiting` or `invoice.confirming` arriving after
    72   the invoice had already ended underpaid, expired or cancelled moved the order
    73   back into an open state. Nothing leaves a final status on the server, so once
    74   one is recorded for an invoice every later event for it is ignored and the
    75   final status stays recorded.
    76 * A new invoice now resets the Paymos status recorded on the payment, so an
    77   event for it is never taken for a stale one after an earlier final status.
    78 * A webhook retry that arrived while the first delivery was still being
    79   processed was answered 200 "duplicate". Paymos gives a delivery 10 seconds and
    80   retries, while a slow reverse-verification call can take longer; the retry was
    81   acknowledged as delivered, and if the first attempt then failed the event was
    82   lost. An event that is only locked, not yet committed, is now answered 409 so
    83   Paymos tries again, and the lock the first delivery holds is left alone.
    84 
    85 = 1.6.0 =
    86 * feat(refunds): finalize clean merchant refunds spec, SDKs, CMS plugins, and targeted test scripts
    87 * wip: snapshot shared working tree before merging main
    88 * wip(refunds): merchant refund plugin work (CMS adapters, PHP SDK, tests) - unverified WIP snapshot
    89 * chore: bundle Paymos PHP SDK v1.9.0
     52= 1.7.7 =
     53* fix(plugins): guard PHP 8.5 setAccessible deprecations and Drupal SDK path in tests
     54* fix(refunds): decouple refund RBAC from Withdraw and unify 12 CMS refund adapters
    9055* chore: rebuild canonical CMS package
    9156
    92 * Moved optional Paymos diagnostics from PHP error_log to the EDD debug log, with masking for supported key patterns. Logging remains off by default.
     57= 1.7.6 =
     58* fix(woocommerce,edd): a network error during Connect keeps the flow alive
    9359
    94 * Compare amounts as exact decimals and require complete invoice snapshots plus API confirmation before changing payment state.
    95 * Serialize order updates and recover when native payment completion returns `false` from save or status updates.
    96 * Check ownership when updating event reservations, and purge at most 100 expired records per reservation.
    97 
    98 Fixed:
    99 * Entries that were present, non-empty and still English — `Connect Paymos` in
    100   German and Spanish, the plugin name in Turkish and Chinese, `Webhook URL` in
    101   Chinese — and one string missing from every catalogue
    102   (`in the invoice currency`, the fallback in the underpayment notice).
    103 * A late non-final webhook could reopen a finished order. Webhooks are
    104   delivered at least once and in no particular order, and only paid orders were
    105   guarded: an `invoice.underpaid_waiting` or `invoice.confirming` arriving after
    106   the invoice had already ended underpaid, expired or cancelled moved the order
    107   back into an open state. Nothing leaves a final status on the server, so once
    108   one is recorded for an invoice every later event for it is ignored and the
    109   final status stays recorded.
    110 * A new invoice now resets the Paymos status recorded on the payment, so an
    111   event for it is never taken for a stale one after an earlier final status.
    112 * A webhook retry that arrived while the first delivery was still being
    113   processed was answered 200 "duplicate". Paymos gives a delivery 10 seconds and
    114   retries, while a slow reverse-verification call can take longer; the retry was
    115   acknowledged as delivered, and if the first attempt then failed the event was
    116   lost. An event that is only locked, not yet committed, is now answered 409 so
    117   Paymos tries again, and the lock the first delivery holds is left alone.
    118 
    119 = 1.5.4 =
    120 * chore: bundle Paymos PHP SDK v1.8.1
    121 
    122 * Moved optional Paymos diagnostics from PHP error_log to the EDD debug log, with masking for supported key patterns. Logging remains off by default.
    123 
    124 * Compare amounts as exact decimals and require complete invoice snapshots plus API confirmation before changing payment state.
    125 * Serialize order updates and recover when native payment completion returns `false` from save or status updates.
    126 * Check ownership when updating event reservations, and purge at most 100 expired records per reservation.
    127 
    128 Fixed:
    129 * Entries that were present, non-empty and still English — `Connect Paymos` in
    130   German and Spanish, the plugin name in Turkish and Chinese, `Webhook URL` in
    131   Chinese — and one string missing from every catalogue
    132   (`in the invoice currency`, the fallback in the underpayment notice).
    133 * A late non-final webhook could reopen a finished order. Webhooks are
    134   delivered at least once and in no particular order, and only paid orders were
    135   guarded: an `invoice.underpaid_waiting` or `invoice.confirming` arriving after
    136   the invoice had already ended underpaid, expired or cancelled moved the order
    137   back into an open state. Nothing leaves a final status on the server, so once
    138   one is recorded for an invoice every later event for it is ignored and the
    139   final status stays recorded.
    140 * A new invoice now resets the Paymos status recorded on the payment, so an
    141   event for it is never taken for a stale one after an earlier final status.
    142 * A webhook retry that arrived while the first delivery was still being
    143   processed was answered 200 "duplicate". Paymos gives a delivery 10 seconds and
    144   retries, while a slow reverse-verification call can take longer; the retry was
    145   acknowledged as delivered, and if the first attempt then failed the event was
    146   lost. An event that is only locked, not yet committed, is now answered 409 so
    147   Paymos tries again, and the lock the first delivery holds is left alone.
    148 
    149 = 1.5.3 =
     60= 1.7.5 =
    15061* chore: rebuild canonical CMS package
    15162
    152 * Moved optional Paymos diagnostics from PHP error_log to the EDD debug log, with masking for supported key patterns. Logging remains off by default.
    153 
    154 * Compare amounts as exact decimals and require complete invoice snapshots plus API confirmation before changing payment state.
    155 * Serialize order updates and recover when native payment completion returns `false` from save or status updates.
    156 * Check ownership when updating event reservations, and purge at most 100 expired records per reservation.
    157 
    158 Fixed:
    159 * Entries that were present, non-empty and still English — `Connect Paymos` in
    160   German and Spanish, the plugin name in Turkish and Chinese, `Webhook URL` in
    161   Chinese — and one string missing from every catalogue
    162   (`in the invoice currency`, the fallback in the underpayment notice).
    163 * A late non-final webhook could reopen a finished order. Webhooks are
    164   delivered at least once and in no particular order, and only paid orders were
    165   guarded: an `invoice.underpaid_waiting` or `invoice.confirming` arriving after
    166   the invoice had already ended underpaid, expired or cancelled moved the order
    167   back into an open state. Nothing leaves a final status on the server, so once
    168   one is recorded for an invoice every later event for it is ignored and the
    169   final status stays recorded.
    170 * A new invoice now resets the Paymos status recorded on the payment, so an
    171   event for it is never taken for a stale one after an earlier final status.
    172 * A webhook retry that arrived while the first delivery was still being
    173   processed was answered 200 "duplicate". Paymos gives a delivery 10 seconds and
    174   retries, while a slow reverse-verification call can take longer; the retry was
    175   acknowledged as delivered, and if the first attempt then failed the event was
    176   lost. An event that is only locked, not yet committed, is now answered 409 so
    177   Paymos tries again, and the lock the first delivery holds is left alone.
    178 
    179 = 1.5.2 =
    180 * fix(edd): validate refund controls and prepare directory database queries
    181 
    182 * Moved optional Paymos diagnostics from PHP error_log to the EDD debug log, with masking for supported key patterns. Logging remains off by default.
    183 
    184 * Compare amounts as exact decimals and require complete invoice snapshots plus API confirmation before changing payment state.
    185 * Serialize order updates and recover when native payment completion returns `false` from save or status updates.
    186 * Check ownership when updating event reservations, and purge at most 100 expired records per reservation.
    187 
    188 Fixed:
    189 * Entries that were present, non-empty and still English — `Connect Paymos` in
    190   German and Spanish, the plugin name in Turkish and Chinese, `Webhook URL` in
    191   Chinese — and one string missing from every catalogue
    192   (`in the invoice currency`, the fallback in the underpayment notice).
    193 * A late non-final webhook could reopen a finished order. Webhooks are
    194   delivered at least once and in no particular order, and only paid orders were
    195   guarded: an `invoice.underpaid_waiting` or `invoice.confirming` arriving after
    196   the invoice had already ended underpaid, expired or cancelled moved the order
    197   back into an open state. Nothing leaves a final status on the server, so once
    198   one is recorded for an invoice every later event for it is ignored and the
    199   final status stays recorded.
    200 * A new invoice now resets the Paymos status recorded on the payment, so an
    201   event for it is never taken for a stale one after an earlier final status.
    202 * A webhook retry that arrived while the first delivery was still being
    203   processed was answered 200 "duplicate". Paymos gives a delivery 10 seconds and
    204   retries, while a slow reverse-verification call can take longer; the retry was
    205   acknowledged as delivered, and if the first attempt then failed the event was
    206   lost. An event that is only locked, not yet committed, is now answered 409 so
    207   Paymos tries again, and the lock the first delivery holds is left alone.
    208 
    209 = 1.5.1 =
    210 * fix(plugins): require helper-complete PHP SDK for refunds
    211 
    212 * Moved optional Paymos diagnostics from PHP error_log to the EDD debug log, with masking for supported key patterns. Logging remains off by default.
    213 
    214 * Compare amounts as exact decimals and require complete invoice snapshots plus API confirmation before changing payment state.
    215 * Serialize order updates and recover when native payment completion returns `false` from save or status updates.
    216 * Check ownership when updating event reservations, and purge at most 100 expired records per reservation.
    217 
    218 Fixed:
    219 * Entries that were present, non-empty and still English — `Connect Paymos` in
    220   German and Spanish, the plugin name in Turkish and Chinese, `Webhook URL` in
    221   Chinese — and one string missing from every catalogue
    222   (`in the invoice currency`, the fallback in the underpayment notice).
    223 * A late non-final webhook could reopen a finished order. Webhooks are
    224   delivered at least once and in no particular order, and only paid orders were
    225   guarded: an `invoice.underpaid_waiting` or `invoice.confirming` arriving after
    226   the invoice had already ended underpaid, expired or cancelled moved the order
    227   back into an open state. Nothing leaves a final status on the server, so once
    228   one is recorded for an invoice every later event for it is ignored and the
    229   final status stays recorded.
    230 * A new invoice now resets the Paymos status recorded on the payment, so an
    231   event for it is never taken for a stale one after an earlier final status.
    232 * A webhook retry that arrived while the first delivery was still being
    233   processed was answered 200 "duplicate". Paymos gives a delivery 10 seconds and
    234   retries, while a slow reverse-verification call can take longer; the retry was
    235   acknowledged as delivered, and if the first attempt then failed the event was
    236   lost. An event that is only locked, not yet committed, is now answered 409 so
    237   Paymos tries again, and the lock the first delivery holds is left alone.
    238 
    239 = 1.5.0 =
    240 * fix(ton): return friendly addresses with existing webhook schema
    241 * feat(edd): native refund adapter for full and overpayment refunds
    242 * fix(edd): refuse native refunds that bypass the Paymos gateway
    243 * fix(edd): prepare clean WordPress.org distribution
    244 * chore: bundle Paymos PHP SDK v1.8.0
     63= 1.7.4 =
    24564* chore: rebuild canonical CMS package
    24665
    247 * Moved optional Paymos diagnostics from PHP error_log to the EDD debug log, with masking for supported key patterns. Logging remains off by default.
     66= 1.7.3 =
     67* merge: integrate Windows WIP onto origin/main (CMS binding, SDK preview, dashboard, plugins, specs)
     68* chore: bundle Paymos PHP SDK v1.10.2
    24869
    249 * Compare amounts as exact decimals and require complete invoice snapshots plus API confirmation before changing payment state.
    250 * Serialize order updates and recover when native payment completion returns `false` from save or status updates.
    251 * Check ownership when updating event reservations, and purge at most 100 expired records per reservation.
    252 
    253 Fixed:
    254 * Entries that were present, non-empty and still English — `Connect Paymos` in
    255   German and Spanish, the plugin name in Turkish and Chinese, `Webhook URL` in
    256   Chinese — and one string missing from every catalogue
    257   (`in the invoice currency`, the fallback in the underpayment notice).
    258 * A late non-final webhook could reopen a finished order. Webhooks are
    259   delivered at least once and in no particular order, and only paid orders were
    260   guarded: an `invoice.underpaid_waiting` or `invoice.confirming` arriving after
    261   the invoice had already ended underpaid, expired or cancelled moved the order
    262   back into an open state. Nothing leaves a final status on the server, so once
    263   one is recorded for an invoice every later event for it is ignored and the
    264   final status stays recorded.
    265 * A new invoice now resets the Paymos status recorded on the payment, so an
    266   event for it is never taken for a stale one after an earlier final status.
    267 * A webhook retry that arrived while the first delivery was still being
    268   processed was answered 200 "duplicate". Paymos gives a delivery 10 seconds and
    269   retries, while a slow reverse-verification call can take longer; the retry was
    270   acknowledged as delivered, and if the first attempt then failed the event was
    271   lost. An event that is only locked, not yet committed, is now answered 409 so
    272   Paymos tries again, and the lock the first delivery holds is left alone.
    273 
    274 = 1.4.10 =
     70= 1.7.2 =
    27571* chore: rebuild canonical CMS package
    27672
    277 * Compare amounts as exact decimals and require complete invoice snapshots plus API confirmation before changing payment state.
    278 * Serialize order updates and recover when native payment completion returns `false` from save or status updates.
    279 * Check ownership when updating event reservations, and purge at most 100 expired records per reservation.
    280 
    281 Fixed:
    282 * Entries that were present, non-empty and still English — `Connect Paymos` in
    283   German and Spanish, the plugin name in Turkish and Chinese, `Webhook URL` in
    284   Chinese — and one string missing from every catalogue
    285   (`in the invoice currency`, the fallback in the underpayment notice).
    286 * A late non-final webhook could reopen a finished order. Webhooks are
    287   delivered at least once and in no particular order, and only paid orders were
    288   guarded: an `invoice.underpaid_waiting` or `invoice.confirming` arriving after
    289   the invoice had already ended underpaid, expired or cancelled moved the order
    290   back into an open state. Nothing leaves a final status on the server, so once
    291   one is recorded for an invoice every later event for it is ignored and the
    292   final status stays recorded.
    293 * A new invoice now resets the Paymos status recorded on the payment, so an
    294   event for it is never taken for a stale one after an earlier final status.
    295 * A webhook retry that arrived while the first delivery was still being
    296   processed was answered 200 "duplicate". Paymos gives a delivery 10 seconds and
    297   retries, while a slow reverse-verification call can take longer; the retry was
    298   acknowledged as delivered, and if the first attempt then failed the event was
    299   lost. An event that is only locked, not yet committed, is now answered 409 so
    300   Paymos tries again, and the lock the first delivery holds is left alone.
    301 
    302 = 1.4.9 =
     73= 1.7.1 =
     74* chore: bundle Paymos PHP SDK v1.10.1
    30375* chore: rebuild canonical CMS package
    30476
    305 * Compare amounts as exact decimals and require complete invoice snapshots plus API confirmation before changing payment state.
    306 * Serialize order updates and recover when native payment completion returns `false` from save or status updates.
    307 * Check ownership when updating event reservations, and purge at most 100 expired records per reservation.
     77= 1.7.0 =
     78* fix(plugins): unblock WordPress checks and align native recovery tests
     79* feat(notifications): rewrite all 71 email and 52 Telegram RU templates, lifecycle series, and R01-R34 audit fixes
     80* chore: bundle Paymos PHP SDK v1.10.0
     81* chore: rebuild canonical CMS package
    30882
    309 Fixed:
    310 * Entries that were present, non-empty and still English — `Connect Paymos` in
    311   German and Spanish, the plugin name in Turkish and Chinese, `Webhook URL` in
    312   Chinese — and one string missing from every catalogue
    313   (`in the invoice currency`, the fallback in the underpayment notice).
    314 * A late non-final webhook could reopen a finished order. Webhooks are
    315   delivered at least once and in no particular order, and only paid orders were
    316   guarded: an `invoice.underpaid_waiting` or `invoice.confirming` arriving after
    317   the invoice had already ended underpaid, expired or cancelled moved the order
    318   back into an open state. Nothing leaves a final status on the server, so once
    319   one is recorded for an invoice every later event for it is ignored and the
    320   final status stays recorded.
    321 * A new invoice now resets the Paymos status recorded on the payment, so an
    322   event for it is never taken for a stale one after an earlier final status.
    323 * A webhook retry that arrived while the first delivery was still being
    324   processed was answered 200 "duplicate". Paymos gives a delivery 10 seconds and
    325   retries, while a slow reverse-verification call can take longer; the retry was
    326   acknowledged as delivered, and if the first attempt then failed the event was
    327   lost. An event that is only locked, not yet committed, is now answered 409 so
    328   Paymos tries again, and the lock the first delivery holds is left alone.
     83= 1.6.5 =
     84* chore: rebuild canonical CMS package
    32985
  • paymos-easy-digital-downloads/trunk/vendor/paymos/php-sdk/bundle-manifest.json

    r3787430 r3804971  
    22  "schema": 1,
    33  "package": "paymos/php-sdk",
    4   "version": "1.9.1",
    5   "tag": "v1.9.1",
    6   "source_commit": "6149157ab3059793314346b4655f546dcd2e2794",
    7   "sha256": "e5d187daf306e288b24ecce47ad9cf8a984be1bda720028eba6a19d9115f98b4",
     4  "version": "1.10.2",
     5  "tag": "v1.10.2",
     6  "source_commit": "6729b2fe8d3bdb9b284e04f6be100f737949f575",
     7  "sha256": "587c9cfecb6c369fd121f1b82bf365c123984bce7beba4e4be81a06fcd9067a3",
    88  "files": [
    99    {
    … …  
    119119    {
    120120      "path": "src/Http/RetryingTransport.php",
    121       "sha256": "0fbbb4d38539c0e24334c28a6f8e071d350d70d6cbaadb03d6b559715ce507dc",
    122       "size": 2549
     121      "sha256": "be993bb9f8a8e67d503b9c13323f053e9222f7581de53a10c070958a6237ba32",
     122      "size": 3176
    123123    },
    124124    {
    … …  
    214214    {
    215215      "path": "src/Plugin/NativeRefundProjectorInterface.php",
    216       "sha256": "395fffe53791853206bf57499bd98d7af331c9141779f7bc37bbd838cacabe3e",
    217       "size": 1418
     216      "sha256": "ab10b3c942089870f349f5d455d29426cc0321c3310ed1f00cd1e5445c0d7b4d",
     217      "size": 1672
    218218    },
    219219    {
    220220      "path": "src/Plugin/RefundCoordinator.php",
    221       "sha256": "44f00de23d044e6ad4cccd62896c2c9302b37d43bb956cf1302e77584a224475",
    222       "size": 11079
     221      "sha256": "4c1e60bdfd6132b7eb5e266ddc5325b2ae30a113159618ad5b5f4dc7aace27b1",
     222      "size": 11380
    223223    },
    224224    {
    … …  
    284284    {
    285285      "path": "src/Resources/BaseResource.php",
    286       "sha256": "2071a0c53d4696cc092197b1a2916c488f6ac6c2b1f1def1911d7abb82dc7ac1",
    287       "size": 5039
     286      "sha256": "1539cfad31fe7e91f11de32b9c637a4cb143d8224c8eb350511ad3e81ee283b4",
     287      "size": 5422
    288288    },
    289289    {
    … …  
    304304    {
    305305      "path": "src/Resources/Refunds.php",
    306       "sha256": "28aadaaef2aca45bd3f09d3e8cb3500e4ee3a5a1a9470f2f0fe5192d5f91a002",
    307       "size": 3634
     306      "sha256": "5e8e7c4f74b504ba9324c96909b588a431f9207ec6b727250236f9396fd11381",
     307      "size": 3963
    308308    },
    309309    {
    … …  
    319319    {
    320320      "path": "src/Version.php",
    321       "sha256": "3b07dc520c5d740286fcda161a6a78b13e1c9f13e96052cbf38e85870524c2f3",
    322       "size": 112
     321      "sha256": "576b8df424acfcef573705613b348ddda0c08b363e529979e9ea65eec372b6d5",
     322      "size": 113
    323323    },
    324324    {
    … …  
    359359    {
    360360      "path": "src/Webhook/WebhookVerifier.php",
    361       "sha256": "d688f4e94fcc0cdf6574bc64fd07e0cc438a0f54ea9c7c2e7eff94fa93752ea2",
    362       "size": 5424
     361      "sha256": "89cce396de58d28a16bc8e161f0ada4b0db37903c06d1a833f480f147b60a199",
     362      "size": 5509
    363363    }
    364364  ]
  • paymos-easy-digital-downloads/trunk/vendor/paymos/php-sdk/src/Http/RetryingTransport.php

    r3787430 r3804971  
    2121    public function request($method, $url, array $headers, $body, $timeoutSeconds)
    2222    {
     23        return $this->requestWithHeaderFactory($method, $url, static function () use ($headers) {
     24            return $headers;
     25        }, $body, $timeoutSeconds);
     26    }
     27
     28    /** Rebuild timestamp-dependent authentication immediately before each physical attempt. */
     29    public function requestWithHeaderFactory($method, $url, callable $headerFactory, $body, $timeoutSeconds)
     30    {
    2331        $attempt = 0;
    2432
    2533        do {
     34            $headers = $this->inner instanceof self ? null : $headerFactory();
    2635            try {
    27                 $response = $this->inner->request($method, $url, $headers, $body, $timeoutSeconds);
     36                $response = $this->inner instanceof self
     37                    ? $this->inner->requestWithHeaderFactory($method, $url, $headerFactory, $body, $timeoutSeconds)
     38                    : $this->inner->request($method, $url, $headers, $body, $timeoutSeconds);
    2839            } catch (\RuntimeException $error) {
    2940                if (!$this->policy->shouldRetryTransportError($method)
  • paymos-easy-digital-downloads/trunk/vendor/paymos/php-sdk/src/Plugin/NativeRefundProjectorInterface.php

    r3787430 r3804971  
    77interface NativeRefundProjectorInterface
    88{
     9    /** Read unavailable before any cash POST: keep the saved intent retryable with the same key. */
     10    public const PREFLIGHT_RETRY = 'refund_preflight_retry';
     11
    912    /**
    1013     * Fresh mapping, connection capability, full original paid total/refunded=0 and saved defaults.
    1114     * Return a review reason on ambiguity/manual changes; null permits the first POST.
     15     * Return PREFLIGHT_RETRY for a transient provider read failure before the first POST.
    1216     * A replay of an unknown request must remain possible when new submissions are disabled.
    1317     */
  • paymos-easy-digital-downloads/trunk/vendor/paymos/php-sdk/src/Plugin/RefundCoordinator.php

    r3787430 r3804971  
    113113        if ($initial) {
    114114            $reason = $this->projector->preflight($intent);
     115            if ($reason === NativeRefundProjectorInterface::PREFLIGHT_RETRY) {
     116                $this->store->recordState($intent->operationId(), RefundStates::NOT_SUBMITTED,
     117                    RefundStates::PROJECTION_NONE, $reason);
     118                return RefundStates::NOT_SUBMITTED;
     119            }
    115120            if ($reason !== null) {
    116121                $this->review($intent, $reason);
  • paymos-easy-digital-downloads/trunk/vendor/paymos/php-sdk/src/Resources/BaseResource.php

    r3787430 r3804971  
    88use Paymos\Exception\ApiException;
    99use Paymos\Http\RequestSigner;
     10use Paymos\Http\RetryingTransport;
    1011use Paymos\Http\TransportInterface;
    1112use Paymos\Version;
    … …  
    5152        $signedQuery = $query === '' ? '' : '?' . ltrim((string) $query, '?');
    5253
    53         $timestamp = (string) call_user_func($this->clock);
    54         $headers = array(
    55             'Authorization' => RequestSigner::authorizationHeader(
    56                 $this->config->apiKey(),
    57                 $this->config->apiSecret(),
    58                 $timestamp,
    59                 $method,
    60                 $path,
    61                 $signedQuery,
    62                 $body
    63             ),
    64             'X-Request-Timestamp' => $timestamp,
    65             'Content-Type' => 'application/json',
    66             'Accept' => 'application/json',
    67             'User-Agent' => 'paymos-php/' . Version::VERSION,
    68         );
     54        $headerFactory = function () use ($method, $path, $signedQuery, $body) {
     55            $timestamp = (string) call_user_func($this->clock);
     56            return array(
     57                'Authorization' => RequestSigner::authorizationHeader(
     58                    $this->config->apiKey(),
     59                    $this->config->apiSecret(),
     60                    $timestamp,
     61                    $method,
     62                    $path,
     63                    $signedQuery,
     64                    $body
     65                ),
     66                'X-Request-Timestamp' => $timestamp,
     67                'Content-Type' => 'application/json',
     68                'Accept' => 'application/json',
     69                'User-Agent' => 'paymos-php/' . Version::VERSION,
     70            );
     71        };
    6972
    7073        $url = $this->config->baseUrl() . $path . $signedQuery;
    71         $response = $this->transport->request($method, $url, $headers, $body, $this->config->timeoutSeconds());
     74        $response = $this->transport instanceof RetryingTransport
     75            ? $this->transport->requestWithHeaderFactory($method, $url, $headerFactory, $body, $this->config->timeoutSeconds())
     76            : $this->transport->request($method, $url, $headerFactory(), $body, $this->config->timeoutSeconds());
    7277
    7378        if ($response->statusCode() < 200 || $response->statusCode() >= 300) {
  • paymos-easy-digital-downloads/trunk/vendor/paymos/php-sdk/src/Resources/Refunds.php

    r3787430 r3804971  
    1717            throw new \InvalidArgumentException('Refund create accepts only invoiceId, mode and externalOrderId.');
    1818        }
    19         if (trim($invoiceId) === '' || trim($externalOrderId) === '' || strlen($externalOrderId) > 200) {
    20             throw new \InvalidArgumentException('Refund invoiceId and externalOrderId are required; key maximum is 200 bytes.');
     19        // .NET string limits count UTF-16 code units, including two for astral characters.
     20        $characters = preg_match_all('/./us', $externalOrderId);
     21        $surrogatePairs = preg_match_all('/[\x{10000}-\x{10FFFF}]/u', $externalOrderId);
     22        if (trim($invoiceId) === '' || trim($externalOrderId) === '' || $characters === false
     23            || $surrogatePairs === false || $characters + $surrogatePairs > 200) {
     24            throw new \InvalidArgumentException('Refund invoiceId and externalOrderId are required; key maximum is 200 UTF-16 code units.');
    2125        }
    2226        if (!in_array($mode, array('full', 'overpayment'), true)) {
  • paymos-easy-digital-downloads/trunk/vendor/paymos/php-sdk/src/Version.php

    r3787430 r3804971  
    77final class Version
    88{
    9     public const VERSION = '1.9.1';
     9    public const VERSION = '1.10.2';
    1010}
  • paymos-easy-digital-downloads/trunk/vendor/paymos/php-sdk/src/Webhook/WebhookVerifier.php

    r3787430 r3804971  
    7676
    7777        foreach ($signatures as $signature) {
    78             if (hash_equals($expected, $signature)) {
     78            if (preg_match('/\A[0-9a-fA-F]{64}\z/', $signature) === 1
     79                && hash_equals($expected, strtolower($signature))) {
    7980                return;
    8081            }
Note: See TracChangeset for help on using the changeset viewer.