sebdesign / laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway
MIT License
42 stars 19 forks source link

Error TransactionPaymentCreated #35

Closed AmityTek closed 1 year ago

AmityTek commented 1 year ago

Hey,

I have one issue regarding transaction payment created.

local.ERROR: Unknown named parameter $MerchantCategoryCode {"exception":"[object] (Error(code: 0): Unknown named parameter $MerchantCategoryCode at /vendor/sebdesign/laravel-viva-payments/src/Events/TransactionPaymentCreated.php:92)

i have this error, but I followed all documentation; I have this

Route::get('viva/webhooks', [SubscriptionController::class, 'verify']);
Route::post('viva/webhooks', [SubscriptionController::class, 'handle']);

and this in my controller

use Sebdesign\VivaPayments\Http\Controllers\WebhookController as BaseController;

class SubscriptionController extends BaseController
[    protected $listen = [
        Registered::class => [
            SendEmailVerificationNotification::class,
        ],
        WebhookEvent::class => [WebhookEventListener::class],
    ];](url)

and mywebhookListener:

    {
        switch ($event->EventTypeId) {
            case WebhookEventType::TransactionPaymentCreated:
                Log::alert('Hello les amis merci beaucoup');
                var_dump($event);
                break;

            case WebhookEventType::TransactionFailed:
                event($event->EventData);
                break;

            case WebhookEventType::TransactionReversalCreated:
                event($event->EventData);
                break;

            default:

                dd('basic', $event);
                break;
        }
    }

Anyone has idea why isn't working ?

AmityTek commented 1 year ago

Any idea ? its urgent ...

sebdesign commented 1 year ago

That error means that there is a MerchantCategoryCode field in the webhook payload, that is not documented by Viva. What needs to be done is to add MerchantCategoryCode property to the TransactionPaymentCreated class. If it's urgent you can submit a PR and I will merge it ASAP.

You can check this commit for example: https://github.com/sebdesign/laravel-viva-payments/commit/54cb738570748f56ae3e4fa1f0c89a9c475fe12f

AmityTek commented 1 year ago

OK thanks Let me check

sebdesign commented 1 year ago

Fixed in v6.0.2