Describe the bug
Whenever am trying to refund an order (Purchase) am getting the error below:
Bavix\Wallet\Internal\Exceptions\TransactionFailedException
Transaction failed. Message: SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 2
insert into `transactions` (`amount`, `confirmed`, `created_at`, `meta`, `payable_id`, `payable_type`, `type`, `updated_at`, `uuid`, `wallet_id`)
values (-1150.00, 1, 2022-11-07 06:00:41, {"title":"Order from B2C-pickup::CO0057","description":"Purchase of Order #CO0057"}, 369, App\Models\Order, withdraw, 2022-11-07 06:00:41, 413b7a9d-1abe-49a6-baa1-35a34093bd05, 874),
(1150.00, 0, 1, 2022-11-07 06:00:41, 2023-11-07 06:00:41, {"title":"Order from B2C-pickup::CO0057","description":"Purchase of Order #CO0057"}, 1037, App\Models\User, deposit, 2022-11-07 06:00:41, bc76ac59-400b-44c5-b6ab-a4368075517d, 470)
Am using below to refund a purchase.
$order=Order::find(369);
$ouser = User::without(['role','wallet','lastTransaction','defaultAddress'])->with('wallets')->find($order->user_id);
$walletFull = $ouser->wallets[0];
$walletZero = $ouser->wallets[1];
$fullValue = $order->full_credit_used ?? 0;
$zeroValue = $order->zero_credit_used ?? 0;
$orderWallet = $order->wallet;
if($walletFull->refund($order)) {
$walletFull->refreshBalance();
if ($zeroValue > 0) {
$walletFull->transferFloat($walletZero, $zeroValue);
$walletFull->refreshBalance();
$walletZero->refreshBalance();
$this->manageLastTransaction($walletZero,$this->order);
}
$this->manageLastTransaction($walletFull,$this->order,$fullValue);
}
Furthermore, a transfer is also giving the same error, i.e, "1136 Column count doesn't match value count at row 2",
Transfer logic is stated below
$metaDeposit = [
'description' => 'Refund from Order #'.$this->order->order_number,
'credit_type' => 'Refunded credits',
'expire_on' => Carbon::now()->addYear()
];
$metaWithdraw = [
'description' => 'Refund for Order #'.$this->order->order_number,
];
$transferMeta = new Extra(
deposit: $metaDeposit,
withdraw: new Option(meta: $metaWithdraw)
);
$orderWallet->transfer($walletFull, $fullValue, $transferMeta);
Trace Error
[2022-11-07 06:34:33] local.ERROR: Transaction failed. Message: SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 2 (SQL: insert into `transactions` (`amount`, `confirmed`, `created_at`, `meta`, `payable_id`, `payable_type`, `type`, `updated_at`, `uuid`, `wallet_id`) values (-1150.00, 1, 2022-11-07 06:34:33, {"title":"Order from B2C-pickup::CO0057","description":"Purchase of Order #CO0057"}, 369, App\Models\Order, withdraw, 2022-11-07 06:34:33, 5240b919-5bb9-4448-976b-828c532eb09a, 874), (1150.00, 0, 1, 2022-11-07 06:34:33, 2023-11-07 06:34:33, {"title":"Order from B2C-pickup::CO0057","description":"Purchase of Order #CO0057"}, 1037, App\Models\User, deposit, 2022-11-07 06:34:33, a90558e5-6234-47ce-a3f9-2daa8d790c2d, 470)) {"exception":"[object] (Bavix\\Wallet\\Internal\\Exceptions\\TransactionFailedException(code: 1024): Transaction failed. Message: SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 2 (SQL: insert into `transactions` (`amount`, `confirmed`, `created_at`, `meta`, `payable_id`, `payable_type`, `type`, `updated_at`, `uuid`, `wallet_id`) values (-1150.00, 1, 2022-11-07 06:34:33, {\"title\":\"Order from B2C-pickup::CO0057\",\"description\":\"Purchase of Order #CO0057\"}, 369, App\\Models\\Order, withdraw, 2022-11-07 06:34:33, 5240b919-5bb9-4448-976b-828c532eb09a, 874), (1150.00, 0, 1, 2022-11-07 06:34:33, 2023-11-07 06:34:33, {\"title\":\"Order from B2C-pickup::CO0057\",\"description\":\"Purchase of Order #CO0057\"}, 1037, App\\Models\\User, deposit, 2022-11-07 06:34:33, a90558e5-6234-47ce-a3f9-2daa8d790c2d, 470)) at /var/www/html/better_cloud/vendor/bavix/laravel-wallet/src/Internal/Service/DatabaseService.php:47)
[stacktrace]
#0 /var/www/html/better_cloud/vendor/bavix/laravel-wallet/src/Services/TransferService.php(107): Bavix\\Wallet\\Internal\\Service\\DatabaseService->transaction()
#1 /var/www/html/better_cloud/vendor/bavix/laravel-wallet/src/Traits/CartPay.php(235): Bavix\\Wallet\\Services\\TransferService->apply()
#2 /var/www/html/better_cloud/vendor/bavix/laravel-wallet/src/Internal/Service/DatabaseService.php(34): Bavix\\Wallet\\Models\\Wallet->Bavix\\Wallet\\Traits\\{closure}()
#3 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php(30): Bavix\\Wallet\\Internal\\Service\\DatabaseService->Bavix\\Wallet\\Internal\\Service\\{closure}()
#4 /var/www/html/better_cloud/vendor/bavix/laravel-wallet/src/Internal/Service/DatabaseService.php(41): Illuminate\\Database\\Connection->transaction()
#5 /var/www/html/better_cloud/vendor/bavix/laravel-wallet/src/Services/AtomicService.php(59): Bavix\\Wallet\\Internal\\Service\\DatabaseService->transaction()
#6 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Cache/Lock.php(126): Bavix\\Wallet\\Services\\AtomicService->Bavix\\Wallet\\Services\\{closure}()
#7 /var/www/html/better_cloud/vendor/bavix/laravel-wallet/src/Internal/Service/LockService.php(55): Illuminate\\Cache\\Lock->block()
#8 /var/www/html/better_cloud/vendor/bavix/laravel-wallet/src/Internal/Service/LockService.php(75): Bavix\\Wallet\\Internal\\Service\\LockService->block()
#9 /var/www/html/better_cloud/vendor/bavix/laravel-wallet/src/Internal/Service/LockService.php(79): Bavix\\Wallet\\Internal\\Service\\LockService->Bavix\\Wallet\\Internal\\Service\\{closure}()
#10 /var/www/html/better_cloud/vendor/bavix/laravel-wallet/src/Services/AtomicService.php(63): Bavix\\Wallet\\Internal\\Service\\LockService->blocks()
#11 /var/www/html/better_cloud/vendor/bavix/laravel-wallet/src/Services/AtomicService.php(79): Bavix\\Wallet\\Services\\AtomicService->blocks()
#12 /var/www/html/better_cloud/vendor/bavix/laravel-wallet/src/Traits/CartPay.php(240): Bavix\\Wallet\\Services\\AtomicService->block()
#13 /var/www/html/better_cloud/vendor/bavix/laravel-wallet/src/Traits/CanPay.php(94): Bavix\\Wallet\\Models\\Wallet->refundCart()
#14 /var/www/html/better_cloud/app/Http/Controllers/HomeController.php(95): Bavix\\Wallet\\Models\\Wallet->refund()
#15 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\\Http\\Controllers\\HomeController->jugad()
#16 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(43): Illuminate\\Routing\\Controller->callAction()
#17 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Routing/Route.php(260): Illuminate\\Routing\\ControllerDispatcher->dispatch()
#18 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Routing/Route.php(205): Illuminate\\Routing\\Route->runController()
#19 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Routing/Router.php(725): Illuminate\\Routing\\Route->run()
#20 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
#21 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#22 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()
#23 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#24 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()
#25 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#26 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()
#27 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#28 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()
#29 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Session\\Middleware\\StartSession->handle()
#30 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#31 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()
#32 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#33 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()
#34 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#35 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Routing/Router.php(726): Illuminate\\Pipeline\\Pipeline->then()
#36 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Routing/Router.php(703): Illuminate\\Routing\\Router->runRouteWithinStack()
#37 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Routing/Router.php(667): Illuminate\\Routing\\Router->runRoute()
#38 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Routing/Router.php(656): Illuminate\\Routing\\Router->dispatchToRoute()
#39 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(190): Illuminate\\Routing\\Router->dispatch()
#40 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
#41 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#42 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#43 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()
#44 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#45 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#46 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()
#47 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#48 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()
#49 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#50 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()
#51 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#52 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Http\\Middleware\\HandleCors->handle()
#53 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#54 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Http\\Middleware\\TrustProxies->handle()
#55 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#56 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(165): Illuminate\\Pipeline\\Pipeline->then()
#57 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(134): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#58 /var/www/html/better_cloud/public/index.php(52): Illuminate\\Foundation\\Http\\Kernel->handle()
#59 /var/www/html/better_cloud/vendor/laravel/framework/src/Illuminate/Foundation/resources/server.php(16): require_once('...')
#60 {main}
Server:
- php version: [8.0.25]
- database: [mysql Ver 8.0.31]
- wallet version [9.6.0]
- cache lock: [array]
- cache wallets: [array]
bug question