# GFPaymentAddOn redirect\_url() not working

**URL:** <https://community.gravityforms.com/t/gfpaymentaddon-redirect-url-not-working/5690>\
**Category:** Get Help\
**Tags:** custom, gfpaymentaddon\
**Created:** [August 12, 2020, 12:06pm UTC](https://community.gravityforms.com/t/gfpaymentaddon-redirect-url-not-working/5690 "2020-08-12T12:06:10Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![user5bf78a1ee47af9.3](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/user5bf78a1ee47af9.3/32/1901_2.png) [@user5bf78a1ee47af9.3](https://community.gravityforms.com/u/user5bf78a1ee47af9.3)\
**Post date:** [August 12, 2020, 12:06pm UTC](https://community.gravityforms.com/t/gfpaymentaddon-redirect-url-not-working/5690/1 "2020-08-12T12:06:10Z")

</div>

Hi,

I’m developing a payment method extension extending GFPaymentAddOn.

After sending the form I need to redirect to a URL.

I’m using the function redirect\_url from the class GFPaymentAddOn but it doesn’t work now, It was working previously.

How could I solve it?

My Code sample:

```
public function redirect_url( $feed, $submission_data, $form, $entry ) {
//some code goes here
return $url; //I checked it by print URL it prints correct url
}

```

It also shows redirect message but not redirecting: [https://prnt.sc/tycg8z](https://prnt.sc/tycg8z)

Checked error log and gravity from log too but nothing found.  
Please help.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [August 12, 2020, 3:20pm UTC](https://community.gravityforms.com/t/gfpaymentaddon-redirect-url-not-working/5690/2 "2020-08-12T15:20:02Z")

</div>

Hi Kapil. Can you share any more of your code or your logging?

---

<div class="post-metadata">

**Author:** ![user5bf78a1ee47af9.3](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/user5bf78a1ee47af9.3/32/1901_2.png) [@user5bf78a1ee47af9.3](https://community.gravityforms.com/u/user5bf78a1ee47af9.3)\
**Post date:** [August 13, 2020, 4:25am UTC](https://community.gravityforms.com/t/gfpaymentaddon-redirect-url-not-working/5690/3 "2020-08-13T04:25:54Z")

</div>

**Here is complete log of Gravity Forms Core:**  
2020-08-13 4:15:33.931355 - DEBUG --\> GFFormDisplay::process\_form(): Starting to process form (#3) submission.  
2020-08-13 4:15:33.932123 - DEBUG --\> GFFormDisplay::process\_form(): Source page number: 1. Target page number: 0.  
2020-08-13 4:15:33.934160 - DEBUG --\> GFCommon::is\_spam\_entry(): Is submission considered spam? No.  
2020-08-13 4:15:33.934755 - DEBUG --\> GFFormDisplay::process\_form(): After validation. Is submission valid? Yes.  
2020-08-13 4:15:33.934801 - DEBUG --\> GFFormDisplay::process\_form(): Submission is valid. Moving forward.  
2020-08-13 4:15:33.934865 - DEBUG --\> GFFormsModel::save\_entry(): Saving entry.  
2020-08-13 4:15:33.938703 - DEBUG --\> GFFormsModel::save\_entry(): Entry record created in the database. ID: 93.  
2020-08-13 4:15:33.940409 - DEBUG --\> GFFormsModel::save\_entry(): Saving entry fields.  
2020-08-13 4:15:33.940512 - DEBUG --\> GFFormsModel::queue\_save\_input\_value(): Queued field operation: Name(#1.2 - name).  
2020-08-13 4:15:33.940562 - DEBUG --\> GFFormsModel::queue\_save\_input\_value(): Queued field operation: Name(#1.3 - name).  
2020-08-13 4:15:33.940602 - DEBUG --\> GFFormsModel::queue\_save\_input\_value(): Queued field operation: Name(#1.4 - name).  
2020-08-13 4:15:33.940639 - DEBUG --\> GFFormsModel::queue\_save\_input\_value(): Queued field operation: Name(#1.6 - name).  
2020-08-13 4:15:33.940674 - DEBUG --\> GFFormsModel::queue\_save\_input\_value(): Queued field operation: Name(#1.8 - name).  
2020-08-13 4:15:33.940728 - DEBUG --\> GFFormsModel::queue\_save\_input\_value(): Queued field operation: Email(#2 - email).  
2020-08-13 4:15:33.940783 - DEBUG --\> GFFormsModel::queue\_save\_input\_value(): Queued field operation: Phone(#3 - phone).  
2020-08-13 4:15:33.940834 - DEBUG --\> GFFormsModel::queue\_save\_input\_value(): Queued field operation: Product Name(#4.1 - product).  
2020-08-13 4:15:33.940871 - DEBUG --\> GFFormsModel::queue\_save\_input\_value(): Queued field operation: Product Name(#4.2 - product).  
2020-08-13 4:15:33.940907 - DEBUG --\> GFFormsModel::queue\_save\_input\_value(): Queued field operation: Product Name(#4.3 - product).  
2020-08-13 4:15:33.944608 - DEBUG --\> GFFormsModel::queue\_save\_input\_value(): Queued field operation: Total(#5 - total).  
2020-08-13 4:15:33.946722 - DEBUG --\> GFFormsModel::save\_entry(): Finished saving entry fields.  
2020-08-13 4:15:35.226438 - DEBUG --\> GF\_Background\_Process::dispatch(): Running for gf\_feed\_processor.  
2020-08-13 4:15:35.227214 - DEBUG --\> GF\_Background\_Process::dispatch(): Unable to dispatch tasks to Admin Ajax: Nothing left to process  
2020-08-13 4:15:35.227314 - DEBUG --\> GFFormsModel::create\_post(): Starting.  
2020-08-13 4:15:35.227399 - DEBUG --\> GFFormsModel::create\_post(): Stopping. The form doesn’t have any post fields.  
2020-08-13 4:15:35.227452 - DEBUG --\> GFAPI::send\_notifications(): Gathering notifications for form\_submission event for entry #93.  
2020-08-13 4:15:35.227515 - DEBUG --\> GFCommon::send\_notifications(): Processing notifications for form\_submission event for entry #93: Array  
(  
[0] =\> 5f2d2150936a1  
)

(only active/applicable notifications are sent)  
2020-08-13 4:15:35.227557 - DEBUG --\> GFCommon::send\_notifications(): Notification is inactive, not processing notification (#5f2d2150936a1 - Admin Notification) for entry #93.  
2020-08-13 4:15:35.227618 - DEBUG --\> GFFormDisplay::handle\_confirmation(): Sending confirmation.  
2020-08-13 4:15:35.227727 - DEBUG --\> GFFormDisplay::handle\_confirmation(): Executing functions hooked to gform\_confirmation.  
2020-08-13 4:15:35.227932 - DEBUG --\> GFFormDisplay::handle\_confirmation(): Confirmation =\> Redirecting you to the Secure Payment Page.

**Here is complete log of my extension Gravity Forms Instamojo Standard Add-On:**  
2020-08-12 11:17:04.958151 - DEBUG --\> GFFeedAddOn::maybe\_process\_feed(): Checking for feeds to process for entry #90 for gravityformsinstamojo.  
2020-08-12 11:17:04.958235 - DEBUG --\> GFFeedAddOn::maybe\_process\_feed(): Starting to process feed (#4 - Instamojo Feed 2) for entry #90 for gravityformsinstamojo  
2020-08-12 11:17:04.958267 - DEBUG --\> GFFeedAddOn::maybe\_process\_feed(): Marking entry #90 as fulfilled for gravityformsinstamojo  
2020-08-12 11:40:27.089879 - DEBUG --\> GFFeedAddOn::maybe\_process\_feed(): Checking for feeds to process for entry #91 for gravityformsinstamojo.  
2020-08-12 11:40:27.089947 - DEBUG --\> GFFeedAddOn::maybe\_process\_feed(): Starting to process feed (#4 - Instamojo Feed 2) for entry #91 for gravityformsinstamojo  
2020-08-12 11:40:27.089977 - DEBUG --\> GFFeedAddOn::maybe\_process\_feed(): Marking entry #91 as fulfilled for gravityformsinstamojo  
2020-08-12 11:41:08.157398 - DEBUG --\> GFFeedAddOn::maybe\_process\_feed(): Checking for feeds to process for entry #92 for gravityformsinstamojo.  
2020-08-12 11:41:08.157473 - DEBUG --\> GFFeedAddOn::maybe\_process\_feed(): Starting to process feed (#4 - Instamojo Feed 2) for entry #92 for gravityformsinstamojo  
2020-08-12 11:41:08.157505 - DEBUG --\> GFFeedAddOn::maybe\_process\_feed(): Marking entry #92 as fulfilled for gravityformsinstamojo

**Code:** [https://drive.google.com/file/d/1BSFNx0ozumyJ00hElym\_x5kWDL8JhiXF/view?usp=sharing](https://drive.google.com/file/d/1BSFNx0ozumyJ00hElym_x5kWDL8JhiXF/view?usp=sharing)

---

<div class="post-metadata">

**Author:** ![richardw8k](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/richardw8k/32/2354_2.png) [@richardw8k](https://community.gravityforms.com/u/richardw8k)\
**Post date:** [August 13, 2020, 8:57am UTC](https://community.gravityforms.com/t/gfpaymentaddon-redirect-url-not-working/5690/4 "2020-08-13T08:57:28Z")

</div>

Have you tried adding some logging statements to the redirect\_url method to log the response from the post request? Based on the current log it would seem that request did not return the expected response so $url was set to an empty string by the else resulting in the forms configured confirmation message being used instead.

---

<div class="post-metadata">

**Author:** ![user5bf78a1ee47af9.3](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/user5bf78a1ee47af9.3/32/1901_2.png) [@user5bf78a1ee47af9.3](https://community.gravityforms.com/u/user5bf78a1ee47af9.3)\
**Post date:** [August 13, 2020, 10:45am UTC](https://community.gravityforms.com/t/gfpaymentaddon-redirect-url-not-working/5690/5 "2020-08-13T10:45:22Z")

</div>

> [@user5bf78a1ee47af9.3](#):
>
> `//I checked it by print URL it prints correct url`

Hey Richard, I already mentioned I checked URL, It prints correctly.  
I tried it with echo statement. And also tried with static URL too.

---

<div class="post-metadata">

**Author:** ![user5bf78a1ee47af9.3](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/user5bf78a1ee47af9.3/32/1901_2.png) [@user5bf78a1ee47af9.3](https://community.gravityforms.com/u/user5bf78a1ee47af9.3)\
**Post date:** [August 24, 2020, 6:59am UTC](https://community.gravityforms.com/t/gfpaymentaddon-redirect-url-not-working/5690/6 "2020-08-24T06:59:22Z")

</div>

@chrishajer Any update on this?

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [August 24, 2020, 5:11pm UTC](https://community.gravityforms.com/t/gfpaymentaddon-redirect-url-not-working/5690/7 "2020-08-24T17:11:31Z")

</div>

Hi George. Can you please add some debugging statements to your code so that the logging goes to the add-on log, or Gravity Forms core log?

You can find information about custom logging statements in Gravity Forms here:

> **[Custom Logging Statements - Gravity Forms Documentation](https://docs.gravityforms.com/custom-logging-statements/)**
>
> While Gravity Forms and its add-ons include numerous logging statements sometimes you may need to add more. This article explains how to add custom logging.

---

<div class="post-metadata">

**Author:** ![user5bf78a1ee47af9.3](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/user5bf78a1ee47af9.3/32/1901_2.png) [@user5bf78a1ee47af9.3](https://community.gravityforms.com/u/user5bf78a1ee47af9.3)\
**Post date:** [September 3, 2020, 10:30am UTC](https://community.gravityforms.com/t/gfpaymentaddon-redirect-url-not-working/5690/8 "2020-09-03T10:30:33Z")

</div>

**Added log in redirect\_url function**

```
public function redirect_url( $feed, $submission_data, $form, $entry ) {
		//Don't process redirect url if request is a Instamoj return
		if(!rgempty( 'gf_instamojo_return', $_GET ) ) {
			return false;
		}
		$meta=$feed['meta'];
		if(isset($meta['instamojoSandbox']) && !empty($meta['instamojoSandbox'])){
			$this->_instamojo_api_url = $this->_instamojo_sandbox_api_url;
		}
		//updating lead's payment_status to Processing
		$entry['payment_status']= 'Processing' ;
		$entry['payment_method']='instamojo';

		// get payment amount form the product url list this should not be less than 10 RS
		$payment_amount = rgar( $submission_data, 'payment_amount' );

		//return after success 
		$return_url = $meta['instamojoReturnUrl'];//$this->return_url( $form['id'], $entry['id'] ) ; 

		//URL that will listen to notifications from Instamoj
		$webhook_callback_url = site_url() . '?page=gf_instamoj_webhook&ref='.$entry['id'] ;
        GFCommon::log_debug( '$webhook_callback_url => ' . $webhook_callback_url );
		$request = new WP_Http();
		$meta=$feed['meta'];
		//add authentication to the insa mojo account
		$headers =['X-Api-Key'=>$meta['instamojoAPIKey'] ,'X-Auth-Token'=>$meta['instamojoAuthToken']];

        $first_name = $meta['billingInformation_firstName'];
        $last_name = $meta['billingInformation_lastName'];
        $name = $last_name ? $entry[$first_name].' '.$entry[$last_name] : $entry[$first_name];
        $email = $entry[$meta['billingInformation_email'] ];
		$phone = $entry[$meta['billingInformation_phone'] ];
		$payload = Array(
		    'purpose' => $meta['instamojoPaymentPurposeDescription'],
		    'amount' => $payment_amount,
            'phone' => $phone,
		    'buyer_name' => $name,
		    'redirect_url' => $return_url,
            //'send_email' => true,
		    'webhook' => $webhook_callback_url,
            //'send_sms' => true,
            'email' => $email,
		    'allow_repeated_payments' => false
		);

		$response = $request->post($this->_instamojo_api_url , array(
			'sslverify' => false, 'ssl' => true,
			'headers'=>$headers, 'timeout' => 20,'body'=>$payload ) );

		GFCommon::log_debug( '$response => ' . $response );
		// try to parse josn 
		$body=json_decode(rgar( $response, 'body' ));
		if ( ! is_wp_error( $response ) && $body->success ) {
			$url=$body->payment_request->longurl;
		   GFCommon::log_debug( '$url => ' . $url );
		   	//update the entry status 
		   	$entry['transaction_id']=$body->payment_request->id;
			$entry['payment_amount']=$body->payment_request->amount;
			$entry['payment_date']=$body->payment_request->created_at;
			$action['payment_status']	= $body->payment_request->payment->status;
		} else {
		   //$this->log_debug( __METHOD__. "(): Unableto find the payment URL Instamoj: ".print_r(rgar( $response, 'body' ),true) );
		   $url='';
		}
		//update the entry 
		GFAPI::update_entry($entry);
		GFCommon::log_debug( '$url => ' . $url );
		return $url;

	}

```

**Gravity Forms Core Log:**  
2020-09-03 10:01:40.800420 - DEBUG --\> GFFormDisplay::process\_form(): Starting to process form (#3) submission.  
2020-09-03 10:01:40.801327 - DEBUG --\> GFFormDisplay::process\_form(): Source page number: 1. Target page number: 0.  
2020-09-03 10:01:40.803226 - DEBUG --\> GFCommon::is\_spam\_entry(): Is submission considered spam? No.  
2020-09-03 10:01:40.803841 - DEBUG --\> GFFormDisplay::process\_form(): After validation. Is submission valid? Yes.  
2020-09-03 10:01:40.803893 - DEBUG --\> GFFormDisplay::process\_form(): Submission is valid. Moving forward.  
2020-09-03 10:01:40.803957 - DEBUG --\> GFFormsModel::save\_entry(): Saving entry.  
2020-09-03 10:01:40.806345 - DEBUG --\> GFFormsModel::save\_entry(): Entry record created in the database. ID: 94.  
2020-09-03 10:01:40.807209 - DEBUG --\> GFFormsModel::save\_entry(): Saving entry fields.  
2020-09-03 10:01:40.807312 - DEBUG --\> GFFormsModel::queue\_save\_input\_value(): Queued field operation: Name(#1.2 - name).  
2020-09-03 10:01:40.807363 - DEBUG --\> GFFormsModel::queue\_save\_input\_value(): Queued field operation: Name(#1.3 - name).  
2020-09-03 10:01:40.807403 - DEBUG --\> GFFormsModel::queue\_save\_input\_value(): Queued field operation: Name(#1.4 - name).  
2020-09-03 10:01:40.807440 - DEBUG --\> GFFormsModel::queue\_save\_input\_value(): Queued field operation: Name(#1.6 - name).  
2020-09-03 10:01:40.807475 - DEBUG --\> GFFormsModel::queue\_save\_input\_value(): Queued field operation: Name(#1.8 - name).  
2020-09-03 10:01:40.807528 - DEBUG --\> GFFormsModel::queue\_save\_input\_value(): Queued field operation: Email(#2 - email).  
2020-09-03 10:01:40.807584 - DEBUG --\> GFFormsModel::queue\_save\_input\_value(): Queued field operation: Phone(#3 - phone).  
2020-09-03 10:01:40.807635 - DEBUG --\> GFFormsModel::queue\_save\_input\_value(): Queued field operation: Product Name(#4.1 - product).  
2020-09-03 10:01:40.807672 - DEBUG --\> GFFormsModel::queue\_save\_input\_value(): Queued field operation: Product Name(#4.2 - product).  
2020-09-03 10:01:40.807707 - DEBUG --\> GFFormsModel::queue\_save\_input\_value(): Queued field operation: Product Name(#4.3 - product).  
2020-09-03 10:01:40.813546 - DEBUG --\> GFFormsModel::queue\_save\_input\_value(): Queued field operation: Total(#5 - total).  
2020-09-03 10:01:40.814618 - DEBUG --\> GFFormsModel::save\_entry(): Finished saving entry fields.  
2020-09-03 10:01:40.821391 - DEBUG --\> $webhook\_callback\_url =\> [http://nishit.pugmarker.net?page=gf\_instamoj\_webhook&ref=94](http://nishit.pugmarker.net?page=gf_instamoj_webhook&ref=94)  
2020-09-03 10:01:42.032330 - DEBUG --\> $response =\> Array  
2020-09-03 10:01:42.032424 - DEBUG --\> $url =\> [https://test.instamojo.com/@nishit\_m/b0a790b1c3894fb39214f81f16ae18a4](https://test.instamojo.com/@nishit_m/b0a790b1c3894fb39214f81f16ae18a4)  
2020-09-03 10:01:42.053971 - DEBUG --\> $url =\> [https://test.instamojo.com/@nishit\_m/b0a790b1c3894fb39214f81f16ae18a4](https://test.instamojo.com/@nishit_m/b0a790b1c3894fb39214f81f16ae18a4)  
2020-09-03 10:01:42.054121 - DEBUG --\> GF\_Background\_Process::dispatch(): Running for gf\_feed\_processor.  
2020-09-03 10:01:42.054757 - DEBUG --\> GF\_Background\_Process::dispatch(): Unable to dispatch tasks to Admin Ajax: Nothing left to process  
2020-09-03 10:01:42.054842 - DEBUG --\> GFFormsModel::create\_post(): Starting.  
2020-09-03 10:01:42.054920 - DEBUG --\> GFFormsModel::create\_post(): Stopping. The form doesn’t have any post fields.  
2020-09-03 10:01:42.054969 - DEBUG --\> GFAPI::send\_notifications(): Gathering notifications for form\_submission event for entry #94.  
2020-09-03 10:01:42.055083 - DEBUG --\> GFCommon::send\_notifications(): Processing notifications for form\_submission event for entry #94: Array  
(  
[0] =\> 5f2d2150936a1  
)

(only active/applicable notifications are sent)  
2020-09-03 10:01:42.055133 - DEBUG --\> GFCommon::send\_notifications(): Notification is inactive, not processing notification (#5f2d2150936a1 - Admin Notification) for entry #94.  
2020-09-03 10:01:42.055192 - DEBUG --\> GFFormDisplay::handle\_confirmation(): Sending confirmation.  
2020-09-03 10:01:42.055291 - DEBUG --\> GFFormDisplay::handle\_confirmation(): Executing functions hooked to gform\_confirmation.  
2020-09-03 10:01:42.055417 - DEBUG --\> GFFormDisplay::handle\_confirmation(): Confirmation =\> Redirecting you to the Secure Payment Page.  
2020-09-03 10:02:00.363224 - DEBUG --\> GFCommon::post\_to\_manager(): endpoint: [https://gravityapi.com/wp-content/plugins/gravitymanager/api.php?op=upgrade\_message&key=b2f56d4a6c2db1ffaf69c50feea6aad5](https://gravityapi.com/wp-content/plugins/gravitymanager/api.php?op=upgrade_message&key=b2f56d4a6c2db1ffaf69c50feea6aad5)  
2020-09-03 10:02:00.657926 - DEBUG --\> GFCommon::log\_remote\_response(): code: 200; body:

**Gravity Forms Instamojo Standard Add-On Log:**

2020-09-03 10:01:40.814826 - DEBUG --\> GFFeedAddOn::maybe\_process\_feed(): Checking for feeds to process for entry #94 for gravityformsinstamojo.  
2020-09-03 10:01:40.814899 - DEBUG --\> GFFeedAddOn::maybe\_process\_feed(): Starting to process feed (#4 - Instamojo Feed 2) for entry #94 for gravityformsinstamojo  
2020-09-03 10:01:40.814929 - DEBUG --\> GFFeedAddOn::maybe\_process\_feed(): Marking entry #94 as fulfilled for gravityformsinstamojo

---

<div class="post-metadata">

**Author:** ![user5bf78a1ee47af9.3](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/user5bf78a1ee47af9.3/32/1901_2.png) [@user5bf78a1ee47af9.3](https://community.gravityforms.com/u/user5bf78a1ee47af9.3)\
**Post date:** [September 9, 2020, 4:09am UTC](https://community.gravityforms.com/t/gfpaymentaddon-redirect-url-not-working/5690/9 "2020-09-09T04:09:13Z")

</div>

@chrishajer Any update on this?

---

<div class="post-metadata">

**Author:** ![richardw8k](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/richardw8k/32/2354_2.png) [@richardw8k](https://community.gravityforms.com/u/richardw8k)\
**Post date:** [January 4, 2022, 5:55pm UTC](https://community.gravityforms.com/t/gfpaymentaddon-redirect-url-not-working/5690/10 "2022-01-04T17:55:23Z")

</div>


