speedway 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,65 @@
1
+ require 'savon'
2
+ require 'akami'
3
+
4
+ module Speedway
5
+ class RapidAPI
6
+ attr_reader :customer_id, :user_name, :password
7
+
8
+ def initialize(customer_id, user_name, password)
9
+ @client = initialize_client
10
+
11
+ @customer_id = customer_id
12
+ @user_name = user_name
13
+ @password = password
14
+ end
15
+
16
+
17
+ def create_access_code(customer, payment, redirect_url)
18
+ @client.request :create_access_code do
19
+ soap.body = {
20
+ 'request' => {
21
+ 'Authentication' => credentials,
22
+ 'Customer' => {
23
+ 'FirstName' => customer[:first_name],
24
+ 'LastName' => customer[:last_name]
25
+ },
26
+ 'Payment' => {
27
+ 'TotalAmount' => (payment[:total_amount] * 100).to_i
28
+ # 'InvoiceNumber' => invoice
29
+ },
30
+ 'RedirectUrl' => redirect_url
31
+ }
32
+ }
33
+ end
34
+ end
35
+
36
+
37
+ def get_access_code_result(access_code)
38
+ @client.request :get_access_code_result do
39
+ soap.body = {
40
+ 'request' => {
41
+ 'Authentication' => credentials,
42
+ 'AccessCode' => access_code
43
+ }
44
+ }
45
+ end
46
+ end
47
+
48
+
49
+ protected
50
+
51
+ def credentials
52
+ {
53
+ 'CustomerID' => customer_id,
54
+ 'Username' => user_name,
55
+ 'Password' => password
56
+ }
57
+ end
58
+
59
+ def initialize_client
60
+ Savon.client do |wsdl, http, wsse|
61
+ wsdl.document = "https://au.ewaypayments.com/hotpotato/soap.asmx?wsdl"
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,49 @@
1
+ #<ewaygateway>
2
+ # <ewayCustomerID>12345678</ewayCustomerID>
3
+ # <ewayOriginalTrxnNumber>1234567</ewayOriginalTrxnNumber>
4
+ # <ewayTotalAmount>10</ewayTotalAmount>
5
+ # <ewayCardExpiryMonth>04</ewayCardExpiryMonth>
6
+ # <ewayCardExpiryYear>09</ewayCardExpiryYear>
7
+ # <ewayOption1></ewayOption1>
8
+ # <ewayOption2></ewayOption2>
9
+ # <ewayOption3></ewayOption3>
10
+ # <ewayRefundPassword>password123</ewayRefundPassword>
11
+ #</ewaygateway>
12
+
13
+ require 'nokogiri'
14
+
15
+ module Speedway
16
+ class RefundAPI
17
+
18
+ attr_accessor :customer_id, :password
19
+
20
+ def initialize(customer_id, password)
21
+ @customer_id = customer_id
22
+ @password = password
23
+ end
24
+
25
+
26
+ def send_payment_refund(original_transaction, total_amount)
27
+ builder = Nokogiri::XML::Builder.new do |xml|
28
+ xml.ewaygateway {
29
+ xml.ewayCustomerID customer_id
30
+ xml.ewayOriginalTrxnNumber original_transaction
31
+ xml.ewayTotalAmount (total_amount * 100).to_i
32
+ xml.ewayRefundPassword password
33
+ xml.ewayCardExpiryMonth nil
34
+ xml.ewayCardExpiryYear nil
35
+ xml.ewayOption1 nil
36
+ xml.ewayOption2 nil
37
+ xml.ewayOption3 nil
38
+ }
39
+ end
40
+
41
+ request = HTTPI::Request.new
42
+ request.url = 'https://www.eway.com.au/gateway/xmlpaymentrefund.asp'
43
+ request.body = builder.to_xml
44
+ response = HTTPI.post(request)
45
+ end
46
+
47
+
48
+ end
49
+ end
@@ -1,3 +1,3 @@
1
1
  module Speedway
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/speedway.rb CHANGED
@@ -1,69 +1,5 @@
1
1
  require 'speedway/version'
2
2
  require 'speedway/response_codes'
3
- require 'savon'
4
- require 'akami'
5
3
 
6
- module Speedway
7
- class RapidAPI
8
- attr_reader :customer_id, :user_name, :password
9
-
10
- def initialize(customer_id, user_name, password)
11
- @client = initialize_client
12
-
13
- @customer_id = customer_id
14
- @user_name = user_name
15
- @password = password
16
-
17
- puts @client.wsdl.soap_actions
18
- end
19
-
20
-
21
- def create_access_code(customer, payment, redirect_url)
22
- @client.request :create_access_code do
23
- soap.body = {
24
- 'request' => {
25
- 'Authentication' => credentials,
26
- 'Customer' => {
27
- 'FirstName' => customer[:first_name],
28
- 'LastName' => customer[:last_name]
29
- },
30
- 'Payment' => {
31
- 'TotalAmount' => (payment[:total_amount] * 100).to_i
32
- # 'InvoiceNumber' => invoice
33
- },
34
- 'RedirectUrl' => redirect_url
35
- }
36
- }
37
- end
38
- end
39
-
40
-
41
- def get_access_code_result(access_code)
42
- @client.request :get_access_code_result do
43
- soap.body = {
44
- 'request' => {
45
- 'Authentication' => credentials,
46
- 'AccessCode' => access_code
47
- }
48
- }
49
- end
50
- end
51
-
52
-
53
- protected
54
-
55
- def credentials
56
- {
57
- 'CustomerID' => customer_id,
58
- 'Username' => user_name,
59
- 'Password' => password
60
- }
61
- end
62
-
63
- def initialize_client
64
- Savon.client do |wsdl, http, wsse|
65
- wsdl.document = "https://au.ewaypayments.com/hotpotato/soap.asmx?wsdl"
66
- end
67
- end
68
- end
69
- end
4
+ require 'speedway/rapid_api'
5
+ require 'speedway/refund_api'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: speedway
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-01 00:00:00.000000000 Z
12
+ date: 2012-08-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: akami
16
- requirement: &70257517903540 !ruby/object:Gem::Requirement
16
+ requirement: &70353450116480 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70257517903540
24
+ version_requirements: *70353450116480
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: savon
27
- requirement: &70257517903080 !ruby/object:Gem::Requirement
27
+ requirement: &70353450108620 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70257517903080
35
+ version_requirements: *70353450108620
36
36
  description: eWay RapidAPI Integration
37
37
  email:
38
38
  - ben.askins@gmail.com
@@ -46,6 +46,8 @@ files:
46
46
  - README.md
47
47
  - Rakefile
48
48
  - lib/speedway.rb
49
+ - lib/speedway/rapid_api.rb
50
+ - lib/speedway/refund_api.rb
49
51
  - lib/speedway/response_codes.rb
50
52
  - lib/speedway/version.rb
51
53
  - speedway.gemspec