def notification

      begin
        posData = JSON.parse(params["posData"])

        order_id = posData["orderID"]
        payment_id = posData["paymentID"]

        order = Spree::Order.find_by_number(order_id) || raise(ActiveRecord::RecordNotFound)
        begin
          order.process_bitpay_ipn payment_id
          head :ok
        rescue => exception
          logger.debug exception
          head :uprocessable_entity
        end
      rescue => error
        logger.error "Spree_Bitpay:  Unprocessable notification received from #{request.remote_ip}: #{params.inspect}"
        head :unprocessable_entity	
      end
    end
def notification

      begin
        posData = JSON.parse(params["posData"])

        order_id = posData["orderID"]
        payment_id = posData["paymentID"]

        order = Spree::Order.find_by_number(order_id) || raise(ActiveRecord::RecordNotFound)
        begin
          order.process_bitpay_ipn payment_id
          head :ok
        rescue => exception
          logger.debug exception
          head :uprocessable_entity
        end
      rescue => error
        logger.error "Spree_Bitpay:  Unprocessable notification received from #{request.remote_ip}: #{params.inspect}"
        head :unprocessable_entity	
      end
    end
Handle IPN from Bitpay server
 Receives incoming IPN message and retrieves official BitPay invoice for processing