From b5d8cdd3e13aa4dbabfe1f2954a1e289797eaf8f Mon Sep 17 00:00:00 2001 From: imikod Date: Sun, 25 Mar 2018 16:44:37 +0300 Subject: [PATCH] add DeletePlan() --- billing.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/billing.go b/billing.go index 5653411..292d56c 100644 --- a/billing.go +++ b/billing.go @@ -73,6 +73,19 @@ func (c *Client) CreateBillingAgreement(a BillingAgreement) (*CreateAgreementRes return response, err } +// DeletePlan deletes a billing plan +// Endpoint: PATCH /v1/payments/billing-plans/ +func (c *Client) DeletePlan(planID string) error { + buf := bytes.NewBuffer([]byte("[{\"op\":\"replace\",\"path\":\"/\",\"value\":{\"state\":\"DELETED\"}}]")) + req, err := http.NewRequest("PATCH", fmt.Sprintf("%s%s", c.APIBase, "/v1/payments/billing-plans/"+planID), buf) + if err != nil { + return err + } + req.SetBasicAuth(c.ClientID, c.Secret) + req.Header.Set("Authorization", "Bearer "+c.Token.Token) + return c.SendWithAuth(req, nil) +} + // ExecuteApprovedAgreement - Use this call to execute (complete) a PayPal agreement that has been approved by the payer. // Endpoint: POST /v1/payments/billing-agreements/token/agreement-execute func (c *Client) ExecuteApprovedAgreement(token string) (*ExecuteAgreementResponse, error) {