Class: Astropay::Streamline
Instance Attribute Summary
Attributes inherited from API
Instance Method Summary collapse
- #build_control_string(invoice_data) ⇒ Object
- #create_invoice(invoice_data) ⇒ Object
- #live_url ⇒ Object
- #test_url ⇒ Object
Methods inherited from API
#build_url, #initialize, #request
Methods included from Request
Constructor Details
This class inherits a constructor from Astropay::API
Instance Method Details
#build_control_string(invoice_data) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/astropay/streamline.rb', line 45 def build_control_string(invoice_data) canonical_string = "#{invoice_data['x_invoice']}V"\ "#{invoice_data['x_amount']}I"\ "#{invoice_data['x_iduser']}2"\ "#{invoice_data['x_bank']}1"\ "#{invoice_data['x_cpf']}H"\ "#{invoice_data['x_bdate']}G"\ "#{invoice_data['x_email']}Y"\ "#{invoice_data['x_zip']}A"\ "#{invoice_data['x_address']}P"\ "#{invoice_data['x_city']}S"\ "#{invoice_data['x_state']}P" control_string = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new, [config.secret_key].pack('A*'), [canonical_string].pack('A*')) control_string.upcase end |
#create_invoice(invoice_data) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/astropay/streamline.rb', line 13 def create_invoice(invoice_data) request_data = invoice_data .transform( 'invoice' => 'x_invoice', 'amount' => 'x_amount', 'currency' => 'x_currency', 'bank' => 'x_bank', 'country' => 'x_country', 'description' => 'x_description', 'user_id' => 'x_iduser', 'cpf' => 'x_cpf', 'name' => 'x_name', 'email' => 'x_email', 'birthday' => 'x_bdate', 'address' => 'x_address', 'zip' => 'x_zip', 'city' => 'x_city', 'state' => 'x_state', 'phone' => 'x_mobile', 'return_url' => 'x_return', 'confirm_url' => 'x_confirmation' ) control_string = build_control_string(request_data) request_data .merge!(config.credentials) .merge!('control' => control_string, 'type' => 'json' ) request('/NewInvoice', request_data) end |
#live_url ⇒ Object
5 6 7 |
# File 'lib/astropay/streamline.rb', line 5 def live_url 'https://astropaycard.com/api_curl/streamline' end |
#test_url ⇒ Object
9 10 11 |
# File 'lib/astropay/streamline.rb', line 9 def test_url 'https://sandbox.astropaycard.com/api_curl/streamline' end |