Class: WebpayBy::Confirmation
- Inherits:
-
Object
- Object
- WebpayBy::Confirmation
- Defined in:
- lib/webpay_by/confirmation.rb
Constant Summary collapse
- SANDBOX_URL =
'https://sandbox.webpay.by'- BILLING_URL =
'https://billing.webpay.by'
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#transaction_id ⇒ Object
readonly
Returns the value of attribute transaction_id.
Instance Method Summary collapse
- #clear_xml_string(xml_str) ⇒ Object
-
#initialize(client:, transaction_id:) ⇒ Confirmation
constructor
A new instance of Confirmation.
-
#send ⇒ Object
ОТВЕТ ЗА ЗАПРОС НА ПОДТВЕРЖДЕНИЕ: Возвращаемый XML выглядит примерно так (без переносов строк): <?xml version=“1.0” encoding=“UTF-8”?> <wsb_api_response> <version>1</version> <command>get_transaction</command> <status>success</status> <fields> <transaction_id>123456789</transaction_id> <batch_timestamp>31231231</batch_timestamp> <currency_id>BYN</currency_id> <amount>100</amount> <payment_method>cc</payment_method> <payment_type>4</payment_type> <order_id>584236984</order_id> <order_num>5874129</order_num> <rrn>154789648154</rrn> <wsb_signature>3021e68df9a7200135725c6331369a22</wsb_signature> </fields> </wsb_api_response>.
- #url_string ⇒ Object
Constructor Details
#initialize(client:, transaction_id:) ⇒ Confirmation
Returns a new instance of Confirmation.
28 29 30 31 |
# File 'lib/webpay_by/confirmation.rb', line 28 def initialize(client:, transaction_id:) @client = client @transaction_id = transaction_id end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
26 27 28 |
# File 'lib/webpay_by/confirmation.rb', line 26 def client @client end |
#transaction_id ⇒ Object (readonly)
Returns the value of attribute transaction_id.
26 27 28 |
# File 'lib/webpay_by/confirmation.rb', line 26 def transaction_id @transaction_id end |
Instance Method Details
#clear_xml_string(xml_str) ⇒ Object
62 63 64 |
# File 'lib/webpay_by/confirmation.rb', line 62 def clear_xml_string(xml_str) xml_str.gsub("\n", '').gsub(/\s{2,}/, '').gsub(' <', '<') end |
#send ⇒ Object
ОТВЕТ ЗА ЗАПРОС НА ПОДТВЕРЖДЕНИЕ: Возвращаемый XML выглядит примерно так (без переносов строк): <?xml version=“1.0” encoding=“UTF-8”?> <wsb_api_response>
<version>1</version>
<command>get_transaction</command>
<status>success</status>
<fields>
<transaction_id>123456789</transaction_id>
<>31231231</batch_timestamp>
<currency_id>BYN</currency_id>
<amount>100</amount>
<payment_method>cc</payment_method>
<payment_type>4</payment_type>
<order_id>584236984</order_id>
<order_num>5874129</order_num>
<rrn>154789648154</rrn>
<wsb_signature>3021e68df9a7200135725c6331369a22</wsb_signature>
</fields>
</wsb_api_response>
56 57 58 59 60 |
# File 'lib/webpay_by/confirmation.rb', line 56 def send xml = clear_xml_string api_request_xml response = Net::HTTP.post_form(URI.parse(url_string), {'*API': '', 'API_XML_REQUEST': xml}).body WebpayBy::ConfirmationResponse.new confirmation: self, response: response end |
#url_string ⇒ Object
33 34 35 |
# File 'lib/webpay_by/confirmation.rb', line 33 def url_string @client.debug_mode? ? SANDBOX_URL : BILLING_URL end |