Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mark order shipping address optional #307

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mollie/orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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.
Expand Down
16 changes: 16 additions & 0 deletions mollie/orders_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
111 changes: 111 additions & 0 deletions testdata/orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": "[email protected]"
},
"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": {
Expand Down
Loading