sharma I
Joined: 13 Jun 2008 Posts: 157
|
Posted: Wed Mar 31, 2010 12:30 pm Post subject: Integrating first data global payment gateway in rails |
|
|
Hi,
For this, we need to register for a sandbox account (test account) in firstdata.com website. By using the following url we can create a test account.
http://www.firstdata.com/gg/apply_test_account.htm
Here, we need to provide the required data like name, address,country etc. After submitting the form, we get a mail with the following data.
Your DBA store name is: "test"
Your store name is between the quotation marks ("): "1234567890"
Your user ID is between the quotation marks ("): "630030"
Your Temporary Password: 12345678
By using the below URL, we can login in the test site with the provided test details in first data global gateway website. Here, we need to login by using store name, userid and password.
https://www.staging.linkpointcentral.com/lpc/servlet/LPCLogin
1) After login into the site, we need to download a .pem file from “DOWNLOAD center” option under the SUPPORT tab. And place this .pem file in our rails application config folder.
2)Then we need to add the below lines of code in our environment.rb file
config.after_initialize do
ActiveMerchant::Billing::LinkpointGateway.pem_file = File.read(File.dirname(__FILE__) + '/1234567890.pem')
ActiveMerchant::Billing::Base.mode = :test
::GATEWAY = ActiveMerchant::Billing::LinkpointGateway.new(
:login => "1234567890"
)
end
3)After this, we have just add the below method in any one of the controller
def creditcard_process
creditcard = ActiveMerchant::Billing::CreditCard.new(
:number => '4743021568285472',
:verification_value => '123',
:month => 8,
:year => 2018,
:first_name => 'test',
:last_name => 'user',
:type => 'VISA'
)
if creditcard.valid?
@amount = 10
response = GATEWAY.authorize(@amount*100, creditcard,
:order_id => '123456',
:billing_address => {
:userid => 1,
:address1 => '1 Main St',
:city => 'San Jose',
:state => 'CA',
:country => 'US',
:zip => '95131'
},
:email => 'test@yahoo.com'
)
if response.message == 'APPROVED'
GATEWAY.capture(@amount,
response.authorization)
render :text => 'Success' and return
else
render :text => 'Fail' and return
end
else
render :text =>'Credit card not valid '
end
end
Here, GATEWAY.authorize method is used to check the authentication of the payment gateway user by using the .pem file. The authorized method return a value or message like APPROVED or DECLINED or NIL.
If the given details are approved by the global gateway then we are going to capture the amount from the user account by using the “capture” method.
After completion of the payment process, the main user get a mail with the corresponding payment process.
By using this payment gateway we can manage the reports very easily and can download the reports of the payment process.
Thank you,
Sharma |
|
sunil.silumala
Joined: 13 Feb 2013 Posts: 1
|
Posted: Wed Feb 13, 2013 1:33 pm Post subject: Getting Error |
|
|
Hello,
I am getting error 'Merchant config file is missing, empty or cannot be read'.
i have gave correct path of pem file and also tried all kind of permission.
can u pls help me.
i am using sandbox account. |
|