JSON API & OmniPay

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!
jafo66
Posts: 75
Joined: 06 Mar 2024, 04:42

JSON API & OmniPay

Post by jafo66 » 19 May 2025, 19:37

Details:
- Laravel
- 2024.07.02 ver
- Omnipay gateway service

We are looking to perform a checkout using the JSON API. We are able to convert the basket to an order with the payment service being marked to correspond with the credit card service. We do not provide any of the credit card details at that time.
When we do the post to get URL for the payment gateway (per the docs: https://github.com/aimeos/aimeos-docs/b ... /orders.md), we get back an empty string in the links/process/href.

Utilizing the standard Aimeos checkout, I see that the credit card is processed through the /shop/checkout/process link. Is there something similar for the order on the JSON API? Or how do we handle this situation as the credit card clearly hasn't been processed yet?

Code: Select all

{
    "meta": {
        "total": 1,
        "prefix": null,
        "content-baseurl": "",
        "csrf": {
            "name": "_token",
            "value": "blSvsVgXLkJo9vfR0unByhpKszP2Et9LozK1GlfR"
        }
    },
    "links": {
        "self": "http://localhost.proxyman.io:8000/jsonapi/order"
    },
    "data": {
        "id": "153",
        "type": "order",
        "links": {
            "self": {
                "href": "http://localhost.proxyman.io:8000/jsonapi/order?id=153",
                "allow": [
                    "GET"
                ]
            },
            "process": {
                "href": "",
                "allow": [
                    "POST"
                ],
                "meta": {
                    "payment.firstname": {
                        "code": "payment.firstname",
                        "type": "string",
                        "label": "First name",
                        "public": true,
                        "default": "Billy",
                        "required": false,
                        "value": null
                    },
                    "payment.lastname": {
                        "code": "payment.lastname",
                        "type": "string",
                        "label": "Last name",
                        "public": true,
                        "default": "Bobby",
                        "required": true,
                        "value": null
                    },
                    "payment.cardno": {
                        "code": "payment.cardno",
                        "type": "number",
                        "label": "Credit card number",
                        "public": true,
                        "default": "",
                        "required": true,
                        "value": null
                    },
                    "payment.cvv": {
                        "code": "payment.cvv",
                        "type": "number",
                        "label": "Verification number",
                        "public": true,
                        "default": "",
                        "required": true,
                        "value": null
                    },
                    "payment.expirymonth": {
                        "code": "payment.expirymonth",
                        "type": "select",
                        "label": "Expiry month",
                        "public": true,
                        "default": [
                            1,
                            2,
                            3,
                            4,
                            5,
                            6,
                            7,
                            8,
                            9,
                            10,
                            11,
                            12
                        ],
                        "required": true,
                        "value": null
                    },
                    "payment.expiryyear": {
                        "code": "payment.expiryyear",
                        "type": "select",
                        "label": "Expiry year",
                        "public": true,
                        "default": [
                            "2025",
                            2026,
                            2027,
                            2028,
                            2029,
                            2030,
                            2031,
                            2032
                        ],
                        "required": true,
                        "value": null
                    },
                    "payment.company": {
                        "code": "payment.company",
                        "type": "string",
                        "label": "Company",
                        "public": false,
                        "default": "",
                        "required": false,
                        "value": null
                    },
                    "payment.address1": {
                        "code": "payment.address1",
                        "type": "string",
                        "label": "Street",
                        "public": false,
                        "default": "123 Nowhere Lane",
                        "required": false,
                        "value": null
                    },
                    "payment.address2": {
                        "code": "payment.address2",
                        "type": "string",
                        "label": "Additional",
                        "public": false,
                        "default": "",
                        "required": false,
                        "value": null
                    },
                    "payment.city": {
                        "code": "payment.city",
                        "type": "string",
                        "label": "City",
                        "public": false,
                        "default": "Chicago",
                        "required": false,
                        "value": null
                    },
                    "payment.postal": {
                        "code": "payment.postal",
                        "type": "string",
                        "label": "Zip code",
                        "public": false,
                        "default": "60124",
                        "required": false,
                        "value": null
                    },
                    "payment.state": {
                        "code": "payment.state",
                        "type": "string",
                        "label": "State",
                        "public": false,
                        "default": "IL",
                        "required": false,
                        "value": null
                    },
                    "payment.countryid": {
                        "code": "payment.countryid",
                        "type": "string",
                        "label": "Country",
                        "public": false,
                        "default": "US",
                        "required": false,
                        "value": null
                    },
                    "payment.telephone": {
                        "code": "payment.telephone",
                        "type": "string",
                        "label": "Telephone",
                        "public": false,
                        "default": "(312) 555-1212",
                        "required": false,
                        "value": null
                    },
                    "payment.email": {
                        "code": "payment.email",
                        "type": "string",
                        "label": "E-Mail",
                        "public": false,
                        "default": "billybobby@example.net",
                        "required": false,
                        "value": null
                    }
                }
            }
        },
        "attributes": {
            "order.id": "153",
            "order.channel": "jsonapi",
            "order.invoiceno": "",
            "order.statusdelivery": -1,
            "order.statuspayment": -1,
            "order.datedelivery": null,
            "order.datepayment": null,
            "order.relatedid": "",
            "order.sitecode": "default",
            "order.customerid": "2",
            "order.languageid": "en",
            "order.currencyid": "USD",
            "order.price": "300.00",
            "order.costs": "0.00",
            "order.rebate": "75.00",
            "order.taxflag": true,
            "order.taxvalue": "0.0000",
            "order.customerref": "",
            "order.comment": ""
        },
        "relationships": {
            "order.service": {
                "data": [
                    {
                        "type": "order.service",
                        "id": "305"
                    },
                    {
                        "type": "order.service",
                        "id": "306"
                    }
                ]
            },
            "order.address": {
                "data": [
                    {
                        "type": "order.address",
                        "id": "153"
                    }
                ]
            }
        }
    },
    "included": [
        {
            "id": "153",
            "type": "order.address",
            "attributes": {
                "order.address.id": "153",
                "order.address.type": "payment",
                "order.address.salutation": "",
                "order.address.company": "",
                "order.address.vatid": "",
                "order.address.title": "",
                "order.address.firstname": "Billy",
                "order.address.lastname": "Bob",
                "order.address.address1": "123 Nowhere Lane",
                "order.address.address2": "",
                "order.address.address3": "",
                "order.address.postal": "60124",
                "order.address.city": "Chicago",
                "order.address.state": "IL",
                "order.address.countryid": "US",
                "order.address.languageid": "en",
                "order.address.telephone": "(312) 555-1212",
                "order.address.telefax": "",
                "order.address.mobile": "",
                "order.address.email": "billybobby@example.net",
                "order.address.website": "",
                "order.address.longitude": null,
                "order.address.latitude": null,
                "order.address.birthday": null,
                "order.address.position": 0,
                "order.address.addressid": "2"
            }
        },
        {
            "id": "305",
            "type": "order.service",
            "attributes": {
                "order.service.id": "305",
                "order.service.price": null,
                "order.service.costs": "0.00",
                "order.service.rebate": "0.00",
                "order.service.taxrate": "0.00",
                "order.service.taxrates": [],
                "order.service.type": "delivery",
                "order.service.code": "email",
                "order.service.name": "Email",
                "order.service.currencyid": "USD",
                "order.service.taxvalue": "0.0000",
                "order.service.taxflag": true,
                "order.service.position": 0,
                "order.service.mediaurl": "",
                "order.service.serviceid": "1"
            }
        },
        {
            "id": "306",
            "type": "order.service",
            "attributes": {
                "order.service.id": "306",
                "order.service.price": null,
                "order.service.costs": "0.00",
                "order.service.rebate": "0.00",
                "order.service.taxrate": "0.00",
                "order.service.taxrates": [],
                "order.service.type": "payment",
                "order.service.code": "credit-card",
                "order.service.name": "Credit Card",
                "order.service.currencyid": "USD",
                "order.service.taxvalue": "0.0000",
                "order.service.taxflag": true,
                "order.service.position": 0,
                "order.service.mediaurl": "",
                "order.service.serviceid": "5"
            }
        }
    ]
}

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

Re: JSON API & OmniPay

Post by aimeos » 20 May 2025, 06:54

If you use the JSON API only to build your own PWA, the existing Aimeos payment integrations are only helpful for the communication from the payment service provider back to your shop server when updating the payment status in an asynchronous way. This is because in PWAs, handling the payment requires a JS library from the payment provider to make sure, no payment data is sent to your shop server but directly to the payment provider. Stripe offers such a JS lib for PWAs to handle credit card payments for example.

The alternative is to forward the customers of your PWA to the checkout process page generated by Aimeos on your shop server and handle the payment using one of the various payment integration options there. In that case, the customers will leave your PWA. This is the easiest option which always work.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

jafo66
Posts: 75
Joined: 06 Mar 2024, 04:42

Re: JSON API & OmniPay

Post by jafo66 » 20 May 2025, 19:20

So if we utilize the javascript from our payment gateway provider directly, how do we automatically mark the order as being received, generate the invoice number, etc. through the JSON or does that have been done via a controller (after the payment is processed)?

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

Re: JSON API & OmniPay

Post by aimeos » 22 May 2025, 15:04

You persist the basket as order via the JSON REST API and the payment status is updated by the payment gateways server (server to server update because you can't set the payment status of an order via the JSON API for obvious reasons). The rest of the processing is async done by cronjobs.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply