-
Notifications
You must be signed in to change notification settings - Fork 0
/
donationpaymentintent.go
executable file
·154 lines (133 loc) · 6.04 KB
/
donationpaymentintent.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package polar
import (
"context"
"errors"
"fmt"
"net/http"
"github.com/polarsource/polar-go/internal/apijson"
"github.com/polarsource/polar-go/internal/param"
"github.com/polarsource/polar-go/internal/requestconfig"
"github.com/polarsource/polar-go/option"
)
// DonationPaymentIntentService contains methods and other services that help with
// interacting with the polar API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewDonationPaymentIntentService] method instead.
type DonationPaymentIntentService struct {
Options []option.RequestOption
}
// NewDonationPaymentIntentService generates a new service that applies the given
// options to each request. These options are applied after the parent client's
// options (if there is one), and before any request-specific options.
func NewDonationPaymentIntentService(opts ...option.RequestOption) (r *DonationPaymentIntentService) {
r = &DonationPaymentIntentService{}
r.Options = opts
return
}
// Create Payment Intent
func (r *DonationPaymentIntentService) New(ctx context.Context, body DonationPaymentIntentNewParams, opts ...option.RequestOption) (res *DonationStripePaymentIntentMutationResponse, err error) {
opts = append(r.Options[:], opts...)
path := "v1/donations/payment_intent"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Update Payment Intent
func (r *DonationPaymentIntentService) Update(ctx context.Context, id string, body DonationPaymentIntentUpdateParams, opts ...option.RequestOption) (res *DonationStripePaymentIntentMutationResponse, err error) {
opts = append(r.Options[:], opts...)
if id == "" {
err = errors.New("missing required id parameter")
return
}
path := fmt.Sprintf("v1/donations/payment_intent/%s", id)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &res, opts...)
return
}
type DonationStripePaymentIntentMutationResponse struct {
Amount int64 `json:"amount,required"`
Currency string `json:"currency,required"`
PaymentIntentID string `json:"payment_intent_id,required"`
ClientSecret string `json:"client_secret,nullable"`
JSON donationStripePaymentIntentMutationResponseJSON `json:"-"`
}
// donationStripePaymentIntentMutationResponseJSON contains the JSON metadata for
// the struct [DonationStripePaymentIntentMutationResponse]
type donationStripePaymentIntentMutationResponseJSON struct {
Amount apijson.Field
Currency apijson.Field
PaymentIntentID apijson.Field
ClientSecret apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *DonationStripePaymentIntentMutationResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r donationStripePaymentIntentMutationResponseJSON) RawJSON() string {
return r.raw
}
type DonationPaymentIntentNewParams struct {
// The amount in cents.
Amount param.Field[int64] `json:"amount,required"`
// The donators email address. Receipts will be sent to this address.
Email param.Field[string] `json:"email,required" format:"email"`
ToOrganizationID param.Field[string] `json:"to_organization_id,required" format:"uuid4"`
// The currency. Currently, only `usd` is supported.
Currency param.Field[string] `json:"currency"`
IssueID param.Field[string] `json:"issue_id" format:"uuid4"`
// Message included with the donation
Message param.Field[string] `json:"message"`
// The organization to give credit to. The pledge will be paid by the authenticated
// user.
OnBehalfOfOrganizationID param.Field[string] `json:"on_behalf_of_organization_id" format:"uuid4"`
// If the payment method should be saved for future usage.
SetupFutureUsage param.Field[DonationPaymentIntentNewParamsSetupFutureUsage] `json:"setup_future_usage"`
}
func (r DonationPaymentIntentNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// If the payment method should be saved for future usage.
type DonationPaymentIntentNewParamsSetupFutureUsage string
const (
DonationPaymentIntentNewParamsSetupFutureUsageOnSession DonationPaymentIntentNewParamsSetupFutureUsage = "on_session"
)
func (r DonationPaymentIntentNewParamsSetupFutureUsage) IsKnown() bool {
switch r {
case DonationPaymentIntentNewParamsSetupFutureUsageOnSession:
return true
}
return false
}
type DonationPaymentIntentUpdateParams struct {
// The amount in cents.
Amount param.Field[int64] `json:"amount,required"`
// The donators email address. Receipts will be sent to this address.
Email param.Field[string] `json:"email,required"`
// The currency. Currently, only `usd` is supported.
Currency param.Field[string] `json:"currency"`
IssueID param.Field[string] `json:"issue_id" format:"uuid4"`
// Message included with the donation
Message param.Field[string] `json:"message"`
// The organization to give credit to. The pledge will be paid by the authenticated
// user.
OnBehalfOfOrganizationID param.Field[string] `json:"on_behalf_of_organization_id" format:"uuid4"`
// If the payment method should be saved for future usage.
SetupFutureUsage param.Field[DonationPaymentIntentUpdateParamsSetupFutureUsage] `json:"setup_future_usage"`
}
func (r DonationPaymentIntentUpdateParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// If the payment method should be saved for future usage.
type DonationPaymentIntentUpdateParamsSetupFutureUsage string
const (
DonationPaymentIntentUpdateParamsSetupFutureUsageOnSession DonationPaymentIntentUpdateParamsSetupFutureUsage = "on_session"
)
func (r DonationPaymentIntentUpdateParamsSetupFutureUsage) IsKnown() bool {
switch r {
case DonationPaymentIntentUpdateParamsSetupFutureUsageOnSession:
return true
}
return false
}