diff --git a/mollie/orders.go b/mollie/orders.go index 5cc7979a..5ca5b842 100644 --- a/mollie/orders.go +++ b/mollie/orders.go @@ -26,7 +26,7 @@ type Order struct { Method PaymentMethod `json:"method,omitempty"` Status OrderStatus `json:"status,omitempty"` Locale Locale `json:"locale,omitempty"` - ShippingAddress OrderAddress `json:"shippingAddress,omitempty"` + ShippingAddress *OrderAddress `json:"shippingAddress,omitempty"` Links OrderLinks `json:"_links,omitempty"` Amount *Amount `json:"amount,omitempty"` AmountCaptured *Amount `json:"amountCaptured,omitempty"` @@ -257,7 +257,7 @@ type OrderListRefundOptions struct { Embed EmbedValue `url:"embed,omitempty"` } -// OrdersService instance operates over refund resources. +// OrdersService instance operates over order resources. type OrdersService service // Get retrieve a single order by its ID. diff --git a/mollie/orders_test.go b/mollie/orders_test.go index 96044487..0326e2e2 100644 --- a/mollie/orders_test.go +++ b/mollie/orders_test.go @@ -53,6 +53,22 @@ func (os *ordersServiceSuite) TestOrdersService_Get() { _, _ = w.Write([]byte(testdata.GetOrderResponse)) }, }, + { + "get orders without shipping address works as expected.", + args{ + context.Background(), + "ord_kEn1PlbGa", + &OrderOptions{ + ProfileID: "pfl_1236h213bv1", + }, + }, + false, + nil, + noPre, + func(w http.ResponseWriter, r *http.Request) { + _, _ = w.Write([]byte(testdata.GetOrderWithoutShippingResponse)) + }, + }, { "get orders, an error is returned from the server", args{ diff --git a/testdata/orders.go b/testdata/orders.go index 932a67ea..4381ef78 100644 --- a/testdata/orders.go +++ b/testdata/orders.go @@ -287,6 +287,117 @@ const GetOrderResponse = `{ } }` +const GetOrderWithoutShippingResponse = `{ + "resource": "order", + "id": "ord_kEn1PlbGa", + "profileId": "pfl_URR55HPMGx", + "method": "ideal", + "amount": { + "value": "1027.99", + "currency": "EUR" + }, + "status": "created", + "isCancelable": true, + "metadata": null, + "createdAt": "2018-08-02T09:29:56+00:00", + "expiresAt": "2018-08-30T09:29:56+00:00", + "mode": "live", + "locale": "nl_NL", + "billingAddress": { + "organizationName": "Mollie B.V.", + "streetAndNumber": "Keizersgracht 313", + "postalCode": "1016 EE", + "city": "Amsterdam", + "country": "nl", + "givenName": "Luke", + "familyName": "Skywalker", + "email": "luke@skywalker.com" + }, + "shopperCountryMustMatchBillingCountry": false, + "consumerDateOfBirth": "1993-10-21", + "orderNumber": "18475", + "redirectUrl": "https://example.org/redirect", + "lines": [ + { + "resource": "orderline", + "id": "odl_dgtxyl", + "orderId": "ord_pbjz8x", + "name": "LEGO Digital 42083 Bugatti Chiron", + "sku": "5702016116977", + "type": "digital", + "status": "created", + "metadata": null, + "isCancelable": false, + "quantity": 2, + "quantityShipped": 0, + "amountShipped": { + "value": "0.00", + "currency": "EUR" + }, + "quantityRefunded": 0, + "amountRefunded": { + "value": "0.00", + "currency": "EUR" + }, + "quantityCanceled": 0, + "amountCanceled": { + "value": "0.00", + "currency": "EUR" + }, + "shippableQuantity": 0, + "refundableQuantity": 0, + "cancelableQuantity": 0, + "unitPrice": { + "value": "399.00", + "currency": "EUR" + }, + "vatRate": "21.00", + "vatAmount": { + "value": "121.14", + "currency": "EUR" + }, + "discountAmount": { + "value": "100.00", + "currency": "EUR" + }, + "totalAmount": { + "value": "698.00", + "currency": "EUR" + }, + "createdAt": "2018-08-02T09:29:56+00:00", + "_links": { + "productUrl": { + "href": "https://shop.lego.com/nl-NL/Bugatti-Chiron-42083", + "type": "text/html" + }, + "imageUrl": { + "href": "https://sh-s7-live-s.legocdn.com/is/image//LEGO/42083_alt1?$main$", + "type": "text/html" + } + } + } + ], + "_embedded": {}, + "_links": { + "self": { + "href": "https://api.mollie.com/v2/orders/ord_pbjz8x", + "type": "application/hal+json" + }, + "checkout": { + "href": "https://www.mollie.com/payscreen/order/checkout/pbjz8x", + "type": "text/html" + }, + "dashboard": { + "href": "https://www.mollie.com/dashboard/org_123456789/orders/ord_pbjz8x", + "type": "text/html" + }, + "documentation": { + "href": "https://docs.mollie.com/reference/v2/orders-api/get-order", + "type": "text/html" + } + } + }` + // CreateOrderRequest example of create order request const CreateOrderRequest = `{ "amount": {