diff --git a/constant.go b/constant.go index f5bcd31a..9dd0b556 100644 --- a/constant.go +++ b/constant.go @@ -7,7 +7,7 @@ const ( OK = "OK" DebugOff = 0 DebugOn = 1 - Version = "1.5.79" + Version = "1.5.80" ) type DebugSwitch int8 diff --git a/doc/apple.md b/doc/apple.md index a9c0bf60..85d6c0c9 100644 --- a/doc/apple.md +++ b/doc/apple.md @@ -44,15 +44,15 @@ if rsp.Receipt != nil { ```go import ( -"github.com/go-pay/gopay/apple" -"github.com/go-pay/gopay/pkg/xlog" + "github.com/go-pay/gopay/apple" + "github.com/go-pay/gopay/pkg/xlog" ) // decode signedPayload payload, err := apple.DecodeSignedPayload(signedPayload) if err != nil { -xlog.Error(err) -return + xlog.Error(err) + return } xlog.Debugf("payload.NotificationType: %s", payload.NotificationType) xlog.Debugf("payload.Subtype: %s", payload.Subtype) @@ -81,8 +81,8 @@ xlog.Color(xlog.RedBright).Info(string(bs1)) // decode renewalInfo renewalInfo, err := payload.DecodeRenewalInfo() if err != nil { -xlog.Error(err) -return + xlog.Error(err) + return } xlog.Debugf("data.renewalInfo: %+v", renewalInfo) bs, _ := json.Marshal(renewalInfo) @@ -106,8 +106,8 @@ xlog.Color(xlog.GreenBright).Info(string(bs)) // decode transactionInfo transactionInfo, err := payload.DecodeTransactionInfo() if err != nil { -xlog.Error(err) -return + xlog.Error(err) + return } xlog.Debugf("data.transactionInfo: %+v", transactionInfo) bs2, _ := json.Marshal(transactionInfo) diff --git a/doc/paypal.md b/doc/paypal.md index f0ea4b09..c9c67c5a 100644 --- a/doc/paypal.md +++ b/doc/paypal.md @@ -38,40 +38,40 @@ client.DebugSwitch = gopay.DebugOn ```go import ( -"github.com/go-pay/gopay" -"github.com/go-pay/gopay/paypal" -"github.com/go-pay/gopay/pkg/util" -"github.com/go-pay/gopay/pkg/xlog" + "github.com/go-pay/gopay" + "github.com/go-pay/gopay/paypal" + "github.com/go-pay/gopay/pkg/util" + "github.com/go-pay/gopay/pkg/xlog" ) // Create Orders example var pus []*paypal.PurchaseUnit var item = &paypal.PurchaseUnit{ -ReferenceId: util.GetRandomString(16), -Amount: &paypal.Amount{ -CurrencyCode: "USD", -Value: "8", -}, + ReferenceId: util.GetRandomString(16), + Amount: &paypal.Amount{ + CurrencyCode: "USD", + Value: "8", + }, } pus = append(pus, item) bm := make(gopay.BodyMap) bm.Set("intent", "CAPTURE"). -Set("purchase_units", pus). -SetBodyMap("application_context", func(b gopay.BodyMap) { -b.Set("brand_name", "gopay"). -Set("locale", "en-PT"). -Set("return_url", "https://example.com/returnUrl"). -Set("cancel_url", "https://example.com/cancelUrl") -}) + Set("purchase_units", pus). + SetBodyMap("application_context", func(b gopay.BodyMap) { + b.Set("brand_name", "gopay"). + Set("locale", "en-PT"). + Set("return_url", "https://example.com/returnUrl"). + Set("cancel_url", "https://example.com/cancelUrl") + }) ppRsp, err := client.CreateOrder(ctx, bm) if err != nil { -xlog.Error(err) -return + xlog.Error(err) + return } if ppRsp.Code != paypal.Success { -// do something -return + // do something + return } ``` @@ -79,8 +79,8 @@ return ```go import ( -"github.com/go-pay/gopay" -"github.com/go-pay/gopay/pkg/xlog" + "github.com/go-pay/gopay" + "github.com/go-pay/gopay/pkg/xlog" ) // Capture payment for order @@ -93,12 +93,12 @@ import ( //}) ppRsp, err := client.OrderCapture(ctx, "4X223967G91314611", nil) if err != nil { -xlog.Error(err) -return + xlog.Error(err) + return } if ppRsp.Code != paypal.Success { -// do something -return + // do something + return } ``` @@ -133,5 +133,5 @@ return * 取消批量支付中收款人无PayPal账号的项目(Cancel Unclaimed Payout Item):`client.CancelUnclaimedPayoutItem()` * 订阅 - * 创建订阅计划(Create plan):`client.CreateBillingPlan()` + * 创建订阅计划(Create plan):`client.CreateBillingPlan()` diff --git a/paypal/payout.go b/paypal/payout.go index 815f1a1a..485704ba 100644 --- a/paypal/payout.go +++ b/paypal/payout.go @@ -1,4 +1,3 @@ -// Package paypal /* @Author: wzy @Time: 2022/6/7 @@ -10,13 +9,14 @@ import ( "encoding/json" "errors" "fmt" - "github.com/go-pay/gopay" "net/http" + + "github.com/go-pay/gopay" ) // 创建批量支出(Create batch payout) -// Code = 0 is success -// 文档:https://developer.paypal.com/docs/api/payments.payouts-batch/v1/#payouts_post +// Code = 0 is success +// 文档:https://developer.paypal.com/docs/api/payments.payouts-batch/v1/#payouts_post func (c *Client) CreateBatchPayout(ctx context.Context, bm gopay.BodyMap) (ppRsp *CreateBatchPayoutRsp, err error) { if err = bm.CheckEmptyError("items", "sender_batch_header"); nil != err { return nil, err @@ -40,8 +40,8 @@ func (c *Client) CreateBatchPayout(ctx context.Context, bm gopay.BodyMap) (ppRsp } // 批量支出详情(Show payout batch details) -// Code = 0 is success -// 文档:https://developer.paypal.com/docs/api/payments.payouts-batch/v1/#payouts_get +// Code = 0 is success +// 文档:https://developer.paypal.com/docs/api/payments.payouts-batch/v1/#payouts_get func (c *Client) ShowPayoutBatchDetails(ctx context.Context, payoutBatchId string, bm gopay.BodyMap) (ppRsp *PayoutBatchDetailRsp, err error) { if payoutBatchId == gopay.NULL { return nil, errors.New("payout_batch_id is empty") @@ -66,8 +66,8 @@ func (c *Client) ShowPayoutBatchDetails(ctx context.Context, payoutBatchId strin } // 批量支出项目详情(Show Payout Item Details) -// Code = 0 is success -// 文档:https://developer.paypal.com/docs/api/payments.payouts-batch/v1/#payouts-item_get +// Code = 0 is success +// 文档:https://developer.paypal.com/docs/api/payments.payouts-batch/v1/#payouts-item_get func (c Client) ShowPayoutItemDetails(ctx context.Context, payoutItemId string) (ppRsp *PayoutItemDetailRsp, err error) { if payoutItemId == gopay.NULL { return nil, errors.New("payout_item_id is empty") @@ -92,8 +92,8 @@ func (c Client) ShowPayoutItemDetails(ctx context.Context, payoutItemId string) } // 取消批量支付中收款人无PayPal账号的项目(Cancel Unclaimed Payout Item) -// Code = 0 is success -// 文档:https://developer.paypal.com/docs/api/payments.payouts-batch/v1/#payouts-item_cancel +// Code = 0 is success +// 文档:https://developer.paypal.com/docs/api/payments.payouts-batch/v1/#payouts-item_cancel func (c Client) CancelUnclaimedPayoutItem(ctx context.Context, payoutItemId string) (ppRsp *CancelUnclaimedPayoutItemRsp, err error) { if payoutItemId == gopay.NULL { return nil, errors.New("payout_item_id is empty") diff --git a/paypal/payout_test.go b/paypal/payout_test.go index 73d8de74..0a59e0e2 100644 --- a/paypal/payout_test.go +++ b/paypal/payout_test.go @@ -1,4 +1,3 @@ -// Package paypal /* @Author: wzy @Time: 2022/6/8 @@ -7,9 +6,10 @@ package paypal import ( "encoding/json" + "testing" + "github.com/go-pay/gopay" "github.com/go-pay/gopay/pkg/xlog" - "testing" ) func TestCreateBatchPayout(t *testing.T) { diff --git a/release_note.txt b/release_note.txt index 69b90473..baf5d70c 100644 --- a/release_note.txt +++ b/release_note.txt @@ -1,3 +1,8 @@ +版本号:Release 1.5.80 +修改记录: + (1) PayPal:增加payout相关的v1接口 + (2) PayPal:部分接口返回参数补齐 + 版本号:Release 1.5.79 修改记录: (1) PayPal:增加订阅相关的v1接口