-
-
Save CameronGilroy/5925769 to your computer and use it in GitHub Desktop.
Pin is working now & the code has been updated - eWay is still giving some errors :(
Trying to get Pin or eWay to work.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"email":"[email protected]","ip":"10.0.0.1","description":"200 Web 2.0 M&Ms","address_line1":"42 Sevenoaks St","address_line2":"","address_city":"Perth","address_postcode":"6454","address_state":"WA","address_country":"Australia"} | |
{"params":{"error":"invalid_resource","error_description":"One or more parameters were missing or invalid.","messages":[{"param":"card.address_line1","code":"card_address_line1_invalid","message":"Card address line1 can't be blank"},{"param":"card.address_city","code":"card_address_city_invalid","message":"Card address city can't be blank"},{"param":"card.address_country","code":"card_address_country_invalid","message":"Card address country can't be blank"}]},"message":"One or more parameters were missing or invalid.","success":false,"test":true,"authorization":null,"fraud_review":null,"avs_result":{"code":null,"message":null,"street_match":null,"postal_match":null},"cvv_result":{"code":null,"message":null}} | |
Error: One or more parameters were missing or invalid. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
opening connection to test-api.pin.net.au... | |
opened | |
<- "POST /1/charges HTTP/1.1\r\nContent-Type: application/json\r\nAuthorization: Basic Nk81NFc4T1NmUW9UamJvUlBHWDZ2QTo=\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: test-api.pin.net.au\r\nContent-Length: 227\r\n\r\n" | |
<- "{\"amount\":\"1000\",\"currency\":\"AUD\",\"email\":\"[email protected]\",\"ip_address\":\"10.0.0.1\",\"description\":\"200 description\",\"card\":{\"number\":\"4024007148673576\",\"expiry_month\":1,\"expiry_year\":2014,\"cvc\":\"123\",\"name\":\"name name\"}}" | |
-> "HTTP/1.1 422 Unprocessable Entity\r\n" | |
-> "Cache-Control: no-cache\r\n" | |
-> "Content-Type: application/json; charset=utf-8\r\n" | |
-> "Date: Thu, 04 Jul 2013 07:34:21 GMT\r\n" | |
-> "Server: Apache/2.2.20 (Ubuntu)\r\n" | |
-> "Status: 422\r\n" | |
-> "Strict-Transport-Security: max-age=31536000\r\n" | |
-> "Vary: User-Agent\r\n" | |
-> "X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11\r\n" | |
-> "X-Rack-Cache: invalidate, pass\r\n" | |
-> "X-Request-Id: 03bba484c7a5454ab398d1314a9400a8\r\n" | |
-> "X-Runtime: 0.023175\r\n" | |
-> "X-UA-Compatible: IE=Edge,chrome=1\r\n" | |
-> "Content-Length: 453\r\n" | |
-> "Connection: Close\r\n" | |
-> "\r\n" | |
reading 453 bytes... | |
-> "" | |
-> "{\"error\":\"invalid_resource\",\"error_description\":\"One or more parameters were missing or invalid.\",\"messages\":[{\"param\":\"card.address_line1\",\"code\":\"card_address_line1_invalid\",\"message\":\"Card address line1 can't be blank\"},{\"param\":\"card.address_city\",\"code\":\"card_address_city_invalid\",\"message\":\"Card address city can't be blank\"},{\"param\":\"card.address_country\",\"code\":\"card_address_country_invalid\",\"message\":\"Card address country can't be blank\"}]}" | |
read 453 bytes | |
Conn close | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "activemerchant" | |
require "active_support/core_ext" | |
ActiveMerchant::Billing::Base.mode = :test | |
# gateway = ActiveMerchant::Billing::EwayRapidGateway.new( | |
# :login => "api_key", | |
# :password => "password" | |
# ) | |
# ActiveMerchant::Billing::EwayRapidGateway.wiredump_device = File.new(File.join(["eway.log"]), "a") | |
gateway = ActiveMerchant::Billing::PinGateway.new( | |
:api_key => "api_key" | |
) | |
ActiveMerchant::Billing::PinGateway.wiredump_device = File.new(File.join(["pin.log"]), "a") | |
credit_card = ActiveMerchant::Billing::CreditCard.new( | |
:brand => "visa", | |
:number => "4200000000000000", | |
:verification_value => "123", | |
:month => 1, | |
:year => Time.now.year+1, | |
:first_name => "name", | |
:last_name => "name" | |
) | |
options = { | |
:email => '[email protected]', | |
:ip => '10.0.0.1', | |
:description => 'description', | |
:address => { | |
:address1 => '15 Edwards St', | |
:address2 => '', | |
:city => 'Young', | |
:zip => '2594', | |
:state => 'NSW', | |
:country => 'Australia' | |
} | |
} | |
if credit_card.valid? | |
puts options.to_json | |
# or gateway.purchase to do both authorize and capture | |
response = gateway.purchase(1000, credit_card, options) | |
if response.success? | |
# gateway.capture(1000, response.authorization) - This is not needed if it is done as a gateway.purchase | |
puts "Purchase complete!" | |
else | |
puts response.to_json | |
puts "Error: #{response.message}" | |
end | |
else | |
puts "Error: credit card is not valid. #{credit_card.errors.full_messages.join('. ')}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment