Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Safallia Joseph created an issue. See original summary.

Safallia Joseph’s picture

@travis the attached patch checks the status code and set pardot submission status. This still does not solve the scenario of a post request being successful but a submission is not made in pardot because of form validation errors. Pardot does not send us back the validation errors. Its actually a edge case scenario, we expect admins to set whatever is set as required in pardot form to be set as required in webform too.

Please review the attached patch

Safallia Joseph’s picture

Assigned: Safallia Joseph » travis-bradbury
Status: Active » Needs review
travis-bradbury’s picture

Assigned: travis-bradbury » Safallia Joseph
Status: Needs review » Needs work

Pardot does not send us back the validation errors. Its actually a edge case scenario, we expect admins to set whatever is set as required in pardot form to be set as required in webform too.

Smoothing out the edge cases is what separates this from the 'remote post' webform handler.

This is also a case that I was hoping to see us handle, unless Pardot makes it physically impossible.

There's a lot of things that can happen when submitting the data and only one of them is success. That's the edge case.

The contents of the log would depend on what information we're able to get back from Pardot. For example, in the event of an outage it may state that the site could not connect to Pardot or if Pardot rejects the submission because fields in the Webform don't match the form handler settings in Pardot, we will display as specific of information as is available to point someone to the problem quickly.

How does someone know they didn't match the forms? Weeks later someone notices they're not getting the marketing leads they expected? Then a developer has to get in there and debug things until they finally spot a simple mismatch?

What does Pardot send back? Can we give some hints when things fail?

+    // Log error message if status code is not 2xx.
+    if ($status_code < 200 || $status_code >= 300) {
+      $pardot_submission->addLog('An unexpected error occured while submitting data to Pardot');
+      $pardot_submission->setStatus(self::PARDOT_ERROR);
+      $pardot_submission->save();
+
+      return $pardot_submission;
+    }

Can't we get more specific than that? Does Pardot ever give 4xx responses? Which ones? Including the actual code would be a start. At least it might mean something to a developer. If it's a 5xx code we should log a message that says it was an error on Pardot's end. If it's 4xx it's not Pardot's problem and we can give something more helpful than "unexected error".

+  /**
+   * {@inheritdoc}
+   */
+  public function getStatus($status) {
+    return $entity->status->value;
+  }

$entity is undefined.

+  /**
+   * Provides the status of a pardot submission entity.
+   *
+   * @return string
+   *   The status string.
+   */
+  public function getStatus();

What is a status string?

+  /**
+   * Get response data.
+   *
+   * @param \Psr\Http\Message\ResponseInterface $response
+   *   The response returned by the remote server.
+   * @param \Drupal\webform_pardot\Entity\PardotSubmissionInterface $pardot_submission
+   *   The pardot submission entity.
+   *
+   * @return \Drupal\webform_pardot\Entity\PardotSubmissionInterface
+   *   Updated pardot submission entity.
+   */
+  private function processResponse(

"Get response data" and "@return Updated pardot submission entity" are conflicting.

Safallia Joseph’s picture

@tbradbury

How does someone know they didn't match the forms? Weeks later someone notices they're not getting the marketing leads they expected? Then a developer has to get in there and debug things until they finally spot a simple mismatch?

What does Pardot send back? Can we give some hints when things fail?

In Pardot response we would be getting errors string `Field is required`, So I have added code to check if the response have that string and added log accordingly

Can't we get more specific than that? Does Pardot ever give 4xx responses? Which ones? Including the actual code would be a start. At least it might mean something to a developer. If it's a 5xx code we should log a message that says it was an error on Pardot's end. If it's 4xx it's not Pardot's problem and we can give something more helpful than "unexected error".

I have modified the log message, I have also included the status code in log message so that will be helpful in debugging.

I have also fixed the other code standard issues. Could you please review.

Safallia Joseph’s picture

Assigned: Safallia Joseph » travis-bradbury
Status: Needs work » Needs review

  • Safallia Joseph authored 99b13d7 on 8.x-1.x
    Issue #3091215 by Safallia Joseph, tbradbury: Handle error and success...
Safallia Joseph’s picture

@Travis I have committed the changes, Please let me know if you think it needs further modifications.

travis-bradbury’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.