Class: Easypay::Client
- Inherits:
-
Object
- Object
- Easypay::Client
- Defined in:
- lib/easypay/client.rb
Constant Summary collapse
- EASYPAY_SERVICE_URL =
Rails.env.production? ? "www.easypay.pt" : "test.easypay.pt"
Instance Method Summary collapse
- #create_reference(object) ⇒ Object
- #get_payment_detail(ep_key, ep_doc) ⇒ Object
- #get_payment_list(type = "last", detail = 10, format = "xml") ⇒ Object
-
#initialize(*params) ⇒ Client
constructor
A new instance of Client.
-
#modify_payment_reference(object, action) ⇒ Object
API methods.
- #request_payment(entity, reference, value, identifier) ⇒ Object
Constructor Details
#initialize(*params) ⇒ Client
Returns a new instance of Client.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/easypay/client.rb', line 6 def initialize *params if params.first.is_a?(Hash) = params.first @easypay_cin = [:easypay_cin] || Easypay::Engine.config.cin @easypay_user = [:easypay_user] || Easypay::Engine.config.user @easypay_entity = [:easypay_entity] || Easypay::Engine.config.entity @easypay_code = [:easypay_code] || Easypay::Engine.config.code @easypay_ref_type = [:easypay_ref_type] || "auto" @easypay_country = [:easypay_country] || "PT" elsif params.first puts "* warning: the method Easypay::Client.new(ep_cin, ep_user, ep_entity) is deprecated, use Easypay::Client.new(:easypay_cin => 'cin', :easypay_user => 'user', :easypay_entity => 'entity')" @easypay_cin = params.shift || Easypay::Engine.config.cin @easypay_user = params.shift || Easypay::Engine.config.user @easypay_entity = params.shift || Easypay::Engine.config.entity @easypay_code = params.shift || Easypay::Engine.config.code @easypay_ref_type = params.shift || "auto" @easypay_country = params.shift || "PT" else @easypay_cin = Easypay::Engine.config.cin @easypay_user = Easypay::Engine.config.user @easypay_entity = Easypay::Engine.config.entity @easypay_code = Easypay::Engine.config.code @easypay_ref_type = "auto" @easypay_country = "PT" end end |
Instance Method Details
#create_reference(object) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/easypay/client.rb', line 46 def create_reference(object) get "01BG", :t_key => object.ep_key, :t_value => object.ep_value, :ep_language => object.ep_language.upcase, :o_name => object.o_name.nil? ? "" : URI.escape(object.o_name), :o_description => object.o_description.nil? ? "" : URI.escape(object.o_description), :o_obs => object.o_obs.nil? ? "" : URI.escape(object.o_obs), :o_mobile => object.o_mobile.nil? ? "" : URI.escape(object.o_mobile), :o_email => object.o_email.nil? ? "" : URI.escape(object.o_email) # :ep_rec => "yes", # Reccurrence stuff # :ep_rec_freq => recurrence, # :ep_rec_url => url_notification_cc end |
#get_payment_detail(ep_key, ep_doc) ⇒ Object
61 62 63 64 65 |
# File 'lib/easypay/client.rb', line 61 def get_payment_detail(ep_key, ep_doc) get "03AG", :ep_key => ep_key, :ep_doc => ep_doc end |
#get_payment_list(type = "last", detail = 10, format = "xml") ⇒ Object
67 68 69 70 71 72 |
# File 'lib/easypay/client.rb', line 67 def get_payment_list(type="last", detail=10, format="xml") get "040BG1", :o_list_type => type, :o_ini => detail, :type => format end |
#modify_payment_reference(object, action) ⇒ Object
API methods
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/easypay/client.rb', line 34 def modify_payment_reference(object, action) get "00BG", :ep_ref => object.ep_reference, :ep_delete => action.match("delete") ? "yes" : "", :t_value => object.ep_value, :o_name => object.o_name.nil? ? "" : URI.escape(object.o_name), :o_description => object.o_description.nil? ? "" : URI.escape(object.o_description), :o_obs => object.o_obs.nil? ? "" : URI.escape(object.o_obs), :o_mobile => object.o_mobile.nil? ? "" : URI.escape(object.o_mobile), :o_email => object.o_email.nil? ? "" : URI.escape(object.o_email) end |
#request_payment(entity, reference, value, identifier) ⇒ Object
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/easypay/client.rb', line 74 def request_payment(entity, reference, value, identifier) get "05AG", :e => entity, :r => reference, :v => value, :k => identifier # :ep_k1 => identifier, # :rec => "yes", # :ep_key_rec => uid end |