Merge branch 'upgrade/payment_info_attr' into 'master'
Pulled info from webhook such as amount_paid, paid_at, payment_fee and payment_method See merge request !3
Showing
2 changed files
with
8 additions
and
2 deletions
| ... | @@ -7,5 +7,9 @@ class AddVarStatusTo<%=@model_name.pluralize.camelize%> < ActiveRecord::Migratio | ... | @@ -7,5 +7,9 @@ class AddVarStatusTo<%=@model_name.pluralize.camelize%> < ActiveRecord::Migratio |
| 7 | add_column :<%=@model_name.pluralize.underscore%>, :var_payment_expires_at, :datetime | 7 | add_column :<%=@model_name.pluralize.underscore%>, :var_payment_expires_at, :datetime |
| 8 | add_column :<%=@model_name.pluralize.underscore%>, :var_id, :string | 8 | add_column :<%=@model_name.pluralize.underscore%>, :var_id, :string |
| 9 | add_column :<%=@model_name.pluralize.underscore%>, :var_service, :string | 9 | add_column :<%=@model_name.pluralize.underscore%>, :var_service, :string |
| 10 | + add_column :<%=model_name.pluralize.underscore%>, :var_fee, :float | ||
| 11 | + add_column :<%=model_name.pluralize.underscore%>, :var_paid_amount, :float | ||
| 12 | + add_column :<%=model_name.pluralize.underscore%>, :var_payment_at, :datetime | ||
| 13 | + add_column :<%=model_name.pluralize.underscore%>, :var_payment_method, :string | ||
| 10 | end | 14 | end |
| 11 | end | 15 | end |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -29,11 +29,13 @@ module Var | ... | @@ -29,11 +29,13 @@ module Var |
| 29 | 29 | ||
| 30 | def self.conekta_webhook(params) | 30 | def self.conekta_webhook(params) |
| 31 | payment = params[:data][:object] | 31 | payment = params[:data][:object] |
| 32 | + time = Time.strptime(payment[:paid_at].to_s, '%s') | ||
| 32 | object = Var.find_charge payment[:id] | 33 | object = Var.find_charge payment[:id] |
| 33 | - object.update_columns(var_status: payment[:status]) | 34 | + object.update({var_status: payment[:status], var_fee: payment[:fee], var_paid_amount: payment[:amount], var_payment_method: payment[:payment_method][:object]) |
| 34 | - object.update_columns(var_payment_at: Time.zone.now) if object.var_payed? | 35 | + object.update_columns(var_payment_at: time) if object.var_payed? |
| 35 | object | 36 | object |
| 36 | rescue Exception => exception | 37 | rescue Exception => exception |
| 38 | + puts exception | ||
| 37 | false | 39 | false |
| 38 | end | 40 | end |
| 39 | 41 | ... | ... |
-
Please register or login to post a comment