Add Revise Subscription (#187)

* Add function revise subscription

* Update README add revise subscription
This commit is contained in:
Dimas Ragil T 2020-12-16 16:40:27 +07:00 committed by GitHub
parent 98cae62470
commit 0f9d1cca16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -70,6 +70,7 @@
* GET /v1/billing/subscriptions/**ID**
* POST /v1/billing/subscriptions/**ID**/activate
* POST /v1/billing/subscriptions/**ID**/cancel
* POST /v1/billing/subscriptions/**ID**/revise
* POST /v1/billing/subscriptions/**ID**/capture
* POST /v1/billing/subscriptions/**ID**/suspend
* GET /v1/billing/subscriptions/**ID**/transactions

View File

@ -10,6 +10,7 @@ type (
SubscriptionBase struct {
PlanID string `json:"plan_id"`
StartTime *JSONTime `json:"start_time,omitempty"`
EffectiveTime *JSONTime `json:"effective_time,omitempty"`
Quantity string `json:"quantity,omitempty"`
ShippingAmount *Money `json:"shipping_amount,omitempty"`
Subscriber *Subscriber `json:"subscriber,omitempty"`
@ -186,3 +187,19 @@ func (c *Client) GetSubscriptionTransactions(requestParams SubscriptionTransacti
err = c.SendWithAuth(req, response)
return response, err
}
// Revise plan or quantity of subscription
// Doc: https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_revise
// Endpoint: POST /v1/billing/subscriptions/{id}/revise
func (c *Client) ReviseSubscription(subscriptionId string, reviseSubscription SubscriptionBase) (*SubscriptionDetailResp, error) {
req, err := c.NewRequest(http.MethodPost, fmt.Sprintf("%s/v1/billing/subscriptions/%s/revise", c.APIBase, subscriptionId), reviseSubscription)
response := &SubscriptionDetailResp{}
if err != nil {
return response, err
}
req.Header.Add("Content-Type", "application/json")
err = c.SendWithAuth(req, response)
return response, err
}