Skip to content
This repository has been archived by the owner on May 12, 2020. It is now read-only.

Creating Invoice no working #74

Closed
ghost opened this issue Dec 19, 2014 · 14 comments
Closed

Creating Invoice no working #74

ghost opened this issue Dec 19, 2014 · 14 comments

Comments

@ghost
Copy link

ghost commented Dec 19, 2014

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.

@jziaja
Copy link

jziaja commented Dec 19, 2014

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!

@ghost
Copy link
Author

ghost commented Dec 19, 2014

Yes the call is hanging (i'm sorry for my bad english).
The request is this:

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!

@jziaja
Copy link

jziaja commented Dec 19, 2014

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?

@ghost
Copy link
Author

ghost commented Dec 19, 2014

I'm sorry but at this point i think that i'm doing somethings wrong. As last option i past an image with the request from terminal.

schermata 2014-12-19 alle 17 15 07

Thanks for your patience!

@jaypatel512
Copy link
Contributor

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.

@jaypatel512
Copy link
Contributor

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.

@jaypatel512
Copy link
Contributor

As, you might already know, you have to have a registered email in your developer account to send the invoice.

However, also make sure that you have invoicing enabled for your account as shown below:

screen shot 2014-12-19 at 11 17 17 am

@ghost
Copy link
Author

ghost commented Dec 19, 2014

I confirm that I get the same output with 401. I checked on https://developer.paypal.com/webapps/developer/account/status
and as in the photo i already enabled invoicing.

schermata 2014-12-19 alle 18 27 23

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?

@jaypatel512
Copy link
Contributor

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.

@jaypatel512
Copy link
Contributor

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 jaypatel512-facilitator@hotmail.com it works, but wont work with anyone else. I think the error message shown is not nice, and it should explicitly mention something like Merchant with Given Email need to be a Pro-Business Member or something.

screen shot 2014-12-19 at 12 24 34 pm

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.

@ghost
Copy link
Author

ghost commented Dec 19, 2014

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.
I thank you sincerely for the help you have provided.
Tomorrow i will carry out the test with a pro account!

Il giorno 19/dic/2014, alle ore 19:27, Jay notifications@github.com ha scritto:

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 jaypatel512-facilitator@hotmail.com it works, but wont work with anyone else. I think the error message shown is not nice, and it should explicitly mention something like Merchant with Given Email need to be a Pro-Business Member or something.

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.


Reply to this email directly or view it on GitHub.

@jaypatel512
Copy link
Contributor

Great. Please feel to re-open this issue, if you run into the issue.

@DeannaWagner
Copy link

DeannaWagner commented Apr 17, 2018

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/

Required account types

You must have a premier or business account to use our APIs, but any account type can send and pay invoices. Customers who do not have a PayPal account can pay invoices as a guest.

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?

@xiaoleih41
Copy link
Contributor

You can create the invoice but if it's a non-business account, it may not be able to accept credit card payments.

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

No branches or pull requests

4 participants