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

Event Payments - Transaction ID Issue #223

Open
cloudcogsio opened this issue Feb 19, 2022 · 4 comments
Open

Event Payments - Transaction ID Issue #223

cloudcogsio opened this issue Feb 19, 2022 · 4 comments

Comments

@cloudcogsio
Copy link
Contributor

Civi 5.45.1 on Wordpress

I seem to be having an issue where the TransactionID is not being set/passed to the gateway for Event Payments.
As a result, the gateway is autogenerating a TransactionID (which is required by the gateway).

This works fine for payments that use the gateway's "purchase" method directly.

However, for payments that are processed off-site (3DS verification), I am getting an error when the gateway posts back to the IPN url.

Error: ipn_payment_callback_exception
Message: "An error may have occurred. Please check your receipt is correct XXX is not a valid integer."
(where XXX is the transaction Id that was generated by the gateway).

Backtrace info:
nz.co.fuzion.omnipaymultiprocessor/CRM/Core/Payment/OmnipayMultiProcessor.php(839)
CRM_Core_Payment_PaymentExtended->handleError('error', 'ipn_completion ...'...

As far as I can tell, the root cause seems to be (only for event payments), the usual integer ID that is passed for a contribution is not being passed for the event payment, however the IPN handler expects the transaction Id that is posted back from an offsite payment to be an integer.
The gateway requires the application to pass a TransactionId. Since none is being passed, it then autogenerates a transaction Id.
This transaction ID must however be unique on the gateway's end, so guessing/passing an arbitrary integer is not viable.

Note, contributions work fine with both direct and offsite payments since the integer transaction Id is being passed to the gateway for those payment transactions. Issue affects off-site event payments only.

@cloudcogsio
Copy link
Contributor Author

@eileenmcnaughton I did some further checking on this looking at Civi code (5.46.2)

It seems that for event payments, payment processing is done BEFORE a contribution record is created.
See "civicrm\CRM\Event\Form\Registration\Confirm.php"
image

The "doPayment()" and more importantly, "processPaymentNotification()" methods of the plugin expects a contributionID to be available.

For event payments, there will be no contribution ID available at the time of payment processing.
A contribution record is only added AFTER execution of the payment.

This presents an issue for off-site payments where the execution flow for a payment involves browser redirect.

For event payments,

  1. The plugin, and by extension, the omnipay gateway is not passed a contributionID since none is available.
  2. On post-back (where the gateway posts back to the ipn url) an "ipn_payment_callback_exception" exception is thrown because it expects that the transactionID that is posted back to the IPN url is an integer and matches that of an existing contribution ID which it then uses to update the contribution status.

Gateways that do not redirect the browser are OK since the payment processing simply returns and the execution flow of CRM_Event_Form_Registration_Confirm->postProcess() is completed, that is, a contribution is created and marked as completed.

I do not see a way forward except for changes to be made in "CRM_Event_Form_Registration_Confirm->postProcess()" where a pending contribution is created before payment processing and the contributionID is added to the parameter array for the payment processor. The contribution can then be updated once the payment processing returns, or in the case of your plugin, the contribution is updated from outside the "CRM_Event_Form_Registration_Confirm->postProcess()" flow.

@eileenmcnaughton
Copy link
Owner

@cloudcogsio I think you are right that the change should be made in CRM_Event_Form_Registration_Confirm->postProcess() - it is definitely a bit tricky as it will require testing & QA but it is ultimately how the code should be working

@cloudcogsio
Copy link
Contributor Author

I didn't see an Issues tab in https://github.com/civicrm/civicrm-core
How do I raise this issue with the project?

@eileenmcnaughton
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants