Fix go rerpotr card issues

This commit is contained in:
Alex Pliutau 2019-08-19 15:33:46 +02:00
parent 61f8ec387c
commit fb6ff6be3d
5 changed files with 17 additions and 9 deletions

View File

@ -13,7 +13,7 @@ func BillingExample() {
Description: "Plan with regular and trial payment definitions.", Description: "Plan with regular and trial payment definitions.",
Type: "fixed", Type: "fixed",
PaymentDefinitions: []pp.PaymentDefinition{ PaymentDefinitions: []pp.PaymentDefinition{
pp.PaymentDefinition{ {
Name: "Regular payment definition", Name: "Regular payment definition",
Type: "REGULAR", Type: "REGULAR",
Frequency: "MONTH", Frequency: "MONTH",
@ -24,14 +24,14 @@ func BillingExample() {
}, },
Cycles: "12", Cycles: "12",
ChargeModels: []pp.ChargeModel{ ChargeModels: []pp.ChargeModel{
pp.ChargeModel{ {
Type: "SHIPPING", Type: "SHIPPING",
Amount: pp.AmountPayout{ Amount: pp.AmountPayout{
Value: "10", Value: "10",
Currency: "USD", Currency: "USD",
}, },
}, },
pp.ChargeModel{ {
Type: "TAX", Type: "TAX",
Amount: pp.AmountPayout{ Amount: pp.AmountPayout{
Value: "12", Value: "12",
@ -40,7 +40,7 @@ func BillingExample() {
}, },
}, },
}, },
pp.PaymentDefinition{ {
Name: "Trial payment definition", Name: "Trial payment definition",
Type: "trial", Type: "trial",
Frequency: "week", Frequency: "week",
@ -51,14 +51,14 @@ func BillingExample() {
}, },
Cycles: "2", Cycles: "2",
ChargeModels: []pp.ChargeModel{ ChargeModels: []pp.ChargeModel{
pp.ChargeModel{ {
Type: "SHIPPING", Type: "SHIPPING",
Amount: pp.AmountPayout{ Amount: pp.AmountPayout{
Value: "1", Value: "1",
Currency: "USD", Currency: "USD",
}, },
}, },
pp.ChargeModel{ {
Type: "TAX", Type: "TAX",
Amount: pp.AmountPayout{ Amount: pp.AmountPayout{
Value: "2", Value: "2",

View File

@ -7,7 +7,7 @@ import (
const format = "2006-01-02T15:04:05Z" const format = "2006-01-02T15:04:05Z"
// Filter type
type Filter struct { type Filter struct {
fields []fmt.Stringer fields []fmt.Stringer
} }
@ -25,6 +25,7 @@ func (s *Filter) String() string {
return filter return filter
} }
// TextField type
type TextField struct { type TextField struct {
name string name string
Is string Is string
@ -34,21 +35,25 @@ func (d TextField) String() string {
return fmt.Sprintf("%s=%s", d.name, d.Is) return fmt.Sprintf("%s=%s", d.name, d.Is)
} }
// TimeField type
type TimeField struct { type TimeField struct {
name string name string
Is time.Time Is time.Time
} }
// String .
func (d TimeField) String() string { func (d TimeField) String() string {
return fmt.Sprintf("%s=%s", d.name, d.Is.UTC().Format(format)) return fmt.Sprintf("%s=%s", d.name, d.Is.UTC().Format(format))
} }
// AddTextField .
func (s *Filter) AddTextField(field string) *TextField { func (s *Filter) AddTextField(field string) *TextField {
f := &TextField{name: field} f := &TextField{name: field}
s.fields = append(s.fields, f) s.fields = append(s.fields, f)
return f return f
} }
// AddTimeField .
func (s *Filter) AddTimeField(field string) *TimeField { func (s *Filter) AddTimeField(field string) *TimeField {
f := &TimeField{name: field} f := &TimeField{name: field}
s.fields = append(s.fields, f) s.fields = append(s.fields, f)

View File

@ -19,7 +19,7 @@ func (c *Client) GetOrder(orderID string) (*Order, error) {
return order, nil 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 // Endpoint: POST /v2/checkout/orders
func (c *Client) CreateOrder(intent string, purchaseUnits []PurchaseUnitRequest, payer *CreateOrderPayer, appContext *ApplicationContext) (*Order, error) { func (c *Client) CreateOrder(intent string, purchaseUnits []PurchaseUnitRequest, payer *CreateOrderPayer, appContext *ApplicationContext) (*Order, error) {
type createOrderRequest struct { type createOrderRequest struct {
@ -32,6 +32,9 @@ func (c *Client) CreateOrder(intent string, purchaseUnits []PurchaseUnitRequest,
order := &Order{} 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}) 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 { if err = c.SendWithAuth(req, order); err != nil {
return order, err return order, err

View File

@ -361,6 +361,7 @@ type (
Breakdown *PurchaseUnitAmountBreakdown `json:"breakdown,omitempty"` Breakdown *PurchaseUnitAmountBreakdown `json:"breakdown,omitempty"`
} }
// PurchaseUnitAmountBreakdown struct
PurchaseUnitAmountBreakdown struct { PurchaseUnitAmountBreakdown struct {
ItemTotal *Money `json:"item_total,omitempty"` ItemTotal *Money `json:"item_total,omitempty"`
Shipping *Money `json:"shipping,omitempty"` Shipping *Money `json:"shipping,omitempty"`

View File

@ -19,7 +19,6 @@ func (c *Client) CreateWebProfile(wp WebProfile) (*WebProfile, error) {
return response, err return response, err
} }
if err = c.SendWithAuth(req, response); err != nil { if err = c.SendWithAuth(req, response); err != nil {
return response, err return response, err
} }