Class: YandexMoney::ExternalPayment

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

Overview

Payments from bank cards without authorization

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Client

included, post

Constructor Details

#initialize(instance_id) ⇒ ExternalPayment

Returns a new instance of ExternalPayment.



11
12
13
# File 'lib/yandex_money/external_payment.rb', line 11

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:



26
27
28
29
# File 'lib/yandex_money/external_payment.rb', line 26

def self.get_instance_id(client_id)
  response = send_external_payment_request("/api/instance-id", client_id: client_id)
  RecursiveOpenStruct.new response.body
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:



59
60
61
62
63
# File 'lib/yandex_money/external_payment.rb', line 59

def process_external_payment(payment_options)
  payment_options[:instance_id] = @instance_id
  response = self.class.send_external_payment_request("/api/process-external-payment", payment_options)
  RecursiveOpenStruct.new response.body
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:



42
43
44
45
46
# File 'lib/yandex_money/external_payment.rb', line 42

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