Class: CyberSourceMergedSpec::RefundController

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

Overview

RefundController

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

#refund_capture(refund_capture_request, id) ⇒ ApiResponse

Refund a capture API is only used, if you have requested Capture independenlty using [/pts/v2/payments/id/captures](https://developer.cybersource.com/api-ref erence-assets/index.html#payments_capture) API call. Include the capture ID in the POST request to refund the captured amount. TODO: type description here from a previous capture request.

Parameters:

  • refund_capture_request (RefundCaptureRequest)

    Required parameter:

  • id (String)

    Required parameter: The capture ID. This ID is returned

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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

def refund_capture(refund_capture_request,
                   id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/pts/v2/captures/{id}/refunds',
                                 Server::DEFAULT)
               .body_param(new_parameter(refund_capture_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(PtsV2CapturesRefundsPost201Response.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Invalid request.',
                             PtsV2CapturesRefundsPost400ResponseException)
                .local_error('502',
                             'Unexpected system error or system timeout.',
                             PtsV2CapturesRefundsPost502ResponseException))
    .execute
end

#refund_payment(refund_payment_request, id) ⇒ ApiResponse

Refund a Payment API is only used, if you have requested Authorization and Capture together in [/pts/v2/payments](https://developer.cybersource.com/api-reference-assets/ index.html#payments_payments) API call. Include the payment ID in the POST request to refund the payment amount. TODO: type description here from a previous payment request.

Parameters:

  • refund_payment_request (RefundPaymentRequest)

    Required parameter:

  • id (String)

    Required parameter: The payment ID. This ID is returned

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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

def refund_payment(refund_payment_request,
                   id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/pts/v2/payments/{id}/refunds',
                                 Server::DEFAULT)
               .body_param(new_parameter(refund_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(PtsV2PaymentsRefundPost201Response.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Invalid request.',
                             PtsV2PaymentsRefundPost400ResponseException)
                .local_error('502',
                             'Unexpected system error or system timeout.',
                             PtsV2PaymentsRefundPost502ResponseException))
    .execute
end