Forums / PayPal RESTful support / PayPal RESTful API Payment Module

PayPal RESTful API Payment Module

Views: 84,737

Results 101 to 120 of 491
13 Jun 2024, 4:56 PM
#101
g2ktcf avatar

g2ktcf

Totally Zenned

Join Date:
Feb 2011
Location:
Lumberton, TX
Posts:
636
Plugin Contributions:
0

PayPal RESTful API Payment Module

g2ktcf:

Why would I be getting an expired token? This is me trying to ENABLE the RESTful module.

2024-06-13 08:25:24: () validateCredentials: Checking ().
TokenCache::clear, clearing cached token.
The curlPost (v1/oauth2/token) request was unsuccessful.
{
"errNum": 401,
"errMsg": "An expired-token error was received.",
"curlErrno": 0,
"name": "n/a",
"message": "n/a",
"details": "n/a",
"debug_id": "n/a"
}
CURL Options: {
"78": 10,
"52": false,
"75": true,
"74": true,
"42": 0,
"19913": true,
"13": 45,
"47": true,
"10002": "https://api-m.paypal.com/v1/oauth2/token"
}



2024-06-13 08:25:24: () validateCredentials: Checking ().
TokenCache::clear, clearing cached token.
The curlPost (v1/oauth2/token) request was unsuccessful.
{
"errNum": 401,
"errMsg": "An expired-token error was received.",
"curlErrno": 0,
"name": "n/a",
"message": "n/a",
"details": "n/a",
"debug_id": "n/a"
}
CURL Options: {
"78": 10,
"52": false,
"75": true,
"74": true,
"42": 0,
"19913": true,
"13": 45,
"47": true,
"10002": "https://api-m.paypal.com/v1/oauth2/token"
}




So I have checked to make 100% sure that curl is enabled.  This is a live site <https://zc157d.dreamhosters.com>

Do not let the zc157d tag confuse you, it is an old sandbox location and I just loaded 2.0.1 into that site.
13 Jun 2024, 7:20 PM
#102
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,110
Plugin Contributions:
56

Re: PayPal RESTful API Payment Module

g2ktcf:

So I have checked to make 100% sure that curl is enabled. This is a live site https://zc157d.dreamhosters.com

Do not let the zc157d tag confuse you, it is an old sandbox location and I just loaded 2.0.1 into that site.
My best guess is that your client-credentials are invalid.

13 Jun 2024, 7:52 PM
#103
g2ktcf avatar

g2ktcf

Totally Zenned

Join Date:
Feb 2011
Location:
Lumberton, TX
Posts:
636
Plugin Contributions:
0

Re: PayPal RESTful API Payment Module

lat9:

My best guess is that your client-credentials are invalid.

I did find an error, however, now I get a warning that the BRAND NEW CREDENTIALS I just created are invalid.

13 Jun 2024, 9:16 PM
#104
g2ktcf avatar

g2ktcf

Totally Zenned

Join Date:
Feb 2011
Location:
Lumberton, TX
Posts:
636
Plugin Contributions:
0

Re: PayPal RESTful API Payment Module

g2ktcf:

I did find an error, however, now I get a warning that the BRAND NEW CREDENTIALS I just created are invalid.

Interesting that I had to go work on something else for a couple of hours. Came back and got the same error. Submitted a case to PP. Tried one more time and it worked...??? Is there some kind of time lag from setting up a new PP API App before the credentials are live???

13 Jun 2024, 9:24 PM
#105
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,110
Plugin Contributions:
56

Re: PayPal RESTful API Payment Module

g2ktcf:

Interesting that I had to go work on something else for a couple of hours. Came back and got the same error. Submitted a case to PP. Tried one more time and it worked...??? Is there some kind of time lag from setting up a new PP API App before the credentials are live???
I've no idea on the time-lag, but happy that you sussed it out.

13 Jun 2024, 10:21 PM
#106
g2ktcf avatar

g2ktcf

Totally Zenned

Join Date:
Feb 2011
Location:
Lumberton, TX
Posts:
636
Plugin Contributions:
0

Re: PayPal RESTful API Payment Module

Making progress. But I did learn the Paypal's developer tools are really good. I have a new error and the error is fully detailed

https://drive.google.com/file/d/1K35vCbSM1apf-IOJN9RG6DF_L8sdQIZX/view?usp=drive_link

Now this is clearly NOT a RESTful PayPal but an account issue at PayPal. But below this link is the full JSON Request and Response. Very nice!

Now if I can just figure out how to set up my account to take credit cards (never had issues with the older system).

15 Jun 2024, 5:39 PM
#107
g2ktcf avatar

g2ktcf

Totally Zenned

Join Date:
Feb 2011
Location:
Lumberton, TX
Posts:
636
Plugin Contributions:
0

Re: PayPal RESTful API Payment Module

I forgot that the new plugin is both Pro AND Express. We do not have a Pro account so we do not take credit cards directly. I set up the plugin to accept them so I appear to be mistaken in that regard. We have to go the PayPal site to enter and use CCs. I was able to verify a new order and refund it completely.

And no, I do not like how PP responds overall. It now FORCES you to create a PP account. But this particular site does not have a huge amount of traffic right now and we cannot pay monthly fees for PP Pro so this is just how it has to go.

15 Jun 2024, 6:40 PM
#108
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,720
Plugin Contributions:
56

Re: PayPal RESTful API Payment Module

[PayPal] now FORCES you to create a PP account.

The workaround would be to use a credit card gateway like Square or Authorize.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

17 Jun 2024, 10:28 AM
#109
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,848
Plugin Contributions:
17

Re: PayPal RESTful API Payment Module

Or update to a free business account and use Express Checkout after modifying your account settings.

https://docs.zen-cart.com/user/payment/paypal_vs_credit_card/#comments

or more detailed https://myzencarthost.com/index.php?rp=/knowledgebase/8/PayPal-Express-Optional-Credit-Card-Setting.html

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

17 Jun 2024, 11:58 AM
#110
g2ktcf avatar

g2ktcf

Totally Zenned

Join Date:
Feb 2011
Location:
Lumberton, TX
Posts:
636
Plugin Contributions:
0

Re: PayPal RESTful API Payment Module

dbltoe:

Or update to a free business account and use Express Checkout after modifying your account settings.

https://docs.zen-cart.com/user/payment/paypal_vs_credit_card/#comments

or more detailed https://myzencarthost.com/index.php?rp=/knowledgebase/8/PayPal-Express-Optional-Credit-Card-Setting.html

We have these settings and I was forced to create a PP Account during the testing of our new site. Now I can tell you that the entire process was a bit confusing as we were already logged into the PayPal developer platform at the same time. From what I can see, I was forced to create the PP account without any other option.

19 Jun 2024, 5:42 AM
#111
siliconbug avatar

siliconbug

Zen Follower

Join Date:
Apr 2009
Posts:
125
Plugin Contributions:
0

Re: PayPal RESTful API Payment Module

siliconbug:

Zen Cart v1.58a
Paypal RESTful v1.0.2
Payment Action: Auth Only

I disable PayPal Express Checkout and enable Paypal RESTful today.

There are two orders. The 1st order is paid by PayPal Wallet, and the 2nd order is paid by Credit Card.

The 1st payment goes through, but the 2nd order gives me an error:

Both orders get this error when I capture the payments, but I can get correct $$ into my PayPal account:

Something under PayPal Transactions doesn't look right.

[Attachment no longer available]

Should I remove PayPal Express Checkout completely? Or any possible issue I missed?

I disable Credit Card and keep using PayPal Wallet only.
Still get the same error after every order:

The payment module's observer (auto.paypalrestful.php) was not loaded; the payment module has been disabled. The payment module has been automatically disabled.
Logs don't show any error, and I can capture $$ without any issue.
/includes/classes/observers/auto.paypalrestful.php is at the right place.
I test it in Sandbox mode, and everything goes well without such an error.

Is there anything I miss?

19 Jun 2024, 11:25 AM
#112
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,110
Plugin Contributions:
56

Re: PayPal RESTful API Payment Module

Turn on the payment module's debug and send the resulting log to me via direct email.

21 Jun 2024, 7:28 PM
#113
jeff_mash avatar

jeff_mash

Totally Zenned

Join Date:
Aug 2004
Posts:
732
Plugin Contributions:
0

Re: PayPal RESTful API Payment Module

I did a successful PayPal test earlier, worked fine. Now trying it again, using the same account, and the same product, and it gives me a WHITE SCREEN as soon as I click the "Confirm Order" button on the OPC checkout page. It never takes me to the PayPal login page.

Here are the two debug log files.

File: myDEBUG-20240621-191454-655888.log

[21-Jun-2024 12:14:55 America/Los_Angeles] Request URI: /store/index.php?main_page=checkout_one_confirmation, IP address: 76.127.00.32
--> [b]PHP Fatal error: Uncaught Error: Call to undefined method paypalr::sendAlertMessage()[/b] in /home/domain/public_html/store/includes/modules/payment/paypalr.php:953
Stack trace:
#0 /home/domain/public_html/store/includes/classes/payment.php(248): paypalr->pre_confirmation_check()
#1 /home/domain/public_html/store/includes/modules/pages/checkout_one_confirmation/header_php.php(246): payment->pre_confirmation_check()
#2 /home/domain/public_html/store/index.php(35): require('/home/domain/...')
#3 {main}
  thrown in /home/domain/public_html/store/includes/modules/payment/paypalr.php on line 953.

File 2: paypalr-c-27905-JefMas-20240621.log (only the bottom part of the log)

2024-06-21 12:14:55: (checkout_one_confirmation) ==> End createOrder\ConfirmPayPalPaymentChoiceRequest::__construct(...) finished, request:
{
    "paypal": {
        "name": {
            "given_name": "Jeff",
            "surname": "Mash"
        },
        "email_address": "email######################",
        "experience_context": {
            "payment_method_preference": "IMMEDIATE_PAYMENT_REQUIRED",
            "brand_name": "Brand",
            "landing_page": "NO_PREFERENCE",
            "shipping_preference": "SET_PROVIDED_ADDRESS",
            "user_action": "PAY_NOW",
            "return_url": "https:\/\/www.domain.com\/store\/ppr_webhook_main.php?op=return",
            "cancel_url": "https:\/\/www.domain.com\/store\/ppr_webhook_main.php?op=cancel"
        }
    }
}
2024-06-21 12:14:55: (checkout_one_confirmation) ==> Start confirmPaymentSource
TokenCache::get, using saved access-token; expires in 31506 seconds.
The curlPost (v2/checkout/orders/0K792404TN0597925/confirm-payment-source) request was unsuccessful.
{
    "errNum": 422,
    "errMsg": "An interface error (422) was returned from PayPal.",
    "curlErrno": 0,
    "name": "UNPROCESSABLE_ENTITY",
    "message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
    "details": [
        {
            "issue": "ORDER_ALREADY_AUTHORIZED",
            "description": "Order already authorized.If 'intent=AUTHORIZE' only one authorization per order is allowed."
        }
    ],
    "debug_id": "4997a45158c3b"
}
CURL Options: {
    "78": 10,
    "52": false,
    "75": true,
    "74": true,
    "42": 0,
    "19913": true,
    "13": 45,
    "47": true,
    "10002": "https:\/\/api-m.paypal.com\/v2\/checkout\/orders\/0K792404TN0597925\/confirm-payment-source",
    "10015": "{\"payment_source\":{\"paypal\":{\"name\":{\"given_name\":\"Jeff\",\"surname\":\"Mash\"},\"email_address\":\"email######################\",\"experience_context\":{\"payment_method_preference\":\"IMMEDIATE_PAYMENT_REQUIRED\",\"brand_name\":\"MJM Magic\",\"landing_page\":\"NO_PREFERENCE\",\"shipping_preference\":\"SET_PROVIDED_ADDRESS\",\"user_action\":\"PAY_NOW\",\"return_url\":\"https:\\\/\\\/www.domain.com\\\/store\\\/ppr_webhook_main.php?op=return\",\"cancel_url\":\"https:\\\/\\\/www.domain.com\\\/store\\\/ppr_webhook_main.php?op=cancel\"}}}}"
}
2024-06-21 12:14:55: (checkout_one_confirmation) ==> End confirmPaymentSource

Is there some kind of conflict with the old paypaldp and paypalwpp modules which I also have installed? I believe I tried to disable them (not uninstall) but still saw the same issue.

I don't understand why this worked earlier in my test and now it doesn't.

  • Jeff
21 Jun 2024, 8:28 PM
#114
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,110
Plugin Contributions:
56

Re: PayPal RESTful API Payment Module

Crud, line 953-956 should read

            $this->sendAlert[B]Email[/B](
                MODULE_PAYMENT_PAYPALR_ALERT_SUBJECT_CONFIRMATION_ERROR,
                MODULE_PAYMENT_PAYPALR_ALERT_CONFIRMATION_ERROR . "\n" . Logger::logJSON($payment_choice_response) . "\n" . Logger::logJSON($this->ppr->getErrorInfo())
            );

... not sendAlertMessage.

Update: GitHub issue created (https://github.com/lat9/paypalr/issues/26)

21 Jun 2024, 8:42 PM
#115
jeff_mash avatar

jeff_mash

Totally Zenned

Join Date:
Aug 2004
Posts:
732
Plugin Contributions:
0

Re: PayPal RESTful API Payment Module

lat9:

Crud, line 953-956 should read

        $this->sendAlert[B]Email[/B](
            MODULE_PAYMENT_PAYPALR_ALERT_SUBJECT_CONFIRMATION_ERROR,
            MODULE_PAYMENT_PAYPALR_ALERT_CONFIRMATION_ERROR . "\n" . Logger::logJSON($payment_choice_response) . "\n" . Logger::logJSON($this->ppr->getErrorInfo())
        );
> ... not sendAlert**Message**.
> 
> Update: GitHub issue created (<https://github.com/lat9/paypalr/issues/26>)

Glad to help find that!  I wonder why it seemed to work to submit my first test order though?  Because it did that, I thought perhaps I screwed something up when toggling modules back and forth.  :D
  • Jeff
21 Jun 2024, 9:30 PM
#116
jeff_mash avatar

jeff_mash

Totally Zenned

Join Date:
Aug 2004
Posts:
732
Plugin Contributions:
0

Re: PayPal RESTful API Payment Module

Jeff_Mash:

Glad to help find that!

Hey Cindy - I manually changed the name of the function to sendAlertEmail() and tried again. This time, I get an actual error message on the OPC page:

"We are unable to process your PayPal Checkout payment at this time. Please contact us for assistance."

Looking at the debug log file, it seems to indicate that this transaction was previously authorized:

024-06-21 14:25:37: (checkout_one_confirmation) ==> Start confirmPaymentSource
TokenCache::get, using saved access-token; expires in 32322 seconds.
The curlPost (v2/checkout/orders/0K792404TN0597925/confirm-payment-source) request was unsuccessful.
{
    "errNum": 422,
    "errMsg": "An interface error (422) was returned from PayPal.",
    "curlErrno": 0,
    "name": "UNPROCESSABLE_ENTITY",
    "message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
    "details": [
        {
            "issue": "ORDER_ALREADY_AUTHORIZED",
            "description": "Order already authorized.If 'intent=AUTHORIZE' only one authorization per order is allowed."
        }
    ],
    "debug_id": "81bd08dcd3053"
}
CURL Options: {
    "78": 10,
    "52": false,
    "75": true,
    "74": true,
    "42": 0,
    "19913": true,
    "13": 45,
    "47": true,
    "10002": "https:\/\/api-m.paypal.com\/v2\/checkout\/orders\/0K792404TN0597925\/confirm-payment-source",
    "10015": "{\"payment_source\":{\"paypal\":{\"name\":{\"given_name\":\"Jeff\",\"surname\":\"Mash\"},\"email_address\":\"email######################\",\"experience_context\":{\"payment_method_preference\":\"IMMEDIATE_PAYMENT_REQUIRED\",\"brand_name\":\"MJM Magic\",\"landing_page\":\"NO_PREFERENCE\",\"shipping_preference\":\"SET_PROVIDED_ADDRESS\",\"user_action\":\"PAY_NOW\",\"return_url\":\"https:\\\/\\\/www.mjmmagic.com\\\/store\\\/ppr_webhook_main.php?op=return\",\"cancel_url\":\"https:\\\/\\\/www.domain.com\\\/store\\\/ppr_webhook_main.php?op=cancel\"}}}}"
}
2024-06-21 14:25:37: (checkout_one_confirmation) ==> End confirmPaymentSourceWe are unable to process your PayPal Checkout payment at this time.  Please contact us for assistance.
************************************************

2024-06-21 14:25:38: (checkout_one) validateCredentials: Checking (1).
TokenCache::get, using saved access-token; expires in 32321 seconds.

************************************************

As you can see, it says "Order already authorized.If 'intent=AUTHORIZE' only one authorization per order is allowed."

However, this is a new transaction I am pushing over. Granted, I am using the same user account, same PayPal account, and purchasing the same product. But the original order that successfully submitted has been VOIDED in PayPal. So I don't know why it's still saying "ORDER_ALREADY_AUTHORIZED" since this would be a new order.

Any way to look into that? I can help debug if need be, just let me know or hit me up on Skype.

  • Jeff
22 Jun 2024, 3:06 PM
#117
jeff_mash avatar

jeff_mash

Totally Zenned

Join Date:
Aug 2004
Posts:
732
Plugin Contributions:
0

Re: PayPal RESTful API Payment Module

I'm wondering if what I pointed out above is somehow tied into the AUTH ONLY setting that we enabled? I don't think most people use AUTH ONLY like we do, so maybe it's a bug? Like I said, the first time we placed the order (Paypal Wallet - AUTH ONLY), it submitted. We voided it out, deleted the order, and tried again using the same customer, same PayPal account, same product. Everything about the order was identical. This time, it failed with the message and log that I documented above this post.

Hope that helps to see if we can help you reproduce it, or to help explain why we would have gotten that "ORDER_ALREADY_AUTHORIZED" error when it was a new (second) order we were testing with the same product and same account.

  • Jeff
23 Jun 2024, 2:45 AM
#118
siliconbug avatar

siliconbug

Zen Follower

Join Date:
Apr 2009
Posts:
125
Plugin Contributions:
0

Re: PayPal RESTful API Payment Module

Jeff_Mash:

I'm wondering if what I pointed out above is somehow tied into the AUTH ONLY setting that we enabled?
Hi Jeff_Mash,

Sorry to interrupt your question. Have you met such an error when you receive an auth-only order?

The payment module's observer (auto.paypalrestful.php) was not loaded; the payment module has been disabled. The payment module has been automatically disabled.
I also use auth-only, but not sure if it's my problem, or an issue while using auth-only mode.

24 Jun 2024, 4:53 PM
#119
jeff_mash avatar

jeff_mash

Totally Zenned

Join Date:
Aug 2004
Posts:
732
Plugin Contributions:
0

Re: PayPal RESTful API Payment Module

siliconbug:

Hi Jeff_Mash,

Sorry to interrupt your question. Have you met such an error when you receive an auth-only order?

I also use auth-only, but not sure if it's my problem, or an issue while using auth-only mode.

Check Step 2 in the installation instructions:

  1. If your site is using a Zen Cart version prior to 2.0.0, add the payment module's required notifications to the order_total class, as described in this Wiki article. Without this update, the payment module will automatically disable itself.

Wiki Link: https://github.com/lat9/paypalr/wiki/Required-changes-to-%60-includes-classes-order_total.php%60

That will probably fix your issue.

Here is also a list of other events that could cause the module to disable:

https://github.com/lat9/paypalr/wiki/Configuring-the-Payment-Module#missing-required-notifications

  • Jeff
24 Jun 2024, 5:57 PM
#120
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,110
Plugin Contributions:
56

Re: PayPal RESTful API Payment Module

Turns out (thanks @siliconbug for the aid in debugging!) that the auto-disable was due to the PayPal ipn_main_handler.php's operation. That was creating an instance of the paypalr payment module and since the IPN processing doesn't load auto-loaded observers ... paypalr was auto-disabling!

See this GitHub issue for the resolution: https://github.com/lat9/paypalr/issues/27