duncanmcclean / simple-commerce

A simple, yet powerful e-commerce addon for Statamic.
https://statamic.com/addons/duncanmcclean/simple-commerce
Other
146 stars 40 forks source link

GatewayData::data() typed wrongly: can be nullable #1111

Closed RafaelKr closed 1 month ago

RafaelKr commented 2 months ago

Description

I'm creating a custom Payment Gateway. The process is very smooth! Good job there :)

I want to add a response log to the gateway data. This happens while we're in the checkout method.

But when calling $order->gatewayData(static::class)->data() I run into DuncanMcClean\SimpleCommerce\Orders\GatewayData::data(): Return value must be of type Illuminate\Support\Collection, null returned because data is not defined at that time. The return type annotation should be ?Collection.

https://github.com/duncanmcclean/simple-commerce/blob/5f0cda71864fff7792a71c824e7dc63680d949e8/src/Orders/GatewayData.php#L41

Alternatively an empty Collection should be returned if data is not yet defined.

Steps to reproduce

  1. Create a Payment Gateway
  2. Add a call to $order->gatewayData(static::class)->data() in the beginning of the checkout method
  3. Create an order and submit the payment step

Environment

Environment
Application Name: <REDACTED>
Laravel Version: 10.48.17
PHP Version: 8.2.21
Composer Version: 2.7.7
Environment: local
Debug Mode: ENABLED
URL: <REDACTED>.localhost:8000
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: mysql
Logs: daily
Mail: smtp
Queue: sync
Session: file

Simple Commerce
Currencies: EUR
Gateways: [VR Pay] Credit Card
Repository: Customer: DuncanMcClean\SimpleCommerce\Customers\EntryCustomerRepository
Repository: Order: DuncanMcClean\SimpleCommerce\Orders\EntryOrderRepository
Repository: Product: DuncanMcClean\SimpleCommerce\Products\EntryProductRepository
Shipping Methods: Free Shipping
Tax Engine: DuncanMcClean\SimpleCommerce\Tax\Standard\TaxEngine

Livewire
Livewire: v3.5.4

Statamic
Addons: 16
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.17.0 PRO

Statamic Addons
[...]
duncanmcclean/simple-commerce: 7.4.0
[...]
vcore/simple-commerce-vr-pay: dev-main
[...]
github-actions[bot] commented 1 month ago

Released as part of v7.4.1.