Class: YandexMoney::ExternalPayment

Inherits:
Object
  • Object
show all
Defined in:
lib/yandex_money/external_payment.rb

Overview

Payments from bank cards without authorization

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instance_id) ⇒ ExternalPayment

Returns a new instance of ExternalPayment.



7
8
9
# File 'lib/yandex_money/external_payment.rb', line 7

def initialize(instance_id)
  @instance_id = instance_id
end

Class Method Details

.get_instance_id(client_id) ⇒ RecursiveOpenStruct

Registers instance of application

Parameters:

  • client_id (String)

    An identifier of application

Returns:

  • (RecursiveOpenStruct)

    A status of operation

Raises:

  • (YandexMoney::InvalidRequestError)

    HTTP request does not conform to protocol format. Unable to parse HTTP request, or the Authorization header is missing or has an invalid value.

  • (YandexMoney::ServerError)

    A technical error occurs (the server responds with the HTTP code 500 Internal Server Error). The application should repeat the request with the same parameters later.

See Also:



22
23
24
25
# File 'lib/yandex_money/external_payment.rb', line 22

def self.get_instance_id(client_id)
  request = send_external_payment_request("/api/instance-id", client_id: client_id)
  RecursiveOpenStruct.new request.parsed_response
end

Instance Method Details

#process_external_payment(payment_options) ⇒ RecursiveOpenStruct

Confirms a payment that was created using the request-extenral-payment method

Parameters:

  • payment_options (Hash)

    Method's parameters. Check out docs for more information.

Returns:

  • (RecursiveOpenStruct)

    A status of payment and additional steps for authorization (if needed)

Raises:

  • (YandexMoney::InvalidRequestError)

    HTTP request does not conform to protocol format. Unable to parse HTTP request, or the Authorization header is missing or has an invalid value.

  • (YandexMoney::ServerError)

    A technical error occurs (the server responds with the HTTP code 500 Internal Server Error). The application should repeat the request with the same parameters later.

See Also:



55
56
57
58
59
# File 'lib/yandex_money/external_payment.rb', line 55

def process_external_payment(payment_options)
  payment_options[:instance_id] = @instance_id
  request = self.class.send_external_payment_request("/api/process-external-payment", payment_options)
  RecursiveOpenStruct.new request.parsed_response
end

#request_external_payment(payment_options) ⇒ RecursiveOpenStruct

Requests a external payment

Parameters:

  • payment_options (Hash)

    Method's parameters. Check out docs for more information.

Returns:

  • (RecursiveOpenStruct)

    A struct, containing payment_id and additional information about a recipient and payer

Raises:

  • (YandexMoney::InvalidRequestError)

    HTTP request does not conform to protocol format. Unable to parse HTTP request, or the Authorization header is missing or has an invalid value.

  • (YandexMoney::ServerError)

    A technical error occurs (the server responds with the HTTP code 500 Internal Server Error). The application should repeat the request with the same parameters later.

See Also:



38
39
40
41
42
# File 'lib/yandex_money/external_payment.rb', line 38

def request_external_payment(payment_options)
  payment_options[:instance_id] = @instance_id
  request = self.class.send_external_payment_request("/api/request-external-payment", payment_options)
  RecursiveOpenStruct.new request.parsed_response
end