clemens / spree_wirecard

MIT License
0 stars 4 forks source link

confirmURL is invalid #2

Closed 23tux closed 11 years ago

23tux commented 11 years ago

When I try in development to make a payment, inside the Wirecard iframe it says CONFIRMURL is invalid. In the Wirecard docs they say, that no private URLs are allowed for the server-to-server communication. But how do I test the payment in development on my machine?

I tried some other payment methods for spree like paypal, and they made a test env for development, and it works.

Any ideas?

clemens commented 11 years ago

Hey,

PayPal is more lenient regarding its redirect URLs. Wirecard explicitly only allows port 80 and port 443 for its confirmURL (not the other URLs though – don't ask, they're weird) as per the integration guide.

I've worked around this by signing up for a dynamic DNS provider (no-ip.com in my case) and forwarding my local port 80 to port 3000. You can use ipfw (Mac OS X) or iptables (Linux) for that. Another option is to start your development server on port 80 but you need to be root or use sudo which I found really inconvenient (also doesn't pay well with RVM).

Another option is to override the payment page and use the confirmURL parameter conditionally like so:

wirecard_qpay_params = @order.wirecard_qpay_params(@payment_method,
  :order_id => @order.number,
  :payment_method_id => @payment_method.id,
  :successURL => wirecard_success_order_checkout_url(@order, :token => @order.token, :payment_method_id => @payment_method.id),
  :failureURL => wirecard_failure_order_checkout_url(@order, :token => @order.token),
  :cancelURL => wirecard_cancel_order_checkout_url(@order, :token => @order.token),
  :serviceURL => root_url,
)
wirecard_qpay_params.merge(:confirmURL => wirecard_confirmations_url) if Rails.env.production?

Hope that helps.

23tux commented 11 years ago

Ah, read over that part with 80 and 443 port redirects, now it makes sense ;) I think I'll find a solution for this, thx!

Another question: Have you considered using ActiveMerchant for the Wirecard integration? I think it's well tested and widely supported. I'm playing with the thought to rewrite your gem based on ActiveMerchant ;)

clemens commented 11 years ago

Wirecard's default API is supported by ActiveMerchant and therefore by Spree out of the box – at least as far as I know. I haven't checked whether or not the confirmation messages are handled the same way but I somehow doubt it because Wirecard bought the QPAY payment page when they annexed an Austrian payment provider named Qenta – so I wouldn't assume they have the same APIs.

Furthermore, I'm not sure if it would have real benefits since the whole authorization & capture process isn't there (which, arguably, is ActiveMerchant's strong suit) so AM could only be used to evaluate the response which would probably use the same code as I've used in my gem anyway with no additional benefits. In short: I'm skeptical. ;)

If you want to fork the gem and rewrite it based on ActiveMerchant, I'm happy to have a look and maybe merge it if I like the result. :)

23tux commented 11 years ago

I just tried it out starting rails on port 80, and give it another try. Unfortunately, I still get the error inside the Wirecard iFrame CONFIRMURL is invalid. Are they doing just a redirect to my url (because this should work, I debugged it, and the confirmURL is set to http://localhost/wirecard_confirmations), or are they really doing a server-to-server communication, so that I need a dynamic IP address?

clemens commented 11 years ago

Maybe. Or maybe they're validating domains based on TLD and stuff. Not sure to be honest!

23tux commented 11 years ago

I emailed the wirecard support, and they said, that only port 80 and 443 is allowed. They said that localhost on port 80 should work, but it doesn't. So I came up with an workaround:

Start your server with rvmsudo rails s -p 80 (or just use sudo if you don't have rvm installed), and use the http://lvh.me/ address (which points to your localhost). Then wirecard accepts the confirmURL