Active Merchant は、コードを大幅に変更することなくゲートウェイを自由に変更できるため、はるかに柔軟な選択肢です。元の質問は、BT 独自の API を使用する方法ではなく、Active Merchant と統合する方法でした。これが、コードを掘り下げた後に見つけた答えです。公開鍵、秘密鍵、販売者 ID は、[アカウント] -> [マイ ユーザー] -> [API キー] の下にあります。
gateway = ActiveMerchant::Billing::BraintreeGateway.new(
:merchant_id => 'Your Merchant ID',
:public_key => 'Your Public Key',
:private_key => 'Your Private Key'
)
creditcard = ActiveMerchant::Billing::CreditCard.new(
:type => 'visa',
:number => '41111111111111111',
:month => 10,
:year => 2014,
:first_name => 'Bob',
:last_name => 'Bobsen'
)
response = gateway.purchase(1000, creditcard)
STDERR.puts response.success?
STDERR.puts response.message
STDERR.puts response.authorization