No order ID found when creating invoice

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
User avatar
EduardoThomasPérezdelPostigo
Posts: 4
Joined: 17 May 2023, 14:02

No order ID found when creating invoice

Post by EduardoThomasPérezdelPostigo » 17 May 2023, 16:01

I'm evaluating Aimeos for a new project; I'm able to go through the different stages to post an order with the JSON API (adding product, customer, address, services, and saving the order)...

Code: Select all

{
    "meta": {
        "total": 1,
        "prefix": null,
        "content-baseurl": "",
        "csrf": {
            "name": "_token",
            "value": "0FNrpzxdTQF6RpraMVxNoijs8sttQIIEEJ7gWgQj"
        }
    },
    "links": {
        "self": {
            "href": "http://localhost/jsonapi/basket",
            "allow": [
                "GET"
            ]
        },
        "order": {
            "href": "http://localhost/jsonapi/order",
            "allow": [
                "POST"
            ]
        }
    },
    "data": {
        "id": "4",
        "type": "basket",
        "links": {
            "self": {
                "href": "http://localhost/jsonapi/basket?id=4",
                "allow": [
                    "GET"
                ]
            }
        },
        "attributes": {
            "order.id": "4",
            "order.channel": "jsonapi",
            "order.invoiceno": "",
            "order.statusdelivery": -1,
            "order.statuspayment": -1,
            "order.datedelivery": null,
            "order.datepayment": null,
            "order.relatedid": "",
            "order.sitecode": "",
            "order.customerid": "",
            "order.languageid": "es",
            "order.currencyid": "EUR",
            "order.price": "100.00",
            "order.costs": "0.00",
            "order.rebate": "0.00",
            "order.taxflag": true,
            "order.taxvalue": "16.6667",
            "order.customerref": "ABCD-12345",
            "order.comment": "test comment"
        },
        "relationships": {
            "basket.product": {
                "data": [
                    {
                        "type": "basket.product",
                        "id": 0
                    }
                ]
            },
            "basket.service": {
                "data": [
                    {
                        "type": "basket.service",
                        "id": "delivery"
                    },
                    {
                        "type": "basket.service",
                        "id": "payment"
                    }
                ]
            },
            "basket.address": {
                "data": [
                    {
                        "type": "basket.address",
                        "id": "payment"
                    }
                ]
            }
        }
    },
    "included": [
        {
            "id": 0,
            "type": "basket.product",
            "attributes": {
                "order.product.id": "4",
                "order.product.price": "100.00",
                "order.product.costs": "0.00",
                "order.product.rebate": "0.00",
                "order.product.taxrate": "20.00",
                "order.product.taxrates": {
                    "tax": "20.00"
                },
                "order.product.type": "default",
                "order.product.stocktype": "default",
                "order.product.prodcode": "appraisal",
                "order.product.productid": "18",
                "order.product.parentproductid": "",
                "order.product.vendor": "Aimeos",
                "order.product.scale": 1,
                "order.product.quantity": 1,
                "order.product.qtyopen": 1,
                "order.product.currencyid": "EUR",
                "order.product.taxvalue": "16.6667",
                "order.product.taxflag": true,
                "order.product.name": "appraisal",
                "order.product.description": "",
                "order.product.mediaurl": "",
                "order.product.timeframe": "",
                "order.product.position": 1,
                "order.product.notes": "",
                "order.product.statuspayment": -1,
                "order.product.statusdelivery": -1
            }
        },
        {
            "id": "delivery",
            "type": "basket.service",
            "attributes": {
                "order.service.id": "7",
                "order.service.price": "0.00",
                "order.service.costs": "0.00",
                "order.service.rebate": "0.00",
                "order.service.taxrate": "0.00",
                "order.service.taxrates": {
                    "tax": "0.00"
                },
                "order.service.type": "delivery",
                "order.service.code": "demo-pickup",
                "order.service.name": "Click & Collect",
                "order.service.currencyid": "EUR",
                "order.service.taxvalue": "0.0000",
                "order.service.taxflag": true,
                "order.service.position": null,
                "order.service.mediaurl": "",
                "order.service.serviceid": "1"
            }
        },
        {
            "id": "payment",
            "type": "basket.service",
            "attributes": {
                "order.service.id": "8",
                "order.service.price": "0.00",
                "order.service.costs": "0.00",
                "order.service.rebate": "0.00",
                "order.service.taxrate": "20.00",
                "order.service.taxrates": {
                    "tax": "20.00"
                },
                "order.service.type": "payment",
                "order.service.code": "demo-invoice",
                "order.service.name": "Invoice",
                "order.service.currencyid": "EUR",
                "order.service.taxvalue": "0.0000",
                "order.service.taxflag": true,
                "order.service.position": null,
                "order.service.mediaurl": "",
                "order.service.serviceid": "6"
            }
        },
        {
            "id": "payment",
            "type": "basket.address",
            "attributes": {
                "order.address.id": "4",
                "nostore": false,
                "order.address.salutation": "",
                "order.address.company": "",
                "order.address.vatid": "",
                "order.address.title": "",
                "order.address.firstname": "",
                "order.address.lastname": "Jones",
                "order.address.address1": "C/ Juancho",
                "order.address.address2": "",
                "order.address.address3": "",
                "order.address.postal": "",
                "order.address.city": "Madrid",
                "order.address.state": "",
                "order.address.countryid": null,
                "order.address.languageid": "es",
                "order.address.telephone": "",
                "order.address.telefax": "",
                "order.address.email": "eduardo.thomas@externos.tinsa.com",
                "order.address.website": "",
                "order.address.longitude": null,
                "order.address.latitude": null,
                "order.address.birthday": null,
                "order.address.position": 0,
                "order.address.type": "payment",
                "order.address.addressid": ""
            }
        }
    ]
}
But when I try to get the invoice, the order ID doesn't exist:

Code: Select all

{
    "meta": {
        "total": 0,
        "prefix": null,
        "content-baseurl": "",
        "csrf": {
            "name": "_token",
            "value": "0FNrpzxdTQF6RpraMVxNoijs8sttQIIEEJ7gWgQj"
        }
    },
    "links": {
        "self": "http://localhost/jsonapi/order"
    },
    "errors": [
        {
            "title": "No order ID found"
        }
    ]
}
Another issue is that I can see the customer on the basket data after adding it via PATCH to http://localhost/jsonapi/basket?id=default&_token=..., but then it is gone in all the other steps.

Any ideas? Thank you in advance.

User avatar
aimeos
Administrator
Posts: 7858
Joined: 01 Jan 1970, 00:00

Re: No order ID found when creating invoice

Post by aimeos » 18 May 2023, 07:47

Which Aimeos version do you use?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
EduardoThomasPérezdelPostigo
Posts: 4
Joined: 17 May 2023, 14:02

Re: No order ID found when creating invoice

Post by EduardoThomasPérezdelPostigo » 18 May 2023, 07:56

aimeos wrote: 18 May 2023, 07:47 Which Aimeos version do you use?
aimeos-laravel:2023.04.1
php:8.1
laravel-framework:10.9

I'm using WSL2.
Last edited by EduardoThomasPérezdelPostigo on 18 May 2023, 07:58, edited 1 time in total.

User avatar
aimeos
Administrator
Posts: 7858
Joined: 01 Jan 1970, 00:00

Re: No order ID found when creating invoice

Post by aimeos » 18 May 2023, 09:21

There was an error in the docs because the API changed in 2023.04. Now it's fixed:
https://aimeos.org/docs/latest/frontend/jsonapi/orders/
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
EduardoThomasPérezdelPostigo
Posts: 4
Joined: 17 May 2023, 14:02

Re: No order ID found when creating invoice

Post by EduardoThomasPérezdelPostigo » 18 May 2023, 09:30

What exactly has changed and when? That is the doc I've been reading for a week.

User avatar
aimeos
Administrator
Posts: 7858
Joined: 01 Jan 1970, 00:00

Re: No order ID found when creating invoice

Post by aimeos » 18 May 2023, 09:49

Re-read the step after saving the basket carefully. This section has changed.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
EduardoThomasPérezdelPostigo
Posts: 4
Joined: 17 May 2023, 14:02

Re: No order ID found when creating invoice

Post by EduardoThomasPérezdelPostigo » 18 May 2023, 10:51

I see the differences, thank you. However, [data][links][process][meta] comes empty:

Code: Select all

            "process": {
                "href": "http://localhost/shop/confirm/demo-invoice?orderid=5",
                "allow": [
                    "POST"
                ],
                "meta": []
            }
And when I do a get on that URL, the response is HTML with this message:
No order ID available
No order ID available in session

Have any of the other steps (adding product, customer, address, and services) changed too between the docs labeled as 2023 and the ones labeled as latest?

User avatar
EduardoThomasPérezdelPostigo
Posts: 4
Joined: 17 May 2023, 14:02

Re: No order ID found when creating invoice

Post by EduardoThomasPérezdelPostigo » 19 May 2023, 07:50

Looks like doing PATCH to http://localhost/jsonapi/basket?id=default&_token= to set the customer at any point of the flow clears the current basket.

User avatar
aimeos
Administrator
Posts: 7858
Joined: 01 Jan 1970, 00:00

Re: No order ID found when creating invoice

Post by aimeos » 19 May 2023, 09:36

A basket PATCH should not clear the basket content because it only sets the send attributes:
- https://github.com/aimeos/ai-client-jso ... #L260-L261
- https://github.com/aimeos/ai-controller ... #L153-L163
- https://github.com/aimeos/aimeos-core/b ... #L448-L482

Make sure you've sent the cookies along with your request.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
aimeos
Administrator
Posts: 7858
Joined: 01 Jan 1970, 00:00

Re: No order ID found when creating invoice

Post by aimeos » 19 May 2023, 09:40

EduardoThomasPérezdelPostigo wrote: 18 May 2023, 10:51 I see the differences, thank you. However, [data][links][process][meta] comes empty:
And when I do a get on that URL, the response is HTML with this message:
The URL depends on the used payment service option and is always an URL to:
1.) a payment provider page (HTML) or
2.) the checkout confirm page (HTML)
EduardoThomasPérezdelPostigo wrote: 18 May 2023, 10:51 Have any of the other steps (adding product, customer, address, and services) changed too between the docs labeled as 2023 and the ones labeled as latest?
Not directly, only order and invoice data (order + order.base) has been merged. Whenever you see somewhere "baseid" in the docs, it's old and wrong. Then, please drop a note so we can fix it.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply