From 98cae624706b501d153aad24d625374b7986e1a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E8=88=AA?= Date: Sat, 28 Nov 2020 16:56:24 +0800 Subject: [PATCH] fix param error while query transactions of subscriptions (#186) url needs start_time and end_time, and both fields remove timezome --- subscription.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/subscription.go b/subscription.go index b33f3d0..711b9ed 100644 --- a/subscription.go +++ b/subscription.go @@ -175,16 +175,14 @@ func (c *Client) SuspendSubscription(subscriptionId, reason string) error { // Doc: https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_transactions // Endpoint: GET /v1/billing/subscriptions/{id}/transactions func (c *Client) GetSubscriptionTransactions(requestParams SubscriptionTransactionsParams) (*SubscriptionTransactionsResponse, error) { - req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/v1/billing/subscriptions/%s/transactions", c.APIBase, requestParams.SubscriptionId), nil) + startTime := requestParams.StartTime.Format("2006-01-02T15:04:05Z") + endTime := requestParams.EndTime.Format("2006-01-02T15:04:05Z") + req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/v1/billing/subscriptions/%s/transactions?start_time=%s&end_time=%s", c.APIBase, requestParams.SubscriptionId, startTime, endTime), nil) response := &SubscriptionTransactionsResponse{} if err != nil { return response, err } - q := req.URL.Query() - q.Add("start_time", requestParams.StartTime.Format(time.RFC3339Nano)) - q.Add("end_time", requestParams.EndTime.Format(time.RFC3339Nano)) - err = c.SendWithAuth(req, response) return response, err }