Class: PaypalServerSdk::VaultController

Inherits:
BaseController show all
Defined in:
lib/paypal_server_sdk/controllers/vault_controller.rb

Overview

VaultController

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_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from PaypalServerSdk::BaseController

Instance Method Details

#create_payment_token(options = {}) ⇒ ApiResponse

Creates a Payment Token from the given payment source and adds it to the Vault of the associated customer. creation with a financial instrument and an optional customer_id. keys for 3 hours.

Parameters:

  • body (PaymentTokenRequest)

    Required parameter: Payment Token

  • paypal_request_id (String)

    Optional parameter: The server stores

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



116
117
118
119
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
146
147
148
149
# File 'lib/paypal_server_sdk/controllers/vault_controller.rb', line 116

def create_payment_token(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v3/vault/payment-tokens',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(options['body']))
               .header_param(new_parameter(options['paypal_request_id'], key: 'PayPal-Request-Id'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(PaymentTokenResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Request is not well-formed, syntactically incorrect, or'\
                              ' violates schema.',
                             ErrorException)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             ErrorException)
                .local_error('404',
                             'Request contains reference to resources that do not exist.',
                             ErrorException)
                .local_error('422',
                             'The requested action could not be performed, semantically'\
                              ' incorrect, or failed business validation.',
                             ErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             ErrorException))
    .execute
end

#create_setup_token(options = {}) ⇒ ApiResponse

Creates a Setup Token from the given payment source and adds it to the Vault of the associated customer. with a instrument type optional financial instrument details and customer_id. keys for 3 hours.

Parameters:

  • body (SetupTokenRequest)

    Required parameter: Setup Token creation

  • paypal_request_id (String)

    Optional parameter: The server stores

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



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
69
70
71
72
73
74
# File 'lib/paypal_server_sdk/controllers/vault_controller.rb', line 44

def create_setup_token(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v3/vault/setup-tokens',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(options['body']))
               .header_param(new_parameter(options['paypal_request_id'], key: 'PayPal-Request-Id'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SetupTokenResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Request is not well-formed, syntactically incorrect, or'\
                              ' violates schema.',
                             ErrorException)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             ErrorException)
                .local_error('422',
                             'The requested action could not be performed, semantically'\
                              ' incorrect, or failed business validation.',
                             ErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             ErrorException))
    .execute
end

#delete_payment_token(id) ⇒ ApiResponse

Delete the payment token associated with the payment token id.

Parameters:

  • id (String)

    Required parameter: ID of the payment token.

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/paypal_server_sdk/controllers/vault_controller.rb', line 12

def delete_payment_token(id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/v3/vault/payment-tokens/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true)
                .local_error('400',
                             'Request is not well-formed, syntactically incorrect, or'\
                              ' violates schema.',
                             ErrorException)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             ErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             ErrorException))
    .execute
end

#get_payment_token(id) ⇒ ApiResponse

Returns a readable representation of vaulted payment source associated with the payment token id.

Parameters:

  • id (String)

    Required parameter: ID of the payment token.

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/paypal_server_sdk/controllers/vault_controller.rb', line 195

def get_payment_token(id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v3/vault/payment-tokens/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(PaymentTokenResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             ErrorException)
                .local_error('404',
                             'The specified resource does not exist.',
                             ErrorException)
                .local_error('422',
                             'The requested action could not be performed, semantically'\
                              ' incorrect, or failed business validation.',
                             ErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             ErrorException))
    .execute
end

#get_setup_token(id) ⇒ ApiResponse

Returns a readable representation of temporarily vaulted payment source associated with the setup token id.

Parameters:

  • id (String)

    Required parameter: ID of the setup token.

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/paypal_server_sdk/controllers/vault_controller.rb', line 80

def get_setup_token(id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v3/vault/setup-tokens/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SetupTokenResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             ErrorException)
                .local_error('404',
                             'The specified resource does not exist.',
                             ErrorException)
                .local_error('422',
                             'The requested action could not be performed, semantically'\
                              ' incorrect, or failed business validation.',
                             ErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             ErrorException))
    .execute
end

#list_customer_payment_tokens(options = {}) ⇒ ApiResponse

Returns all payment tokens for a customer. representing a specific customer in merchant’s/partner’s system or records. integer indicating the maximum number of results to return at one time. representing the page of the results. boolean indicating total number of items (total_items) and pages (total_pages) are expected to be returned in the response.

Parameters:

  • customer_id (String)

    Required parameter: A unique identifier

  • page_size (Integer)

    Optional parameter: A non-negative, non-zero

  • page (Integer)

    Optional parameter: A non-negative, non-zero integer

  • total_required (TrueClass | FalseClass)

    Optional parameter: A

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/paypal_server_sdk/controllers/vault_controller.rb', line 163

def list_customer_payment_tokens(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v3/vault/payment-tokens',
                                 Server::DEFAULT)
               .query_param(new_parameter(options['customer_id'], key: 'customer_id'))
               .query_param(new_parameter(options['page_size'], key: 'page_size'))
               .query_param(new_parameter(options['page'], key: 'page'))
               .query_param(new_parameter(options['total_required'], key: 'total_required'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(CustomerVaultPaymentTokensResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Request is not well-formed, syntactically incorrect, or'\
                              ' violates schema.',
                             ErrorException)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             ErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             ErrorException))
    .execute
end