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.",
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",

View File

@ -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)

View File

@ -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

View File

@ -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"`

View File

@ -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
}