0

我正在使用 activemerchant 实施贝宝直接付款以下是代码

def credit_card_details
    credit_card = ActiveMerchant::Billing::CreditCard.new(
                :first_name         => 'Bob',
                :last_name          => 'Bobsen',
                :number             => '4242424242424242',
                :month              => '8',
                :year               => '2012',
                :verification_value => '123')

    errors.add(:expire_year, "Credit card expired") if credit_card.expired?
    errors.add(:cc_number, "invalid credit card details") unless credit_card.valid?

    if credit_card.valid?
      # Capture $10 from the credit card
      amount = 1000
      response = PAYPAL_GATEWAY.purchase(amount, credit_card)

      if response.success?
        puts "Successfully charged $#{sprintf("%.2f", amount / 100)} to the credit card #{credit_card.display_number}"
      else

        raise StandardError, response.inspect
      end
    end
  end

我正在尝试使用其他信用卡详细信息,但它导致“A 字段比服务器允许的长或短”这个错误。所以我用active_merchants github页面中指定的替换了cc详细信息仍然没有运气。我不明白出了什么问题?

4

1 回答 1

0

我认为您错过了 card_type 或分支。这两个中的一个已被弃用。试试看哪个有效。由于您错过了信用卡类型,因此字段可能未对齐或映射错误。

于 2013-06-21T15:43:35.920 回答