forked from plutov/paypal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_test.go
59 lines (51 loc) · 1.25 KB
/
example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package paypal_test
import (
"context"
"github.com/plutov/paypal/v4"
)
func Example() {
// Initialize client
c, err := paypal.NewClient("clientID", "secretID", paypal.APIBaseSandBox)
if err != nil {
panic(err)
}
// Retrieve access token
_, err = c.GetAccessToken(context.Background())
if err != nil {
panic(err)
}
}
func ExampleClient_CreatePayout_Venmo() {
// Initialize client
c, err := paypal.NewClient("clientID", "secretID", paypal.APIBaseSandBox)
if err != nil {
panic(err)
}
// Retrieve access token
_, err = c.GetAccessToken(context.Background())
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.CreatePayout(context.Background(), payout)
}