1
0
зеркало из https://github.com/glebtv/yookassa.git synced 2026-09-03 09:46:16 +03:00
Этот коммит содержится в:
Ivan Shamatov
2021-10-31 23:19:28 +03:00
родитель ef8000cbaf
Коммит 2f5a64794d
5 изменённых файлов: 159 добавлений и 23 удалений

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

@@ -5,12 +5,41 @@ require_relative "./types"
module Yookassa
module Entity
class Card < Dry::Struct
attribute :first6, Types::Integer
attribute :last4, Types::Integer
attribute :expiry_month, Types::Integer
attribute :expiry_year, Types::Integer
attribute :card_type, Types::String
attribute :source, Types::String
# first6 [string, optional]
# 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
# last4 [string, required]
# Last 4 digits of the card's number.
attribute :last4, Types::String
# expiry_month [string, required]
# Expiration date, month, MM.
attribute :expiry_month, Types::Coercible::Integer
# expiry_year [string, required]
# Expiration date, year, YYYY.
attribute :expiry_year, Types::Coercible::Integer
# card_type [string, required]
# Type of bank card. Possible values: MasterCard (for Mastercard and Maestro cards), Visa (for Visa and Visa Electron cards),
# Mir, UnionPay, JCB, AmericanExpress, DinersClub, and Unknown.
attribute :card_type, Types::String.enum("MasterCard", "Visa", "Mir", "UnionPay", "JCB", "AmericanExpress", "DinersClub", "Unknown")
# issuer_country [string, optional]
# Code of the country where the bank card was issued according to ISO-3166 alpha-2. Example: RU.
attribute? :issuer_country, Types::String
# issuer_name [string, optional]
# Name of the issuing bank.
attribute? :issuer_name, Types::String
# source [string, optional]
# Source of bank card details. Possible values: apple_pay, google_pay.
# For payments where the user selects a card saved in Apple Pay or Google Pay.
attribute? :source, Types::String.enum("apple_pay", "google_pay")
end
end
end

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

@@ -2,8 +2,12 @@
require_relative "./types"
require_relative "./amount"
require_relative "./payment_method"
require_relative "./payment_methods"
require_relative "./confirmation"
require_relative "./recipient"
require_relative "./cancelation_details"
require_relative "./authorization_details"
require_relative "./transfer"
module Yookassa
module Entity

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

@@ -1,16 +0,0 @@
# frozen_string_literal: true
require_relative "./types"
require_relative "./card"
module Yookassa
module Entity
class PaymentMethod < Dry::Struct
attribute :type, Types::String
attribute :id, Types::String
attribute :saved, Types::Bool
attribute? :card, Entity::Card
attribute? :title, Types::String
end
end
end

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

@@ -0,0 +1,107 @@
# frozen_string_literal: true
require_relative "./types"
require_relative "./card"
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
class BankCard < Base
attribute :type, Types.Value('bank_card')
# login [string, optional]
# User's login in Alfa-Click (linked phone number or the additional login).
attribute? :card, Entity::Card
end
class Alfabank < Base
attribute :type, Types.Value('alfabank')
# login [string, optional]
# User's login in Alfa-Click (linked phone number or the additional login).
attribute? :login, Types::String
end
class YooMoney < Base
attribute :type, Types.Value('yoo_money')
# account_number [string, optional]
# The number of the YooMoney wallet used for making the payment.
attribute? :account_number, Types::String
end
class Sberbank < Base
attribute :type, Types.Value('sberbank')
# phone [string, optional]
# TThe phone number specified during the registration process of the SberBank Online/SberPay account,
# specified in the ITU-T E.164 format, for example, 79000000000.
attribute? :phone, Types::String
end
class ApplePay < Base
attribute :type, Types.Value('apple_pay')
end
class Cash < Base
attribute :type, Types.Value('cash')
end
class DirectCarrierBilling < Base
attribute :type, Types.Value('mobile_balance')
end
class GooglePay < Base
attribute :type, Types.Value('google_pay')
end
class Installments < Base
attribute :type, Types.Value('installments')
end
class Qiwi < Base
attribute :type, Types.Value('qiwi')
end
class Tinkoff < Base
attribute :type, Types.Value('tinkoff_bank')
end
class Wechat < Base
attribute :type, Types.Value('wechat')
end
class Webmoney < Base
attribute :type, Types.Value('webmoney')
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
end
end

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

@@ -0,0 +1,12 @@
# frozen_string_literal: true
require_relative "./types"
module Yookassa
module Entity
class Recipient < Dry::Struct
attribute :account_id, Types::String
attribute :gateway_id, Types::String
end
end
end