1
0
зеркало из https://github.com/glebtv/yookassa.git synced 2026-08-28 15:16:18 +03:00
* Initial setup for docs

* running payments endpoints

* documentation for deals and payouts
Этот коммит содержится в:
Ivan Shamatov
2021-11-20 14:14:59 +03:00
коммит произвёл GitHub
родитель 7f79ffa4b4
Коммит a61bbaf461
10 изменённых файлов: 974 добавлений и 56 удалений

Просмотреть файл

@@ -33,6 +33,10 @@ module Yookassa
api_call { http.headers("Idempotence-Key" => idempotency_key).post("#{API_URL}#{endpoint}", json: payload) }
end
def delete(endpoint, idempotency_key:)
api_call { http.headers("Idempotence-Key" => idempotency_key).delete("#{API_URL}#{endpoint}") }
end
def api_call
response = yield if block_given?
body = JSON.parse(response.body.to_s, symbolize_names: true)

Просмотреть файл

@@ -16,7 +16,7 @@ module Yookassa
attribute :type, Types.Value("embedded")
# Token for the YooMoney Checkout Widget initialization.
attribute? :confirmation_token, Types::String
attribute :confirmation_token, Types::String
end
class External < Base
@@ -39,14 +39,14 @@ module Yookassa
attribute :type, Types.Value("qr")
# Data for generating the QR code.
attribute? :confirmation_data, Types::String
attribute :confirmation_data, Types::String
end
class Redirect < Base
attribute :type, Types.Value("redirect")
# The URL that the user will be redirected to for payment confirmation.
attribute? :confirmation_url, Types::String
attribute :confirmation_url, Types::String
# A request for making a payment with authentication by 3-D Secure. It works if you accept
# bank card payments without user confirmation by default. In other cases, the 3-D Secure
@@ -56,7 +56,7 @@ module Yookassa
# The URL that the user will return to after confirming or canceling the payment on the webpage.
# Maximum 2048 characters.
attribute :return_url, Types::String
attribute? :return_url, Types::String
end
end

Просмотреть файл

@@ -1,52 +0,0 @@
# frozen_string_literal: true
require "http"
require_relative "./stores"
require_relative "./webhooks"
require_relative "./entity/error"
module Yookassa
class PartnerAPI
API_URL = "https://api.yookassa.ru/v3/"
def initialize(oauth_token:)
@http = HTTP.headers("Authorization" => "Bearer #{oauth_token}")
.headers(accept: "application/json")
end
def stores
@stores ||= Stores.new(self)
end
def webhooks
@webhooks ||= Webhooks.new(self)
end
def get(endpoint)
api_call { get("#{API_URL}#{endpoint}", params: query) }
end
def post(endpoint, idempotency_key:, payload: {})
api_call { http.headers("Idempotence-Key" => idempotency_key).post("#{API_URL}#{endpoint}", json: payload) }
end
def delete(endpoint, idempotency_key:)
HTTP.headers("Authorization" => "Bearer #{oauth_token}")
.headers("Idempotence-Key" => idempotency_key)
.delete("#{API_URL}#{endpoint}")
end
private
attr_reader :http
def api_call
response = yield if block_given?
body = JSON.parse(response.body.to_s, symbolize_names: true)
return body if response.status.success?
Entity::Error.new(**body)
end
end
end