Class: OffsitePayments::Integrations::Latipay::RefundInterface
- Inherits:
-
Interface
- Object
- Interface
- OffsitePayments::Integrations::Latipay::RefundInterface
- Defined in:
- lib/offsite_payments/integrations/latipay.rb
Defined Under Namespace
Classes: RefundRequestError
Class Method Summary collapse
Instance Method Summary collapse
- #call(order_id, refund_amount, reference = '') ⇒ Object
- #validate_response(parsed_response) ⇒ Object
Methods inherited from Interface
base_url, #initialize, #sign, #verify_signature
Constructor Details
This class inherits a constructor from OffsitePayments::Integrations::Latipay::Interface
Class Method Details
.url ⇒ Object
147 148 149 150 |
# File 'lib/offsite_payments/integrations/latipay.rb', line 147 def self.url # according to latipay doc, this url does not have a version part. "https://api.latipay.net/refund" end |
Instance Method Details
#call(order_id, refund_amount, reference = '') ⇒ Object
152 153 154 155 156 157 158 159 160 161 |
# File 'lib/offsite_payments/integrations/latipay.rb', line 152 def call(order_id, refund_amount, reference = '') raise ArgumentError, "Order ID must be specified" if order_id.blank? raise ArgumentError, "Refund amount must be specified" if refund_amount.blank? = { refund_amount: refund_amount, reference: reference, user_id: @user_id, order_id: order_id } [:signature] = self.sign() raw_response = ssl_post(self.class.url, .to_json, standard_headers) parsed_response = parse_response(raw_response) validate_response(parsed_response) parsed_response['message'] end |
#validate_response(parsed_response) ⇒ Object
163 164 165 |
# File 'lib/offsite_payments/integrations/latipay.rb', line 163 def validate_response(parsed_response) raise RefundRequestError, parsed_response unless parsed_response['code'] == 0 end |