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
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
2020-09-03 10:01:42.053971 - DEBUG --> $url => 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
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