Sha256: fe741c11e6375fdc3dd2b8a2ad721780b7d3b5f58559cf36323fb995a2fde9b4

Contents?: true

Size: 918 Bytes

Versions: 7

Compression:

Stored size: 918 Bytes

Contents

module EasyPayULatam
  class Api::V1::PayUAdditionalChargesController < ApiController

    acts_as_token_authentication_handler_for User

    def create

      addcharge = current_user.last_payment.add_charge(params)

      unless addcharge.response.blank?
        render status: 200, json: {message: "ok"}
      else
        msg = addcharge.error["errorList"].blank? ? addcharge.error["description"] : addcharge.error["errorList"].to_sentence
        render status: 411, json: {message: msg }
      end
    end

    def destroy
  
      if current_user.last_payments.count > 0
        current_user.last_payment.remove_charge(params[:charge_id])

        render status: 200, json: {message: "¡Cargo extra cancelado correctamente, tu plan estará activo por el periodo que ya habías pagado!"}
      else
        render status: 411, json: {message: "No tienes cargos extra para cancelar"}
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
easy_pay_u_latam-0.1.32 app/controllers/easy_pay_u_latam/api/v1/pay_u_additional_charges_controller.rb
easy_pay_u_latam-0.1.31 app/controllers/easy_pay_u_latam/api/v1/pay_u_additional_charges_controller.rb
easy_pay_u_latam-0.1.29 app/controllers/easy_pay_u_latam/api/v1/pay_u_additional_charges_controller.rb
easy_pay_u_latam-0.1.28 app/controllers/easy_pay_u_latam/api/v1/pay_u_additional_charges_controller.rb
easy_pay_u_latam-0.1.27 app/controllers/easy_pay_u_latam/api/v1/pay_u_additional_charges_controller.rb
easy_pay_u_latam-0.1.26 app/controllers/easy_pay_u_latam/api/v1/pay_u_additional_charges_controller.rb
easy_pay_u_latam-0.1.23 app/controllers/easy_pay_u_latam/api/v1/pay_u_additional_charges_controller.rb