Class: Stripe::Token
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::Token
- Extended by:
- APIOperations::Create
- Defined in:
- lib/stripe/resources/token.rb
Overview
Tokenization is the process Stripe uses to collect sensitive card or bank account details, or personally identifiable information (PII), directly from your customers in a secure manner. A token representing this information is returned to your server to use. Use our [recommended payments integrations](docs.stripe.com/payments) to perform this process on the client-side. This guarantees that no sensitive card data touches your server, and allows your integration to operate in a PCI-compliant way.
If you can’t use client-side tokenization, you can also create tokens using the API with either your publishable or secret API key. If your integration uses this method, you’re responsible for any PCI compliance that it might require, and you must keep your secret API key safe. Unlike with client-side tokenization, your customer’s information isn’t sent directly to Stripe, so we can’t determine how it’s handled or stored.
You can’t store or use tokens more than once. To store card or bank account information for later use, create [Customer](docs.stripe.com/api#customers) objects or [External accounts](docs.stripe.com/api#external_accounts). [Radar](docs.stripe.com/radar), our integrated solution for automatic fraud protection, performs best with integrations that use client-side tokenization.
Defined Under Namespace
Classes: Redaction
Constant Summary collapse
- OBJECT_NAME =
"token"
Constants inherited from StripeObject
StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary collapse
-
#bank_account ⇒ Object
readonly
These bank accounts are payment methods on ‘Customer` objects.
-
#card ⇒ Object
readonly
You can store multiple cards on a customer in order to charge the customer later.
-
#client_ip ⇒ Object
readonly
IP address of the client that generates the token.
-
#created ⇒ Object
readonly
Time at which the object was created.
-
#id ⇒ Object
readonly
Unique identifier for the object.
-
#livemode ⇒ Object
readonly
If the object exists in live mode, the value is ‘true`.
-
#object ⇒ Object
readonly
String representing the object’s type.
-
#redaction ⇒ Object
readonly
Redaction status of this token.
-
#type ⇒ Object
readonly
Type of the token: ‘account`, `bank_account`, `card`, or `pii`.
-
#used ⇒ Object
readonly
Determines if you have already used this token (you can only use tokens once).
Attributes inherited from APIResource
Attributes inherited from StripeObject
Class Method Summary collapse
-
.create(params = {}, opts = {}) ⇒ Object
Creates a single-use token that represents a bank account’s details.
- .field_remappings ⇒ Object
- .inner_class_types ⇒ Object
- .object_name ⇒ Object
Methods included from APIOperations::Create
Methods inherited from APIResource
class_name, custom_method, #refresh, #request_stripe_object, resource_url, #resource_url, retrieve, save_nested_resource
Methods included from APIOperations::Request
Methods inherited from StripeObject
#==, #[], #[]=, #_get_inner_class_type, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, field_encodings, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values
Constructor Details
This class inherits a constructor from Stripe::StripeObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject
Instance Attribute Details
#bank_account ⇒ Object (readonly)
These bank accounts are payment methods on ‘Customer` objects.
On the other hand [External Accounts](/api#external_accounts) are transfer destinations on ‘Account` objects for connected accounts. They can be bank accounts or debit cards as well, and are documented in the links above.
Related guide: [Bank debits and transfers](/payments/bank-debits-transfers)
52 53 54 |
# File 'lib/stripe/resources/token.rb', line 52 def bank_account @bank_account end |
#card ⇒ Object (readonly)
You can store multiple cards on a customer in order to charge the customer later. You can also store multiple debit cards on a recipient in order to transfer to those cards later.
Related guide: [Card payments with Sources](docs.stripe.com/sources/cards)
58 59 60 |
# File 'lib/stripe/resources/token.rb', line 58 def card @card end |
#client_ip ⇒ Object (readonly)
IP address of the client that generates the token.
60 61 62 |
# File 'lib/stripe/resources/token.rb', line 60 def client_ip @client_ip end |
#created ⇒ Object (readonly)
Time at which the object was created. Measured in seconds since the Unix epoch.
62 63 64 |
# File 'lib/stripe/resources/token.rb', line 62 def created @created end |
#id ⇒ Object (readonly)
Unique identifier for the object.
64 65 66 |
# File 'lib/stripe/resources/token.rb', line 64 def id @id end |
#livemode ⇒ Object (readonly)
If the object exists in live mode, the value is ‘true`. If the object exists in test mode, the value is `false`.
66 67 68 |
# File 'lib/stripe/resources/token.rb', line 66 def livemode @livemode end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
68 69 70 |
# File 'lib/stripe/resources/token.rb', line 68 def object @object end |
#redaction ⇒ Object (readonly)
Redaction status of this token. If not null, this token is associated to a redaction job.
70 71 72 |
# File 'lib/stripe/resources/token.rb', line 70 def redaction @redaction end |
#type ⇒ Object (readonly)
Type of the token: ‘account`, `bank_account`, `card`, or `pii`.
72 73 74 |
# File 'lib/stripe/resources/token.rb', line 72 def type @type end |
#used ⇒ Object (readonly)
Determines if you have already used this token (you can only use tokens once).
74 75 76 |
# File 'lib/stripe/resources/token.rb', line 74 def used @used end |
Class Method Details
.create(params = {}, opts = {}) ⇒ Object
Creates a single-use token that represents a bank account’s details. You can use this token with any v1 API method in place of a bank account dictionary. You can only use this token once. To do so, attach it to a [connected account](docs.stripe.com/api#accounts) where [controller.requirement_collection](docs.stripe.com/api/accounts/object#account_object-controller-requirement_collection) is application, which includes Custom accounts.
78 79 80 |
# File 'lib/stripe/resources/token.rb', line 78 def self.create(params = {}, opts = {}) request_stripe_object(method: :post, path: "/v1/tokens", params: params, opts: opts) end |
.field_remappings ⇒ Object
86 87 88 |
# File 'lib/stripe/resources/token.rb', line 86 def self.field_remappings @field_remappings = {} end |
.inner_class_types ⇒ Object
82 83 84 |
# File 'lib/stripe/resources/token.rb', line 82 def self.inner_class_types @inner_class_types = { redaction: Redaction } end |
.object_name ⇒ Object
29 30 31 |
# File 'lib/stripe/resources/token.rb', line 29 def self.object_name "token" end |