forked from xendit/xendit-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_test.go
56 lines (49 loc) · 1.32 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
package cardlesscredit_test
import (
"fmt"
"log"
"time"
"github.com/xendit/xendit-go/cardlesscredit"
"github.com/xendit/xendit-go"
)
func ExampleCreatePayment() {
xendit.Opt.SecretKey = "examplesecretkey"
createPaymentData := cardlesscredit.CreatePaymentParams{
CardlessCreditType: xendit.CardlessCreditTypeEnumKREDIVO,
ExternalID: "cardless-credit-" + time.Now().String(),
Amount: 200000,
PaymentType: xendit.PaymentTypeEnum3Months,
Items: []cardlesscredit.Item{
{
ID: "123",
Name: "Laptop Asus Ila",
Price: 200000,
Type: "Laptop",
URL: "http://asus-ila.com",
Quantity: 1,
},
},
CustomerDetails: cardlesscredit.CustomerDetails{
FirstName: "Michael",
LastName: "Belajarrock",
Email: "michaelbelajarrock@mail.com",
Phone: "08123123123",
},
ShippingAddress: cardlesscredit.ShippingAddress{
FirstName: "Michael",
LastName: "Belajarjazz",
Address: "Jalan Teknologi No. 12",
City: "Jakarta",
PostalCode: "40000",
Phone: "08123123123",
CountryCode: "IDN",
},
RedirectURL: "https://google.com",
CallbackURL: "https://google.com",
}
resp, err := cardlesscredit.CreatePayment(&createPaymentData)
if err != nil {
log.Fatal(err)
}
fmt.Printf("created payment: %+v\n", resp)
}