Plugin Directory

Changeset 3257439


Ignore:
Timestamp:
03/18/2025 01:57:17 AM (13 months ago)
Author:
sepayteam
Message:

fix: improve webhook handling and settings update

Location:
sepay-gateway/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sepay-gateway/trunk/includes/class-wc-sepay-api.php

    r3253700 r3257439  
    320320        }
    321321
    322         if (isset($response['data']['id'])) {
    323             update_option('wc_sepay_webhook_id', $response['data']['id']);
     322        if (isset($response['status']) && $response['status'] === 'success') {
     323            update_option('wc_sepay_webhook_id', $response['data']['id'] ?? $webhook_id ?? null);
    324324            update_option('wc_sepay_webhook_api_key', $api_key);
    325325        }
     
    389389    public function disconnect()
    390390    {
     391        $settings = get_option('woocommerce_sepay_settings');
     392
     393        if ($settings) {
     394            $settings['api_key'] = get_option('wc_sepay_webhook_api_key');
     395            update_option('woocommerce_sepay_settings', $settings);
     396        }
     397
    391398        delete_option('wc_sepay_access_token');
    392399        delete_option('wc_sepay_refresh_token');
  • sepay-gateway/trunk/readme.txt

    r3254400 r3257439  
    44 - Tags: woocommerce, payment gateway, vietqr, ngan hang, thanh toan
    55 - Requires WooCommerce at least: 2.1
    6  - Stable Tag: 1.1.1
    7  - Version: 1.1.1
     6 - Stable Tag: 1.1.2
     7 - Version: 1.1.2
    88 - Tested up to: 6.6
    99 - Requires at least: 5.6
  • sepay-gateway/trunk/sepay-gateway.php

    r3254400 r3257439  
    66 * Author: SePay Team
    77 * Author URI: https://sepay.vn/
    8  * Version: 1.1.1
     8 * Version: 1.1.2
    99 * Requires Plugins: woocommerce
    1010 * Text Domain: sepay-gateway
     
    120120        $webhook_url = home_url('/wp-json/sepay-gateway/v');
    121121
    122         $response = $api->create_webhook($bank_account_id, null);
    123 
    124         if (! isset($response['data']['id'])) {
     122        $webhooks = $api->get_webhooks([
     123            'webhook_url' => $webhook_url,
     124            'api_key' => $api_token,
     125        ]);
     126
     127        $webhook_id = isset($webhooks[0]['id']) ? $webhooks[0]['id'] : null;
     128
     129        $response = $api->create_webhook($bank_account_id, $webhook_id);
     130
     131        if ($response['status'] !== 'success') {
    125132            wp_send_json_error(['message' => 'Có lỗi xảy ra khi tạo webhook. Vui lòng thử lại sau.']);
    126133        }
Note: See TracChangeset for help on using the changeset viewer.