Class: CyberSourceMergedSpec::PaymentsController

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

Overview

PaymentsController

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

#create_order_request(order_payment_request, id) ⇒ ApiResponse

Create a Payment Order Request TODO: type description here order request.

Parameters:

  • order_payment_request (OrderPaymentRequest)

    Required parameter:

  • id (String)

    Required parameter: Request identifier number for the

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/cyber_source_merged_spec/controllers/payments_controller.rb', line 120

def create_order_request(order_payment_request,
                         id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/pts/v2/payment-references/{id}/intents',
                                 Server::DEFAULT)
               .body_param(new_parameter(order_payment_request)
                            .is_required(true))
               .template_param(new_parameter(id, key: 'id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .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(PtsV2PaymentsOrderPost201Response.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Invalid request.',
                             PtsV2PaymentsPost400ResponseException)
                .local_error('502',
                             'Unexpected system error or system timeout.',
                             PtsV2PaymentsPost502ResponseException))
    .execute
end

#create_payment(create_payment_request) ⇒ ApiResponse

A payment authorizes the amount for the transaction. There are a number of supported payment features, such as E-commerce and Card Present - Credit Card/Debit Card, Echeck, e-Wallets, Level II/III Data, etc.. A payment response includes the status of the request. It also includes processor-specific information when the request is successful and errors if unsuccessful. See the [Payments Developer Guides Page](https://developer.cybersource.com/docs/cybs/en-us/payments/developer /ctv/rest/payments/payments-intro.html). Authorization can be requested with Capture, Decision Manager, Payer Authentication(3ds), and Token Creation. TODO: type description here

Parameters:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/cyber_source_merged_spec/controllers/payments_controller.rb', line 22

def create_payment(create_payment_request)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/pts/v2/payments',
                                 Server::DEFAULT)
               .body_param(new_parameter(create_payment_request)
                            .is_required(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .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(PtsV2PaymentsPost201Response.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Invalid request.',
                             PtsV2PaymentsPost400ResponseException)
                .local_error('502',
                             'Unexpected system error or system timeout.',
                             PtsV2PaymentsPost502ResponseException))
    .execute
end

#create_session_request(create_session_req) ⇒ ApiResponse

Create Alternative Payments Sessions Request type description here

Parameters:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/cyber_source_merged_spec/controllers/payments_controller.rb', line 151

def create_session_request(create_session_req)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/pts/v2/payment-references',
                                 Server::DEFAULT)
               .body_param(new_parameter(create_session_req)
                            .is_required(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .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(PtsV2PaymentsPost201Response2.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Invalid request.',
                             PtsV2PaymentsPost400ResponseException)
                .local_error('502',
                             'Unexpected system error or system timeout.',
                             PtsV2PaymentsPost502ResponseException))
    .execute
end

#increment_auth(id, increment_auth_request) ⇒ ApiResponse

Use this service to authorize additional charges in a lodging or autorental transaction. Include the ID returned from the original authorization in the PATCH request to add additional charges to that authorization. authorization request. TODO: type description here

Parameters:

  • id (String)

    Required parameter: The ID returned from the original

  • increment_auth_request (IncrementAuthRequest)

    Required parameter:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/cyber_source_merged_spec/controllers/payments_controller.rb', line 54

def increment_auth(id,
                   increment_auth_request)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PATCH,
                                 '/pts/v2/payments/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: 'id')
                                .is_required(true)
                                .should_encode(true))
               .body_param(new_parameter(increment_auth_request)
                            .is_required(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .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(PtsV2IncrementalAuthorizationPatch201Response.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Invalid request.',
                             PtsV2IncrementalAuthorizationPatch400ResponseException)
                .local_error('502',
                             'Unexpected system error or system timeout.',
                             PtsV2IncrementalAuthorizationPatch502ResponseException))
    .execute
end

#refresh_payment_status(id, refresh_payment_status_request) ⇒ ApiResponse

Checks and updates the payment status to be checked and updated. Required parameter: TODO: type description here

Parameters:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/cyber_source_merged_spec/controllers/payments_controller.rb', line 87

def refresh_payment_status(id,
                           refresh_payment_status_request)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/pts/v2/refresh-payment-status/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: 'id')
                                .is_required(true)
                                .should_encode(true))
               .body_param(new_parameter(refresh_payment_status_request)
                            .is_required(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .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(PtsV2PaymentsPost201Response1.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Invalid request.',
                             PtsV2PaymentsPost400ResponseException)
                .local_error('502',
                             'Unexpected system error or system timeout.',
                             PtsV2PaymentsPost502ResponseException))
    .execute
end

#update_session_request(create_session_request, id) ⇒ ApiResponse

Update Alternative Payments Sessions Request TODO: type description here from a previous payment request.

Parameters:

  • create_session_request (CreateSessionRequest)

    Required parameter:

  • id (String)

    Required parameter: The payment ID. This ID is returned

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/cyber_source_merged_spec/controllers/payments_controller.rb', line 180

def update_session_request(create_session_request,
                           id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PATCH,
                                 '/pts/v2/payment-references/{id}',
                                 Server::DEFAULT)
               .body_param(new_parameter(create_session_request)
                            .is_required(true))
               .template_param(new_parameter(id, key: 'id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .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(PtsV2PaymentsPost201Response2.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Invalid request.',
                             PtsV2PaymentsPost400ResponseException)
                .local_error('502',
                             'Unexpected system error or system timeout.',
                             PtsV2PaymentsPost502ResponseException))
    .execute
end