class MidasClient::Transaction
Public Instance Methods
asynchronous_debit_transaction(*params)
click to toggle source
This method dispatches a debit payment transaction request, that's receive an authorization URL,¶ ↑
where the payer must authorize the transaction. Params: externalId: string (Transaction identification on the client application) externalDate: Date and time form client application - YYYY-MM-DDThh:mm:SS.sssTDZ - ISO8601 pan: DebitCard Number expirationMonth: expirationYear: holderName: customer/documentType: CPF/CNPJ customer/documentNumber: if CPF 11 digits else CNPJ 13 digits cvv: number (Security Code) amount: number (Only integer numbers, with the last two digits representing the cents. For example: 100 is equivalent to R$ 1,00) callbackUrl: string (URL used to notify the client application about the transaction authorization result. async notification ) redirectUrl: string (URL used to notify the client application that the transaction authorization result successful. ) errorUrl: string (URL used to notify the client application that the transaction authorization result failed) # Response: result: { success: true/false code: "XXX" message: "Some message to you" }, "authenticationUrl": "https://qasecommerce.cielo.com.br/web/index.cbmp?id=ac470d041f660e21d253a5741e59c5b4", "transactionToken":"6accbedb2da4f7bfbca5b5fed3669be6",
# File lib/midas_client/transaction.rb, line 159 def asynchronous_debit_transaction(*params) # Parametros são recebidos como um array de hash, pego o 1o item do array params = params.first # define o método de envio da requisição method = :post # monta a URL de chamada da requisição endpoint= get_env[:url] + EndPoints::OPERATIONS[:context] + EndPoints::OPERATIONS[:asynchronous_debit_transaction] # regulariza formato da data params[:externalDate] = (params[:externalDate].blank? ? Time.now.iso8601(1) : params[:externalDate]) # faz a chamada a plataforma de pagamento (MIDAS) request(method, endpoint, self.login, self.password, params) end
asynchronous_transaction(*params)
click to toggle source
This method dispatches a payment transaction creation request, already performing¶ ↑
the authorization and capture in only one step, but sending the response using the informed callback URL, in an asynchronous away. Params: externalId: string (Transaction identification on the client application) externalDate: Date and time form client application - YYYY-MM-DDThh:mm:SS.sssTDZ - ISO8601 cardToken: string (created by method card_store) cvv: number (Security Code) softDescriptor: string (Text to be shown on the credit card invoice entry) amount: number (Only integer numbers, with the last two digits representing the cents. For example: 100 is equivalent to R$ 1,00) instalments: number (1 to 12) callbackUrl: string (URL used to notify the client application about the transaction creation result. ) # Response: result: { success: true/false code: "XXX" message: "Some message to you" }, transactionToken: "65ffe2897b832cb89cb2063b74fbb143",
# File lib/midas_client/transaction.rb, line 113 def asynchronous_transaction(*params) # Parametros são recebidos como um array de hash, pego o 1o item do array params = params.first # define o método de envio da requisição method = :post # monta a URL de chamada da requisição endpoint= get_env[:url] + EndPoints::OPERATIONS[:context] + EndPoints::OPERATIONS[:asynchronous_transaction] # regulariza o formato da data params[:externalDate] = (params[:externalDate].blank? ? Time.now.iso8601(1) : params[:externalDate]) # faz a chamada a plataforma de pagamento (MIDAS) request(method, endpoint, self.login, self.password, params) end
cancellation(transaction_token)
click to toggle source
This method performs a cancellation in a already authorized transaction.¶ ↑
This is a is synchronous operation. Params: transactionToken: string (Transaction unique identification generated by our gateway and received in the transaction authorization response) Response: result: { success: true/false code: "XXX" message: "Some message to you" }
# File lib/midas_client/transaction.rb, line 262 def cancellation(transaction_token) # define o método de envio da requisição method = :put # monta a URL de chamada da requisição endpoint = get_env[:url] + EndPoints::OPERATIONS[:context] + EndPoints::OPERATIONS[:cancel].gsub('{transactionToken}', transaction_token) # faz a chamada a plataforma de pagamento (MIDAS) request(method, endpoint, self.login, self.password, {}) end
capture(transaction_token)
click to toggle source
This method performs a capture (confirmation) in a already authorized transaction.¶ ↑
This is a is synchronous operation. Params: transactionToken: string (Transaction unique identification generated by our gateway and received in the transaction authorization response) Response: result: { success: true/false code: "XXX" message: "Some message to you" }
# File lib/midas_client/transaction.rb, line 237 def capture(transaction_token) # define o método de envio da requisição method = :put # monta a URL de chamada da requisição endpoint = get_env[:url] + EndPoints::OPERATIONS[:context] + EndPoints::OPERATIONS[:confirm].gsub('{transactionToken}', transaction_token) # faz a chamada a plataforma de pagamento (MIDAS) request(method, endpoint, self.login, self.password, {}) end
card_store(*params)
click to toggle source
This method securely stores credit card's data (pan, expiration…)¶ ↑
and returns a token to be used to perform payment transactions. Params: externalId: number (Transaction identification on the client application) pan: number expirationMonth: number (format: MM) expirationYear: number (format: YYYY) holderName: string customer/documentType: string (values: {'CPF', 'CNPJ'}) customer/documentNumber: string Response success: { "result": { "success":"true", "code":"000", "message":"Success" }, "brand":"VISA", "cardToken":"2b5141a2209384e4266c8f7cbaf67a2d" } Response Failure { :result=>{ :success=>false, :code=>"120", :message=>"O numero do documento eh obrigatorio" } }
# File lib/midas_client/transaction.rb, line 36 def card_store(*params) # Parametros são recebidos como um array de hash, pego o 1o item do array params = params.first # define o método de envio da requisição method = :post # monta a URL de chamada da requisição endpoint= get_env[:url] + EndPoints::OPERATIONS[:context] + EndPoints::OPERATIONS[:store] # faz a chamada a plataforma de pagamento (MIDAS) request(method, endpoint, login, password, params) end
query_external_id(externalId)
click to toggle source
This method performs a query by a specific transaction's identifier, called external ID.¶ ↑
This is a is synchronous operation, using method GET Params: transactionToken: string (Transaction unique identification generated by customer) { "result": { "success": true, "code": "000", "message": "Sucesso" }, "pagging": { "limit": 1, "count": 1, "current": 1 }, "transactions": [ { "externalId": "906cb7ec", "externalDate": "2017-08-26T03:02:28.7", "paymentMethod": "CREDIT_CARD", "creditCard": { "brand": "VISA", "panLastDigits": "0308", "expirationMonth": 12, "expirationYear": 2020, "holderName": "CARLOS A C OLIVEIRA", "customer": { "documentType": "CPF", "documentNumber": "07564954744" } }, "amount": 12000, "instalments": 5, "callbackUrl": "http://coliveira.dynu.com:3001/callback/906cb7ec", "nsu": "464672", "authorizationCode": "123456", "token": "8935aa77e9e4ed962d594910f96bf73f", "status": "CAPTURED" } ] }
# File lib/midas_client/transaction.rb, line 370 def query_external_id(externalId) # define o método de envio da requisição method = :get # monta a URL de chamada da requisição endpoint = get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:by_external_id].gsub('{externalId}', externalId) request(method, endpoint, login, password, {}) end
query_transaction(transaction_token)
click to toggle source
This method performs a query by a specific transaction.¶ ↑
This is a is synchronous operation, using method GET Params: transactionToken: string (Transaction unique identification generated by our gateway and received in the transaction authorization response)# Response: result: { success: true/false code: "XXX" message: "Some message to you" }
# File lib/midas_client/transaction.rb, line 314 def query_transaction(transaction_token) # define o método de envio da requisição method = :get # monta a URL de chamada da requisição endpoint = get_env[:url] + EndPoints::OPERATIONS[:context] + EndPoints::OPERATIONS[:query_by_transaction].gsub('{transactionToken}', transaction_token) request(method, endpoint, login, password, {}) end
query_user_cards(document_type='CPF', document_number)
click to toggle source
This method performs a query to list all creditcards form a user.¶ ↑
This is a is synchronous operation, using method GET Params: documentType: string (CPF or CNPJ) documentNumber: string Response: result: { success: true/false code: "XXX" message: "Some message to you" }
# File lib/midas_client/transaction.rb, line 394 def query_user_cards(document_type='CPF', document_number) # define o método de envio da requisição method = :get # monta a URL de chamada da requisição endpoint = get_env[:url] + EndPoints::OPERATIONS[:context] + EndPoints::OPERATIONS[:cards_by_user].gsub('{documentType}', document_type).gsub('{documentNumber}', document_number) request(method, endpoint, login, password, {}) end
refund(transaction_token)
click to toggle source
This method performs a refund in a captured authorized transaction.¶ ↑
This is a is synchronous operation. Params: transactionToken: string (Transaction unique identification generated by our gateway and received in the transaction authorization response)# Response: result: { success: true/false code: "XXX" message: "Some message to you" }
# File lib/midas_client/transaction.rb, line 288 def refund(transaction_token) # define o método de envio da requisição method = :put # monta a URL de chamada da requisição endpoint = get_env[:url] + EndPoints::OPERATIONS[:context] + EndPoints::OPERATIONS[:refund].gsub('{transactionToken}', transaction_token) # faz a chamada a plataforma de pagamento (MIDAS) request(method, endpoint, self.login, self.password, {}) end
synchronous_transaction(*params)
click to toggle source
This method creates a payment transaction, already performing¶ ↑
the authorization and capture in only one step. Params: externalId: string (Transaction identification on the client application) externalDate: Date and time form client application - YYYY-MM-DDThh:mm:SS.sssTDZ - ISO8601 cardToken: string (created by method card_store) cvv: number (Security Code) amount: number (Only integer numbers, with the last two digits representing the cents. For example: 100 is equivalent to R$ 1,00) instalments: number (1 to 12) Response: result: { success: true/false code: "XXX" message: "Some message to you" }, transactionToken: "65ffe2897b832cb89cb2063b74fbb143", nsu: "99999"
# File lib/midas_client/transaction.rb, line 72 def synchronous_transaction(*params) # Parametros são recebidos como um array de hash, pego o 1o item do array params = params.first # define o método de envio da requisição method = :post # monta a URL de chamada da requisição endpoint= get_env[:url] + EndPoints::OPERATIONS[:context] + EndPoints::OPERATIONS[:synchronous_transaction] # regulariza o formato da data params[:externalDate] = params[:externalDate].blank? ? Time.now.iso8601(1) : params[:externalDate] # faz a chamada a plataforma de pagamento (MIDAS) request(method, endpoint, self.login, self.password, params) end