mirror of
https://github.com/rjNemo/go-wiki
synced 2026-06-06 02:36:40 +00:00
50 lines
1.6 KiB
Go
50 lines
1.6 KiB
Go
package stripe
|
|
|
|
import "encoding/json"
|
|
|
|
// EphemeralKeyParams is the set of parameters that can be used when creating
|
|
// an ephemeral key.
|
|
type EphemeralKeyParams struct {
|
|
Params `form:"*"`
|
|
Customer *string `form:"customer"`
|
|
IssuingCard *string `form:"issuing_card"`
|
|
StripeVersion *string `form:"-"` // This goes in the `Stripe-Version` header
|
|
}
|
|
|
|
// EphemeralKey is the resource representing a Stripe ephemeral key. This is used by Mobile SDKs
|
|
// to for example manage a Customer's payment methods.
|
|
type EphemeralKey struct {
|
|
AssociatedObjects []struct {
|
|
ID string `json:"id"`
|
|
Type string `json:"type"`
|
|
} `json:"associated_objects"`
|
|
|
|
Created int64 `json:"created"`
|
|
Expires int64 `json:"expires"`
|
|
ID string `json:"id"`
|
|
Livemode bool `json:"livemode"`
|
|
|
|
// RawJSON is provided so that it may be passed back to the frontend
|
|
// unchanged. Ephemeral keys are issued on behalf of another client which
|
|
// may be running a different version of the bindings and thus expect a
|
|
// different JSON structure. This ensures that if the structure differs
|
|
// from the version of these bindings, we can still pass back a compatible
|
|
// key.
|
|
RawJSON []byte `json:"-"`
|
|
}
|
|
|
|
// UnmarshalJSON handles deserialization of an EphemeralKey.
|
|
// This custom unmarshaling is needed because we need to store the
|
|
// raw JSON on the object so it may be passed back to the frontend.
|
|
func (e *EphemeralKey) UnmarshalJSON(data []byte) error {
|
|
type ephemeralKey EphemeralKey
|
|
var ee ephemeralKey
|
|
err := json.Unmarshal(data, &ee)
|
|
if err == nil {
|
|
*e = EphemeralKey(ee)
|
|
}
|
|
|
|
e.RawJSON = data
|
|
|
|
return nil
|
|
}
|