Skip to content

Commit

Permalink
Merge upstream and update generated code for v1281
Browse files Browse the repository at this point in the history
  • Loading branch information
stripe-openapi[bot] committed Oct 9, 2024
2 parents e8f4b4f + 2e92acc commit 5b07b19
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 25 deletions.
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1279
v1281
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,13 @@ import (
func make_raw_request() error {
stripe.Key = "sk_test_123"

b, err := stripe.GetRawRequestBackend(stripe.APIBackend)
if err != nil {
return err
}

client := rawrequest.Client{B: b, Key: apiKey}

payload := map[string]interface{}{
"event_name": "hotdogs_eaten",
"payload": map[string]string{
Expand All @@ -588,7 +595,7 @@ func make_raw_request() error {
return err
}

v2_resp, err := rawrequest.Post("/v2/billing/meter_events", string(body), nil)
v2_resp, err := client.RawRequest(http.MethodPost, "/v2/billing/meter_events", string(body), nil)
if err != nil {
return err
}
Expand All @@ -605,7 +612,7 @@ func make_raw_request() error {
form.AppendTo(formValues, payload)
content := formValues.Encode()

v1_resp, err := rawrequest.Post("/v1/billing/meter_events", content, nil)
v1_resp, err := client.RawRequest(http.MethodPost, "/v1/billing/meter_events", content, nil)
if err != nil {
return err
}
Expand All @@ -619,7 +626,9 @@ func make_raw_request() error {

return nil
}

```
See more examples in the [/example/v2 folder](example/v2).

## Support

Expand Down
50 changes: 50 additions & 0 deletions account.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,12 @@ type AccountCapabilitiesJPBankTransferPaymentsParams struct {
Requested *bool `form:"requested"`
}

// The kakao_pay_payments capability.
type AccountCapabilitiesKakaoPayPaymentsParams struct {
// Passing true requests the capability for the account, if it is not already requested. A requested capability may not immediately become active. Any requirements to activate the capability are returned in the `requirements` arrays.
Requested *bool `form:"requested"`
}

// The klarna_payments capability.
type AccountCapabilitiesKlarnaPaymentsParams struct {
// Passing true requests the capability for the account, if it is not already requested. A requested capability may not immediately become active. Any requirements to activate the capability are returned in the `requirements` arrays.
Expand All @@ -462,6 +468,12 @@ type AccountCapabilitiesKonbiniPaymentsParams struct {
Requested *bool `form:"requested"`
}

// The kr_card_payments capability.
type AccountCapabilitiesKrCardPaymentsParams struct {
// Passing true requests the capability for the account, if it is not already requested. A requested capability may not immediately become active. Any requirements to activate the capability are returned in the `requirements` arrays.
Requested *bool `form:"requested"`
}

// The legacy_payments capability.
type AccountCapabilitiesLegacyPaymentsParams struct {
// Passing true requests the capability for the account, if it is not already requested. A requested capability may not immediately become active. Any requirements to activate the capability are returned in the `requirements` arrays.
Expand Down Expand Up @@ -498,6 +510,12 @@ type AccountCapabilitiesMXBankTransferPaymentsParams struct {
Requested *bool `form:"requested"`
}

// The naver_pay_payments capability.
type AccountCapabilitiesNaverPayPaymentsParams struct {
// Passing true requests the capability for the account, if it is not already requested. A requested capability may not immediately become active. Any requirements to activate the capability are returned in the `requirements` arrays.
Requested *bool `form:"requested"`
}

// The oxxo_payments capability.
type AccountCapabilitiesOXXOPaymentsParams struct {
// Passing true requests the capability for the account, if it is not already requested. A requested capability may not immediately become active. Any requirements to activate the capability are returned in the `requirements` arrays.
Expand All @@ -510,6 +528,12 @@ type AccountCapabilitiesP24PaymentsParams struct {
Requested *bool `form:"requested"`
}

// The payco_payments capability.
type AccountCapabilitiesPaycoPaymentsParams struct {
// Passing true requests the capability for the account, if it is not already requested. A requested capability may not immediately become active. Any requirements to activate the capability are returned in the `requirements` arrays.
Requested *bool `form:"requested"`
}

// The paynow_payments capability.
type AccountCapabilitiesPayNowPaymentsParams struct {
// Passing true requests the capability for the account, if it is not already requested. A requested capability may not immediately become active. Any requirements to activate the capability are returned in the `requirements` arrays.
Expand Down Expand Up @@ -546,6 +570,12 @@ type AccountCapabilitiesRevolutPayPaymentsParams struct {
Requested *bool `form:"requested"`
}

// The samsung_pay_payments capability.
type AccountCapabilitiesSamsungPayPaymentsParams struct {
// Passing true requests the capability for the account, if it is not already requested. A requested capability may not immediately become active. Any requirements to activate the capability are returned in the `requirements` arrays.
Requested *bool `form:"requested"`
}

// The sepa_bank_transfer_payments capability.
type AccountCapabilitiesSEPABankTransferPaymentsParams struct {
// Passing true requests the capability for the account, if it is not already requested. A requested capability may not immediately become active. Any requirements to activate the capability are returned in the `requirements` arrays.
Expand Down Expand Up @@ -691,10 +721,14 @@ type AccountCapabilitiesParams struct {
JCBPayments *AccountCapabilitiesJCBPaymentsParams `form:"jcb_payments"`
// The jp_bank_transfer_payments capability.
JPBankTransferPayments *AccountCapabilitiesJPBankTransferPaymentsParams `form:"jp_bank_transfer_payments"`
// The kakao_pay_payments capability.
KakaoPayPayments *AccountCapabilitiesKakaoPayPaymentsParams `form:"kakao_pay_payments"`
// The klarna_payments capability.
KlarnaPayments *AccountCapabilitiesKlarnaPaymentsParams `form:"klarna_payments"`
// The konbini_payments capability.
KonbiniPayments *AccountCapabilitiesKonbiniPaymentsParams `form:"konbini_payments"`
// The kr_card_payments capability.
KrCardPayments *AccountCapabilitiesKrCardPaymentsParams `form:"kr_card_payments"`
// The legacy_payments capability.
LegacyPayments *AccountCapabilitiesLegacyPaymentsParams `form:"legacy_payments"`
// The link_payments capability.
Expand All @@ -707,10 +741,14 @@ type AccountCapabilitiesParams struct {
MultibancoPayments *AccountCapabilitiesMultibancoPaymentsParams `form:"multibanco_payments"`
// The mx_bank_transfer_payments capability.
MXBankTransferPayments *AccountCapabilitiesMXBankTransferPaymentsParams `form:"mx_bank_transfer_payments"`
// The naver_pay_payments capability.
NaverPayPayments *AccountCapabilitiesNaverPayPaymentsParams `form:"naver_pay_payments"`
// The oxxo_payments capability.
OXXOPayments *AccountCapabilitiesOXXOPaymentsParams `form:"oxxo_payments"`
// The p24_payments capability.
P24Payments *AccountCapabilitiesP24PaymentsParams `form:"p24_payments"`
// The payco_payments capability.
PaycoPayments *AccountCapabilitiesPaycoPaymentsParams `form:"payco_payments"`
// The paynow_payments capability.
PayNowPayments *AccountCapabilitiesPayNowPaymentsParams `form:"paynow_payments"`
// The paypal_payments capability.
Expand All @@ -723,6 +761,8 @@ type AccountCapabilitiesParams struct {
RechnungPayments *AccountCapabilitiesRechnungPaymentsParams `form:"rechnung_payments"`
// The revolut_pay_payments capability.
RevolutPayPayments *AccountCapabilitiesRevolutPayPaymentsParams `form:"revolut_pay_payments"`
// The samsung_pay_payments capability.
SamsungPayPayments *AccountCapabilitiesSamsungPayPaymentsParams `form:"samsung_pay_payments"`
// The sepa_bank_transfer_payments capability.
SEPABankTransferPayments *AccountCapabilitiesSEPABankTransferPaymentsParams `form:"sepa_bank_transfer_payments"`
// The sepa_debit_payments capability.
Expand Down Expand Up @@ -1316,10 +1356,14 @@ type AccountCapabilities struct {
JCBPayments AccountCapabilityStatus `json:"jcb_payments"`
// The status of the Japanese customer_balance payments (JPY currency) capability of the account, or whether the account can directly process Japanese customer_balance charges.
JPBankTransferPayments AccountCapabilityStatus `json:"jp_bank_transfer_payments"`
// The status of the KakaoPay capability of the account, or whether the account can directly process KakaoPay payments.
KakaoPayPayments AccountCapabilityStatus `json:"kakao_pay_payments"`
// The status of the Klarna payments capability of the account, or whether the account can directly process Klarna charges.
KlarnaPayments AccountCapabilityStatus `json:"klarna_payments"`
// The status of the konbini payments capability of the account, or whether the account can directly process konbini charges.
KonbiniPayments AccountCapabilityStatus `json:"konbini_payments"`
// The status of the KrCard capability of the account, or whether the account can directly process KrCard payments.
KrCardPayments AccountCapabilityStatus `json:"kr_card_payments"`
// The status of the legacy payments capability of the account.
LegacyPayments AccountCapabilityStatus `json:"legacy_payments"`
// The status of the link_payments capability of the account, or whether the account can directly process Link charges.
Expand All @@ -1332,10 +1376,14 @@ type AccountCapabilities struct {
MultibancoPayments AccountCapabilityStatus `json:"multibanco_payments"`
// The status of the Mexican customer_balance payments (MXN currency) capability of the account, or whether the account can directly process Mexican customer_balance charges.
MXBankTransferPayments AccountCapabilityStatus `json:"mx_bank_transfer_payments"`
// The status of the NaverPay capability of the account, or whether the account can directly process NaverPay payments.
NaverPayPayments AccountCapabilityStatus `json:"naver_pay_payments"`
// The status of the OXXO payments capability of the account, or whether the account can directly process OXXO charges.
OXXOPayments AccountCapabilityStatus `json:"oxxo_payments"`
// The status of the P24 payments capability of the account, or whether the account can directly process P24 charges.
P24Payments AccountCapabilityStatus `json:"p24_payments"`
// The status of the Payco capability of the account, or whether the account can directly process Payco payments.
PaycoPayments AccountCapabilityStatus `json:"payco_payments"`
// The status of the paynow payments capability of the account, or whether the account can directly process paynow charges.
PayNowPayments AccountCapabilityStatus `json:"paynow_payments"`
// The status of the PayPal payments capability of the account, or whether the account can directly process PayPal charges.
Expand All @@ -1348,6 +1396,8 @@ type AccountCapabilities struct {
RechnungPayments AccountCapabilityStatus `json:"rechnung_payments"`
// The status of the RevolutPay capability of the account, or whether the account can directly process RevolutPay payments.
RevolutPayPayments AccountCapabilityStatus `json:"revolut_pay_payments"`
// The status of the SamsungPay capability of the account, or whether the account can directly process SamsungPay payments.
SamsungPayPayments AccountCapabilityStatus `json:"samsung_pay_payments"`
// The status of the SEPA customer_balance payments (EUR currency) capability of the account, or whether the account can directly process SEPA customer_balance charges.
SEPABankTransferPayments AccountCapabilityStatus `json:"sepa_bank_transfer_payments"`
// The status of the SEPA Direct Debits payments capability of the account, or whether the account can directly process SEPA Direct Debits charges.
Expand Down
14 changes: 0 additions & 14 deletions rawrequest/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
package rawrequest

import (
"net/http"

stripe "github.com/stripe/stripe-go/v80"
)

Expand All @@ -16,15 +14,3 @@ type Client struct {
func (c Client) RawRequest(method string, path string, content string, params *stripe.RawParams) (*stripe.APIResponse, error) {
return c.B.RawRequest(method, path, c.Key, content, params)
}

func Get(path string, params *stripe.RawParams) (*stripe.APIResponse, error) {
return stripe.RawRequest(http.MethodGet, path, "", params)
}

func Post(path, content string, params *stripe.RawParams) (*stripe.APIResponse, error) {
return stripe.RawRequest(http.MethodPost, path, content, params)
}

func Delete(path string, params *stripe.RawParams) (*stripe.APIResponse, error) {
return stripe.RawRequest(http.MethodDelete, path, "", params)
}
17 changes: 9 additions & 8 deletions rawrequest/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
_ "github.com/stripe/stripe-go/v80/testing"
)

func stubAPIBackend(testServer *httptest.Server) {
func createTestClient(testServer *httptest.Server) Client {
backend := stripe.GetBackendWithConfig(
stripe.APIBackend,
&stripe.BackendConfig{
Expand All @@ -23,7 +23,8 @@ func stubAPIBackend(testServer *httptest.Server) {
},
).(*stripe.BackendImplementation)

stripe.SetBackend(stripe.APIBackend, backend)
return Client{B: backend, Key: stripe.Key}
// stripe.SetBackend(stripe.APIBackend, backend)
}

func TestV2PostRequest(t *testing.T) {
Expand All @@ -42,11 +43,11 @@ func TestV2PostRequest(t *testing.T) {
w.Write([]byte(`{"object": "abc", "xyz": {"def": "jih"}}`))
}))

stubAPIBackend(testServer)
client := createTestClient(testServer)

var params *stripe.RawParams

_, err := Post("/v2/abc", `{"xyz": {"def": "jih"}}`, params)
_, err := client.RawRequest(http.MethodPost, "/v2/abc", `{"xyz": {"def": "jih"}}`, params)
assert.NoError(t, err)

assert.Nil(t, params) // original params should not be modified
Expand Down Expand Up @@ -74,11 +75,11 @@ func TestRawV1PostRequest(t *testing.T) {
w.Write([]byte(`{"object": "abc", "xyz": {"def": "jih"}}`))
}))

stubAPIBackend(testServer)
client := createTestClient(testServer)

var params *stripe.RawParams

_, err := Post("/v1/abc", `abc=123&a[name]=nested`, params)
_, err := client.RawRequest(http.MethodPost, "/v1/abc", `abc=123&a[name]=nested`, params)
assert.NoError(t, err)

assert.Nil(t, params) // original params should not be modified
Expand Down Expand Up @@ -110,13 +111,13 @@ func TestV2GetRequestWithAdditionalHeaders(t *testing.T) {
w.Write([]byte(`{"object": "abc", "xyz": {"def": "jih"}}`))
}))

stubAPIBackend(testServer)
client := createTestClient(testServer)

headers := http.Header{}
headers.Set("foo", "bar")
params := &stripe.RawParams{Params: stripe.Params{Headers: headers}, StripeContext: "acct_123"}

_, err := Get("/v2/abc", params)
_, err := client.RawRequest(http.MethodGet, "/v2/abc", "", params)
assert.NoError(t, err)

assert.Equal(t, ``, body)
Expand Down

0 comments on commit 5b07b19

Please sign in to comment.