1
0
зеркало из https://github.com/glebtv/yookassa.git synced 2026-09-03 17:55:51 +03:00
Этот коммит содержится в:
Ivan Shamatov
2021-11-09 01:01:13 +03:00
коммит произвёл GitHub
родитель 811ab20f05
Коммит c5c1e8a54e
13 изменённых файлов: 167 добавлений и 30 удалений

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

@@ -9,11 +9,11 @@ module Yookassa
# First 6 digits of the cards number (BIN). For payments with bank cards saved in YooMoney
# and other services, the specified BIN might not correspond with the last4, expiry_year, expiry_month values.
# For payments with bank cards saved in Apple Pay or Google Pay, the parameter contains Device Account Number.
attribute? :first6, Types::String
attribute? :first6, Types::Coercible::Integer
# last4 [string, required]
# Last 4 digits of the card's number.
attribute :last4, Types::String
attribute :last4, Types::Coercible::Integer
# expiry_month [string, required]
# Expiration date, month, MM.

27
lib/yookassa/entity/collection.rb Обычный файл
Просмотреть файл

@@ -0,0 +1,27 @@
# frozen_string_literal: true
require_relative "./types"
require_relative "./payment"
require_relative "./receipt"
require_relative "./refund"
module Yookassa
module Entity
class Collection < Dry::Struct
attribute :type, Types.Value("list")
attribute? :next_cursor, Types::String
end
class PaymentCollection < Collection
attribute :items, Types::Array.of(Payment)
end
class RefundCollection < Collection
attribute :items, Types::Array.of(Refund)
end
class ReceiptCollection < Collection
attribute :items, Types::Array.of(Receipt)
end
end
end

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

@@ -7,16 +7,8 @@ module Yookassa
module Entity
module PaymentMethod
class Base < Dry::Struct
# id [string, required]
# Payment method ID.
attribute :id, Types::String
# saved [boolean, required]
# Saving payment methods allows conducting automatic recurring payments .
attribute :saved, Types::Bool
# title [string, optional]
# Payment method name.
attribute? :title, Types::String
end
@@ -90,18 +82,18 @@ module Yookassa
end
end
PaymentMethods = PaymentMethod::BankCard |
PaymentMethod::Alfabank |
PaymentMethod::YooMoney |
PaymentMethod::Sberbank |
PaymentMethod::ApplePay |
PaymentMethod::Cash |
PaymentMethod::DirectCarrierBilling |
PaymentMethod::GooglePay |
PaymentMethod::Installments |
PaymentMethod::Qiwi |
PaymentMethod::Tinkoff |
PaymentMethod::Wechat |
PaymentMethod::Webmoney
PaymentMethods = PaymentMethod::BankCard |
PaymentMethod::Alfabank |
PaymentMethod::YooMoney |
PaymentMethod::Sberbank |
PaymentMethod::ApplePay |
PaymentMethod::Cash |
PaymentMethod::DirectCarrierBilling |
PaymentMethod::GooglePay |
PaymentMethod::Installments |
PaymentMethod::Qiwi |
PaymentMethod::Tinkoff |
PaymentMethod::Wechat |
PaymentMethod::Webmoney
end
end

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

@@ -17,11 +17,11 @@ module Yookassa
# Store's tax system. The parameter is only required if you use several tax systems.
# Otherwise, the parameter is not specified. List of possible values:
# https://yookassa.ru/en/developers/54fz/parameters-values#tax-systems
attribute? :tax_system_code, Types::Integer
attribute? :tax_system_code, Types::Coercible::Integer
# User's phone number for sending the receipt. Set in the ITU-T E.164 format, for example, 79000000000.
# !DEPRECATED PARAMETER: we recommend specifying the details in the receipt.customer.phone parameter.
attribute? :phone, Types::String
attribute? :phone, Types::Coercible::String
# User's email address for sending the receipt.
# !DEPRECATED PARAMETER: we recommend specifying the details in the receipt.customer.email parameter.

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

@@ -5,8 +5,8 @@ require_relative "./types"
module Yookassa
module Entity
class Recipient < Dry::Struct
attribute :account_id, Types::String
attribute :gateway_id, Types::String
attribute :account_id, Types::Coercible::Integer
attribute :gateway_id, Types::Coercible::Integer
end
end
end

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

@@ -35,7 +35,7 @@ module Yookassa
# description [string, optional]
# Reason behind the refund.
attribute :description, Types::String
attribute? :description, Types::String
# sources [array, optional]
# Information about money held for refunds: the amount to be held and the stores getting the refunds.

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

@@ -1,6 +1,7 @@
# frozen_string_literal: true
require_relative "./entity/payment"
require_relative "./entity/collection"
module Yookassa
class Payments
@@ -28,6 +29,11 @@ module Yookassa
Entity::Payment.new(**data.merge(idempotency_key: idempotency_key))
end
def list(filters: {})
data = api.get("payments", query: filters)
Entity::PaymentCollection.new(**data)
end
private
attr_reader :api

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

@@ -1,6 +1,7 @@
# frozen_string_literal: true
require_relative "./entity/refund"
require_relative "./entity/collection"
module Yookassa
class Refunds
@@ -18,6 +19,11 @@ module Yookassa
Entity::Refund.new(**data.merge(idempotency_key: idempotency_key))
end
def list(filters: {})
data = api.get("refunds", query: filters)
Entity::RefundCollection.new(**data)
end
private
attr_reader :api