Search code examples
ruby-on-railsactivemerchant

Is it possible to change the amount from authorize to capture in ActiveMerchant?


I'm doing a function that authorize first the user's credit card information. From that I can get a response and able to save the transaction_id or authorization key w/c can be use to capture the money from Credit Card.

But I need to do it separate way, just to authorize the credit card info first. Since, authorizing the card requires the initial amount like for ex:

credit_card = ActiveMerchant::Billing::CreditCard.new(
 :number     => '4111111111111111',
 :month      => '8',
 :year       => '2009',
 :first_name => 'Tobias',
 :last_name  => 'Luetke',
 :verification_value  => '123'
)

# initial amount - 1000
response = gateway.authorize(1000, credit_card)

My BIG question now is that, is it possible to use the #capture:

with different amount, now 2000

gateway.capture(2000, response.authorization)


Solution

  • Yeah I think it is possible since both capture and authorize are standalone server calls,

    Authorization - You request an authorization when a customer makes a purchase. An authorization, provided by the customer’s card issuing bank, confirms the cardholder’s ability to pay, ensuring that the customer's credit card account is in good standing with sufficient funds to complete the purchase.

    Capture - After providing a service/product to the customer, you ‘capture’ the relevant information from the authorization and submit it in a capture/settlement request that your processor uses to initiate a funds transfer between the customer's credit card account and your checking account.

    Source

    So by definition it should be possible, but you would not know if the user will be able to pay the amount you intend to capture(if the amount is higher than the one in authorize call).