forked from go-packages/paypal
add recipient_wallet payout field (#165)
This commit is contained in:
parent
a0d03ecb0d
commit
18b47a0652
|
@ -15,3 +15,41 @@ func Example() {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ExampleClient_CreateSinglePayout_Venmo() {
|
||||||
|
// Initialize client
|
||||||
|
c, err := paypal.NewClient("clientID", "secretID", paypal.APIBaseSandBox)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve access token
|
||||||
|
_, err = c.GetAccessToken()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set payout item with Venmo wallet
|
||||||
|
payout := paypal.Payout{
|
||||||
|
SenderBatchHeader: &paypal.SenderBatchHeader{
|
||||||
|
SenderBatchID: "Payouts_2018_100007",
|
||||||
|
EmailSubject: "You have a payout!",
|
||||||
|
EmailMessage: "You have received a payout! Thanks for using our service!",
|
||||||
|
},
|
||||||
|
Items: []paypal.PayoutItem{
|
||||||
|
{
|
||||||
|
RecipientType: "EMAIL",
|
||||||
|
RecipientWallet: paypal.VenmoRecipientWallet,
|
||||||
|
Receiver: "receiver@example.com",
|
||||||
|
Amount: &paypal.AmountPayout{
|
||||||
|
Value: "9.87",
|
||||||
|
Currency: "USD",
|
||||||
|
},
|
||||||
|
Note: "Thanks for your patronage!",
|
||||||
|
SenderItemID: "201403140001",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
c.CreateSinglePayout(payout)
|
||||||
|
}
|
|
@ -3,9 +3,10 @@
|
||||||
package paypal
|
package paypal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
// All test values are defined here
|
// All test values are defined here
|
||||||
|
@ -38,6 +39,36 @@ func TestGetUserInfo(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCreateVenmoPayout(t *testing.T) {
|
||||||
|
c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)
|
||||||
|
c.GetAccessToken()
|
||||||
|
|
||||||
|
payout := Payout{
|
||||||
|
SenderBatchHeader: &SenderBatchHeader{
|
||||||
|
SenderBatchID: "Payouts_2018_100007",
|
||||||
|
EmailSubject: "You have a payout!",
|
||||||
|
EmailMessage: "You have received a payout! Thanks for using our service!",
|
||||||
|
},
|
||||||
|
Items: []PayoutItem{
|
||||||
|
{
|
||||||
|
RecipientType: "EMAIL",
|
||||||
|
RecipientWallet: VenmoRecipientWallet,
|
||||||
|
Receiver: "receiver@example.com",
|
||||||
|
Amount: &AmountPayout{
|
||||||
|
Value: "9.87",
|
||||||
|
Currency: "USD",
|
||||||
|
},
|
||||||
|
Note: "Thanks for your patronage!",
|
||||||
|
SenderItemID: "201403140001",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := c.CreateSinglePayout(payout)
|
||||||
|
assert.NoError(t, err, "should accept venmo wallet")
|
||||||
|
assert.Greater(t, len(res.Items), 0)
|
||||||
|
}
|
||||||
|
|
||||||
func TestCreateSinglePayout(t *testing.T) {
|
func TestCreateSinglePayout(t *testing.T) {
|
||||||
c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)
|
c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)
|
||||||
c.GetAccessToken()
|
c.GetAccessToken()
|
||||||
|
@ -285,13 +316,13 @@ func TestSubscriptionPlans(t *testing.T) {
|
||||||
TotalCycles: 0,
|
TotalCycles: 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
PaymentPreferences: PaymentPreferences{
|
PaymentPreferences: &PaymentPreferences{
|
||||||
AutoBillOutstanding: false,
|
AutoBillOutstanding: false,
|
||||||
SetupFee: nil,
|
SetupFee: nil,
|
||||||
SetupFeeFailureAction: SetupFeeFailureActionCancel,
|
SetupFeeFailureAction: SetupFeeFailureActionCancel,
|
||||||
PaymentFailureThreshold: 0,
|
PaymentFailureThreshold: 0,
|
||||||
},
|
},
|
||||||
Taxes: Taxes{
|
Taxes: &Taxes{
|
||||||
Percentage: "19",
|
Percentage: "19",
|
||||||
Inclusive: false,
|
Inclusive: false,
|
||||||
},
|
},
|
||||||
|
|
7
types.go
7
types.go
|
@ -115,6 +115,12 @@ const (
|
||||||
FeatureUpdateCustomerDispute string = "UPDATE_CUSTOMER_DISPUTES"
|
FeatureUpdateCustomerDispute string = "UPDATE_CUSTOMER_DISPUTES"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// https://developer.paypal.com/docs/api/payments.payouts-batch/v1/?mark=recipient_wallet#definition-recipient_wallet
|
||||||
|
const (
|
||||||
|
PaypalRecipientWallet string = "PAYPAL"
|
||||||
|
VenmoRecipientWallet string = "VENMO"
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
LinkRelSelf string = "self"
|
LinkRelSelf string = "self"
|
||||||
LinkRelActionURL string = "action_url"
|
LinkRelActionURL string = "action_url"
|
||||||
|
@ -736,6 +742,7 @@ type (
|
||||||
// PayoutItem struct
|
// PayoutItem struct
|
||||||
PayoutItem struct {
|
PayoutItem struct {
|
||||||
RecipientType string `json:"recipient_type"`
|
RecipientType string `json:"recipient_type"`
|
||||||
|
RecipientWallet string `json:"recipient_wallet"`
|
||||||
Receiver string `json:"receiver"`
|
Receiver string `json:"receiver"`
|
||||||
Amount *AmountPayout `json:"amount"`
|
Amount *AmountPayout `json:"amount"`
|
||||||
Note string `json:"note,omitempty"`
|
Note string `json:"note,omitempty"`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user