lib/bs2_api/payment/async.rb in bs2_api-1.6.2 vs lib/bs2_api/payment/async.rb in bs2_api-1.7.0

- old
+ new

@@ -19,18 +19,31 @@ # @param[String] client_secret The password for the account with # id client_id. Optional, if not passed the default will be used. def check_payment_status( request_id, client_id: Bs2Api.configuration.client_id, - client_secret: Bs2Api.configuration.client_secret + client_secret: Bs2Api.configuration.client_secret, + proxy: nil ) - url = request_status_url(request_id) + bearer_token = Bs2Api::Request::Auth.token( client_id: client_id, client_secret: client_secret ) - headers = { 'Authorization': "Bearer #{bearer_token}" } - response = HTTParty.get(url, headers: headers) + + response = HTTParty.get( + request_status_url(request_id), + http_proxyaddr: proxy&.host, + http_proxyport: proxy&.port, + http_proxyuser: proxy&.user, + http_proxypass: proxy&.password, + headers: { + 'Authorization': "Bearer #{bearer_token}" + } + ) + + raise Bs2Api::Errors::Base, response.body.to_s unless response.success? + Bs2Api::Entities::AsyncStatus.from_response response.parsed_response end private