diff --git a/CHANGELOG.md b/CHANGELOG.md index cb2ac8d98..59ad4a677 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog Fab-manager +## v5.0.3 2021 June 14 + +- Updated user's manual for v5 +- Improved test coverage on payment schedules +- Fix a bug: unable to process stripe payments with 3DS authentication +- Fix a bug: unable to book an event +- Fix a bug: unable to list user's payment schedules in the dashboard + ## v5.0.2 2021 June 11 - Ability to upgrade to a specific version with the script @@ -53,6 +61,10 @@ - [TODO DEPLOY] `rails fablab:maintenance:rebuild_stylesheet` - [TODO DEPLOY] `\curl -sSL https://raw.githubusercontent.com/sleede/fab-manager/master/scripts/rename-adminsys.sh | bash` +## v4.7.13 2020 June 11 + +- Fix a bug: unable to process stripe payments with 3DS authentication + ## v4.7.12 2021 June 09 - Fix a bug: unable to process stripe payments diff --git a/Procfile b/Procfile index e68a73938..bbda6f44f 100644 --- a/Procfile +++ b/Procfile @@ -1,4 +1,4 @@ -web: bundle exec rails server puma -p $PORT +#web: bundle exec rails server puma -p $PORT worker: bundle exec sidekiq -C ./config/sidekiq.yml wp-client: bin/webpack-dev-server wp-server: SERVER_BUNDLE_ONLY=yes bin/webpack --watch diff --git a/app/controllers/api/payment_schedules_controller.rb b/app/controllers/api/payment_schedules_controller.rb index f195ed22b..1b909bd8d 100644 --- a/app/controllers/api/payment_schedules_controller.rb +++ b/app/controllers/api/payment_schedules_controller.rb @@ -8,7 +8,7 @@ class API::PaymentSchedulesController < API::ApiController def index @payment_schedules = PaymentSchedule.where('invoicing_profile_id = ?', current_user.invoicing_profile.id) - .includes(:invoicing_profile, :payment_schedule_items, :subscription) + .includes(:invoicing_profile, :payment_schedule_items, :payment_schedule_objects) .joins(:invoicing_profile) .order('payment_schedules.created_at DESC') .page(params[:page]) diff --git a/app/controllers/api/stripe_controller.rb b/app/controllers/api/stripe_controller.rb index 3aa1b79b5..533332663 100644 --- a/app/controllers/api/stripe_controller.rb +++ b/app/controllers/api/stripe_controller.rb @@ -34,7 +34,7 @@ class API::StripeController < API::PaymentsController }, { api_key: Setting.get('stripe_secret_key') } ) elsif params[:payment_intent_id].present? - intent = Stripe::PaymentIntent.confirm(params[:payment_intent_id], api_key: Setting.get('stripe_secret_key')) + intent = Stripe::PaymentIntent.confirm(params[:payment_intent_id], {}, { api_key: Setting.get('stripe_secret_key') }) end rescue Stripe::CardError => e # Display error on client diff --git a/app/frontend/src/javascript/controllers/dashboard.js b/app/frontend/src/javascript/controllers/dashboard.js index f589b4cf8..5fbb80328 100644 --- a/app/frontend/src/javascript/controllers/dashboard.js +++ b/app/frontend/src/javascript/controllers/dashboard.js @@ -12,72 +12,73 @@ */ 'use strict'; -Application.Controllers.controller('DashboardController', ['$scope', 'memberPromise', 'trainingsPromise', 'SocialNetworks', function ($scope, memberPromise, trainingsPromise, SocialNetworks) { - // Current user's profile - $scope.user = memberPromise; +Application.Controllers.controller('DashboardController', ['$scope', 'memberPromise', 'trainingsPromise', 'SocialNetworks', 'growl', + function ($scope, memberPromise, trainingsPromise, SocialNetworks, growl) { + // Current user's profile + $scope.user = memberPromise; - // List of social networks associated with this user and toggle 'show all' state - $scope.social = { - showAllLinks: false, - networks: SocialNetworks - }; + // List of social networks associated with this user and toggle 'show all' state + $scope.social = { + showAllLinks: false, + networks: SocialNetworks + }; - /** - * Check if the member has used his training credits for the given credit - * @param trainingCredits array of credits used by the member - * @param trainingId id of the training to find - */ - $scope.hasUsedTrainingCredit = function (trainingCredits, trainingId) { - return trainingCredits.find(tc => tc.training_id === trainingId); - }; + /** + * Check if the member has used his training credits for the given credit + * @param trainingCredits array of credits used by the member + * @param trainingId id of the training to find + */ + $scope.hasUsedTrainingCredit = function (trainingCredits, trainingId) { + return trainingCredits.find(tc => tc.training_id === trainingId); + }; - /** - * Return the name associated with the provided training ID - * @param trainingId training identifier - * @return {string} - */ - $scope.getTrainingName = function (trainingId) { - return trainingsPromise.find(t => t.id === trainingId).name; - }; + /** + * Return the name associated with the provided training ID + * @param trainingId training identifier + * @return {string} + */ + $scope.getTrainingName = function (trainingId) { + return trainingsPromise.find(t => t.id === trainingId).name; + }; - /* PRIVATE SCOPE */ + /* PRIVATE SCOPE */ - /** - * Kind of constructor: these actions will be realized first when the controller is loaded - */ - const initialize = () => $scope.social.networks = filterNetworks(); + /** + * Kind of constructor: these actions will be realized first when the controller is loaded + */ + const initialize = () => $scope.social.networks = filterNetworks(); - /** - * Filter the social networks or websites that are associated with the profile of the user provided in promise - * and return the filtered networks - * @return {Array} - */ - const filterNetworks = function () { - const networks = []; - for (const network of Array.from(SocialNetworks)) { - if ($scope.user.profile[network] && ($scope.user.profile[network].length > 0)) { - networks.push(network); + /** + * Filter the social networks or websites that are associated with the profile of the user provided in promise + * and return the filtered networks + * @return {Array} + */ + const filterNetworks = function () { + const networks = []; + for (const network of Array.from(SocialNetworks)) { + if ($scope.user.profile[network] && ($scope.user.profile[network].length > 0)) { + networks.push(network); + } } - } - return networks; - }; + return networks; + }; - /** - * Callback used in PaymentScheduleDashboard, in case of error - */ - $scope.onError = function (message) { - growl.error(message); - }; + /** + * Callback used in PaymentScheduleDashboard, in case of error + */ + $scope.onError = function (message) { + growl.error(message); + }; - /** - * Callback triggered when the user has successfully updated his card - */ - $scope.onCardUpdateSuccess = function (message) { - growl.success(message); - }; + /** + * Callback triggered when the user has successfully updated his card + */ + $scope.onCardUpdateSuccess = function (message) { + growl.success(message); + }; - // !!! MUST BE CALLED AT THE END of the controller - return initialize(); -} + // !!! MUST BE CALLED AT THE END of the controller + return initialize(); + } ]); diff --git a/app/frontend/src/javascript/controllers/events.js.erb b/app/frontend/src/javascript/controllers/events.js.erb index 3f9d0a54d..d25b27740 100644 --- a/app/frontend/src/javascript/controllers/events.js.erb +++ b/app/frontend/src/javascript/controllers/events.js.erb @@ -633,7 +633,7 @@ Application.Controllers.controller('ShowEventController', ['$scope', '$state', ' * Create a hash map implementing the Reservation specs * @param reserve {Object} Reservation parameters (places...) * @param event {Object} Current event - * @return {{reservable_id:number, reservable_type:string, slots_attributes:Array, nb_reserve_places:number}} + * @return {{reservation: {reservable_id:number, reservable_type:string, slots_attributes:Array, nb_reserve_places:number}}} */ const mkReservation = function (reserve, event) { const reservation = { @@ -661,7 +661,7 @@ Application.Controllers.controller('ShowEventController', ['$scope', '$state', ' } } - return reservation; + return { reservation }; }; /** diff --git a/app/models/user.rb b/app/models/user.rb index bfcc85924..853046268 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -53,7 +53,7 @@ class User < ApplicationRecord end before_create :assign_default_role - after_commit :create_stripe_customer, on: [:create] + after_commit :create_gateway_customer, on: [:create] after_commit :notify_admin_when_user_is_created, on: :create after_create :init_dependencies after_update :notify_group_changed, if: :saved_change_to_group_id? @@ -366,8 +366,8 @@ class User < ApplicationRecord errors.add(:cgu, I18n.t('activerecord.errors.messages.empty')) if cgu == '0' end - def create_stripe_customer - StripeWorker.perform_async(:create_stripe_customer, id) + def create_gateway_customer + PaymentGatewayService.new.create_user(id) end def send_devise_notification(notification, *args) diff --git a/app/services/payment_gateway_service.rb b/app/services/payment_gateway_service.rb index 27edf0f5d..b1ec6fb46 100644 --- a/app/services/payment_gateway_service.rb +++ b/app/services/payment_gateway_service.rb @@ -23,6 +23,10 @@ class PaymentGatewayService @gateway.create_subscription(payment_schedule, gateway_object_id) end + def create_user(user_id) + @gateway.create_user(user_id) + end + def create_coupon(coupon_id) @gateway.create_coupon(coupon_id) end diff --git a/doc/README.md b/doc/README.md index d797071b4..8c6aa6266 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1,12 +1,20 @@ # Fab-Manager's documentations +##### Table of contents + +1. [User's manual](#users-manual)
+2. [System administrator](#system-administrator)
+2.1. [Upgrades procedures](#upgrades-procedures)
+3. [Translator's documentation](#translators-documentation)
+4. [Developer's documentation](#developers-documentation)
+4.1. [Architecture](#architecture)
+4.2. [How to setup a development environment](#how-to-setup-a-development-environment)
+4.3. [Externals](#externals)
+4.4. [Diagrams](#diagrams)
+ ### User's manual The following guide describes what you can do and how to use Fab-manager. - - [Français](fr/guide_utilisation_fab_manager_v4.7.pdf) - -### General documentation -Translators, contributors, developers and system administrators should start by reading this document. -- [Read first](../README.md) + - [Français](fr/guide_utilisation_fab_manager_v5.0.pdf) ### System administrator The following guides are designed for the people that perform software maintenance. diff --git a/doc/fr/guide_utilisation_fab_manager_v4.7.pdf b/doc/fr/guide_utilisation_fab_manager_v4.7.pdf deleted file mode 100755 index fb8f126ca..000000000 Binary files a/doc/fr/guide_utilisation_fab_manager_v4.7.pdf and /dev/null differ diff --git a/doc/fr/guide_utilisation_fab_manager_v5.0.pdf b/doc/fr/guide_utilisation_fab_manager_v5.0.pdf new file mode 100755 index 000000000..7290df798 Binary files /dev/null and b/doc/fr/guide_utilisation_fab_manager_v5.0.pdf differ diff --git a/lib/pay_zen/helper.rb b/lib/pay_zen/helper.rb index 047980920..ea98c972b 100644 --- a/lib/pay_zen/helper.rb +++ b/lib/pay_zen/helper.rb @@ -19,10 +19,10 @@ class PayZen::Helper end ## generate an unique string reference for the content of a cart - def generate_ref(cart_items, customer, date = DateTime.current) + def generate_ref(cart_items, customer) require 'sha3' - content = { cart_items: cart_items, customer: customer }.to_json + date.to_s + content = { cart_items: cart_items, customer: customer }.to_json + DateTime.current.to_s # It's safe to truncate a hash. See https://crypto.stackexchange.com/questions/74646/sha3-255-one-bit-less SHA3::Digest.hexdigest(:sha224, content)[0...24] end diff --git a/lib/payment/service.rb b/lib/payment/service.rb index 742bad526..4437328e8 100644 --- a/lib/payment/service.rb +++ b/lib/payment/service.rb @@ -8,6 +8,8 @@ module Payment; end class Payment::Service def create_subscription(_payment_schedule, _gateway_object_id); end + def create_user(_user_id); end + def create_coupon(_coupon_id); end def delete_coupon(_coupon_id); end diff --git a/lib/stripe/service.rb b/lib/stripe/service.rb index f3015327d..f9d1624d6 100644 --- a/lib/stripe/service.rb +++ b/lib/stripe/service.rb @@ -49,6 +49,10 @@ class Stripe::Service < Payment::Service pgo.save! end + def create_user(user_id) + StripeWorker.perform_async(:create_stripe_customer, user_id) + end + def create_coupon(coupon_id) coupon = Coupon.find(coupon_id) stp_coupon = { id: coupon.code } diff --git a/package.json b/package.json index 541cb44f4..1ea208922 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fab-manager", - "version": "5.0.2", + "version": "5.0.3", "description": "Fab-manager is the FabLab management solution. It provides a comprehensive, web-based, open-source tool to simplify your administrative tasks and your marker's projects.", "keywords": [ "fablab", diff --git a/test/controllers/payment_schedules_controller_test.rb b/test/controllers/payment_schedules_controller_test.rb new file mode 100644 index 000000000..446e5a558 --- /dev/null +++ b/test/controllers/payment_schedules_controller_test.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +require 'test_helper' + +class PaymentSchedulesControllerTest < ActionDispatch::IntegrationTest + def setup + @user = User.friendly.find('pjproudhon') + login_as(@user, scope: :user) + end + + test "should get user's schedules" do + get payment_schedules_url + assert_response :success + + assert_equal @user.invoicing_profile.payment_schedules.count, json_response(response.body).length + end +end diff --git a/test/fixtures/invoicing_profiles.yml b/test/fixtures/invoicing_profiles.yml index 3d2a4e206..626c047bb 100644 --- a/test/fixtures/invoicing_profiles.yml +++ b/test/fixtures/invoicing_profiles.yml @@ -53,3 +53,10 @@ atiermoulin: first_name: Amandine last_name: Tiermoulin email: a.tiermoulin@mail.fr + +proudhon: + id: 9 + user_id: 9 + first_name: Pierre-Joseph + last_name: Proudhon + email: pj.proudhon@la-propriete.org diff --git a/test/fixtures/payment_gateway_objects.yml b/test/fixtures/payment_gateway_objects.yml index d15d2624b..3dd7fbc88 100644 --- a/test/fixtures/payment_gateway_objects.yml +++ b/test/fixtures/payment_gateway_objects.yml @@ -1,161 +1,210 @@ -pgo_1: +pgo1: + id: 1 item_type: 'InvoiceItem' item_id: 1 gateway_object_type: 'Stripe::Subscription' gateway_object_id: 'sub_8DGB4ErIc2asOv' pgo2: + id: 2 item_type: 'Subscription' item_id: 1 gateway_object_type: 'Stripe::Subscription' gateway_object_id: 'sub_8DGB4ErIc2asOv' pgo3: + id: 3 item_type: 'Invoice' item_id: 1 gateway_object_type: 'Stripe::Invoice' gateway_object_id: 'in_17wpf92sOmf47Nz9itj6vmJw' pgo4: + id: 4 item_type: 'Plan' item_id: 1 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyXhfyNiGkWR' pgo5: + id: 5 item_type: 'Plan' item_id: 2 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPykam7a4satn' pgo6: + id: 6 item_type: 'Plan' item_id: 3 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyM4N36h86G0' pgo7: + id: 7 item_type: 'Plan' item_id: 4 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZQAhb9nLu4jfN' pgo8: + id: 8 item_type: 'Machine' item_id: 1 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyHpMCl38iQl' pgo9: + id: 9 item_type: 'Machine' item_id: 2 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyPShaaRgSML' pgo10: + id: 10 item_type: 'Machine' item_id: 3 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyEjmdfMowhY' pgo11: + id: 11 item_type: 'Machine' item_id: 4 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPy85vZOQpAo5' pgo12: + id: 12 item_type: 'Machine' item_id: 5 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyBJEgbcpWMC' pgo13: + id: 13 item_type: 'Machine' item_id: 6 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyjCzvLmLWAz' pgo14: + id: 14 item_type: 'Space' item_id: 1 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyHjIb2owoB8' pgo15: + id: 15 item_type: 'Training' item_id: 1 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyXw6BDBBFOg' pgo16: + id: 16 item_type: 'Training' item_id: 2 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPytTl1wSB5jH' pgo17: + id: 17 item_type: 'Training' item_id: 3 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyAA1A4QfEyL' pgo18: + id: 18 item_type: 'Training' item_id: 4 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyU27NjDSmqB' pgo19: + id: 19 item_type: 'Training' item_id: 5 gateway_object_type: 'Stripe::Product' gateway_object_id: 'prod_IZPyvdgQHMByB3' pgo20: + id: 20 item_type: 'User' item_id: 1 gateway_object_type: 'Stripe::Customer' gateway_object_id: 'cus_8CyNk3UTi8lvCc' pgo21: + id: 21 item_type: 'User' item_id: 2 gateway_object_type: 'Stripe::Customer' gateway_object_id: 'cus_8Di1wjdVktv5kt' pgo22: + id: 22 item_type: 'User' item_id: 3 gateway_object_type: 'Stripe::Customer' gateway_object_id: 'cus_8CzHcwBJtlA3IL' pgo23: + id: 23 item_type: 'User' item_id: 4 gateway_object_type: 'Stripe::Customer' gateway_object_id: 'cus_8CzKe50I0J1gaI' pgo24: + id: 24 item_type: 'User' item_id: 5 gateway_object_type: 'Stripe::Customer' gateway_object_id: 'cus_8CzNtM08NVlSGN' pgo25: + id: 25 item_type: 'User' item_id: 6 gateway_object_type: 'Stripe::Customer' gateway_object_id: 'cus_8CzQK5uXPeyh4K' pgo26: + id: 26 item_type: 'User' item_id: 7 gateway_object_type: 'Stripe::Customer' gateway_object_id: 'cus_8E2ys9zDZgetWX' pgo27: + id: 27 item_type: 'User' item_id: 8 gateway_object_type: 'Stripe::Customer' gateway_object_id: 'cus_IhIynmoJbzLpwX' + +pgo28: + id: 28 + gateway_object_id: b28adca1f5805ecfae87ecea + gateway_object_type: PayZen::Order + item_type: PaymentSchedule + item_id: 12 + +pgo29: + id: 29 + gateway_object_id: 5f02e6573ff844f391238e5185644929 + gateway_object_type: PayZen::Token + item_type: PaymentSchedule + item_id: 12 + +pgo30: + id: 30 + gateway_object_id: 20210614KPWlKu + gateway_object_type: PayZen::Subscription + item_type: PaymentSchedule + item_id: 12 + payment_gateway_object_id: 29 diff --git a/test/fixtures/payment_schedule_items.yml b/test/fixtures/payment_schedule_items.yml index e69de29bb..e689becc7 100644 --- a/test/fixtures/payment_schedule_items.yml +++ b/test/fixtures/payment_schedule_items.yml @@ -0,0 +1,168 @@ +payment_schedule_item_105: + id: 105 + amount: 9474 + due_date: '2021-06-14 12:24:45.836045' + state: paid + details: '{"recurring": 9466, "adjustment": 8, "other_items": 0}' + payment_method: card + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: 6168dcf85b00be2b45a36bbb3217e8b965a179c37922962978960062eac4bec6 + created_at: '2021-06-14 12:24:45.847551' + updated_at: '2021-06-14 13:00:41.302605' + +payment_schedule_item_106: + id: 106 + amount: 9466 + due_date: '2021-07-14 12:24:45.836332' + state: new + details: '{"recurring": 9466}' + payment_method: + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: ada6f6afe6489919d193ff6030923c0d524294529f13374f9a57d5691e9669fd + created_at: '2021-06-14 12:24:45.855717' + updated_at: '2021-06-14 12:24:45.858475' + + +payment_schedule_item_107: + id: 107 + amount: 9466 + due_date: '2021-08-14 12:24:45.836606' + state: new + details: '{"recurring": 9466}' + payment_method: + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: 7ca8bf5648235c8a706a01c5e788939ad5cfcc66c26782127ed1ed766379b005 + created_at: '2021-06-14 12:24:45.863237' + updated_at: '2021-06-14 12:24:45.865874' + +payment_schedule_item_108: + id: 108 + amount: 9466 + due_date: '2021-09-14 12:24:45.836767' + state: new + details: '{"recurring": 9466}' + payment_method: + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: 9d4925443f1537e07258140930489565542e48c39e3f9e48dd982bfae64cb759 + created_at: '2021-06-14 12:24:45.869357' + updated_at: '2021-06-14 12:24:45.872088' + +payment_schedule_item_109: + id: 109 + amount: 9466 + due_date: '2021-10-14 12:24:45.836900' + state: new + details: '{"recurring": 9466}' + payment_method: + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: 157ff90f880ebc5532be14898da65dcfc227fa54aaadc37a1f123dbeefa32640 + created_at: '2021-06-14 12:24:45.875500' + updated_at: '2021-06-14 12:24:45.879057' + +payment_schedule_item_110: + id: 110 + amount: 9466 + due_date: '2021-11-14 12:24:45.837025' + state: new + details: '{"recurring": 9466}' + payment_method: + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: 9b162c2b342d8c82e9163202a22a405b879d4b2ad2409a61ad10942f743bc576 + created_at: '2021-06-14 12:24:45.882343' + updated_at: '2021-06-14 12:24:45.884709' + +payment_schedule_item_111: + id: 111 + amount: 9466 + due_date: '2021-12-14 12:24:45.837025' + state: new + details: '{"recurring": 9466}' + payment_method: + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: 9b162c2b342d8c82e9163202a22a405b879d4b2ad2409a61ad10942f743bc576 + created_at: '2021-06-14 12:24:45.882343' + updated_at: '2021-06-14 12:24:45.884709' + +payment_schedule_item_112: + id: 112 + amount: 9466 + due_date: '2022-01-14 12:24:45.837025' + state: new + details: '{"recurring": 9466}' + payment_method: + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: 9b162c2b342d8c82e9163202a22a405b879d4b2ad2409a61ad10942f743bc576 + created_at: '2021-06-14 12:24:45.882343' + updated_at: '2021-06-14 12:24:45.884709' + +payment_schedule_item_113: + id: 113 + amount: 9466 + due_date: '2022-02-14 12:24:45.837025' + state: new + details: '{"recurring": 9466}' + payment_method: + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: 9b162c2b342d8c82e9163202a22a405b879d4b2ad2409a61ad10942f743bc576 + created_at: '2021-06-14 12:24:45.882343' + updated_at: '2021-06-14 12:24:45.884709' + +payment_schedule_item_114: + id: 114 + amount: 9466 + due_date: '2022-03-14 12:24:45.837025' + state: new + details: '{"recurring": 9466}' + payment_method: + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: 9b162c2b342d8c82e9163202a22a405b879d4b2ad2409a61ad10942f743bc576 + created_at: '2021-06-14 12:24:45.882343' + updated_at: '2021-06-14 12:24:45.884709' + +payment_schedule_item_115: + id: 115 + amount: 9466 + due_date: '2022-04-14 12:24:45.837025' + state: new + details: '{"recurring": 9466}' + payment_method: + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: 9b162c2b342d8c82e9163202a22a405b879d4b2ad2409a61ad10942f743bc576 + created_at: '2021-06-14 12:24:45.882343' + updated_at: '2021-06-14 12:24:45.884709' + +payment_schedule_item_116: + id: 116 + amount: 9466 + due_date: '2022-05-14 12:24:45.837025' + state: new + details: '{"recurring": 9466}' + payment_method: + client_secret: + payment_schedule_id: 12 + invoice_id: + footprint: 9b162c2b342d8c82e9163202a22a405b879d4b2ad2409a61ad10942f743bc576 + created_at: '2021-06-14 12:24:45.882343' + updated_at: '2021-06-14 12:24:45.884709' diff --git a/test/fixtures/payment_schedule_objects.yml b/test/fixtures/payment_schedule_objects.yml index e69de29bb..4a366c042 100644 --- a/test/fixtures/payment_schedule_objects.yml +++ b/test/fixtures/payment_schedule_objects.yml @@ -0,0 +1,9 @@ +payment_schedule_oject_10: + id: 10 + object_type: Subscription + object_id: 5 + payment_schedule_id: 12 + main: true + footprint: a1ef3a0c3abac7e02bc11193458c0d1e90a5acf290c9e3b4e7c049a7efcbeb30 + created_at: '2021-06-14 12:24:45.890373' + updated_at: '2021-06-14 12:24:45.894701' diff --git a/test/fixtures/payment_schedules.yml b/test/fixtures/payment_schedules.yml index e69de29bb..7ccecb8b6 100644 --- a/test/fixtures/payment_schedules.yml +++ b/test/fixtures/payment_schedules.yml @@ -0,0 +1,15 @@ +payment_schedule_12: + id: 12 + total: 180000 + reference: 210600309/E + payment_method: card + wallet_amount: + wallet_transaction_id: + coupon_id: + footprint: d4b66236895cdf18e21f64429a388050407f29bc228141ed95c89686b7daa716 + environment: development + invoicing_profile_id: 9 + statistic_profile_id: 9 + operator_profile_id: 1 + created_at: '2021-06-14 12:24:45.843714' + updated_at: '2021-06-14 12:24:45.908386' diff --git a/test/fixtures/profiles.yml b/test/fixtures/profiles.yml index 0daf95b3b..439ba2875 100644 --- a/test/fixtures/profiles.yml +++ b/test/fixtures/profiles.yml @@ -86,3 +86,14 @@ profile_8: software_mastered: freecad created_at: 2018-05-10 09:22:42.427521000 Z updated_at: 2021-01-04 14:36:39.729052932 Z + +profile_9: + id: 9 + user_id: 9 + first_name: Pierre-Joseph + last_name: Proudhon + phone: '0324121478' + interest: anarchisme, philosophie + software_mastered: + created_at: 2020-06-15 18:03:06.553623000 Z + updated_at: 2021-06-14 15:51:39.729052000 Z diff --git a/test/fixtures/statistic_profiles.yml b/test/fixtures/statistic_profiles.yml index 0acc8c1a6..3ecf17ddd 100644 --- a/test/fixtures/statistic_profiles.yml +++ b/test/fixtures/statistic_profiles.yml @@ -53,3 +53,10 @@ atiermoulin: gender: false birthday: 1985-09-01 group_id: 1 + +proudhon: + id: 9 + user_id: 9 + gender: true + birthday: 1809-01-15 + group_id: 1 diff --git a/test/fixtures/subscriptions.yml b/test/fixtures/subscriptions.yml index 49cac741d..87b4fdcd4 100644 --- a/test/fixtures/subscriptions.yml +++ b/test/fixtures/subscriptions.yml @@ -36,3 +36,12 @@ subscription_4: updated_at: 2018-06-11 14:27:12.427521000 Z expiration_date: 2018-07-11 14:27:12.427521000 Z canceled_at: + +subscription_5: + id: 5 + plan_id: 4 + statistic_profile_id: 9 + created_at: 2021-06-14 12:24:45.836045000 Z + updated_at: 2021-06-14 12:24:45.836045000 Z + expiration_date: 2022-06-14 12:24:45.836045000 Z + canceled_at: diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 7d80696f7..94b49105a 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -253,3 +253,35 @@ user_8: auth_token: merged_at: is_allow_newsletter: false + +user_9: + id: 9 + username: pjproudhon + email: pj.proudhon@la-propriete.org + encrypted_password: $2a$10$OJpiDDU/4WALJglRv0eS/eNeN6csXqhiMegn3pdciw6U.ELyCw53u + reset_password_token: + reset_password_sent_at: + remember_created_at: + sign_in_count: 1 + current_sign_in_at: 2020-06-29 13:34:36.725287 + last_sign_in_at: 2020-06-29 13:34:36.725287 + current_sign_in_ip: 162.21.14.7 + last_sign_in_ip: 162.21.14.7 + confirmation_token: + confirmed_at: 2020-10-23 07:55:32.355523 + confirmation_sent_at: 2020-06-15 18:03:06.728856 + unconfirmed_email: + failed_attempts: 0 + unlock_token: + locked_at: + created_at: 2020-06-15 18:03:06.553623 + updated_at: 2020-06-15 18:03:06.730140 + is_allow_contact: true + group_id: 1 + slug: pjproudhon + is_active: true + provider: + uid: + auth_token: + merged_at: + is_allow_newsletter: true diff --git a/test/fixtures/wallets.yml b/test/fixtures/wallets.yml index d810a3ce3..77ca99305 100644 --- a/test/fixtures/wallets.yml +++ b/test/fixtures/wallets.yml @@ -29,3 +29,7 @@ wallet_7: wallet_8: invoicing_profile_id: 8 amount: 0 + +wallet_9: + invoicing_profile_id: 9 + amount: 0 diff --git a/test/integration/payzen_test.rb b/test/integration/payzen_test.rb index 83c1ac81d..42b529b1c 100644 --- a/test/integration/payzen_test.rb +++ b/test/integration/payzen_test.rb @@ -93,7 +93,7 @@ class PayzenTest < ActionDispatch::IntegrationTest cs = CartService.new(@user) cart = cs.from_hash(cart_items) amount = cart.total[:total] - id = PayZen::Helper.generate_ref(cart_items, @user.id, DateTime.new(1970, 1, 1, 0, 0, 0)) + id = 'dffd53627a4901e986862674' VCR.use_cassette('confirm_payzen_payment_success') do client = PayZen::PCI::Charge.new