Skip to content

Issue with IP whitelist check #15

@lesliepoolman

Description

@lesliepoolman

Hello,

I am having a bit of trouble with integrating the gem into my rails application. Specifically

def isIpAddressValid()

I coded in a workaround in my controller

class PaymentWallController < ApplicationController
  def pingback
    payload = request.GET
    pingback = Paymentwall::Pingback.new(payload, request.remote_ip)
    order = pingback.getProduct.getId
    if isipvalid?(request.remote_ip) && pingback.validate(Rails.env.production? ? false : true)
      if pingback.isDeliverable
        find_order_by_reference_and_complete_asynchronously order
        render 'pingback', layout: false

      elsif pingback.isCancelable
        redirect_to order_url(order), notice: 'Your payment failed, please contact us if this is an error'
      end
      puts 'OK' # Paymentwall expects response to be OK, otherwise the pingback will be resent
    else
      PaymentResponse.log_response pingback.getErrorSummary, 'goodsid'
    end
    PaymentResponse.log_response payload, 'goodsid'
  end

  private

  def isipvalid?(ipaddress)
    ipwhitelist = [
      '174.36.92.186',
      '174.36.96.66',
      '174.36.92.187',
      '174.36.92.192',
      '174.37.14.28'
    ]

    ipwhitelist.push(*(0..255).map { |n| "216.127.71.#{n}" })

    ipwhitelist.include? ipaddress
  end
end

As you can see I added my own whitelist check and bypassed yours because every time I try to make a test payment the ip address comes back as invalid even though it is in the range "216.127.71.XXX"

Can you please let me know if there is any more information you need or any suggestions?

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions