LauLamanApps / iZettleApi

iZettle Api php intergration
MIT License
12 stars 15 forks source link

Non-existent VAT values returned from iZettle API causing issues #33

Open DMCTowns opened 5 years ago

DMCTowns commented 5 years ago

Fatal error: Uncaught TypeError: Argument 7 passed to LauLamanApps\IzettleApi\API\Purchase\Product::__construct() must be of the type float, null given

This seems to be caused by VAT values not being present in the Purchase data block returned from the iZettle API:

        {
            "amount": 1699,
            "country": "GB",
            "currency": "GBP",
            "discounts": [],
            "gpsCoordinates": {
                "accuracyMeters": 11.0,
                "latitude": 51.60504687,
                "longitude": -0.59811193
            },
            "groupedVatAmounts": {},
            "organizationId": 00000000,
            "payments": [
                {
                    "amount": 1699,
                    "attributes": {
                        "applicationIdentifier": "XXXXXXXXXXX",
                        "cardIssuingBank": "LLOYDS BANK PLC",
                        "cardPaymentEntryMode": "CONTACTLESS_EMV",
                        "cardType": "VISA",
                        "maskedPan": "XXXXXXXXXXXXXXX",
                        "referenceNumber": "XXXXXXXXXXX",
                        "terminalVerificationResults": "0000000000"
                    },
                    "type": "IZETTLE_CARD",
                    "uuid": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX"
                }
            ],
            "products": [
                {
                    "autoGenerated": false,
                    "barcode": "978-0-241-39863-0",
                    "description": "",
                    "id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX",
                    "libraryProduct": true,
                    "name": "The Art of Statistics - David Spiegelhalter",
                    "productUuid": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX",
                    "quantity": "1",
                    "rowTaxableAmount": 1699,
                    "unitPrice": 1699,
                    "variantName": "The Art of Statistics - David Spiegelhalter",
                    "variantUuid": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX"
                }
            ],
            "published": true,
            "purchaseNumber": 261,
            "purchaseUUID": "XXXXXXXXXXXX",
            "purchaseUUID1": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX",
            "receiptCopyAllowed": true,
            "refund": false,
            "refunded": false,
            "source": "POS",
            "timestamp": "2019-04-03T19:24:17.088+0000",
            "userDisplayName": "XXXXXX XXXXXXXX",
            "userId": 0000000
        }

I have a branch that fixes this, if you would like to take a look at it?

LauLaman commented 5 years ago

@DMCTowns Feel free to open an PR