ekoseoglu / php-parasut-api-v4

Parasut API Version 4
39 stars 13 forks source link

Bad Request: relationships->details must have exactly one element Hatası #9

Open noneym opened 1 year ago

noneym commented 1 year ago

Merhaba

Fatura oluştururken birden fazla ürün gönderdiğimde hata alıyorum, tek ürün gönderdiğim de hiç bir sorun yok. 2 gündür uğraşıyorum çözüm bulamadım örnek kod aşağıda.

kod örneklerinizde çoklu ürün gönderimine dair bir örnek yok keza parasüt'ün dökümantasyonunda da yok.

  $createInvoiceData = [
            "data" => [
                "type" => "sales_invoices",
                "attributes" => [
                    "item_type" => "invoice",
                    "description" => "Clinixo", //fatura açıklaması
                    "issue_date" => $date, //düzenleme tarihi
                    "due_date" => $date, //son tahsilat tarihi
                    "currency" => "TRL", //döviz tipi // TRL, USD, EUR, GBP
                    "shipment_included" => false, //irsaliye
                ],
                "relationships" => [
                    "details" => [
                        "data" => [
                            0 => [
                                "type" => "sales_invoice_details",
                                "attributes" => [
                                    "quantity" => 1, //birim adedi
                                    "unit_price" => 100, //birim fiyatı (kdv'siz fiyatı)
                                    "vat_rate" => 8, //kdv oranı
                                    "description" => "XXXXX" //ürün açıklaması
                                ],
                                "relationships" => [
                                    "product" => [
                                        "data" => [
                                            "id" => 1003698667, //ürün id
                                            "type" => "products"
                                        ]
                                    ]
                                ]
                            ],
                            1 => [
                                "type" => "sales_invoice_details",
                                "attributes" => [
                                    "quantity" => 1, //birim adedi
                                    "unit_price" => 100, //birim fiyatı (kdv'siz fiyatı)
                                    "vat_rate" => 18, //kdv oranı
                                    "description" => "XXXXX2" //ürün açıklaması
                                ],
                                "relationships" => [
                                    "product" => [
                                        "data" => [
                                            "id" => 1003698668, //ürün id
                                            "type" => "products"
                                        ]
                                    ]
                                ]
                            ],
                        ]
                    ],
                    "contact" => [
                        "data" => [
                            "type" => "contacts",
                            "id" => $customer_id  //müşteri id
                        ]
                    ]
                ]
            ]
        ];