This repository has been archived by the owner on Mar 25, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapplepay_test.go
98 lines (70 loc) · 22.5 KB
/
applepay_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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package themap
import (
"context"
"fmt"
"os"
"strings"
"testing"
"github.com/jarcoal/httpmock"
)
func TestApplePayBlock(t *testing.T) {
payload := []byte(strings.TrimSpace(`{"version":"EC_v1","data":"TGuomSxhVblEfMiJdbVe9JeN9K52znlr1Q3n2OsMwz4luSJAZbumg/ZFgBYyty2Dhst4GQinLffz11vO3VH/kdRShRlM74esNW3cz0hRC0Lfg0to2ddqfxzwun4euELpo0Q3CZeBbfC7Hq5WZtnApTUEvpOrshCaJIgj5n7LHcgu0BLpyeENgPuEHFamejzAyRW4vQ2gw4dg1MsHN0WxC5OQ7vLvRyIfXLifIwQb6zSOHGRh3izuAV8V5Gk0CbYq6x+DnKa9MRSm9efF8Uv1yZFyxI13BjD6yfFJtRa7LLOXnn6I+8OekKxDcNxxPmhRK6JW/5KXDrLa4/XgFGr+cxb/jG9F7uyEgXLNveQsQBoIBlcLEqQYSl7UD783XbUYmUwWhwLBh6196hllOJqVPM3J8Q060+5V4nLWnmtcWuGO3A==","signature":"MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwEAAKCAMIID4zCCA4igAwIBAgIITDBBSVGdVDYwCgYIKoZIzj0EAwIwejEuMCwGA1UEAwwlQXBwbGUgQXBwbGljYXRpb24gSW50ZWdyYXRpb24gQ0EgLSBHMzEmMCQGA1UECwwdQXBwbGUgQ2VydGlmaWNhdGlvbi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2xd8zg7kGf9F3wsIW2WT8ZyaYISb1T4en0bmcubCYkhYQaZDwmSHQAAMYIBjDCCAYgCAQEwgYYwejEuMCwGA1UEAwwlQXBwbGUgQXBwbGljYXRpb24gSW50ZWdyYXRpb24gQ0EgLSBHMzEmMCQGA1UECwwdQXBwbGUgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxEzARBgNVBAoMCkFwcGxlIEluYy4xCzAJBgNVBAYTAlVTAghMMEFJUZ1UNjANBglghkgBZQMEAgEFAKCBlTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0yMDA4MDQxNTQ0NTZaMCoGCSqGSIb3DQEJNDEdMBswDQYJYIZIAWUDBAIBBQChCgYIKoZIzj0EAwIwLwYJKoZIhvcNAQkEMSIEIKv98YQszshK+0jYAX8r6Mcshr0/7qC65LznVrkfdsEOMAoGCCqGSM49BAMCBEcwRQIgSodWMkWOKFY1tv0yLu25tQFwIuggrzVVc4ygg0lLMN8CIQDk9kJmD8BgMJmgHHpnh01JWHjpgvIVyLLuBGGUNj1jxAAAAAAAAA==","header":{"ephemeralPublicKey":"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEXZRD8nW8mbVLw+fAvjCWUjjUQHHqqi6Fd2VuDD9LZpsJX7aErN1B3HEm7GHPmr4q3oJ6f+yQOVRvtU/hxXMrcw==","publicKeyHash":"eRBhXMP8PITmbMLkhyVMtz4RMb6UmKEC8SpEr54AZdE=","transactionId":"b027c4fc440641a58e1496f23c6f9abfbdaac5292988a55861f77ad6216c34ad"}}`))
var base64 string = `eyJ2ZXJzaW9uIjoiRUNfdjEiLCJkYXRhIjoiVEd1b21TeGhWYmxFZk1pSmRiVmU5SmVOOUs1MnpubHIxUTNuMk9zTXd6NGx1U0pBWmJ1bWcvWkZnQll5dHkyRGhzdDRHUWluTGZmejExdk8zVkgva2RSU2hSbE03NGVzTlczY3owaFJDMExmZzB0bzJkZHFmeHp3dW40ZXV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FzenNoSyswallBWDhyNk1jc2hyMC83cUM2NUx6blZya2Zkc0VPTUFvR0NDcUdTTTQ5QkFNQ0JFY3dSUUlnU29kV01rV09LRlkxdHYweUx1MjV0UUZ3SXVnZ3J6VlZjNHlnZzBsTE1OOENJUURrOWtKbUQ4QmdNSm1nSEhwbmgwMUpXSGpwZ3ZJVnlMTHVCR0dVTmoxanhBQUFBQUFBQUE9PSIsImhlYWRlciI6eyJlcGhlbWVyYWxQdWJsaWNLZXkiOiJNRmt3RXdZSEtvWkl6ajBDQVFZSUtvWkl6ajBEQVFjRFFnQUVYWlJEOG5XOG1iVkx3K2ZBdmpDV1VqalVRSEhxcWk2RmQyVnVERDlMWnBzSlg3YUVyTjFCM0hFbTdHSFBtcjRxM29KNmYreVFPVlJ2dFUvaHhYTXJjdz09IiwicHVibGljS2V5SGFzaCI6ImVSQmhYTVA4UElUbWJNTGtoeVZNdHo0Uk1iNlVtS0VDOFNwRXI1NEFaZEU9IiwidHJhbnNhY3Rpb25JZCI6ImIwMjdjNGZjNDQwNjQxYTU4ZTE0OTZmMjNjNmY5YWJmYmRhYWM1MjkyOTg4YTU1ODYxZjc3YWQ2MjE2YzM0YWQifX0=`
reply := `{
"Success": true,
"OrderId": "ApplePayTestOrder-001",
"Amount": 300,
"ErrCode": ""
}`
httpmock.Activate()
defer httpmock.DeactivateAndReset()
httpmock.RegisterResponder("POST", APILink+"/Block",
httpmock.NewStringResponder(200, reply))
trans := New("SendtipsTestTerminal", "ApplePayTestOrder-001")
ctx := context.Background()
err := trans.ApplePayBlock(ctx, 300, payload)
if err != nil {
t.Error("Error occurred", err.Error())
}
if trans.ApplePayToken != base64 {
t.Error("Base64 encoding fail", trans.ApplePayToken)
}
}
func TestApplePay(t *testing.T) {
payload := []byte(strings.TrimSpace(` {"version":"EC_v1","data":"TGuomSxhVblEfMiJdbVe9JeN9K52znlr1Q3n2OsMwz4luSJAZbumg/ZFgBYyty2Dhst4GQinLffz11vO3VH/kdRShRlM74esNW3cz0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ZEU9IiwidHJhbnNhY3Rpb25JZCI6ImIwMjdjNGZjNDQwNjQxYTU4ZTE0OTZmMjNjNmY5YWJmYmRhYWM1MjkyOTg4YTU1ODYxZjc3YWQ2MjE2YzM0YWQifX0=`
reply := `{
"Success": true,
"OrderId": "ApplePayTestOrder-001",
"Amount": 300,
"ErrCode": ""
}`
httpmock.Activate()
defer httpmock.DeactivateAndReset()
httpmock.RegisterResponder("POST", APILink+"/Pay",
httpmock.NewStringResponder(200, reply))
trans := New("SendtipsTestTerminal", "ApplePayTestOrder-001")
ctx := context.Background()
err := trans.ApplePay(ctx, 300, payload)
if err != nil {
t.Error("Error occurred", err.Error())
}
if trans.ApplePayToken != base64 {
t.Error("Base64 encoding fail", trans.ApplePayToken)
}
}
func ExampleApplePay() {
payload := []byte(strings.TrimSpace(` {"version":"EC_v1","data":"TGuomSxhVblEfMiJdbVe9JeN9K52znlr1Q3n2OsMwz4luSJAZbumg/ZFgBYyty2Dhst4GQinLffz11vO3VH/kdRShRlM74esNW3cz0hRC0Lfg0to2ddqfxzwun4euELpo0Q3CZeBbfC7Hq5WZtnApTUEvpOrshCaJIgj5n7LHcgu0BLpyeENgPuEHFamejzAyRW4vQ2gw4dg1MsHN0WxC5OQ7vLvRyIfXLifIwQb6zSOHGRh3izuAV8V5Gk0CbYq6x+DnKa9MRSm9efF8Uv1yZFyxI13BjD6yfFJtRa7LLOXnn6I+8OekKxDcNxxPmhRK6JW/5KXDrLa4/XgFGr+cxb/jG9F7uyEgXLNveQsQBoIBlcLEqQYSl7UD783XbUYmUwWhwLBh6196hllOJqVPM3J8Q060+5V4nLWnmtcWuGO3A==","signature":"MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwEAAKCAMIID4zCCA4igAwIBAgIITDBBSVGdVDYwCgYIKoZIzj0EAwIwejEuMCwGA1UEAwwlQXBwbGUgQXBwbGljYXRpb24gSW50ZWdyYXRpb24gQ0EgLSBHMzEmMCQG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4mPebWZ+Y1UENj53pwv4CMDIt1UQhsKMFd2xd8zg7kGf9F3wsIW2WT8ZyaYISb1T4en0bmcubCYkhYQaZDwmSHQAAMYIBjDCCAYgCAQEwgYYwejEuMCwGA1UEAwwlQXBwbGUgQXBwbGljYXRpb24gSW50ZWdyYXRpb24gQ0EgLSBHMzEmMCQGA1UECwwdQXBwbGUgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxEzARBgNVBAoMCkFwcGxlIEluYy4xCzAJBgNVBAYTAlVTAghMMEFJUZ1UNjANBglghkgBZQMEAgEFAKCBlTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0yMDA4MDQxNTQ0NTZaMCoGCSqGSIb3DQEJNDEdMBswDQYJYIZIAWUDBAIBBQChCgYIKoZIzj0EAwIwLwYJKoZIhvcNAQkEMSIEIKv98YQszshK+0jYAX8r6Mcshr0/7qC65LznVrkfdsEOMAoGCCqGSM49BAMCBEcwRQIgSodWMkWOKFY1tv0yLu25tQFwIuggrzVVc4ygg0lLMN8CIQDk9kJmD8BgMJmgHHpnh01JWHjpgvIVyLLuBGGUNj1jxAAAAAAAAA==","header":{"ephemeralPublicKey":"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEXZRD8nW8mbVLw+fAvjCWUjjUQHHqqi6Fd2VuDD9LZpsJX7aErN1B3HEm7GHPmr4q3oJ6f+yQOVRvtU/hxXMrcw==","publicKeyHash":"eRBhXMP8PITmbMLkhyVMtz4RMb6UmKEC8SpEr54AZdE=","transactionId":"b027c4fc440641a58e1496f23c6f9abfbdaac5292988a55861f77ad6216c34ad"}}`))
// check themap hostname env is set, otherwise use default host
apihost, ok := os.LookupEnv("THEMAPAPIHOST")
if ok {
APILink = apihost
}
pay := New(os.Getenv("THEMAPTERMID"), "ApplePayTestOrder-001")
err := pay.ApplePay(context.TODO(), 300, payload)
if err != nil {
fmt.Errorf("Error occurred: %v", err)
}
fmt.Printf("%v", pay.Success)
// Output: false
}