-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add recipient_wallet payout field (#165)
- Loading branch information
Showing
3 changed files
with
84 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,41 @@ func Example() { | |
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: "[email protected]", | ||
Amount: &paypal.AmountPayout{ | ||
Value: "9.87", | ||
Currency: "USD", | ||
}, | ||
Note: "Thanks for your patronage!", | ||
SenderItemID: "201403140001", | ||
}, | ||
}, | ||
} | ||
|
||
c.CreateSinglePayout(payout) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,10 @@ | |
package paypal | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// 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: "[email protected]", | ||
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) { | ||
c, _ := NewClient(testClientID, testSecret, APIBaseSandBox) | ||
c.GetAccessToken() | ||
|
@@ -285,13 +316,13 @@ func TestSubscriptionPlans(t *testing.T) { | |
TotalCycles: 0, | ||
}, | ||
}, | ||
PaymentPreferences: PaymentPreferences{ | ||
PaymentPreferences: &PaymentPreferences{ | ||
AutoBillOutstanding: false, | ||
SetupFee: nil, | ||
SetupFeeFailureAction: SetupFeeFailureActionCancel, | ||
PaymentFailureThreshold: 0, | ||
}, | ||
Taxes: Taxes{ | ||
Taxes: &Taxes{ | ||
Percentage: "19", | ||
Inclusive: false, | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters