OpenBazaar / openbazaar-go

OpenBazaar 2.0 Server Daemon in Go
MIT License
991 stars 284 forks source link

Add /ob/checkoutbreakdown Endpoint #2090

Closed hoffmabc closed 4 years ago

hoffmabc commented 4 years ago

This enables checkout breakdown call to get an itemized breakdown of an order.

The format to make the call is as follows:

{
    "shipTo": "Elwood Blues",
    "address": "1060 W Addison",
    "city": "Chicago",
    "state": "Illinois",
    "countryCode": "UNITED_STATES",
    "postalCode": "60613",
    "addressNotes": "",
    "items": [
        {
            "listingHash": "QmTjLBaqrunGmvCD9A3joXLXGudAwxnQvMtvcggQ5rahxN",
            "bigQuantity": "1",
            "options": [
                {
                    "name": "Sizes",
                    "value": "Small"
                },
                {
                    "name": "Color",
                    "value": "Red"
                }
            ],
            "shipping": {
                "name": "Worldwide",
                "service": "Standard"
            },
            "memo": "thanks!",
            "coupons": []
        }
    ],
    "moderator": "QmcdkKM2fWCKzTZdpjEY6abzRbDhRRJvNmqwNKVyiDtGky",
    "paymentCoin": "LTC"
}

This call returns:

{
    "basePrice": "45433155",
    "coupon": "4543316",
    "optionSurcharge": "9086631",
    "priceCurrency": {
        "code": "USD",
        "divisibility": 2
    },
    "quantity": "43",
    "shippingPrice": "290772224",
    "tax": "0",
    "totalPrice": "2439760434"
}
hoffmabc commented 4 years ago

@drwasho this should be ready to test out. @cpacia: once @drwasho passes this then you can review and we can merge it in.

coveralls commented 4 years ago

Coverage Status

Coverage decreased (-0.3%) to 40.669% when pulling c74057ae34f87044178046002c5f1bcf99cfb223 on brian.checkoutBreakdown into 9e17a661e2afc25f7c630a79280bc99c51b77153 on master.