Class: StickyIoRestfulApiV2025731::TokenizationController
- Inherits:
-
BaseController
- Object
- BaseController
- StickyIoRestfulApiV2025731::TokenizationController
- Defined in:
- lib/sticky_io_restful_api_v2025731/controllers/tokenization_controller.rb
Overview
TokenizationController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#tokenize_api_credentials(domain, v2_ext, method) ⇒ ApiResponse
This call is intended to be used to tokenize API credentials for each API endpoint.
-
#tokenize_payment(body, domain, v2_ext) ⇒ ApiResponse
Get a temporary token that will be used as an alternative to sending personal cardholder information (card number, expiry, CVV) with a new_order call.
Methods inherited from BaseController
#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters
Constructor Details
This class inherits a constructor from StickyIoRestfulApiV2025731::BaseController
Instance Method Details
#tokenize_api_credentials(domain, v2_ext, method) ⇒ ApiResponse
This call is intended to be used to tokenize API credentials for each API endpoint. The token in the response from this call can be used as the replacement of your plain API credentials (username and password), this is an alternative to keep your API credentials secure when making API calls. ##How to use the token The token should be pass as a ‘Bearer` token in the `Authorization` header for the API call passed when creating the token. For example: A call to `/api/v2/token/tokenize_payment ` will create a token specifically for the `tokenize_payment` endpoint, that token should be passed as a `Bearer` token in the `Authorization` header for the subsequent call to `/api/v2/tokenize_payment`. ##Important Note The life of the token is 10 minutes from the time of its creation.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/tokenization_controller.rb', line 71 def tokenize_api_credentials(domain, v2_ext, method) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/.{domain}{v2_ext}token/{method}', Server::SERVER_1) .template_param(new_parameter(domain, key: 'domain') .is_required(true) .should_encode(true)) .template_param(new_parameter(v2_ext, key: 'v2_ext') .is_required(true) .should_encode(true)) .template_param(new_parameter(method, key: 'method') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('basic'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(TokenizeApiCredentials.method(:from_hash)) .is_api_response(true)) .execute end |
#tokenize_payment(body, domain, v2_ext) ⇒ ApiResponse
Get a temporary token that will be used as an alternative to sending personal cardholder information (card number, expiry, CVV) with a new_order call. It is passed to new_order via the ‘payment_token` attribute. The token is valid for 15 minutes **Request Data** Request parameters expected during this API call: | Field | Requirement | Default | Data Type | Description | | — | — | — | — | — | | card_number | Required | - | String | The card number 12-19 digits | | cvv | Optional | - | String | The cvv 3-4 digits | | expiry | Required | - | String | The expiry format is: MM-YYYY | | brand | Optionally | Mapped by the cc number to (Visa, Master, AMEX, Discover, Diners) | String | The brand name | description here
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 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/tokenization_controller.rb', line 27 def tokenize_payment(body, domain, v2_ext) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/.{domain}{v2_ext}tokenize_payment', Server::SERVER_1) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body) .is_required(true)) .template_param(new_parameter(domain, key: 'domain') .is_required(true) .should_encode(true)) .template_param(new_parameter(v2_ext, key: 'v2_ext') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('basic'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(TokenizePayment.method(:from_hash)) .is_api_response(true)) .execute end |