payza 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- Copyright 2012 YOURNAME
1
+ Copyright 2012 Spiridon Alin
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,3 +1,31 @@
1
1
  module Payza
2
- require 'payza/mass_pay_api'
2
+
3
+ class Payza
4
+
5
+ def initialize(sandbox = false)
6
+ type = sandbox ? "sandbox" : "live"
7
+ config = YAML.load_file("#{Rails.root}/config/payza.yml") rescue nil
8
+ if config
9
+ @url = config[type]["url"]
10
+ @myUserName = config[type]["user"]
11
+ @apiPassword = config[type]["pass"]
12
+ end
13
+ end
14
+
15
+ def call_payza(data, method)
16
+ data.merge!({"USER" => @myUserName, "PASSWORD" => @apiPassword})
17
+ qs = {}
18
+ data.each do |key, value|
19
+ qs[key.to_s.upcase] = URI.escape(value.to_s)
20
+ end
21
+
22
+ options = {:body => qs}
23
+ parseResponse HTTParty.post(@url+method, options)
24
+ end
25
+
26
+ def parseResponse(input)
27
+ @responseArray = Rack::Utils.parse_nested_query(input)
28
+ end
29
+ end
30
+
3
31
  end
@@ -1,3 +1,3 @@
1
1
  module Payza
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payza
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,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-15 00:00:00.000000000 Z
12
+ date: 2012-09-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -28,7 +28,7 @@ dependencies:
28
28
  - !ruby/object:Gem::Version
29
29
  version: 3.2.6
30
30
  - !ruby/object:Gem::Dependency
31
- name: curb
31
+ name: HTTParty
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
@@ -43,30 +43,13 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: sqlite3
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- description: ! 'A simple gem for the Payza payment network - MassPay only '
46
+ description: A simple gem for the Payza payment network
63
47
  email:
64
48
  - spiridon.alin@gmail.com
65
49
  executables: []
66
50
  extensions: []
67
51
  extra_rdoc_files: []
68
52
  files:
69
- - lib/payza/mass_pay_api.rb
70
53
  - lib/payza/version.rb
71
54
  - lib/payza.rb
72
55
  - lib/tasks/payza_tasks.rake
@@ -103,7 +86,7 @@ files:
103
86
  - test/dummy/script/rails
104
87
  - test/payza_test.rb
105
88
  - test/test_helper.rb
106
- homepage: http://ajaxmasters.com
89
+ homepage: https://github.com/azertys/payza
107
90
  licenses: []
108
91
  post_install_message:
109
92
  rdoc_options: []
@@ -1,148 +0,0 @@
1
- require "net/https"
2
-
3
- class MassPayApi
4
-
5
- =begin
6
- /**
7
- * MassPayClient::__construct()
8
- *
9
- * Constructs a MassPayClient object
10
- *
11
- * @param boolean for sandbox or live.
12
- */
13
- =end
14
-
15
- def initialize(sandbox = false)
16
- type = sandbox ? "sandbox" : "live"
17
- config = YAML.load_file("#{Rails.root}/config/payza.yml") rescue nil
18
- if config
19
- @url = config[type]["url"]
20
- @myUserName = config[type]["user"]
21
- @apiPassword = config[type]["pass"]
22
- @action = '/executemasspay'
23
- end
24
- end
25
-
26
- =begin
27
- /**
28
- * MassPayClient::setUrl()
29
- *
30
- * Sets the $url variable
31
- *
32
- * @param string $newUrl New url address.
33
- */
34
- =end
35
-
36
- def setUrl(newUrl)
37
- @url = newUrl
38
- end
39
-
40
- =begin
41
- /**
42
- * MassPayClient::getUrl()
43
- *
44
- * Returns the url variable
45
- *
46
- * @return string A variable containing a URL address.
47
- */
48
- =end
49
-
50
- def getUrl()
51
- @url
52
- end
53
-
54
- =begin
55
- /**
56
- * MassPayClient::buildPostVariables()
57
- *
58
- * Builds a URL encoded post string which contains the variables to be
59
- * sent to the API in the correct format.
60
- *
61
- * @param int $payments Array containing the payments to be made.
62
- * @param string $currency 3 letter ISO-4217 currency code.
63
- * @param string $receiverEmail Recipient's email address.
64
- * @param string $senderEmail Your secondary email (optional).
65
- * @param int $purchaseType A valid purchase type code.
66
- * @param int $testMode Test mode status.
67
- *
68
- * @return string The URL encoded post string
69
- */
70
- =end
71
-
72
- def buildPostVariables(payments, currency = 'USD', senderEmail = '', testMode = '1')
73
- iteration = payments.count
74
- payees = {}
75
- @dataToSend = {
76
- "USER" => @myUserName,
77
- "PASSWORD" => @apiPassword,
78
- "CURRENCY" => currency,
79
- "SENDEREMAIL" => senderEmail,
80
- "TESTMODE" => testMode
81
- }
82
- #check if the received variable is an array
83
- if (!payments.kind_of?(Array))
84
- abort("Argument is not an array!")
85
- else
86
- #create another array with proper parameter names
87
- #variable used for the subscript of the payment number
88
- p = 0
89
- for x in 0..iteration-1 do
90
- p += 1
91
- payees = {
92
- "RECEIVEREMAIL_#{p}" => payments[x]["receiver"],
93
- "AMOUNT_#{p}" => payments[x]["amount"],
94
- "NOTE_#{p}" => payments[x]["note"]
95
- }
96
-
97
- @dataToSend = @dataToSend.merge(payees)
98
- end
99
- end
100
- @dataToSend
101
- end
102
-
103
- =begin
104
- /**
105
- * MassPayClient::send()
106
- *
107
- * Sends the URL encoded post string to the MassPay API
108
- * using cURL and retrieves the response.
109
- *
110
- * @return string The response from the MassPay API.
111
- */
112
- =end
113
-
114
- def send()
115
- http = Curl.post(@url+@action, @dataToSend)
116
- parseResponse http.body_str
117
- self
118
- end
119
-
120
- =begin
121
- /**
122
- * MassPayClient::parseResponse()
123
- *
124
- * Parses the encoded response from the MassPay API
125
- * into an associative array.
126
- *
127
- * @param string $input The string to be parsed by the function.
128
- */
129
- =end
130
-
131
- def parseResponse(input)
132
- @responseArray = Rack::Utils.parse_nested_query(input)
133
- end
134
-
135
- =begin
136
- /**
137
- * MassPayClient::getResponse()
138
- *
139
- * Returns the responseArray
140
- *
141
- * @return string An array containing the response variables.
142
- */
143
- =end
144
-
145
- def getResponse()
146
- @responseArray
147
- end
148
- end