fix param error while query transactions of subscriptions (#186)

url needs start_time and end_time, and both fields remove timezome
This commit is contained in:
方航 2020-11-28 16:56:24 +08:00 committed by GitHub
parent ef386ff32f
commit 98cae62470
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -175,16 +175,14 @@ func (c *Client) SuspendSubscription(subscriptionId, reason string) error {
// Doc: https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_transactions // Doc: https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_transactions
// Endpoint: GET /v1/billing/subscriptions/{id}/transactions // Endpoint: GET /v1/billing/subscriptions/{id}/transactions
func (c *Client) GetSubscriptionTransactions(requestParams SubscriptionTransactionsParams) (*SubscriptionTransactionsResponse, error) { 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{} response := &SubscriptionTransactionsResponse{}
if err != nil { if err != nil {
return response, err 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) err = c.SendWithAuth(req, response)
return response, err return response, err
} }