Method: ActiveMerchant::Billing::BluePayGateway#refund

Defined in:
lib/active_merchant/billing/gateways/blue_pay.rb

#refund(money, identification, options = {}) ⇒ Object

Performs a credit.

This transaction indicates that money should flow from the merchant to the customer.

Parameters

  • money – The amount to be credited to the customer as an Integer value in cents.

  • payment_object – This can either be one of three things: A CreditCard object, A Check object, or a token. The token is called the Master ID. This is a unique transaction ID returned from a previous transaction. This token associates all the stored information for a previous transaction. If the payment_object is a token, then the transaction type will reverse a previous capture or purchase transaction, returning the funds to the customer. If the amount is nil, a full credit will be processed. This is referred to a REFUND transaction in BluePay. If the payment_object is either a CreditCard or Check object, then the transaction type will be an unmatched credit placing funds in the specified account. This is referred to a CREDIT transaction in BluePay.

  • options – A hash of parameters.



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 159

def refund(money, identification, options = {})
  if identification && !identification.kind_of?(String)
    ActiveMerchant.deprecated 'refund should only be used to refund a referenced transaction'
    return credit(money, identification, options)
  end

  post = {}
  post[:PAYMENT_ACCOUNT] = ''
  post[:MASTER_ID]  = identification
  post[:TRANS_TYPE] = 'REFUND'
  post[:DOC_TYPE] = options[:doc_type] if options[:doc_type]
  post[:NAME1] = options[:first_name] || ''
  post[:NAME2] = options[:last_name] if options[:last_name]
  post[:ZIP] = options[:zip] if options[:zip]
  add_invoice(post, options)
  add_address(post, options)
  add_customer_data(post, options)
  commit('CREDIT', money, post, options)
end