Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add is email receipt as doPayment parameter #985

Open
wants to merge 1 commit into
base: 6.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/WebformCivicrmPostProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,14 @@ public function postSave(WebformSubmissionInterface $webform_submission) {
->fields($record)
->execute();

$isEmailReceipt = wf_crm_aval($this->data, "receipt:number_number_of_receipt", FALSE);

// Calling an IPN payment processor will result in a redirect so this happens after everything else
if ($this->contributionIsIncomplete && !$this->contributionIsPayLater && !empty($this->ent['contribution'][1]['id']) && !$this->submission->isDraft()) {
// webform_submission_send_mail($this->node, $this->submission);
$this->submitIPNPayment();
$this->submitIPNPayment($isEmailReceipt);
}
$isEmailReceipt = wf_crm_aval($this->data, "receipt:number_number_of_receipt", FALSE);

// Send receipt
if (empty($this->submission->isDraft())
&& !empty($this->ent['contribution'][1]['id'])
Expand Down Expand Up @@ -2101,8 +2103,10 @@ private function createDeferredPayment() {

/**
* Call IPN payment processor to redirect to payment site
*
* @param int $isEmailReceipt
*/
private function submitIPNPayment() {
private function submitIPNPayment($isEmailReceipt) {
$params = $this->data['contribution'][1]['contribution'][1];
$processor_type = $this->utils->wf_civicrm_api('payment_processor', 'getsingle', ['id' => $params['payment_processor_id']]);
$paymentProcessor = \Civi\Payment\System::singleton()->getById($params['payment_processor_id']);
Expand Down Expand Up @@ -2160,6 +2164,7 @@ private function submitIPNPayment() {
$params['cancelURL'] = $this->getIpnRedirectUrl('cancel');
}

$params['is_email_receipt'] = $isEmailReceipt;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we simply use

$params['is_email_receipt'] = wf_crm_aval($this->data, "receipt:number_number_of_receipt", FALSE);

instead of sending $isEmailReceipt as a param argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! Like this? #987

$this->form_state->set(['civicrm', 'doPayment'], $params);

}
Expand Down
Loading