I am trying to implement paypal payment gateway using activemerchet but getting error-A field was longer or shorter than the server allows
i am using credrntials of pro account. I saw other SO questions but it was not helpful
require 'rubygems'
require 'active_merchant'
ActiveMerchant::Billing::Base.mode = :test
gateway = ActiveMerchant::Billing::TrustCommerceGateway.new(
:login => 'XXX@gmail.com',
:password => 'my_password',
:signature => 'my_signature')
credit_card = ActiveMerchant::Billing::CreditCard.new(
:first_name => 'f_name',
:last_name => 'l_name',
:number => '4032034467080704',
:month => '9',
:year => '2021',
:verification_value => '123',
:brand => 'VISA'
)
AMOUNT = 1000
def purchase_options
{
ip: "127.0.0.1",
billing_address: {
name: "Flaying Cakes",
address1: "123 5th Av.",
city: "New York",
state: "NY",
country: "US",
zip: "10001"
}
}
end
if credit_card.validate.empty?
response = gateway.purchase(AMOUNT, credit_card, purchase_options)
if response.success?
puts "Successfully charged to the credit card #{credit_card.display_number}"
else
raise StandardError, response.message
end
else
puts "credit card is not valid #{credit_card.errors.full_messages.join(". ")}"
end
I changed
gateway = ActiveMerchant::Billing::TrustCommerceGateway.new
to
gateway = ActiveMerchant::Billing::PaypalGateway.new
and it worked fine.