diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..f9b4f4b --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,28 @@ +version: 2.1 +orbs: + ruby: circleci/ruby@0.1.2 + +jobs: + build: + docker: + - image: circleci/ruby:2.6.3-stretch-node + executor: ruby/default + steps: + - checkout + - restore_cache: + keys: + - yookassa-bundle-{{ checksum "Gemfile.lock" }} + - yookassa-bundle- + - run: + name: Install dependencies + command: | + bundle check || bundle install --jobs=4 --retry=3 --path vendor/bundle + - save_cache: + paths: + - ./vendor/bundle + key: yookassa-bundle-{{ checksum "Gemfile.lock" }} + + - run: + name: Run tests + command: | + bundle exec rspec --profile 10 --format progress diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 88064d4..0000000 --- a/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -sudo: false -language: ruby -cache: bundler -rvm: - - 2.5.3 -before_install: gem install bundler -v 1.17.3 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index 8550867..0000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,74 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as -contributors and maintainers pledge to making participation in our project and -our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, gender identity and expression, level of experience, -nationality, personal appearance, race, religion, or sexual identity and -orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment -include: - -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery and unwelcome sexual attention or -advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable -behavior and are expected to take appropriate and fair corrective action in -response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or -reject comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. Examples of -representing a project or community include using an official project e-mail -address, posting via an official social media account, or acting as an appointed -representative at an online or offline event. Representation of a project may be -further defined and clarified by project maintainers. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at andy.paderin@gmail.com. All -complaints will be reviewed and investigated and will result in a response that -is deemed necessary and appropriate to the circumstances. The project team is -obligated to maintain confidentiality with regard to the reporter of an incident. -Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good -faith may face temporary or permanent repercussions as determined by other -members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at [http://contributor-covenant.org/version/1/4][version] - -[homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/4/ diff --git a/Gemfile b/Gemfile index fc7f711..fd22095 100644 --- a/Gemfile +++ b/Gemfile @@ -1,8 +1,10 @@ -source "https://rubygems.org" +# frozen_string_literal: true -git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } +source 'https://rubygems.org' -# Specify your gem's dependencies in yandex-checkout.gemspec +git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } + +# Specify your gem's dependencies in yookassa.gemspec gemspec group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index b95af54..dc696a0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - yandex-checkout (0.1.1) + yookassa (0.1.0) evil-client (~> 3.0) GEM @@ -12,26 +12,26 @@ GEM ast (2.4.0) byebug (11.0.1) coderay (1.1.2) - concurrent-ruby (1.1.5) + concurrent-ruby (1.1.7) crack (0.4.3) safe_yaml (~> 1.0.0) diff-lcs (1.3) docile (1.3.1) - dry-initializer (3.0.1) - evil-client (3.0.3) + dry-initializer (3.0.4) + evil-client (3.0.4) dry-initializer (>= 2.1, < 4) mime-types (~> 3.1) rack (~> 2) - tram-policy (>= 0.3.1, < 2) + tram-policy (>= 0.3.1, < 3) hashdiff (0.4.0) - i18n (1.6.0) + i18n (1.8.5) concurrent-ruby (~> 1.0) jaro_winkler (1.5.2) - json (2.2.0) + json (2.3.1) method_source (0.9.2) - mime-types (3.2.2) + mime-types (3.3.1) mime-types-data (~> 3.2015) - mime-types-data (3.2019.0331) + mime-types-data (3.2020.1104) parallel (1.17.0) parser (2.6.3.0) ast (~> 2.4.0) @@ -42,7 +42,7 @@ GEM byebug (~> 11.0) pry (~> 0.10) public_suffix (3.1.0) - rack (2.0.7) + rack (2.2.3) rainbow (3.0.0) rake (12.3.2) rspec (3.8.0) @@ -72,7 +72,7 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) - tram-policy (1.0.1) + tram-policy (2.0.1) dry-initializer (> 2, < 4) i18n (~> 1.0) unicode-display_width (1.6.0) @@ -92,7 +92,7 @@ DEPENDENCIES rubocop (~> 0.71) simplecov (~> 0.16) webmock (~> 3.5) - yandex-checkout! + yookassa! BUNDLED WITH 1.17.3 diff --git a/README.md b/README.md index 1820b56..069b364 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,17 @@ -# Yandex::Checkout +# YooKassa API Ruby Client -Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/yandex/checkout`. To experiment with that code, run `bin/console` for an interactive prompt. +[![Gem Version][gem-badger]][gem] +[![Yookassa](https://circleci.com/gh/paderinandrey/yookassa.svg?style=svg)](https://circleci.com/gh/paderinandrey/yookassa) -TODO: Delete this and the text above, and describe your gem +[gem-badger]: https://img.shields.io/gem/v/yookassa.svg?style=flat&color=blue +[gem]: https://rubygems.org/gems/yookassa ## Installation Add this line to your application's Gemfile: ```ruby -gem 'yandex-checkout' +gem 'yookassa' ``` And then execute: @@ -18,26 +20,21 @@ And then execute: Or install it yourself as: - $ gem install yandex-checkout + $ gem install yookassa ## Usage TODO: Write usage instructions here -## Development - -After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. - -To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). - ## Contributing -Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/yandex-checkout. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. +Everyone is encouraged to help improve this project. Here are a few ways you can help: + +- [Report bugs](https://github.com/paderinandrey/yookassa/issues) +- Fix bugs and [submit pull requests](https://github.com/paderinandrey/yookassa/pulls) +- Write, clarify, or fix documentation +- Suggest or add new features ## License The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). - -## Code of Conduct - -Everyone interacting in the Yandex::Checkout project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/yandex-checkout/blob/master/CODE_OF_CONDUCT.md). diff --git a/lib/yandex-checkout.rb b/lib/yandex-checkout.rb deleted file mode 100644 index 738f19e..0000000 --- a/lib/yandex-checkout.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -require 'evil/client' - -require 'yandex-checkout/version' -require 'yandex-checkout/payment' -require 'yandex-checkout/refund' -require 'yandex-checkout/response' -require 'yandex-checkout/callable' -require 'yandex-checkout/optional' -require 'yandex-checkout/entity/payment' -require 'yandex-checkout/entity/refund' -require 'yandex-checkout/error' diff --git a/lib/yandex-checkout/version.rb b/lib/yandex-checkout/version.rb deleted file mode 100644 index 8f935aa..0000000 --- a/lib/yandex-checkout/version.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -module YandexCheckout - VERSION = '0.1.1' -end diff --git a/lib/yookassa.rb b/lib/yookassa.rb new file mode 100644 index 0000000..9f53334 --- /dev/null +++ b/lib/yookassa.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'evil/client' + +require 'yookassa/version' +require 'yookassa/payment' +require 'yookassa/refund' +require 'yookassa/response' +require 'yookassa/callable' +require 'yookassa/optional' +require 'yookassa/entity/payment' +require 'yookassa/entity/refund' +require 'yookassa/error' diff --git a/lib/yandex-checkout/callable.rb b/lib/yookassa/callable.rb similarity index 84% rename from lib/yandex-checkout/callable.rb rename to lib/yookassa/callable.rb index 9893cb7..fa08026 100644 --- a/lib/yandex-checkout/callable.rb +++ b/lib/yookassa/callable.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module YandexCheckout +module Yookassa module Callable def call(*args) new(*args) diff --git a/lib/yandex-checkout/entity/amount.rb b/lib/yookassa/entity/amount.rb similarity index 68% rename from lib/yandex-checkout/entity/amount.rb rename to lib/yookassa/entity/amount.rb index f3442a7..4182e04 100644 --- a/lib/yandex-checkout/entity/amount.rb +++ b/lib/yookassa/entity/amount.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -module YandexCheckout +module Yookassa module Entity class Amount extend Dry::Initializer - extend YandexCheckout::Callable - include YandexCheckout::Optional + extend Yookassa::Callable + include Yookassa::Optional option :value, proc(&:to_f), optional: true option :currency, proc(&:to_s), optional: true diff --git a/lib/yandex-checkout/entity/card.rb b/lib/yookassa/entity/card.rb similarity index 74% rename from lib/yandex-checkout/entity/card.rb rename to lib/yookassa/entity/card.rb index 7d5b3b4..26b23a7 100644 --- a/lib/yandex-checkout/entity/card.rb +++ b/lib/yookassa/entity/card.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -module YandexCheckout +module Yookassa module Entity class Card extend Dry::Initializer - extend YandexCheckout::Callable - include YandexCheckout::Optional + extend Yookassa::Callable + include Yookassa::Optional option :first6 option :last4 diff --git a/lib/yandex-checkout/entity/confirmation.rb b/lib/yookassa/entity/confirmation.rb similarity index 76% rename from lib/yandex-checkout/entity/confirmation.rb rename to lib/yookassa/entity/confirmation.rb index b8a0d8b..cab9f3a 100644 --- a/lib/yandex-checkout/entity/confirmation.rb +++ b/lib/yookassa/entity/confirmation.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -module YandexCheckout +module Yookassa module Entity class Confirmation extend Dry::Initializer - extend YandexCheckout::Callable - include YandexCheckout::Optional + extend Yookassa::Callable + include Yookassa::Optional option :type, proc(&:to_s), optional: true option :confirmation_url, proc(&:to_s), optional: true diff --git a/lib/yandex-checkout/entity/payment.rb b/lib/yookassa/entity/payment.rb similarity index 89% rename from lib/yandex-checkout/entity/payment.rb rename to lib/yookassa/entity/payment.rb index eaa6100..e91f5b4 100644 --- a/lib/yandex-checkout/entity/payment.rb +++ b/lib/yookassa/entity/payment.rb @@ -4,9 +4,9 @@ require_relative './payment_method' require_relative './confirmation' -module YandexCheckout +module Yookassa module Entity - class Payment < YandexCheckout::Response + class Payment < Yookassa::Response option :paid option :amount, Entity::Amount option :created_at diff --git a/lib/yandex-checkout/entity/payment_method.rb b/lib/yookassa/entity/payment_method.rb similarity index 76% rename from lib/yandex-checkout/entity/payment_method.rb rename to lib/yookassa/entity/payment_method.rb index b5e1c3e..fb123eb 100644 --- a/lib/yandex-checkout/entity/payment_method.rb +++ b/lib/yookassa/entity/payment_method.rb @@ -2,12 +2,12 @@ require_relative './card' -module YandexCheckout +module Yookassa module Entity class PaymentMethod extend Dry::Initializer - extend YandexCheckout::Callable - include YandexCheckout::Optional + extend Yookassa::Callable + include Yookassa::Optional option :type, proc(&:to_s) option :id, proc(&:to_s) diff --git a/lib/yandex-checkout/entity/refund.rb b/lib/yookassa/entity/refund.rb similarity index 82% rename from lib/yandex-checkout/entity/refund.rb rename to lib/yookassa/entity/refund.rb index b5826dc..56dabea 100644 --- a/lib/yandex-checkout/entity/refund.rb +++ b/lib/yookassa/entity/refund.rb @@ -2,9 +2,9 @@ require_relative './amount' -module YandexCheckout +module Yookassa module Entity - class Refund < YandexCheckout::Response + class Refund < Yookassa::Response option :payment_id option :created_at, proc(&:to_s) option :amount, Entity::Amount diff --git a/lib/yandex-checkout/error.rb b/lib/yookassa/error.rb similarity index 86% rename from lib/yandex-checkout/error.rb rename to lib/yookassa/error.rb index ef921e9..7181614 100644 --- a/lib/yandex-checkout/error.rb +++ b/lib/yookassa/error.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -module YandexCheckout +module Yookassa class Error extend Dry::Initializer - extend YandexCheckout::Callable - include YandexCheckout::Optional + extend Yookassa::Callable + include Yookassa::Optional option :type, proc(&:to_s) option :id, proc(&:to_s), optional: true diff --git a/lib/yandex-checkout/optional.rb b/lib/yookassa/optional.rb similarity index 95% rename from lib/yandex-checkout/optional.rb rename to lib/yookassa/optional.rb index 9351080..4bed54c 100644 --- a/lib/yandex-checkout/optional.rb +++ b/lib/yookassa/optional.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module YandexCheckout +module Yookassa module Optional private diff --git a/lib/yandex-checkout/payment.rb b/lib/yookassa/payment.rb similarity index 95% rename from lib/yandex-checkout/payment.rb rename to lib/yookassa/payment.rb index c5a31f1..53bdc3c 100644 --- a/lib/yandex-checkout/payment.rb +++ b/lib/yookassa/payment.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -module YandexCheckout +module Yookassa class Payment < Evil::Client option :shop_id, proc(&:to_s) option :api_key, proc(&:to_s) - path { 'https://payment.yandex.net/api/v3/payments' } + path { 'https://api.yookassa.ru/v3/payments' } security { basic_auth shop_id, api_key } operation :get_payment_info do diff --git a/lib/yandex-checkout/refund.rb b/lib/yookassa/refund.rb similarity index 90% rename from lib/yandex-checkout/refund.rb rename to lib/yookassa/refund.rb index dd8b605..a3acf5b 100644 --- a/lib/yandex-checkout/refund.rb +++ b/lib/yookassa/refund.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -module YandexCheckout +module Yookassa class Refund < Evil::Client option :shop_id, proc(&:to_s) option :api_key, proc(&:to_s) - path { 'https://payment.yandex.net/api/v3/refunds' } + path { 'https://api.yookassa.ru/v3/refunds' } security { basic_auth shop_id, api_key } operation :get_refund_info do diff --git a/lib/yandex-checkout/response.rb b/lib/yookassa/response.rb similarity index 94% rename from lib/yandex-checkout/response.rb rename to lib/yookassa/response.rb index c5d267d..f4053b9 100644 --- a/lib/yandex-checkout/response.rb +++ b/lib/yookassa/response.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module YandexCheckout +module Yookassa class Response extend Dry::Initializer option :id, proc(&:to_s) diff --git a/lib/yookassa/version.rb b/lib/yookassa/version.rb new file mode 100644 index 0000000..66fd411 --- /dev/null +++ b/lib/yookassa/version.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Yookassa + VERSION = '0.1.0' +end diff --git a/spec/fixtures/payment_response.json b/spec/fixtures/payment_response.json index 5082c25..662b38e 100644 --- a/spec/fixtures/payment_response.json +++ b/spec/fixtures/payment_response.json @@ -9,11 +9,10 @@ "confirmation": { "type": "redirect", "return_url": "https://url.test", - "confirmation_url": "https://money.yandex.ru/payments/external/confirmation?orderId=2490ded1-000f-5000-8000-1f64111bc63e" + "confirmation_url": "https://money.yookassa.ru/payments/external/confirmation?orderId=2490ded1-000f-5000-8000-1f64111bc63e" }, "created_at": "2019-06-10T21:26:41.395Z", - "metadata": { - }, + "metadata": {}, "payment_method": { "type": "bank_card", "id": "2490ded1-000f-5000-8000-1f64111bc63e", diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a23d861..1539d0c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,10 +1,12 @@ +# frozen_string_literal: true + begin require 'pry' rescue LoadError nil end -require 'yandex-checkout' +require 'yookassa' require 'webmock/rspec' RSpec.configure do |config| diff --git a/spec/yandex-checkout_spec.rb b/spec/yandex-checkout_spec.rb deleted file mode 100644 index 7a6ed85..0000000 --- a/spec/yandex-checkout_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -RSpec.describe YandexCheckout do - it 'has a version number' do - expect(YandexCheckout::VERSION).not_to be nil - end -end diff --git a/spec/yandex-checkout/payment_spec.rb b/spec/yookassa/payment_spec.rb similarity index 81% rename from spec/yandex-checkout/payment_spec.rb rename to spec/yookassa/payment_spec.rb index 770e10f..dfa53f4 100644 --- a/spec/yandex-checkout/payment_spec.rb +++ b/spec/yookassa/payment_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -RSpec.describe YandexCheckout::Payment do +RSpec.describe Yookassa::Payment do let(:settings) { { shop_id: 'SHOP_ID', api_key: 'API_KEY' } } let(:idempotency_key) { 12_345 } let(:payment) { described_class.new(settings) } shared_examples 'returns_payment_object' do it 'returns success' do - expect(subject).to be_kind_of YandexCheckout::Response + expect(subject).to be_kind_of Yookassa::Response expect(subject.id).to eq '2490ded1-000f-5000-8000-1f64111bc63e' expect(subject.test).to eq true expect(subject.paid).to eq false @@ -18,17 +18,17 @@ expect(subject.expires_at).to eq nil expect(subject.metadata).to eq Hash[] - expect(subject.amount).to be_kind_of YandexCheckout::Entity::Amount + expect(subject.amount).to be_kind_of Yookassa::Entity::Amount expect(subject.amount.currency).to eq 'RUB' expect(subject.amount.value).to eq 10.0 - expect(subject.confirmation).to be_kind_of YandexCheckout::Entity::Confirmation - expect(subject.confirmation.confirmation_url).to eq 'https://money.yandex.ru/payments/external/confirmation?orderId=2490ded1-000f-5000-8000-1f64111bc63e' + expect(subject.confirmation).to be_kind_of Yookassa::Entity::Confirmation + expect(subject.confirmation.confirmation_url).to eq 'https://money.yookassa.ru/payments/external/confirmation?orderId=2490ded1-000f-5000-8000-1f64111bc63e' expect(subject.confirmation.type).to eq 'redirect' expect(subject.confirmation.return_url).to eq 'https://url.test' expect(subject.confirmation.enforce).to eq nil - expect(subject.payment_method).to be_kind_of YandexCheckout::Entity::PaymentMethod + expect(subject.payment_method).to be_kind_of Yookassa::Entity::PaymentMethod expect(subject.payment_method.card).to eq nil expect(subject.payment_method.id).to eq '2490ded1-000f-5000-8000-1f64111bc63e' expect(subject.payment_method.saved).to eq false @@ -39,7 +39,7 @@ describe '#create' do let(:params) { { payment: File.read('spec/fixtures/payment.json') } } - let(:url) { 'https://payment.yandex.net/api/v3/payments' } + let(:url) { 'https://api.yookassa.ru/v3/payments' } let(:body) { File.read('spec/fixtures/payment_response.json') } before { stub_request(:any, //).to_return(body: body) } @@ -55,7 +55,7 @@ describe '#get_payment_info' do let(:payment_id) { '2490ded1-000f-5000-8000-1f64111bc63e' } - let(:url) { "https://payment.yandex.net/api/v3/payments/#{payment_id}" } + let(:url) { "https://api.yookassa.ru/v3/payments/#{payment_id}" } let(:body) { File.read('spec/fixtures/payment_response.json') } before { stub_request(:any, //).to_return(body: body) } @@ -72,7 +72,7 @@ describe '#capture' do let(:payment_id) { '2490ded1-000f-5000-8000-1f64111bc63e' } let(:params) { { payment: File.read('spec/fixtures/payment.json') } } - let(:url) { "https://payment.yandex.net/api/v3/payments/#{payment_id}/capture" } + let(:url) { "https://api.yookassa.ru/v3/payments/#{payment_id}/capture" } let(:body) { File.read('spec/fixtures/payment_response.json') } before { stub_request(:any, //).to_return(body: body) } @@ -88,7 +88,7 @@ describe '#cancel' do let(:payment_id) { '2490ded1-000f-5000-8000-1f64111bc63e' } - let(:url) { "https://payment.yandex.net/api/v3/payments/#{payment_id}/cancel" } + let(:url) { "https://api.yookassa.ru/v3/payments/#{payment_id}/cancel" } let(:body) { File.read('spec/fixtures/payment_response.json') } before { stub_request(:any, //).to_return(body: body) } diff --git a/spec/yandex-checkout/refund_spec.rb b/spec/yookassa/refund_spec.rb similarity index 83% rename from spec/yandex-checkout/refund_spec.rb rename to spec/yookassa/refund_spec.rb index 33ae5b4..5373e80 100644 --- a/spec/yandex-checkout/refund_spec.rb +++ b/spec/yookassa/refund_spec.rb @@ -1,20 +1,20 @@ # frozen_string_literal: true -RSpec.describe YandexCheckout::Refund do +RSpec.describe Yookassa::Refund do let(:settings) { { shop_id: 'SHOP_ID', api_key: 'API_KEY' } } let(:idempotency_key) { 12_345 } let(:payment) { described_class.new(settings) } shared_examples 'returns_refund_object' do it 'returns success' do - expect(subject).to be_kind_of YandexCheckout::Response + expect(subject).to be_kind_of Yookassa::Response expect(subject.id).to eq '2491ab0c-0015-5000-9000-1640c7f1a6f0' expect(subject.payment_id).to eq '2491a6e2-000f-5000-9000-1480e820ae17' expect(subject.status).to eq 'succeeded' expect(subject.created_at).to eq '2019-06-11T11:58:04.502Z' expect(subject.description).to eq 'test refund, idem-key 78c95366-ec4b-4284-a0fd-41e694bcdf11' - expect(subject.amount).to be_kind_of YandexCheckout::Entity::Amount + expect(subject.amount).to be_kind_of Yookassa::Entity::Amount expect(subject.amount.currency).to eq 'RUB' expect(subject.amount.value).to eq 8.0 end @@ -22,7 +22,7 @@ describe '#create' do let(:payload) { File.read('spec/fixtures/refund.json') } - let(:url) { 'https://payment.yandex.net/api/v3/refunds' } + let(:url) { 'https://api.yookassa.ru/v3/refunds' } let(:body) { File.read('spec/fixtures/refund_response.json') } before { stub_request(:any, //).to_return(body: body) } @@ -38,7 +38,7 @@ describe '#get_refund_info' do let(:payment_id) { '2490ded1-000f-5000-8000-1f64111bc63e' } - let(:url) { "https://payment.yandex.net/api/v3/refunds/#{payment_id}" } + let(:url) { "https://api.yookassa.ru/v3/refunds/#{payment_id}" } let(:body) { File.read('spec/fixtures/refund_response.json') } before { stub_request(:any, //).to_return(body: body) } diff --git a/spec/yookassa_spec.rb b/spec/yookassa_spec.rb new file mode 100644 index 0000000..c08df3a --- /dev/null +++ b/spec/yookassa_spec.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +RSpec.describe Yookassa do + it 'has a version number' do + expect(Yookassa::VERSION).not_to be nil + end +end diff --git a/yandex-checkout.gemspec b/yookassa.gemspec similarity index 75% rename from yandex-checkout.gemspec rename to yookassa.gemspec index 3a52813..b375d76 100644 --- a/yandex-checkout.gemspec +++ b/yookassa.gemspec @@ -2,16 +2,16 @@ lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'yandex-checkout/version' +require 'yookassa/version' Gem::Specification.new do |spec| - spec.name = 'yandex-checkout' - spec.version = YandexCheckout::VERSION + spec.name = 'yookassa' + spec.version = Yookassa::VERSION spec.authors = 'Andrey Paderin' spec.email = 'andy.paderin@gmail.com' - spec.summary = 'This product is used for managing payments under The Yandex.Checkout API For usage by those who implemented Yandex.Checkout using the API method.' - spec.homepage = 'https://github.com/paderinandrey/yandex-checkout' + spec.summary = 'This product is used for managing payments under The Yookassa API For usage by those who implemented Yookassa using the API method.' + spec.homepage = 'https://github.com/paderinandrey/yookassa' spec.license = 'MIT' spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)