forked from tooolbox/cybersource-rest-client-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
70 lines (61 loc) · 2.03 KB
/
main.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
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"log"
"github.com/go-openapi/strfmt"
"github.com/tooolbox/cybersource-rest-client-go/client"
"github.com/tooolbox/cybersource-rest-client-go/client/payments"
"github.com/tooolbox/cybersource-rest-client-go/config"
)
func main() {
cfg := config.Config{
AuthenticationType: config.AuthTypeHTTPSignature,
RunEnvironment: config.RunEnvSandbox,
MerchantId: "testrest",
MerchantKeyId: "08c94330-f618-42a3-b09d-e1e43be5efda",
MerchantSecretKey: "yBJxy6LjM2TmcPGu+GaJrHtkke25fPpUX+UY6/L/1tE=",
DebugLogging: true,
}
tr, err := cfg.Transport()
if err != nil {
log.Fatal(err)
}
c := client.New(tr, strfmt.Default)
req := payments.NewCreatePaymentParams().WithCreatePaymentRequest(payments.CreatePaymentBody{
ClientReferenceInformation: &payments.CreatePaymentParamsBodyClientReferenceInformation{
Code: "TC50171_3",
},
ProcessingInformation: &payments.CreatePaymentParamsBodyProcessingInformation{
CommerceIndicator: "internet",
},
PaymentInformation: &payments.CreatePaymentParamsBodyPaymentInformation{
Card: &payments.CreatePaymentParamsBodyPaymentInformationCard{
Number: "4111111111111111",
ExpirationMonth: "12",
ExpirationYear: "2031",
SecurityCode: "123",
},
},
OrderInformation: &payments.CreatePaymentParamsBodyOrderInformation{
AmountDetails: &payments.CreatePaymentParamsBodyOrderInformationAmountDetails{
TotalAmount: "13.37",
Currency: "USD",
},
BillTo: &payments.CreatePaymentParamsBodyOrderInformationBillTo{
FirstName: "John",
LastName: "Doe",
Address1: "1 Market St",
Address2: "Address 2",
Locality: "san francisco",
AdministrativeArea: "CA",
PostalCode: "94105",
Country: "US",
Email: "test@cybs.com",
PhoneNumber: "4158880000",
},
},
})
created, err := c.Payments.CreatePayment(req)
log.Printf("\n\n")
log.Printf("Created: %v\n", created)
log.Printf("Err: %v\n", err)
}