Why isn't my discount applying correctly in REST API with PHP?

Hi @pstanek

You can try again with the following data: (wrap the draft_order attribute outside, change the variant_id to match the store)

{
"draft_order":{
    "email": "testujedarek@pocztavp.pl",
    "line_items": [
        {
            "variant_id": "39635639107745",
            "quantity": "3",
            "applied_discount": {
                "value_type": "fixed_amount",
                "value": 142,
                "amount": 426,
                "title": "Promo",
                "description": "Promo"
            }
        }
    ],
    "shipping_address": {
        "first_name": "Darek",
        "last_name": "Test",
        "address1": "Test 1",
        "phone": "123123123",
        "city": "Test",
        "zip": "12-123",
        "country": "Poland"
    },
    "shipping_line": {
        "title": "Kurier",
        "price": 0
    }
}
}

I tested it, and it’s successful. The following is the result:

{
    "draft_order": {
        "id": 926101668001,
        "note": null,
        "email": "testujedarek@pocztavp.pl",
        "taxes_included": true,
        "currency": "EUR",
        "invoice_sent_at": null,
        "created_at": "2022-11-09T09:08:12+00:00",
        "updated_at": "2022-11-09T09:08:12+00:00",
        "tax_exempt": false,
        "completed_at": null,
        "name": "#D50",
        "status": "open",
        "line_items": [
            {
                "id": 57353938403489,
                "variant_id": 39635639107745,
                "product_id": 6664666513569,
                "title": "All In One Snail Repair Cream",
                "variant_title": "75ml",
                "sku": "MIZ-13AL1SNLRPR-F",
                "vendor": "Mizon",
                "quantity": 3,
                "requires_shipping": true,
                "taxable": true,
                "gift_card": false,
                "fulfillment_service": "manual",
                "grams": 150,
                "tax_lines": [
                    {
                        "rate": 0.21,
                        "title": "Tax",
                        "price": "0.00"
                    }
                ],
                "applied_discount": {
                    "description": "Promo",
                    "value": "142.0",
                    "title": "Promo",
                    "amount": "90.00",
                    "value_type": "fixed_amount"
                },
                "name": "All In One Snail Repair Cream - 75ml",
                "properties": [],
                "custom": false,
                "price": "30.00",
                "admin_graphql_api_id": "gid://shopify/DraftOrderLineItem/57353938403489"
            }
        ],
        "shipping_address": {
            "first_name": "Darek",
            "address1": "Test 1",
            "phone": "123123123",
            "city": "Test",
            "zip": "12-123",
            "province": null,
            "country": "Poland",
            "last_name": "Test",
            "address2": null,
            "company": null,
            "latitude": null,
            "longitude": null,
            "name": "Darek Test",
            "country_code": "PL",
            "province_code": null
        },
        "billing_address": null,
        "invoice_url": "https://development-service-1.myshopify.com/55931240609/invoices/96162a151298a30bc5cb3e68aa742a60",
        "applied_discount": null,
        "order_id": null,
        "shipping_line": {
            "title": "Kurier",
            "custom": true,
            "handle": null,
            "price": "0.00"
        },
        "tax_lines": [
            {
                "rate": 0.21,
                "title": "Tax",
                "price": "0.00"
            },
            {
                "rate": 0.21,
                "title": "Tax",
                "price": "0.00"
            }
        ],
        "tags": "",
        "note_attributes": [],
        "total_price": "0.00",
        "subtotal_price": "0.00",
        "total_tax": "0.00",
        "payment_terms": null,
        "admin_graphql_api_id": "gid://shopify/DraftOrder/926101668001",
        "customer": {
            "id": 6401438875809,
            "email": "testujedarek@pocztavp.pl",
            "accepts_marketing": false,
            "created_at": "2022-11-09T09:04:52+00:00",
            "updated_at": "2022-11-09T09:04:52+00:00",
            "first_name": "Darek",
            "last_name": "Test",
            "orders_count": 0,
            "state": "disabled",
            "total_spent": "0.00",
            "last_order_id": null,
            "note": null,
            "verified_email": true,
            "multipass_identifier": null,
            "tax_exempt": false,
            "tags": "",
            "last_order_name": null,
            "currency": "EUR",
            "phone": null,
            "accepts_marketing_updated_at": "2022-11-09T09:04:52+00:00",
            "marketing_opt_in_level": null,
            "tax_exemptions": [],
            "email_marketing_consent": {
                "state": "not_subscribed",
                "opt_in_level": "single_opt_in",
                "consent_updated_at": null
            },
            "sms_marketing_consent": null,
            "admin_graphql_api_id": "gid://shopify/Customer/6401438875809",
            "default_address": {
                "id": 7689759129761,
                "customer_id": 6401438875809,
                "first_name": "Darek",
                "last_name": "Test",
                "company": null,
                "address1": "Test 1",
                "address2": null,
                "city": "Test",
                "province": null,
                "country": "Poland",
                "zip": "12-123",
                "phone": "123123123",
                "name": "Darek Test",
                "province_code": null,
                "country_code": "PL",
                "country_name": "Poland",
                "default": true
            }
        }
    }
}

I hope this can help you.