Skip to content

Commit

Permalink
v1.5.80
Browse files Browse the repository at this point in the history
  • Loading branch information
iGoogle-ink committed Jun 8, 2022
1 parent adeca4e commit 9d0b8ba
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 48 deletions.
2 changes: 1 addition & 1 deletion constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const (
OK = "OK"
DebugOff = 0
DebugOn = 1
Version = "1.5.79"
Version = "1.5.80"
)

type DebugSwitch int8
16 changes: 8 additions & 8 deletions doc/apple.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
54 changes: 27 additions & 27 deletions doc/paypal.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,49 +38,49 @@ 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
}
```

- Capture payment for order

```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
Expand All @@ -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
}
```

Expand Down Expand Up @@ -133,5 +133,5 @@ return
* 取消批量支付中收款人无PayPal账号的项目(Cancel Unclaimed Payout Item):`client.CancelUnclaimedPayoutItem()`

* <font color='#003087' size='4'>订阅</font>
* 创建订阅计划(Create plan):`client.CreateBillingPlan()`
* 创建订阅计划(Create plan):`client.CreateBillingPlan()`

20 changes: 10 additions & 10 deletions paypal/payout.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Package paypal
/*
@Author: wzy
@Time: 2022/6/7
Expand All @@ -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
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions paypal/payout_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Package paypal
/*
@Author: wzy
@Time: 2022/6/8
Expand All @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions release_note.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
版本号:Release 1.5.80
修改记录:
(1) PayPal:增加payout相关的v1接口
(2) PayPal:部分接口返回参数补齐

版本号:Release 1.5.79
修改记录:
(1) PayPal:增加订阅相关的v1接口
Expand Down

0 comments on commit 9d0b8ba

Please sign in to comment.