Class: ShellSmartPayApi::PartnerNotificationController
- Inherits:
-
BaseController
- Object
- BaseController
- ShellSmartPayApi::PartnerNotificationController
- Defined in:
- lib/shell_smart_pay_api/controllers/partner_notification_controller.rb
Overview
PartnerNotificationController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#cancel_fueling(body: nil) ⇒ void
Enables Shell to inform partner that a Mobile Payment transaction has been cancelled by Shell as an error/issue occured.
-
#finalise_fueling(body: nil) ⇒ void
Enables Shell to inform partner of the successful completion of a transaction.
-
#partner_token(grant_type, client_id, client_secret) ⇒ AccessTokenResponse
To access the Partner’s endpoints, for sending callback messages, Shell will need to connect to the Partner API end points.
Methods inherited from BaseController
#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent
Constructor Details
This class inherits a constructor from ShellSmartPayApi::BaseController
Instance Method Details
#cancel_fueling(body: nil) ⇒ void
This method returns an undefined value.
Enables Shell to inform partner that a Mobile Payment transaction has been cancelled by Shell as an error/issue occured. Note this needs to be implemented over HTTPS
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/shell_smart_pay_api/controllers/partner_notification_controller.rb', line 76 def cancel_fueling(body: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/cancelFueling', Server::SHELL) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .body_serializer(proc do |param| param.to_json unless param.nil? end)) .response(new_response_handler .is_response_void(true) .local_error('400', 'Bad Request', APIException) .local_error('401', 'Unauthorized', APIException)) .execute end |
#finalise_fueling(body: nil) ⇒ void
This method returns an undefined value.
Enables Shell to inform partner of the successful completion of a transaction. Note this needs to be implemented over HTTPS
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/shell_smart_pay_api/controllers/partner_notification_controller.rb', line 52 def finalise_fueling(body: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/finaliseFueling', Server::SHELL) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .body_serializer(proc do |param| param.to_json unless param.nil? end)) .response(new_response_handler .is_response_void(true) .local_error('400', 'Bad Request', APIException) .local_error('401', 'Unauthorized', APIException)) .execute end |
#partner_token(grant_type, client_id, client_secret) ⇒ AccessTokenResponse
To access the Partner’s endpoints, for sending callback messages, Shell will need to connect to the Partner API end points. It is recemmended that the partner offers OAuth 2.0 as a standard for call back APIs and will require the OAuth 2.0 token for authentication. Note this needs to be implemented over HTTPS grant typee refers to the way an application gets an access token. OAuth 2.0 defines several grant types, including the authorization code flow. you will receive a client ID and a client secret. The client ID is considered public information, and is used to build login URLs, or included in Javascript source code on a page. app, you will receive a client ID and a client secret. The client ID is considered public information, and is used to build login URLs, or included in Javascript source code on a page. The client secret must be kept confidential.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/shell_smart_pay_api/controllers/partner_notification_controller.rb', line 27 def partner_token(grant_type, client_id, client_secret) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/token', Server::SHELL) .form_param(new_parameter(grant_type, key: 'grant_type')) .form_param(new_parameter(client_id, key: 'client_id')) .form_param(new_parameter(client_secret, key: 'client_secret')) .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type')) .header_param(new_parameter('application/json', key: 'accept'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(AccessTokenResponse.method(:from_hash)) .local_error('401', 'Unauthorized', AccessTokenErrorException)) .execute end |