Class: Payoneer::Client
- Inherits:
-
Object
- Object
- Payoneer::Client
- Defined in:
- lib/payoneer/client.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Instance Method Summary collapse
-
#expanded_payout(payee_id:, client_reference_id:, amount:, currency:, description:, payout_date: Time.now, seller_id:, seller_name:, seller_url:, seller_type: 'ECOMMERCE', orders_type: 'url', path:, credentials:) ⇒ Object
Includes additional items as needed to be Payoneer SAFE compliant.
-
#initialize(configuration) ⇒ Client
constructor
A new instance of Client.
- #payee_details(payee_id) ⇒ Object
- #payee_signup_url(payee_id, redirect_url: nil, redirect_time: nil) ⇒ Object
- #payout(program_id:, payment_id:, payee_id:, amount:, description:, payment_date: Time.now, currency: 'USD') ⇒ Object
- #payout_details(payee_id:, payment_id:) ⇒ Object
- #status ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(configuration) ⇒ Client
Returns a new instance of Client.
5 6 7 |
# File 'lib/payoneer/client.rb', line 5 def initialize(configuration) @configuration = configuration end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
3 4 5 |
# File 'lib/payoneer/client.rb', line 3 def configuration @configuration end |
Instance Method Details
#expanded_payout(payee_id:, client_reference_id:, amount:, currency:, description:, payout_date: Time.now, seller_id:, seller_name:, seller_url:, seller_type: 'ECOMMERCE', orders_type: 'url', path:, credentials:) ⇒ Object
Includes additional items as needed to be Payoneer SAFE compliant
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/payoneer/client.rb', line 43 def (payee_id:, client_reference_id:, amount:, currency:, description:, payout_date: Time.now, seller_id:, seller_name:, seller_url:, seller_type: 'ECOMMERCE', orders_type: 'url', path:, credentials:) params = { payee_id: payee_id, client_reference_id: client_reference_id, amount: amount, currency: currency, description: description, payout_date: payout_date.strftime('%Y-%m-%d'), orders_report: { merchant: { id: seller_id, store: { name: seller_name, url: seller_url, type: seller_type } }, orders: { type: orders_type, path: path, credentials: credentials } } } begin response = RestClient::Request.execute( method: :post, url: "#{configuration.json_base_uri}/payouts", payload: params.to_json, headers: { content_type: 'application/json', accept: :json, Authorization: 'Basic ' + Base64.encode64("#{configuration.username}:#{configuration.api_password}").chomp }, **configuration. ) hash = JSON.parse(response.body) hash['PaymentID'] = hash['payout_id'] # Keep consistent with the normal payout response body create_response(hash) rescue RestClient::Exception => e if e.http_body hash = JSON.parse(e.http_body) create_response(hash, e.http_code) end end end |
#payee_details(payee_id) ⇒ Object
23 24 25 26 27 |
# File 'lib/payoneer/client.rb', line 23 def payee_details(payee_id) post('GetPayeeDetails', p4: payee_id, p10: true) do |response| response['CompanyDetails'].present? ? response['Payee'].merge(response['CompanyDetails']) : response['Payee'] end end |
#payee_signup_url(payee_id, redirect_url: nil, redirect_time: nil) ⇒ Object
17 18 19 20 21 |
# File 'lib/payoneer/client.rb', line 17 def payee_signup_url(payee_id, redirect_url: nil, redirect_time: nil) post('GetToken', p4: payee_id, p6: redirect_url, p8: redirect_time, p9: configuration.auto_approve_sandbox_accounts, p10: true) do |response| response['Token'] end end |
#payout(program_id:, payment_id:, payee_id:, amount:, description:, payment_date: Time.now, currency: 'USD') ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/payoneer/client.rb', line 29 def payout(program_id:, payment_id:, payee_id:, amount:, description:, payment_date: Time.now, currency: 'USD') post( 'PerformPayoutPayment', p4: program_id, p5: payment_id, p6: payee_id, p7: format('%.2f', amount), p8: description, p9: payment_date.strftime('%m/%d/%Y %H:%M:%S'), Currency: currency ) end |
#payout_details(payee_id:, payment_id:) ⇒ Object
93 94 95 |
# File 'lib/payoneer/client.rb', line 93 def payout_details(payee_id:, payment_id:) post('GetPaymentStatus', p4: payee_id, p5: payment_id) end |
#status ⇒ Object
9 10 11 |
# File 'lib/payoneer/client.rb', line 9 def status post('Echo') end |
#version ⇒ Object
13 14 15 |
# File 'lib/payoneer/client.rb', line 13 def version post('GetVersion') end |