1 Star 0 Fork 0

李.斯科特 / gopay

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
subscriptions.go 1000 Bytes
一键复制 编辑 原始数据 按行查看 历史
LeeScott 提交于 2023-03-14 16:59 . github-gitee
package paypal
import (
"context"
"encoding/json"
"fmt"
"net/http"
"gitee.com/LeeScott/gopay"
)
// 创建订阅计划(CreateBillingPlan)
// Code = 0 is success
// 文档:https://developer.paypal.com/docs/api/subscriptions/v1/#plans_create
func (c *Client) CreateBillingPlan(ctx context.Context, bm gopay.BodyMap) (ppRsp *CreateBillingRsp, err error) {
if err = bm.CheckEmptyError("product_id", "billing_cycles"); err != nil {
return nil, err
}
res, bs, err := c.doPayPalPost(ctx, bm, subscriptionCreate)
if err != nil {
return nil, err
}
ppRsp = &CreateBillingRsp{Code: Success}
ppRsp.Response = new(BillingDetail)
if err = json.Unmarshal(bs, ppRsp.Response); err != nil {
return nil, fmt.Errorf("[%w]: %v, bytes: %s", gopay.UnmarshalErr, err, string(bs))
}
if res.StatusCode != http.StatusCreated {
ppRsp.Code = res.StatusCode
ppRsp.Error = string(bs)
ppRsp.ErrorResponse = new(ErrorResponse)
_ = json.Unmarshal(bs, ppRsp.ErrorResponse)
}
return ppRsp, nil
}
Go
1
https://gitee.com/LeeScott/gopay.git
git@gitee.com:LeeScott/gopay.git
LeeScott
gopay
gopay
v1.5.93

搜索帮助