-
Notifications
You must be signed in to change notification settings - Fork 6
/
payments.go
48 lines (38 loc) · 1.22 KB
/
payments.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
// Copyright 2021-present Airheart, Inc. All rights reserved.
// This source code is licensed under the Apache 2.0 license found
// in the LICENSE file in the root directory of this source tree.
package duffel
import (
"context"
)
type (
PaymentType string
Payment struct {
Amount string `json:"amount"`
CreatedAt DateTime `json:"created_at"`
Currency string `json:"currency"`
ID string `json:"id"`
LiveMode bool `json:"live_mode"`
Type PaymentType `json:"type"`
}
CreatePaymentRequest struct {
OrderID string `json:"order_id"`
Payment CreatePayment `json:"payment"`
}
CreatePayment struct {
Amount string `json:"amount"`
Currency string `json:"currency"`
Type PaymentType `json:"type"`
}
OrderPaymentClient interface {
CreatePayment(ctx context.Context, req CreatePaymentRequest) (*Payment, error)
}
)
const (
PaymentTypeBalance = PaymentType("balance")
PaymentTypeCash = PaymentType("arc_bsp_cash")
)
func (a *API) CreatePayment(ctx context.Context, req CreatePaymentRequest) (*Payment, error) {
return newRequestWithAPI[CreatePaymentRequest, Payment](a).Post("/air/payments", &req).Single(ctx)
}
var _ OrderPaymentClient = (*API)(nil)