Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
momostafa opened this issue Jul 8, 2024 · 4 comments · Fixed by #972
Closed

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

momostafa opened this issue Jul 8, 2024 · 4 comments · Fixed by #972
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@momostafa
Copy link

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

@momostafa momostafa added the question Further information is requested label Jul 8, 2024
@rez1dent3 rez1dent3 added the bug Something isn't working label Jul 8, 2024
@rez1dent3 rez1dent3 linked a pull request Jul 8, 2024 that will close this issue
@rez1dent3
Copy link
Member

Yes, this is god related to adding soft delete. I'll fix it today or tomorrow.

@momostafa
Copy link
Author

Thank you for your quick response

@rez1dent3
Copy link
Member

@momostafa FYI. Tag 11.1.0

Thanks for your feedback

@momostafa
Copy link
Author

Thanks a lot I will update

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants