Class: MastercardCoreSdk::Api::AccessTokenApi

Inherits:
Object
  • Object
show all
Includes:
Client, Core, Exceptions, Tracker
Defined in:
lib/mastercard_core_sdk/api/access_token_api.rb

Overview

Invokes AccessTokenApi.

Class Method Summary collapse

Class Method Details

.create(oauth_token, oauth_verifier, api_config = nil) ⇒ AccessTokenResponse

Note:

Since version 1.2.0, the method signature for create has changed.

This API call is used to exchange a request token for a long access token from the Masterpass service. For Pairing during checkout, this service will need to be called twice:

  1. To request the checkout access token, which is used to retrieve checkout data.

  2. To request the long access token, which is used to retrieve precheckout data.

You will need the Request Token (oauth_token) and Verifier (oauth_verifier) from the merchant callback to get an access token.

Parameters:

  • oauth_token

    the oauth token, which is used to retrieve checkout data.

  • oauth_verifier

    the oauth verifier.

  • api_config (defaults to: nil)

    Optional ApiConfig object.

Returns:



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/mastercard_core_sdk/api/access_token_api.rb', line 23

def self.create(oauth_token, oauth_verifier, api_config = nil)
  path = "/oauth/consumer/v1/access_token"
  
  service_request = ServiceRequest.new
  service_request.headers = {"oauth_verifier" => oauth_verifier, "oauth_token" => oauth_token}  
  service_request.content_type = "application/xml"
  api_client = ApiClient.new(api_config)

  api_client.api_tracker = TokenApiTracker.new
  api_client.error_handler = ErrorHandler.new
  return api_client.call(path, service_request, "POST", AccessTokenResponse)
end