Class: CyberSourceMergedSpec::TokenizeController

Inherits:
BaseController show all
Defined in:
lib/cyber_source_merged_spec/controllers/tokenize_controller.rb

Overview

TokenizeController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

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 CyberSourceMergedSpec::BaseController

Instance Method Details

#tokenize(post_tokenize_request, profile_id: nil) ⇒ ApiResponse

| | | | | --- | --- | --- | |The Tokenize API endpoint facilitates the creation of various TMS tokens such as Customers, Payment Instruments, Shipping Addresses, and Instrument Identifiers in a single operation. The request includes a processingInformation object, which specifies "TOKEN_CREATE" and the types of tokens to be created. The tokenInformation section of the request includes detailed information relevant to each token type. This includes attributes for Customers, Payment Instruments, Shipping Addresses, Instrument Identifiers and Transient Token data. The payload is flexible, allowing for different combinations of tokens to be created in a single request.|      |The API response includes a responses array, which details the outcome of the tokenization process for each requested resource type, such as Customer, Payment Instrument, Shipping Address, and Instrument Identifier. Each entry in this array provides an HTTP status code such as 201/200 for successful creations, and a unique identifier for the newly created token.
In cases where token creation encounters issues, the response includes a non-2XX status code and an errors array for the affected resource. Each error object in the array details the error type and a descriptive message providing insight into why a particular token creation was not attempted or failed. TODO: type description here containing user specific TMS configuration.

Parameters:

  • post_tokenize_request (PostTokenizeRequest)

    Required parameter:

  • profile_id (String) (defaults to: nil)

    Optional parameter: The Id of a profile

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/cyber_source_merged_spec/controllers/tokenize_controller.rb', line 36

def tokenize(post_tokenize_request,
             profile_id: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/tms/v2/tokenize',
                                 Server::DEFAULT)
               .body_param(new_parameter(post_tokenize_request)
                            .is_required(true))
               .header_param(new_parameter('application/json;charset=utf-8', key: 'Content-Type'))
               .header_param(new_parameter(profile_id, key: 'profile-id'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(TokenizeResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Bad Request: e.g. A required header value could be missing.',
                             TokenizeException)
                .local_error('403',
                             'Forbidden: e.g. The profile might not have permission to'\
                              ' perform the operation.',
                             TokenizeException2Exception)
                .local_error('424',
                             'Failed Dependency: e.g. The profile represented by the'\
                              ' profile-id may not exist or the profile-id was entered'\
                              ' incorrectly.',
                             TokenizeException3Exception)
                .local_error('500',
                             'Unexpected error.',
                             TokenizeException4Exception))
    .execute
end