VPaypal 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,165 @@
1
+ require File.dirname(__FILE__)+"/../lib/v_paypal"
2
+ require 'yaml'
3
+ require 'test/unit'
4
+ class VPaypalTest < Test::Unit::TestCase
5
+
6
+ def test_with_set_express_checkout
7
+ @request_params = {
8
+ "OrderTotal" => "10.00",
9
+ "CancelURL" => "http://foo1.com",
10
+ "ReturnURL" => "http://foo2.com",
11
+ "sandbox_username" => "biz_api2.dumb.com",
12
+ "sandbox_password" => "gemvpaypal"
13
+ }
14
+ endpoint_url = ""
15
+ vpp = VPaypal::PaypalPro.new(endpoint_url)
16
+ res_2 = vpp.vRequest("SetExpressCheckout",@request_params)
17
+ client_1 = PayPalAPIAAInterface.new
18
+ client_1.options['protocol.http.ssl_config.verify_mode'] = OpenSSL::SSL::VERIFY_PEER
19
+ client_1.options['protocol.http.ssl_config.ca_file'] = File.dirname(__FILE__)+'/../certs/api_cert_chain.crt'
20
+ client_1.options['protocol.http.ssl_config.client_cert'] = File.dirname(__FILE__)+'/../certs/client.cert'
21
+ client_1.options['protocol.http.ssl_config.client_key'] = File.dirname(__FILE__)+'/../certs/client.keys'
22
+
23
+ client_1.headerhandler << VPaypal::RequesterCredentialsHandler.new(@request_params["sandbox_username"], @request_params["sandbox_password"],'')
24
+
25
+ req_1 =SetExpressCheckoutReq.new
26
+ type_1 = SetExpressCheckoutRequestType.new
27
+ type_1.version = "2.0"
28
+ details_1 = SetExpressCheckoutRequestDetailsType.new
29
+ type_1.setExpressCheckoutRequestDetails = details_1
30
+ ns_1 = "urn:ebay:apis:eBLBaseComponents"
31
+ otqname_1 = XSD::QName.new(ns_1, "OrderTotal")
32
+ otele_1 = SOAP::SOAPElement.new(otqname_1, @request_params["OrderTotal"])
33
+ otele_1.extraattr["currencyID"] = "USD"
34
+
35
+ details_1.orderTotal = otele_1
36
+ details_1.returnURL = @request_params["ReturnURL"]
37
+ details_1.cancelURL = @request_params["CancelURL"]
38
+
39
+ req_1.setExpressCheckoutRequest=type_1
40
+ res_1 = client_1.setExpressCheckout(req_1)
41
+ print_error(res_1,res_2)
42
+ assert_equal(res_1.ack.to_s, res_2.ack.to_s)
43
+ end
44
+ def test_with_do_direct_payment
45
+ endpoint_url = ""
46
+ vpp = VPaypal::PaypalPro.new(endpoint_url)
47
+ @request_params = {"PaymentActionCode" => "Sale",
48
+ "OrderTotal"=>"10.00" ,
49
+ "FirstName"=> "First",
50
+ "LastName" => "Last",
51
+ "Street1"=>"Some street" ,
52
+ "StateOrProvince"=>"ny",
53
+ "CityName"=>"new york",
54
+ "Country"=>"US",
55
+ "PostalCode" => "10013",
56
+ "CreditCardType" => "Visa",
57
+ "CreditCardNumber" =>"4747586528909458",
58
+ "ExpMonth" => "1",
59
+ "ExpYear" => "2007" ,
60
+ "CVV2" => "000",
61
+ "IPAddress" => "61.11.28.22",
62
+ "sandbox_username" => "biz_api2.dumb.com",
63
+ "sandbox_password" => "gemvpaypal"
64
+ }
65
+ @test_request_params = { "PaymentAction-PaymentActionCodeType" => @request_params["PaymentActionCode"],
66
+ "PaymentDetails" =>
67
+ {"OrderTotal"=> @request_params["OrderTotal"]
68
+ },
69
+ "CreditCard-CreditCardDetails" =>
70
+ {"CardOwner-PayerInfo" =>
71
+ {"PayerName-PersonName" =>
72
+ {"FirstName"=> @request_params["FirstName"],
73
+ "LastName" => @request_params["LastName"]
74
+ },
75
+ "Address" =>
76
+ { "Street1"=>@request_params["Street1"] ,
77
+ "StateOrProvince"=>@request_params["StateOrProvince"],
78
+ "CityName"=> @request_params["CityName"],
79
+ "Country"=> @request_params["Country"],
80
+ "PostalCode" => @request_params["PostalCode"],
81
+ } ,
82
+ },
83
+ "CreditCardType" => @request_params["CreditCardType"],
84
+ "CreditCardNumber" => @request_params["CreditCardNumber"],
85
+ "ExpMonth" => @request_params["ExpMonth"],
86
+ "ExpYear" => @request_params["ExpYear"] ,
87
+ "CVV2" => @request_params["CVV2"]
88
+ },
89
+
90
+ "IPAddress" => @request_params["IPAddress"]
91
+ }
92
+ res_2 = vpp.vRequest("DoDirectPayment",@test_request_params)
93
+ client_1 = PayPalAPIAAInterface.new
94
+ client_1.options['protocol.http.ssl_config.verify_mode'] = OpenSSL::SSL::VERIFY_PEER
95
+ client_1.options['protocol.http.ssl_config.ca_file'] = File.dirname(__FILE__)+'/../certs/api_cert_chain.crt'
96
+ client_1.options['protocol.http.ssl_config.client_cert'] = File.dirname(__FILE__)+'/../certs/client.cert'
97
+ client_1.options['protocol.http.ssl_config.client_key'] = File.dirname(__FILE__)+'/../certs/client.keys'
98
+
99
+ client_1.headerhandler << VPaypal::RequesterCredentialsHandler.new(@request_params["sandbox_username"], @request_params["sandbox_password"],'')
100
+
101
+ req_1 =DoDirectPaymentReq.new
102
+ type_1 = DoDirectPaymentRequestType.new
103
+ type_1.version = "2.0"
104
+ details_1 = DoDirectPaymentRequestDetailsType.new
105
+ type_1.doDirectPaymentRequestDetails = details_1
106
+ ns_1 = "urn:ebay:apis:eBLBaseComponents"
107
+ otqname_1 = XSD::QName.new(ns_1, "OrderTotal")
108
+ otele_1 = SOAP::SOAPElement.new(otqname_1, @request_params["OrderTotal"])
109
+ otele_1.extraattr["currencyID"] = "USD"
110
+ details_1.paymentAction = PaymentActionCodeType::Sale
111
+ paymentDetails = PaymentDetailsType.new
112
+ paymentDetails.orderTotal = otele_1
113
+ details_1.paymentDetails = paymentDetails
114
+ creditCard =CreditCardDetailsType.new
115
+ payerInfo = PayerInfoType.new
116
+ payerName = PersonNameType.new
117
+ payerName.firstName = @request_params["FirstName"]
118
+ payerName.lastName = @request_params["LastName"]
119
+ payerInfo.payerName = payerName
120
+ address = AddressType.new
121
+ address.street1 = @request_params["Street1"]
122
+ address.cityName = @request_params["CityName"]
123
+ address.stateOrProvince = @request_params["StateOrProvince"]
124
+ address.country = @request_params["Country"]
125
+ address.postalCode = @request_params["PostalCode"]
126
+ payerInfo.address = address
127
+ creditCard.cardOwner = payerInfo
128
+ creditCard.creditCardType = CreditCardTypeType::Visa
129
+ creditCard.creditCardNumber = @request_params["CreditCardNumber"]
130
+ creditCard.expMonth = @request_params["ExpMonth"]
131
+ creditCard.expYear = @request_params["ExpYear"]
132
+ creditCard.cVV2 = @request_params["CVV2"]
133
+ details_1.creditCard = creditCard
134
+ details_1.iPAddress = @request_params["IPAddress"]
135
+ req_1.doDirectPaymentRequest=type_1
136
+ res_1 = client_1.doDirectPayment(req_1)
137
+ print_error(res_1,res_2)
138
+ assert_equal(res_1.ack.to_s, res_2.ack.to_s)
139
+ end
140
+
141
+ def print_error(res_1,res_2)
142
+ msg=""
143
+ if(res_1.ack=="Failure")
144
+ er= res_1.errors
145
+ msg += show_error(er)+" in res_1."
146
+ end
147
+ if(res_2.ack=="Failure")
148
+ er= res_2.errors
149
+ msg += show_error(er)+" in res_2."
150
+ end
151
+ if msg!=""
152
+ assert_raise(msg)
153
+ end
154
+ end
155
+
156
+ def show_error(er=nil)
157
+ if !er[0].nil?
158
+ er.each do |error|
159
+ m += "#{error.longMessage}<br/>"
160
+ end
161
+ else
162
+ m = "#{er.longMessage}<br/>"
163
+ end
164
+ end
165
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.11
3
+ specification_version: 1
4
+ name: VPaypal
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.0.1
7
+ date: 2006-02-27 00:00:00 -06:00
8
+ summary: A Library to use Paypal Pro.
9
+ require_paths:
10
+ - lib
11
+ email: ritukamthan@gmail.com
12
+ homepage: http://rubyforge.org/projects/vpaypal/
13
+ rubyforge_project:
14
+ description:
15
+ autorequire: v_paypal
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ authors:
29
+ - Ritu Kamthan
30
+ files:
31
+ - certs/api_cert_chain.crt
32
+ - certs/client.cert
33
+ - certs/client.keys
34
+ - config/v_paypal.yml
35
+ - test/v_paypal_test.rb
36
+ - lib/v_paypal.rb
37
+ - lib/v_paypal
38
+ - lib/v_paypal/paypal_pro.rb
39
+ - lib/v_paypal/requester_credentials_handler.rb
40
+ - lib/v_paypal/default.rb
41
+ - lib/v_paypal/defaultDriver.rb
42
+ - lib/v_paypal/PayPalAPIInterfaceServiceClient.rb
43
+ - README
44
+ test_files:
45
+ - test/v_paypal_test.rb
46
+ rdoc_options: []
47
+
48
+ extra_rdoc_files:
49
+ - README
50
+ executables: []
51
+
52
+ extensions: []
53
+
54
+ requirements: []
55
+
56
+ dependencies: []
57
+