0

Trustcommerce で Activemerchant をテストするために使用している purchase.rb という名前のファイルがあります。

"rubygems" が必要 "active_merchant" が必要

TrustCommerce テスト サーバーを使用する

ActiveMerchant::Billing::Base.mode = :test amount = 1000

credit_card = ActiveMerchant::Billing::CreditCard.new(
             :first_name         => 'againchangeD',
             :last_name          => 'Tessdsdst',
             :number             => '4242424242424242',
             :month              => '8',
             :year               => '2012',
             :verification_value => '123'

           )


billing_address = { :address1 => '9909 Down the Road',
    :city => 'San Francisco', :state => 'CA',
    :country => 'US', :zip => '23456', :phone => '(555)555-5555'}


options = {:billing_address => billing_address}

#カードを検証すると、カードの種類が自動的に検出されます

if credit_card.valid?

# TrustCommerce サービスのゲートウェイ オブジェクトを作成します

gateway = ActiveMerchant::Billing::TrustCommerceGateway.new(
           :login => "xxxxxx",
           :password => "xxxxxx"
         )

# response = gateway.authorize(金額, credit_card)

# これは前に実行された authorize() でサンドボックスから受け取った transid です

   trans_id = 027-0004842047
   response = gateway.capture(amount,trans_id)


   if response.success?
       good = 'yes'
   puts "Successful #{good}"
   else
       puts "NO"
       raise StandardError, response.message
   end

終わり

端末で ruby​​ purchase.rb を実行すると、「027-0004842047 のため無効な 8 進数です。これを回避する方法を知っている人はいますか?このようなファイルを ruby​​ コマンドで実行するのではなく、実際に Rails アプリをビルドした場合に違いはありますか? ありがとう

4

1 に答える 1

0

愚かな私...

これで問題は解決しました: trans_id = '027-0004842047'

私はそれを文字列として扱わなければなりませんでした

于 2011-05-11T05:10:52.517 に答える