Skip to content

Bavix\Wallet\Exceptions\UnconfirmedInvalid Confirmation has already been reset #971

@momostafa

Description

@momostafa

Describe your task
When I try to delete a transaction that is not confirmed i get below error

Bavix\Wallet\Exceptions\UnconfirmedInvalid
Confirmation has already been reset

To Reproduce
Steps to reproduce the behavior:
I am using Filament v3.2.92 for rendering tables

  1. Go to transactions table list view
  2. Click on on delete record
  3. the page displays error Bavix\Wallet\Exceptions\UnconfirmedInvalid
    Confirmation has already been reset
  4. If edit the record and change it from unconfirmed to confirmed only then i am able to delete the record

Trace Error
I don't have it...

Expected behavior
I expect to be able to delete transactions record either confirmed or unconfirmed

Server:

  • Laravel 11.11.0
  • php version: 8.2.19
  • database: mysql 8.0.12
  • wallet version : 11.0.6
  • cache lock: database
  • cache wallets: database

my extended transaction model

<?php

namespace App\Models;


use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use App\Models\User;
use Bavix\Wallet\Traits\CanConfirm;
use Kevupton\LaravelCoinpayments\Models\Transaction as CoinpaymentsTransaction;
use Kevupton\LaravelCoinpayments\Coinpayments;


class Transaction extends \Bavix\Wallet\Models\Transaction
{
    use HasFactory;
    use CanConfirm;

    //use WatchableTrait;

    protected $fillable = [
        'payable_type',
        'payable_id',
        'wallet_id',
        'uuid',
        'type',
        'amount',
        'confirmed',
        'meta',
        'created_at',
        'updated_at',
    ];

    protected $casts = [
        'wallet_id' => 'int',
        'confirmed' => 'bool',
        'meta' => 'array',
    ];



    public function owner(): BelongsTo
    {
        return $this->belongsTo(User::class, 'id', 'payable_id');
    }


    public function wallet(): BelongsTo
    {
        return $this->belongsTo(Wallet::class);

    }


    public function onModelSaved(): void
    {
        optional($this->wallet)->refreshBalance();
    }

    public static function refreshTransactionStatus($TxnId, $all = false)
    {


        $private_key = env('COINPAYMENTS_PRIVATE_KEY');
        $public_key = env('COINPAYMENTS_PUBLIC_KEY');
        $merchant_id = env('COINPAYMENTS_MERCHANT_ID');
        $ipn_secret = env('COINPAYMENTS_IPN_SECRET');
        $ipn_url = env('COINPAYMENTS_IPN_URL');

        $transaction = new Coinpayments($private_key,
            $public_key,
            $merchant_id,
            $ipn_secret,
            $ipn_url,'json');

        $txn_id = $transaction->getTransactionInfo($TxnId, $all);

        $status = $txn_id->getResponse()['result']['status'];
        $status_text = $txn_id->getResponse()['result']['status_text'];
        $error = $txn_id->getResponse()['error'];
       // dd($error);
        if($error == 'ok') {

        CoinpaymentsTransaction::where('txn_id', $TxnId)->update(['status' => $status, 'status_text' => $status_text]);

        $updated = 'Status:'. ' ' . $status_text;
        return $updated;
       } else {
        return $error;
       }
        
    }
    
}

Thanks for your help and support

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingquestionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions