Used nodes:
Linux raspberrypi 4.9.41-v7+ #1023 SMP Tue Aug 8 16:00:15 BST 2017 armv7l GNU/Linux
Linux localhost.localdomain 4.14.5-200.fc26.x86_64 #1 SMP Mon Dec 11 16:29:08 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
require 'openssl' | |
class String | |
def encrypt(key) | |
cipher = OpenSSL::Cipher::Cipher.new('DES-EDE3-CBC').encrypt | |
cipher.key = Digest::SHA1.hexdigest key | |
s = cipher.update(self) + cipher.final | |
s.unpack('H*')[0].upcase | |
end |
# MODEL | |
class Case < ActiveRecord::Base | |
include Eventable | |
has_many :tasks | |
concerning :Assignment do | |
def assign_to(new_owner:, details:) | |
transaction do |
# Sum feature's price and convert to cents | |
amount = self.features.inject(0) { |sum, feature| sum + feature.price} | |
amount_in_cents = (amount * 100).to_i | |
# Create needed Paymill object (client / payment / offer / subscription) | |
client = Paymill::Client.create email: email, description: name | |
payment = Paymill::Payment.create token: paymill_card_token, client: client.id | |
offer = Paymill::Offer.create amount: amount_in_cents, currency: "EUR", interval: "1 MONTH", name: "Subscription for #{name}" | |
subscription = Paymill::Subscription.create offer: offer.id, client: client.id, payment: payment.id |