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