1
|
|
|
package mollie |
2
|
|
|
|
3
|
|
|
import ( |
4
|
|
|
"context" |
5
|
|
|
"encoding/json" |
6
|
|
|
) |
7
|
|
|
|
8
|
|
|
// Wallet describes the wallet types that Mollie supports. |
9
|
|
|
type Wallet string |
10
|
|
|
|
11
|
|
|
// Available wallet types. |
12
|
|
|
const ( |
13
|
|
|
ApplePayWallet Wallet = "applepay" |
14
|
|
|
) |
15
|
|
|
|
16
|
|
|
// WalletsService operates over the resources described |
17
|
|
|
// in Mollie's wallets API endpoints section. |
18
|
|
|
type WalletsService service |
19
|
|
|
|
20
|
|
|
// ApplePaymentSession contains information about an Apple pay session. |
21
|
|
|
type ApplePaymentSession struct { |
22
|
|
|
EpochTimestamp int `json:"epochTimestamp,omitempty"` |
23
|
|
|
ExpiresAt int `json:"expiresAt,omitempty"` |
24
|
|
|
MerchantSessionID string `json:"merchantSessionIdentifier,omitempty"` |
25
|
|
|
Nonce string `json:"nonce,omitempty"` |
26
|
|
|
MerchantID string `json:"merchantIdentified,omitempty"` |
27
|
|
|
DomainName string `json:"domainName,omitempty"` |
28
|
|
|
DisplayName string `json:"displayName,omitempty"` |
29
|
|
|
Signature string `json:"signature,omitempty"` |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
// ApplePaymentSessionRequest contains the body parameters for requesting |
33
|
|
|
// a valid PaymentSession from Apple. |
34
|
|
|
type ApplePaymentSessionRequest struct { |
35
|
|
|
Domain string `json:"domain,omitempty"` |
36
|
|
|
ValidationURL string `json:"validationUrl,omitempty"` |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
// ApplePaymentSession returns an Apple Payment Session object valid for one transaction. |
40
|
|
|
// |
41
|
|
|
// See: https://docs.mollie.com/reference/v2/wallets-api/request-apple-pay-payment-session |
42
|
|
|
func (ms *WalletsService) ApplePaymentSession(ctx context.Context, asr *ApplePaymentSessionRequest) ( |
43
|
|
|
res *Response, |
44
|
|
|
aps *ApplePaymentSession, |
45
|
|
|
err error, |
46
|
|
|
) { |
47
|
|
|
u := "v2/wallets/applepay/sessions" |
48
|
|
|
|
49
|
|
|
res, err = ms.client.post(ctx, u, asr, nil) |
50
|
|
|
if err != nil { |
51
|
|
|
return |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
if err = json.Unmarshal(res.content, &aps); err != nil { |
55
|
|
|
return |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
return |
59
|
|
|
} |
60
|
|
|
|