-
Notifications
You must be signed in to change notification settings - Fork 257
Creating Invoice no working #74
Comments
By 'on hold and never returns', do you mean that the call is hanging? Can you capture the full request being sent to PayPal and paste it here to see if we can reproduce it on our end? Thanks! |
Yes the call is hanging (i'm sorry for my bad english). import paypalrestsdk
from paypalrestsdk import Invoice
paypalrestsdk.configure({
"mode": "sandbox",
"client_id": "AbQsJhDUmxAZA6oJ6wiz7qHy68ttoy8AL5vULPjDJ_WsSja0SMtoXlC2qYEw",
"client_secret": "EPtq-xBGINJ7qxa1Sxh-9dlLNqFTrv07Dnq49mIFzqs8N0qnL1Nt87hzuaO9"
})
invoice = Invoice({
'merchant_info': {
"email": "seller@hastega.org",
},
"billing_info": [{
"email": "example@example.com"
}],
"items": [{
"name": "Widgets",
"quantity": 20,
"unit_price": {
"currency": "USD",
"value": 2
}
}],
})
response = invoice.create()
print(response) Thanks very much for the support! |
Testing with that request and credentials, I get the following response: {
"name": "AUTHORIZATION_ERROR",
"message": "Authorization error occurred.",
"debug_id": "2c735a83beaa8"
} Can you try it again and see if you still experience a hang? |
Btw, just as a safe side, once you are done with this issue, I would recommend, creating a new clientId and secret. As this is exposed externally already. |
Hey @conventi I think we found the issue. Can you please try out this script as shown below. I have added logging to better reflect what is happening. import paypalrestsdk
import logging
# Include Headers and Content by setting logging level to DEBUG, particularly for
# Paypal-Debug-Id if requesting PayPal Merchant Technical Services for support
logging.basicConfig(level=logging.DEBUG)
paypalrestsdk.configure({
"mode": "sandbox", # sandbox or live
"client_id": "AbQsJhDUmxAZA6oJ6wiz7qHy68ttoy8AL5vULPjDJ_WsSja0SMtoXlC2qYEw",
"client_secret": "EPtq-xBGINJ7qxa1Sxh-9dlLNqFTrv07Dnq49mIFzqs8N0qnL1Nt87hzuaO9"
})
from paypalrestsdk import Invoice
invoice = Invoice({
'merchant_info': {
"email": "seller@hastega.org",
},
"billing_info": [{
"email": "example@example.com"
}],
"items": [{
"name": "Widgets",
"quantity": 20,
"unit_price": {
"currency": "USD",
"value": 2
}
}],
})
if invoice.create():
print(invoice)
else:
print(invoice.error) This is what we got: INFO:root:Request[POST]: https://api.sandbox.paypal.com/v1/oauth2/token
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.sandbox.paypal.com
DEBUG:requests.packages.urllib3.connectionpool:"POST /v1/oauth2/token HTTP/1.1" 200 428
INFO:root:Response[200]: OK, Duration: 0.690284s.
DEBUG:root:debug_id: 052acdbd12366
INFO:root:PayPal-Request-Id: 98dd1cdd-1988-4b9f-9352-3ce45d6ce38c
INFO:root:Request[POST]: https://api.sandbox.paypal.com/v1/invoicing/invoices
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.sandbox.paypal.com
DEBUG:requests.packages.urllib3.connectionpool:"POST /v1/invoicing/invoices HTTP/1.1" 401 99
INFO:root:Response[401]: Unauthorized, Duration: 0.422529s.
DEBUG:root:debug_id: 49291ea112ea1
What we saw was, there is a code that checks the exception, and retries if the access token becomes invalid (401 Unathorized). however, the issue is , 401 could occur also when you have invalid scope, (which means, you have not enabled the invoicing services). Can you please try this code, and see if you are seeing the same result. We are still finding the exact reason behind the issue, however, this would help. |
I confirm that I get the same output with 401. I checked on https://developer.paypal.com/webapps/developer/account/status I also tried the master account (not "seller@hastega.org" that was created for testing in Sandbox->Account) but I get the same output . Where am I wrong? |
I am sure, you already covered this, but make sure you are using sandbox clientId and secret for sandbox testing. I am looking into the debug_id, and will let you know about the error. |
Oh ! I found the issue. Can you please make sure you have a business pro account for the email you are using for invoicing. As you can see here, if I try with I will create the issue for this, and get the error updated to more meaningful message. However, in the mean time, please make sure you are using the email with business account. |
Perfect! I realized what the problem was. I thought it was a permissions issue because payments worked perfectly. I apologize for not having checked to have a pro account.
|
Great. Please feel to re-open this issue, if you run into the issue. |
We should not need to make the 3rd party have a business pro account according to the documentation: https://developer.paypal.com/docs/integration/direct/invoicing/
My business pro account should be able to use paypal to create an invoice for a 3rd party non business account. Did I misunderstand the documents? |
You can create the invoice but if it's a non-business account, it may not be able to accept credit card payments. |
I followed the instructions but when i call invoice.create( ) it remains on hold and never returns. Only If i set an unregistered email in merchant_info it return with the correct error message. I'm testing the code with the sandbox api credentials.
The text was updated successfully, but these errors were encountered: