mirror of
https://github.com/plutov/paypal.git
synced 2025-02-02 15:10:36 +01:00
ActivatePlan definition
This commit is contained in:
parent
e033a62fe2
commit
77c97c8824
16
billing.go
16
billing.go
|
@ -1,7 +1,9 @@
|
||||||
package paypalsdk
|
package paypalsdk
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -35,3 +37,17 @@ func (c *Client) CreateBillingPlan(plan BillingPlan) (*CreateBillingResp, error)
|
||||||
|
|
||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Activates a billing plan
|
||||||
|
// By default, a new plan is not activated
|
||||||
|
// Endpoint: PATCH /v1/payments/billing-plans/
|
||||||
|
func (c *Client) ActivatePlan(planID string) error {
|
||||||
|
buf := bytes.NewBuffer([]byte("[{\"op\":\"replace\",\"path\":\"/\",\"value\":{\"state\":\"ACTIVE\"}}]"))
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user