The payment reference field currently uses UIDs to link payments to users, just like the rest of the system. For the reference this is even more important than anything else, because while the payments are in the queue, the UID is the only thing that links them to anything else.

As a consequence, the payment reference field (and Payment for Webform, which shares part of the code base) does not support anonymous users. A solution has been to gather the payers' email addresses if they are anonymous and store it in the queue. The follow-up question is how to obtain the addresses, as some contexts already do that, such as the user registration form. A possible solution would be to make the widget allow site builders to select an existing email field on the entity to get the email address from. If there is no email field configured, the widget simply does not support anonymous users.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Xano’s picture

Xano’s picture

The idea is to disallow anonymous users from using the field as long as the email module is not enabled. When it is, create an email field on payments of the payment_reference bundle that is accessible to anonymous users only. After submitting the payment form (and effectively making the payment) they will receive an e-mail with a coupon/code/token that can be used to claim the payment. A reference to the payment will be stored in their session, so when they return to the payment reference field widget, they can just as easily use the payment as authenticated users can. However, if the session is somehow terminated, they can use the coupon/code/token to claim the payment next time they view the field widget.

helmo’s picture

That sounds like a good workflow

Xano’s picture

Issue summary: View changes
Status: Active » Needs work
FileSize
17.37 KB

Thanks for the feedback!

This patch updates the payment reference payment type settings form (on /admin/config/services/payment/type/payment_reference) with additional configuration elements. It also extends the default configuration, and contains code for sending the email.

To do:

  • Translate configuration.
  • Create and store retrieval codes.
  • Extend the form element with the option to accept a retrieval code.
  • Unit test \Drupal\payment_reference\Plugin\Field\FieldType\PaymentReferenceItemList::defaultAccess()
Xano’s picture

Xano’s picture

FileSize
31.43 KB
Xano’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 6: payment_2088951_6.patch, failed testing.

Xano’s picture

@tstoeckler about fixing this:

Yes, you should write a custom mapper. You need to ask your plugins for their config names, and then add a route plugin and then add a mapper foreach route to the respective config names
Xano’s picture

Status: Needs work » Needs review
FileSize
29.6 KB

Re-roll.

However, I am not sure we should add this feature. It's pretty complex, yet it may not suffice for many people as I can imagine not everyone will want to use the built-in method to generate reference codes, or so send the reference codes over e-mail in this particular way.

Instead of requiring payment before allowing visitors to create user accounts, visitors should perhaps be allowed to creata accounts without payment, and be redirected to a payment page directly after registration where making a payment grants them an additional user role.

If anonymous users are allowed to create nodes for money, the nodes can remain unpublished or have another type of flag set that is changed directly after the anonymous user makes a payment for that node.

And if site builders have a situation where the context cannot be interrupted, but they want anonymous users to make payments after all, maybe they should build their own solutions, are they would just be too specific for payment to support out of the box.

I'd like some feedback from everybody about this. What is most interesting, are technical suggestions to support this feature, that address the issues that I raised earlier in this comment. Thank you.

Status: Needs review » Needs work

The last submitted patch, 10: payment_2088951_10.patch, failed testing.

helmo’s picture

The patch seems like a lot of code to 'just' generate and maintain a reference token. But it mostly makes sense when I read it more closely.

Why the "Because of this, your payment was not made." remark if sending the mail fails.
Is the mail sent before starting the payment transaction?
The body text "You just made a payment at" suggests after the payment.

Xano’s picture

All the extra code is necessary to process payments for anonymous users in such a way that they can recover the payment in case the workflow is interrupted between making the payment and the system assigning it to something like an order. However, this is so specific that I am indeed inclined to just let this be, as it will not be sufficient for many people and the code does have to be maintained.

helmo’s picture

Status: Needs work » Closed (won't fix)

I agree that the maintenance hassle for this code is not worth it.

Thanks anyway.