Class: PaypalServerSdk::VaultController
- Inherits:
-
BaseController
- Object
- BaseController
- PaypalServerSdk::VaultController
- Defined in:
- lib/paypal_server_sdk/controllers/vault_controller.rb
Overview
VaultController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#create_payment_token(options = {}) ⇒ ApiResponse
Creates a Payment Token from the given payment source and adds it to the Vault of the associated customer.
-
#create_setup_token(options = {}) ⇒ ApiResponse
Creates a Setup Token from the given payment source and adds it to the Vault of the associated customer.
-
#delete_payment_token(id) ⇒ ApiResponse
Delete the payment token associated with the payment token id.
-
#get_payment_token(id) ⇒ ApiResponse
Returns a readable representation of vaulted payment source associated with the payment token id.
-
#get_setup_token(id) ⇒ ApiResponse
Returns a readable representation of temporarily vaulted payment source associated with the setup token id.
-
#list_customer_payment_tokens(options = {}) ⇒ ApiResponse
Returns all payment tokens for a customer.
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.
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( = {}) 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(['body'])) .header_param(new_parameter(['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.
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( = {}) 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(['body'])) .header_param(new_parameter(['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.
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.
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.
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.
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( = {}) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/v3/vault/payment-tokens', Server::DEFAULT) .query_param(new_parameter(['customer_id'], key: 'customer_id')) .query_param(new_parameter(['page_size'], key: 'page_size')) .query_param(new_parameter(['page'], key: 'page')) .query_param(new_parameter(['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 |