Developer forum

Forum » Development » creating order through /dwapi/ecommerce/carts/{secret}/createorder doesn't complete order in DW

creating order through /dwapi/ecommerce/carts/{secret}/createorder doesn't complete order in DW

Mikkel Hammer
Mikkel Hammer
Reply

Dear Dynamicweb,

As the title states, when we complete orders through the endpoint, it seems like the order never completes which also results in no emails being sent to the customer.
Our thougths are because alot of the logic might be in the Cart module, which is never hit.

How would you recommend going forward?
Below i've inserted some logs of a order through the webshop and endpoint.

Best Regard,
Mikkel
 



On this picture the last of the orders are completed through the webshop, which shows it's completed, but the other two are through the endpoint.
image

Here's the log from the ORDER6979 (webshop), which shows some Dynamicweb.Ecommerce.Cart.DefaultCheckoutHandler logic
image

and here the log from ORDER6983 (endpoint), which is fairly empty
image


Replies

 
Mikkel Hammer
Mikkel Hammer
Reply

Dear Dynamicweb,

Any thoughts on this?

Best Regard,
Mikkel

 
Morten Snedker Dynamicweb Employee
Morten Snedker
Reply

Hi Mikkel,

I notice in the response from endpoint that it has "Complete:False" and "IsCart: True", which indicates that endpoint is returning a response, stating that the order is not complete. The dwapi has a /dwapi/ecommerce/carts/{secret}/createorder, which will transform the cart to order. Do you do that along the process?

Let me have a comment.

/snedker

 
Mikkel Hammer
Mikkel Hammer
Reply

Dear Morten,

We're trying to complete the order through the POST /dwapi/ecommerce/carts/{secret}/createorder endpoint.
It returns OK and when you try to access the cart through GET /dwapi/ecommerce/carts/{secret}, it returns "The cart is completed."

Are you surposed to use another endpoint to complete the order after that?

Here is a snippet from our code we're using at /createorder


Best regards,
Mikkel

 
Mikkel Hammer
Mikkel Hammer
Reply

Hi again,

We thought it would be helpful with some recreational steps to how we're using the endpoints.

1. create cart with POST "/dwapi/ecommerce/carts?CurrencyCode=DKK&CountryCode=DK&LanguageId=LANG1"
2. add product with POST "/dwapi/ecommerce/carts/{secret}/items" with the body:

{
    "ProductId": "{insert product id}",
    "Quantity": 1
}

3. create order with POST "/dwapi/ecommerce/carts/{secret}/createorder" with the body of the cart

Also here's how the cart information we're trying to post to it looks like:
We have tried setting a ShopId to SHOP1 and set Completed to true, with no luck so far.
{
    "Id": "CART17817",
    "SecondaryUserName": "",
    "Secret": "d114a85921a64361b326532e517e0df0",
    "VoucherCode": "",
    "CreatedAt": "2022-01-14T08:50:50.1683277+01:00",
    "Modified": "2022-01-14T08:58:56.0245688+01:00",
    "Completed": false,
    "IntegrationOrderId": "",
    "RecurringOrderId": 0,
    "CustomerUserId": 33119,
    "CustomerNumber": "100083",
    "CustomerCompany": "Test company",
    "CustomerTitle": "",
    "CustomerName": "Test name",
    "CustomerFirstName": "",
    "CustomerSurname": "",
    "CustomerMiddleName": "",
    "CustomerHouseNumber": "",
    "CustomerAddress": "Test address 12",
    "CustomerAddress2": "",
    "CustomerZip": "4621",
    "CustomerCity": "GADSTRUP",
    "CustomerCountry": "Denmark",
    "CustomerCountryCode": "DK",
    "CustomerRegion": "",
    "CustomerPhone": "*",
    "CustomerEmail": "test@test.com",
    "CustomerCell": "",
    "CustomerAccepted": false,
 "OrderLines": [
        {
            "Id": "OL306935",
            "ProductId": "72459",
            "ProductLanguageId": "LANG1",
            "ProductName": "SAVAGE MINNOW TAIL80 8CM 6G BLUE PEARL SILVER 5PCS",
            "ProductNumber": "72459",
            "ProductImage": "/Files/Images/missing_image.jpg",
            "PrimaryOrDefaultGroup": {},
            "Quantity": 1.0,
            "OrderLineFields": {},
            "Price": {
                "Price": 10.38,
                "PriceFormatted": "kr. 10.38",
                "PriceWithoutVat": 10.38,
                "PriceWithoutVatFormatted": "kr. 10.38",
                "PriceWithVat": 12.98,
                "PriceWithVatFormatted": "kr. 12.98",
                "Vat": 2.6,
                "VatFormatted": "kr. 2.60",
                "VATPercent": 25.0,
                "VATPercentFormatted": "25%",
                "CurrencyCode": "EUR"
            },
            "UnitPrice": {
                "Price": 10.38,
                "PriceFormatted": "kr. 10.38",
                "PriceWithoutVat": 10.38,
                "PriceWithoutVatFormatted": "kr. 10.38",
                "PriceWithVat": 12.98,
                "PriceWithVatFormatted": "kr. 12.98",
                "Vat": 2.6,
                "VatFormatted": "kr. 2.60",
                "VATPercent": 25.0,
                "VATPercentFormatted": "25%",
                "CurrencyCode": "EUR"
            },
            "UnitPriceBeforeDiscount": {
                "PriceFormatted": "kr. 0.00",
                "PriceWithoutVatFormatted": "kr. 0.00",
                "PriceWithVatFormatted": "kr. 0.00",
                "VatFormatted": "kr. 0.00",
                "VATPercent": 25.0,
                "VATPercentFormatted": "25%",
                "CurrencyCode": "EUR"
            },
            "TotalDiscount": {
                "PriceFormatted": "kr. 0.00",
                "PriceWithoutVatFormatted": "kr. 0.00",
                "PriceWithVatFormatted": "kr. 0.00",
                "VatFormatted": "kr. 0.00",
                "VATPercentFormatted": "0%",
                "CurrencyCode": "EUR"
            }
        }
    ],
    "OrderFields": {
        "SpAxOrderStatus": {
            "SystemName": "SpAxOrderStatus",
            "Name": "Order status",
            "Type": "Text(255)"
        },
        "SpAxIsAxOrder": {
            "SystemName": "SpAxIsAxOrder",
            "Name": "Order is from AX",
            "Type": "Checkbox"
        },
        "AXMiscFee": {
            "SystemName": "AXMiscFee",
            "Name": "AXMiscellaneousFee",
            "Type": ""
        },
        "AXMiscText": {
            "SystemName": "AXMiscText",
            "Name": "AXMiscellaneousText",
            "Type": ""
        },
        "AXDeliveryFee": {
            "SystemName": "AXDeliveryFee",
            "Name": "AXDeliveryFee",
            "Type": ""
        },
        "AXTotalDiscount": {
            "SystemName": "AXTotalDiscount",
            "Name": "AXTotalDiscount",
            "Type": ""
        },
        "AXDeliveryFeeTax": {
            "SystemName": "AXDeliveryFeeTax",
            "Name": "AXDeliveryFeeTax",
            "Type": ""
        },
        "AXVoucherDisc": {
            "SystemName": "AXVoucherDisc",
            "Name": "AXVoucherDisc",
            "Type": ""
        },
        "SpAxFirstAvailableDeliveryDate": {
            "SystemName": "SpAxFirstAvailableDeliveryDate",
            "Name": "First available delivery date",
            "Type": "Date"
        },
        "SpAxChosenDeliveryDate": {
            "SystemName": "SpAxChosenDeliveryDate",
            "Name": "Chosen delivery date",
            "Type": "Date"
        },
        "SpAxLastKnownVoucherValue": {
            "SystemName": "SpAxLastKnownVoucherValue",
            "Name": "Last known voucher value",
            "Type": "Text(255)"
        },
        "SpGeneratedQuote": {
            "SystemName": "SpGeneratedQuote",
            "Name": "Sp generated quote",
            "Type": "Checkbox"
        },
        "SpAxDWOrderId": {
            "SystemName": "SpAxDWOrderId",
            "Name": "Order Id from AX",
            "Type": "Text(50)"
        },
        "SpAxIsJustImported": {
            "SystemName": "SpAxIsJustImported",
            "Name": "Order just imported from AX",
            "Type": "Checkbox"
        }
    },
    "TotalDiscount": {
        "PriceFormatted": "kr. 0.00",
        "PriceWithoutVatFormatted": "kr. 0.00",
        "PriceWithVatFormatted": "kr. 0.00",
        "VatFormatted": "kr. 0.00",
        "VATPercentFormatted": "0%",
        "CurrencyCode": "EUR"
    },
    "TotalProductDiscount": {
        "PriceFormatted": "kr. 0.00",
        "PriceWithoutVatFormatted": "kr. 0.00",
        "PriceWithVatFormatted": "kr. 0.00",
        "VatFormatted": "kr. 0.00",
        "VATPercentFormatted": "0%",
        "CurrencyCode": "EUR"
    },
    "TotalOrderDiscount": {
        "PriceFormatted": "kr. 0.00",
        "PriceWithoutVatFormatted": "kr. 0.00",
        "PriceWithVatFormatted": "kr. 0.00",
        "VatFormatted": "kr. 0.00",
        "VATPercentFormatted": "0%",
        "CurrencyCode": "EUR"
    },
    "Price": {
        "Price": 87.38,
        "PriceFormatted": "kr. 87.38",
        "PriceWithoutVat": 87.38,
        "PriceWithoutVatFormatted": "kr. 87.38",
        "PriceWithVat": 89.98,
        "PriceWithVatFormatted": "kr. 89.98",
        "Vat": 2.6,
        "VatFormatted": "kr. 2.60",
        "VATPercent": 2.9755092698558023,
        "VATPercentFormatted": "2.98%",
        "CurrencyCode": "EUR"
    },
    "PriceBeforeFees": {
        "Price": 10.38,
        "PriceFormatted": "kr. 10.38",
        "PriceWithoutVat": 10.38,
        "PriceWithoutVatFormatted": "kr. 10.38",
        "PriceWithVat": 12.98,
        "PriceWithVatFormatted": "kr. 12.98",
        "Vat": 2.6,
        "VatFormatted": "kr. 2.60",
        "VATPercent": 25.0,
        "VATPercentFormatted": "25%",
        "CurrencyCode": "EUR"
    },
    "TotalPriceBeforeFeesAndTaxes": {
        "Price": 10.379999999999995,
        "PriceFormatted": "kr. 10.38",
        "PriceWithoutVat": 10.379999999999995,
        "PriceWithoutVatFormatted": "kr. 10.38",
        "PriceWithVat": 12.980000000000004,
        "PriceWithVatFormatted": "kr. 12.98",
        "Vat": 2.6,
        "VatFormatted": "kr. 2.60",
        "VATPercent": 25.04816955684009,
        "VATPercentFormatted": "25.05%",
        "CurrencyCode": "EUR"
    },
    "TotalTaxes": {
        "PriceFormatted": "kr. 0.00",
        "PriceWithoutVatFormatted": "kr. 0.00",
        "PriceWithVatFormatted": "kr. 0.00",
        "VatFormatted": "kr. 0.00",
        "VATPercentFormatted": "0%",
        "CurrencyCode": "EUR"
    },
    "ShippingFee": {
        "PriceFormatted": "kr. 0.00",
        "PriceWithoutVatFormatted": "kr. 0.00",
        "PriceWithVatFormatted": "kr. 0.00",
        "VatFormatted": "kr. 0.00",
        "VATPercentFormatted": "0%",
        "CurrencyCode": "EUR"
    },
    "PaymentMethod": {
        "Id": "PAY3",
        "Name": "Invoice",
        "Description": "",
        "Icon": "",
        "Code": "",
        "TermsCode": "",
        "TermsDescription": ""
    },
    "PaymentFee": {
        "Price": 77.0,
        "PriceFormatted": "kr. 77.00",
        "PriceWithoutVat": 77.0,
        "PriceWithoutVatFormatted": "kr. 77.00",
        "PriceWithVat": 77.0,
        "PriceWithVatFormatted": "kr. 77.00",
        "VatFormatted": "kr. 0.00",
        "VATPercentFormatted": "0%",
        "CurrencyCode": "EUR"
    }
}

Best regards,
Mikkel

 
Nicolai Pedersen
Reply
This post has been marked as an answer

We have a pull request that will make it possible to finish the last piece of the order. It does not in our current implementation that you have available (for some reason)

Votes for this answer: 1
 
Mikkel Hammer
Mikkel Hammer
Reply

Hi again,

After doing some testing after upgrading DW to 9.13, it completes the order correctly now, so cheers for that!

But as I mentioned in the first post i made in this thread, there's still no "Order confirmation" email being sent that you've successfully completed your order.
Which we think is because that logic is related to the Cart module. Is that true, and if so, are there any plan to solve this any time soon?

this is the "new" log after the 9.13 update.

Best regards,
Mikkel

 
Mikkel Hammer
Mikkel Hammer
Reply

Hi DW,

Any thoughts on the last post regarding no email confirmation when completing an order through the API

Best regards,
Mikkel

 
Scott Forsyth Dynamicweb Employee
Scott Forsyth
Reply
This post has been marked as an answer

Hi Mikkel,

We just had this come up on one of our projects and someone found this post. The issue was that the orderService.Save() method needs to be explicitly called at the end. For example: orderService.Save(cartItem). The other property setters aren't enough by themselves. Once the Save() was added, the email was successfully sent.

I'm mentioning in case it helps you or someone else in the future.

Scott

Votes for this answer: 1
 
Nicolai Pedersen
Reply

You are talking about CreateOrder in CartController?

 
Martin Moen
Reply

Bump! We also need to know how to send order confirmations through `/dwapi/ecommerce/carts/{secret}/createorder` because it is not beeing sent at the moment.
We tried to add a notification through the order flows, but no email is sent.

 

You must be logged in to post in the forum