From fb6ff6be3d2bdacfd21b00a75159848b54a84bd2 Mon Sep 17 00:00:00 2001 From: Alex Pliutau Date: Mon, 19 Aug 2019 15:33:46 +0200 Subject: [PATCH] Fix go rerpotr card issues --- billing_test.go | 12 ++++++------ filter.go | 7 ++++++- order.go | 5 ++++- types.go | 1 + webprofile.go | 1 - 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/billing_test.go b/billing_test.go index e7844ea..bf3373f 100644 --- a/billing_test.go +++ b/billing_test.go @@ -13,7 +13,7 @@ func BillingExample() { Description: "Plan with regular and trial payment definitions.", Type: "fixed", PaymentDefinitions: []pp.PaymentDefinition{ - pp.PaymentDefinition{ + { Name: "Regular payment definition", Type: "REGULAR", Frequency: "MONTH", @@ -24,14 +24,14 @@ func BillingExample() { }, Cycles: "12", ChargeModels: []pp.ChargeModel{ - pp.ChargeModel{ + { Type: "SHIPPING", Amount: pp.AmountPayout{ Value: "10", Currency: "USD", }, }, - pp.ChargeModel{ + { Type: "TAX", Amount: pp.AmountPayout{ Value: "12", @@ -40,7 +40,7 @@ func BillingExample() { }, }, }, - pp.PaymentDefinition{ + { Name: "Trial payment definition", Type: "trial", Frequency: "week", @@ -51,14 +51,14 @@ func BillingExample() { }, Cycles: "2", ChargeModels: []pp.ChargeModel{ - pp.ChargeModel{ + { Type: "SHIPPING", Amount: pp.AmountPayout{ Value: "1", Currency: "USD", }, }, - pp.ChargeModel{ + { Type: "TAX", Amount: pp.AmountPayout{ Value: "2", diff --git a/filter.go b/filter.go index d067c65..33aabd2 100644 --- a/filter.go +++ b/filter.go @@ -7,7 +7,7 @@ import ( const format = "2006-01-02T15:04:05Z" - +// Filter type type Filter struct { fields []fmt.Stringer } @@ -25,6 +25,7 @@ func (s *Filter) String() string { return filter } +// TextField type type TextField struct { name string Is string @@ -34,21 +35,25 @@ func (d TextField) String() string { return fmt.Sprintf("%s=%s", d.name, d.Is) } +// TimeField type type TimeField struct { name string Is time.Time } +// String . func (d TimeField) String() string { return fmt.Sprintf("%s=%s", d.name, d.Is.UTC().Format(format)) } +// AddTextField . func (s *Filter) AddTextField(field string) *TextField { f := &TextField{name: field} s.fields = append(s.fields, f) return f } +// AddTimeField . func (s *Filter) AddTimeField(field string) *TimeField { f := &TimeField{name: field} s.fields = append(s.fields, f) diff --git a/order.go b/order.go index d0ddfbe..e2d46d6 100644 --- a/order.go +++ b/order.go @@ -19,7 +19,7 @@ func (c *Client) GetOrder(orderID string) (*Order, error) { return order, nil } -// Create Order - Use this call to create an order +// CreateOrder - Use this call to create an order // Endpoint: POST /v2/checkout/orders func (c *Client) CreateOrder(intent string, purchaseUnits []PurchaseUnitRequest, payer *CreateOrderPayer, appContext *ApplicationContext) (*Order, error) { type createOrderRequest struct { @@ -32,6 +32,9 @@ func (c *Client) CreateOrder(intent string, purchaseUnits []PurchaseUnitRequest, order := &Order{} req, err := c.NewRequest("POST", fmt.Sprintf("%s%s", c.APIBase, "/v2/checkout/orders"), createOrderRequest{Intent: intent, PurchaseUnits: purchaseUnits, Payer: payer, ApplicationContext: appContext}) + if err != nil { + return order, err + } if err = c.SendWithAuth(req, order); err != nil { return order, err diff --git a/types.go b/types.go index 0d9d2d0..26ec14a 100644 --- a/types.go +++ b/types.go @@ -361,6 +361,7 @@ type ( Breakdown *PurchaseUnitAmountBreakdown `json:"breakdown,omitempty"` } + // PurchaseUnitAmountBreakdown struct PurchaseUnitAmountBreakdown struct { ItemTotal *Money `json:"item_total,omitempty"` Shipping *Money `json:"shipping,omitempty"` diff --git a/webprofile.go b/webprofile.go index 15161f5..55af2fb 100644 --- a/webprofile.go +++ b/webprofile.go @@ -19,7 +19,6 @@ func (c *Client) CreateWebProfile(wp WebProfile) (*WebProfile, error) { return response, err } - if err = c.SendWithAuth(req, response); err != nil { return response, err }