joalla / discogs_client

Continuation of the "Official Python Client for the Discogs API"
https://python3-discogs-client.readthedocs.io
Other
299 stars 49 forks source link

Can PayPal transaction IDs be accessed? #72

Closed 0todd0000 closed 2 years ago

0todd0000 commented 2 years ago

Hello! Thank you for the wonderful client!!

I'm able to retrieve most Order information, and I'm now trying to access PayPal transaction IDs, which now appear in the Order messages section like this:

{BUYER} sent payment of {AMOUNT} (Transaction #{PAYPAL_TRANSACTION_ID})

I can access this message like this:


import discogs_client as dc

# MY_DISCOGS_TOKEN = {a string}
# MY_DISCOGS_ID    = {my user ID}
# ORDER_ID         = {an order number (integer)}

client   = dc.Client('PersonalDatabaseApplication/0.1', user_token=MY_DISCOGS_TOKEN)
order    = client.order( f'{MY_DISCOGS_ID}-{ORDER_ID}' )
order.refresh()
msgs     = order.messages
msg      = msgs[3].message

print( msg )

but the result is just this:

{BUYER} sent payment of {AMOUNT} 

with no PayPal transaction ID.

Is it possible to get the PayPal transaction ID another way?

Thanks!

AnssiAhola commented 2 years ago

Hey @0todd0000

Are you sure the Paypal transaction ID is part of the message? Maybe it's something Discogs adds at their end into the message when displaying it in your orders etc. Or its removed from the message before returning it from the API?

Not sure, sorry.

0todd0000 commented 2 years ago

Yes, I'm sure!

Here is a screenshot with confidential details hidden:



I think this feature was introduced in late 2021 or January 2022 when Discogs offered a new PayPal integration option.

The PayPal transaction ID can be seen in various locations in the HTML source for a Discogs order, including inside <div class="thread_content">, so it can be easily parsed from the HTML, but it would be nicer if I could access it through discogs_client. 😊

AnssiAhola commented 2 years ago

Can you try querying the API endpoint url directly with

url = "https://api.discogs.com/marketplace/orders/ORDER_ID/messages"
print(client._get(url))

Is the message included in that response and does it include the Transaction ID ? If not then I think Discogs either parses it out before returning data from the API point or the Transaction ID is added to the message only in Discogs.com Orders -page

0todd0000 commented 2 years ago

Yes, the message is included in that response, but it does not include the Transaction ID. The message looks like this:

   {'type': 'payment',
    'timestamp': {TIMESTAMP},
    'order': {'id': {ORDER_ID},
     'resource_url': 'https://api.discogs.com/marketplace/orders/{ORDER_NUMBER'},
    'message': '{BUYER_NAME} sent payment of {AMOUNT}.',
    'actor': {'id': {BUYER_ID},
     'username': {BUYER_NAME},
     'resource_url': '/user/{BUYER_NICKNAME}',
     'is_admin': False},
    'subject': ''},

Understood, I'll just download the HTML for order page, then parse the Transaction ID manually.

Thank you for your help!