2019-08-21 15:50:20 +02:00
|
|
|
package paypal_test
|
2016-03-07 07:00:22 +01:00
|
|
|
|
2021-01-03 10:28:52 +01:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/plutov/paypal/v4"
|
|
|
|
)
|
2016-03-07 07:00:22 +01:00
|
|
|
|
2016-03-07 07:12:38 +01:00
|
|
|
func Example() {
|
2016-03-07 07:00:22 +01:00
|
|
|
// Initialize client
|
2019-08-21 15:50:20 +02:00
|
|
|
c, err := paypal.NewClient("clientID", "secretID", paypal.APIBaseSandBox)
|
2016-03-07 07:00:22 +01:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2016-12-22 06:12:47 +01:00
|
|
|
// Retrieve access token
|
2021-01-03 10:28:52 +01:00
|
|
|
_, err = c.GetAccessToken(context.Background())
|
2016-03-07 07:00:22 +01:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
2020-08-14 01:20:35 +02:00
|
|
|
|
2021-01-20 09:28:04 +01:00
|
|
|
func ExampleClient_CreatePayout_Venmo() {
|
2020-08-14 01:20:35 +02:00
|
|
|
// Initialize client
|
|
|
|
c, err := paypal.NewClient("clientID", "secretID", paypal.APIBaseSandBox)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Retrieve access token
|
2021-01-03 10:28:52 +01:00
|
|
|
_, err = c.GetAccessToken(context.Background())
|
2020-08-14 01:20:35 +02:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-11-17 10:59:42 +01:00
|
|
|
|
2020-08-14 01:20:35 +02:00
|
|
|
// 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{
|
|
|
|
{
|
2020-11-17 10:59:42 +01:00
|
|
|
RecipientType: "EMAIL",
|
2020-08-14 01:20:35 +02:00
|
|
|
RecipientWallet: paypal.VenmoRecipientWallet,
|
2020-11-17 10:59:42 +01:00
|
|
|
Receiver: "receiver@example.com",
|
2020-08-14 01:20:35 +02:00
|
|
|
Amount: &paypal.AmountPayout{
|
|
|
|
Value: "9.87",
|
|
|
|
Currency: "USD",
|
|
|
|
},
|
|
|
|
Note: "Thanks for your patronage!",
|
|
|
|
SenderItemID: "201403140001",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-01-20 09:28:04 +01:00
|
|
|
c.CreatePayout(context.Background(), payout)
|
2020-11-17 10:59:42 +01:00
|
|
|
}
|