Problem/Motivation
https://hopeforelika.com/checkout/6/payment/return?PayerID=AXs6Z22sCBTJG...
If create payment subscription anonymous have php erorr.
Error: Call to a member function id() on null in Drupal\paypal_subscriptions\Plugin\Commerce\PaymentGateway\ExpressCheckoutSubscriptions->doExpressCheckoutDetails() (line 159 of /home/wibeone/hopeforelika.com/web/modules/contrib/paypal_subscriptions/src/Plugin/Commerce/PaymentGateway/ExpressCheckoutSubscriptions.php).
Steps to reproduce
Proposed resolution
Get customer from order.
// Build NVP data for PayPal API request.
$account = User::load($order->getCustomerId());
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | 3422938-property-rename-anonymous-payment-fix.patch | 1.79 KB | cbovard |
| #10 | paypal_subscriptions-3422938-property-rename.patch | 2.06 KB | cbovard |
| #3 | paypal_subscriptions-3422938.patch | 832 bytes | abhishek_gupta1 |
Issue fork paypal_subscriptions-3422938
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
abhishek_gupta1 commentedComment #3
abhishek_gupta1 commented@Utilvideo , I have fixed the issue and created Patch.
Comment #4
pavelculacov commentedThanks.
Comment #5
pavelculacov commented+1 Confirm worked.
Comment #7
cbovard commentedHello Everyone,
I have encountered this same bug and saw in the codebase https://git.drupalcode.org/project/paypal_subscriptions/-/blob/2.0.x/src...
The
should be
The protected property is:
https://git.drupalcode.org/project/paypal_subscriptions/-/blob/2.0.x/src...
abhishek_gupta1 Did a great job with the patch. I have built up more on this to fix the property declaration and some error handling.
I have run tests with a Drupal Commerce install using Commerce Recurring. Further tests were working well with the Subscriptions in the Paypal Sandbox.
Comment #9
cbovard commentedI added the PR and can test this patch. Please let me know if there needs to be changes or the error handling logic needs to be stripped out.
Comment #10
cbovard commentedHad to redo the patch off of the 2.0.x branch as there was some issues when I tested it. The Diff patch above wanted to alter the paypal_subscriptions.info.yml file.
Comment #11
pavelculacov commented"I do not agree with the patch. Why can't an anonymous user subscribe on PayPal?
Suggestion: Load the user if they exist. If not, allow an anonymous donation.
I don't think the 'name' value from the user is strictly required. We should make it dependent on whether the user is logged in. If they are logged in, get the name; if not, use 'Anonymous' as the default."
'SUBSCRIBERNAME' => $account->get('name')->value,
In my donation charity for girl, it used for anonymous users....
https://hopeforelika.com/donate
I need test your patch. Maybe it worked. because if user Id 0 name for anonymous is empty ""
Comment #14
cbovard commentedHello,
I added in some new logic here:
I ran some tests with Paypal with a membership based Commerce site with a Guest checkout. The username that appears is: guest user name
Which is used below here:
Of course I kept the property name fix.
Attached is the patch and let me know if there are needed changes.
Comment #15
cbovard commentedUnassigning for review. Thank you.