• Resolved esd3104

    (@esd3104)


    I want to implement showing certain payment gateways based on the country of the billing address. This can be implemented with a filter and unsetting gateways based on the country code.

    This works perfectly with Stripe and other checkout options like check or things that use native WC payment gateways.

    However, I think because GDP implements an iframe for the payment details inputs, if the billing country is changed on the checkout page, which causes the GDP gateway to be shown and something else removed, the GDP gateway is shown as/when I want it to, but the card and other entry fields are missing. If you refresh the checkout page, then they appear. I guess the iframe call is triggered.

    Is there some alternative to the iframe? Some other options to have the card number and other input fields available like some of the other WC gateway options?

    The image shows that after a change to a billing country where I want GDP to be shown for that billing country, the payment option is shown but missing entry fields.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Steve

    (@skyvergesteve)

    Hey @esd3104 ,

    Thanks for contacting us about GoDaddy Payments! I’m happy to help out ??

    Currently, the plugin only supports the iframe method for loading the credit card form fields. Your assumptions on what is happening with the blank fields until page refresh are correct, the iframe loading isn’t getting triggered until the page refresh.

    I have the site URL from your previous post but didn’t see the country dropdown option. Would it be possible to add this back to Checkout so I can take a look at the behavior?

    Cheers,
    Steve

    Thread Starter esd3104

    (@esd3104)

    @skyvergesteve Thanks for the response. You should just be able to change the billing country field towards the top of the checkout page. US country brings up another payment gateway. Any other country selected in this default WC Checkout field will call the GDP Payment Gateway. You should be able to flip backwards and forwards changing the country and trigger the payment gateway change.

    Thread Starter esd3104

    (@esd3104)

    In case it matters/helps please see the filter code I found and modified for my use case. Basically I wanted to test GDP by using that gateway for everyone outside US. If it works well I may then make it the default.

    add_filter( 'woocommerce_available_payment_gateways', 'rudr_gateway_by_country' );
    
    function rudr_gateway_by_country( $gateways ) {
    	
    	if( is_admin() ) {
    		return $gateways;
    	}
    	
    	if( is_wc_endpoint_url( 'order-pay' ) ) { // Pay for order page
    
    		$order = wc_get_order( wc_get_order_id_by_order_key( $_GET[ 'key' ] ) );
    		$country = $order->get_billing_country();
    
    	} else { // Cart page
    
    		$country = WC()->customer->get_billing_country();
    
    	}
    
    	if ( 'US' === $country ) {
    		if ( isset( $gateways[ 'poynt_credit_card' ] ) ) {
    			unset( $gateways[ 'poynt_credit_card' ] );
    		} 
    	
    	}
    if ( 'US' !== $country ) {
    		if ( isset( $gateways[ 'stripe' ] ) ) {
    			unset( $gateways[ 'stripe' ] );
    		} 
    	
    	}
    
    	return $gateways;
    
    }
    
    Plugin Support Kari-SkyVerge

    (@kariskyverge)

    Hey @esd3104

    Thank you for the additional information! I was able to see on your site the issue, where selecting another billing country outside the US attempts to change the payment method, however no fields appear. Then, if you refresh the checkout page, keeping the new billing country, the credit card form does indeed populate.

    With the code that you sent here, were you able to get this working with both Stripe and Poynt/GDPmts?

    If not, I am wondering instead if you could add code for a page refresh when the billing country is changed, which would then bring up the new credit card fields? This would look something like: onchange=”location.reload()” command or similar, connected to that field.

    Would you please let us know if this would be a fair workaround for you, and if you are able to get that working as intended?

    All the Best,
    Kari

    Thread Starter esd3104

    (@esd3104)

    The auto refresh thing (onchange) I did some research and played around with some stuff I found online and tried to adapt but I couldn’t get anything to work. Beyond my abilities as I don’t really do PHP and or CSS for a living. ??

    Plugin Support amberskyverge

    (@amberskyverge)

    Hey @esd3104,

    In regards to PHP or coding updates, I’m afraid that customizations are?not covered under our support policy, so implementing this directly or modifying it further is not something we can assist with.

    If you need help in terms of implementing this, my recommendation would be to reach out to a developer who is experienced in customizing WooCommerce from any of the following organizations:

    Is there anything else I can help out with?

    All the best,

    Thread Starter esd3104

    (@esd3104)

    No thanks. We won’t save enough by using GDP to cover the costs.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Alternative to iFrame Form?’ is closed to new replies.