-
Notifications
You must be signed in to change notification settings - Fork 2
/
payment_methods.go
130 lines (109 loc) · 5.62 KB
/
payment_methods.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// Code generated by the Paddle SDK Generator; DO NOT EDIT.
package paddle
import "context"
// SavedPaymentMethodType: Type of payment method saved..
type SavedPaymentMethodType string
const (
SavedPaymentMethodTypeAlipay SavedPaymentMethodType = "alipay"
SavedPaymentMethodTypeApplePay SavedPaymentMethodType = "apple_pay"
SavedPaymentMethodTypeCard SavedPaymentMethodType = "card"
SavedPaymentMethodTypeGooglePay SavedPaymentMethodType = "google_pay"
SavedPaymentMethodTypePaypal SavedPaymentMethodType = "paypal"
)
// PayPal: Information about the PayPal payment method saved. `null` unless `type` is `paypal`.
type PayPal struct {
// Email: Email address associated with the PayPal account.
Email string `json:"email,omitempty"`
// Reference: PayPal payment method identifier.
Reference string `json:"reference,omitempty"`
}
// PaymentMethodOrigin: Describes how this payment method was saved..
type PaymentMethodOrigin string
const (
PaymentMethodOriginSavedDuringPurchase PaymentMethodOrigin = "saved_during_purchase"
PaymentMethodOriginSubscription PaymentMethodOrigin = "subscription"
)
// PaymentMethod: Represents a customer payment method entity.
type PaymentMethod struct {
// ID: Unique Paddle ID for this payment method entity, prefixed with `paymtd_`.
ID string `json:"id,omitempty"`
// CustomerID: Paddle ID of the customer that this payment method is saved for, prefixed with `ctm_`.
CustomerID string `json:"customer_id,omitempty"`
// AddressID: Paddle ID of the address for this payment method, prefixed with `add_`.
AddressID string `json:"address_id,omitempty"`
// Type: Type of payment method saved.
Type SavedPaymentMethodType `json:"type,omitempty"`
// Card: Information about the credit or debit card saved. `null` unless `type` is `card`.
Card *Card `json:"card,omitempty"`
// Paypal: Information about the PayPal payment method saved. `null` unless `type` is `paypal`.
Paypal *PayPal `json:"paypal,omitempty"`
// Origin: Describes how this payment method was saved.
Origin PaymentMethodOrigin `json:"origin,omitempty"`
// SavedAt: RFC 3339 datetime string of when this entity was saved. Set automatically by Paddle.
SavedAt string `json:"saved_at,omitempty"`
// UpdatedAt: RFC 3339 datetime string of when this entity was updated. Set automatically by Paddle.
UpdatedAt string `json:"updated_at,omitempty"`
}
// PaymentMethodsClient is a client for the Payment methods resource.
type PaymentMethodsClient struct {
doer Doer
}
// ListCustomerPaymentMethodsRequest is given as an input to ListCustomerPaymentMethods.
type ListCustomerPaymentMethodsRequest struct {
// URL path parameters.
CustomerID string `in:"path=customer_id" json:"-"`
// AddressID is a query parameter.
// Return entities related to the specified address. Use a comma-separated list to specify multiple address IDs.
AddressID []string `in:"query=address_id;omitempty" json:"-"`
// After is a query parameter.
// Return entities after the specified Paddle ID when working with paginated endpoints. Used in the `meta.pagination.next` URL in responses for list operations.
After *string `in:"query=after;omitempty" json:"-"`
// OrderBy is a query parameter.
/*
Order returned entities by the specified field and direction (`[ASC]` or `[DESC]`). For example, `?order_by=id[ASC]`.
Valid fields for ordering: `id`.
*/
OrderBy *string `in:"query=order_by;omitempty" json:"-"`
// PerPage is a query parameter.
/*
Set how many entities are returned per page. Paddle returns the maximum number of results if a number greater than the maximum is requested. Check `meta.pagination.per_page` in the response to see how many were returned.
Default: `50`; Maximum: `200`.
*/
PerPage *int `in:"query=per_page;omitempty" json:"-"`
// SupportsCheckout is a query parameter.
// Return entities that support being presented at checkout (`true`) or not (`false`).
SupportsCheckout *bool `in:"query=supports_checkout;omitempty" json:"-"`
}
// ListCustomerPaymentMethods performs the GET operation on a Payment methods resource.
func (c *PaymentMethodsClient) ListCustomerPaymentMethods(ctx context.Context, req *ListCustomerPaymentMethodsRequest) (res *Collection[*PaymentMethod], err error) {
if err := c.doer.Do(ctx, "GET", "/customers/{customer_id}/payment-methods", req, &res); err != nil {
return nil, err
}
return res, nil
}
// GetCustomerPaymentMethodRequest is given as an input to GetCustomerPaymentMethod.
type GetCustomerPaymentMethodRequest struct {
// URL path parameters.
CustomerID string `in:"path=customer_id" json:"-"`
PaymentMethodID string `in:"path=payment_method_id" json:"-"`
}
// GetCustomerPaymentMethod performs the GET operation on a Payment methods resource.
func (c *PaymentMethodsClient) GetCustomerPaymentMethod(ctx context.Context, req *GetCustomerPaymentMethodRequest) (res *PaymentMethod, err error) {
if err := c.doer.Do(ctx, "GET", "/customers/{customer_id}/payment-methods/{payment_method_id}", req, &res); err != nil {
return nil, err
}
return res, nil
}
// DeleteCustomerPaymentMethodRequest is given as an input to DeleteCustomerPaymentMethod.
type DeleteCustomerPaymentMethodRequest struct {
// URL path parameters.
CustomerID string `in:"path=customer_id" json:"-"`
PaymentMethodID string `in:"path=payment_method_id" json:"-"`
}
// DeleteCustomerPaymentMethod performs the DELETE operation on a Payment methods resource.
func (c *PaymentMethodsClient) DeleteCustomerPaymentMethod(ctx context.Context, req *DeleteCustomerPaymentMethodRequest) (err error) {
if err := c.doer.Do(ctx, "DELETE", "/customers/{customer_id}/payment-methods/{payment_method_id}", req, nil); err != nil {
return err
}
return nil
}