add DeletePlan()

This commit is contained in:
imikod 2018-03-25 16:44:37 +03:00 committed by GitHub
parent b0bf27bc89
commit b5d8cdd3e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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