-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_test.go
64 lines (56 loc) · 1.35 KB
/
client_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
60
61
62
63
64
package sveawebpay
import (
"os"
"testing"
"github.com/joho/godotenv"
)
//TestClientPreparePayment tests the `Client` method `PreparePayment`
func TestClientPreparePayment(t *testing.T) {
//Load .env file
if err := godotenv.Load(); err != nil {
t.Errorf("failed to load .env: %v", err.Error())
}
//Create client
c := NewClient(os.Getenv("MERCHANT_ID_TEST"), os.Getenv("SECRET_TEST"))
c.Test = true
//Create order
order := Order{
PaymentMethod: PaymentMethodCard,
Currency: "SEK",
Amount: 100,
Vat: 25,
CustomerRefNo: "1337",
Lang: LangEnglish,
IPAddress: "127.0.0.1",
SSN: "999999-9999",
Customer: Customer{
LegalName: "Test Testsson",
SSN: "999999-9999",
AddressLine1: "Testgatan 1",
PostalCode: "111 11",
City: "Testdalen",
},
}
//Add order row
order.AddRow(
OrderRow{
Name: "Test",
Description: "Some test",
Amount: 100,
Vat: 25,
Quantity: 1,
ArticleNumber: "1",
Unit: "st",
IPAddress: "127.0.0.1",
},
)
//Prepare the payment
preparedPayment, err := c.PreparePayment(order)
if err != nil && ErrToCode(err) < 0 {
t.Error(err)
return
}
t.Logf("PreparedPayment: %v", preparedPayment)
t.Logf("URL: %v", preparedPayment.URL())
t.Logf("Statuscode: %v", ErrToCode(err))
}