Skip to content
Commits on Source (2)
......@@ -65,6 +65,7 @@ class Paypal(LoginBrowser):
promo = URL('https://www.paypal.com/fr/webapps/mpp/clickthru/paypal-app-promo-2.*',
'/fr/webapps/mpp/clickthru.*', PromoPage)
account = URL('https://www.paypal.com/businessexp/money',
'https://www.paypal.com/myaccount/money',
'https://www.paypal.com/webapps/business/money', AccountPage)
pro_history = URL('https://\w+.paypal.com/businessexp/transactions/activity\?.*',
ProHistoryPage)
......
......@@ -24,7 +24,7 @@
from weboob.tools.compat import unicode
from weboob.capabilities.bank import Account
from weboob.capabilities.base import NotAvailable, Currency
from weboob.capabilities.base import NotAvailable
from weboob.exceptions import BrowserUnavailable, ActionNeeded
from weboob.browser.exceptions import ServerError
from weboob.browser.pages import HTMLPage, JsonPage, LoggedPage
......@@ -93,7 +93,7 @@ def exec_decoder(mtc):
cleaner_code = re.sub(r"%s\('([^']+)'\)" % re.escape(decoder_name), exec_decoder, cleaner_code)
cookie = re.search(r'xppcts = (\w+);', cleaner_code).group(1)
sessionID = re.search(r"%s'([^']+)'" % re.escape("'&_sessionID='+encodeURIComponent("), cleaner_code).group(1)
sessionID = re.search(r"%s\w+\('([^']+)'" % re.escape("'&_sessionID='+encodeURIComponent("), cleaner_code).group(1)
csrf = re.search(r"%s'([^']+)'" % re.escape("'&_csrf='+encodeURIComponent("), cleaner_code).group(1)
key, value = re.findall(r"'(\w+)','(\w+)'", cleaner_code)[-1]
......@@ -106,9 +106,12 @@ def exec_decoder(mtc):
get_token_func_declaration = "var " + get_token_func_name + "="
cleaner_code = cleaner_code.replace(get_token_func_declaration, get_token_func_declaration + "window.ADS_JS_TOKEN=")
# Remove the call to an infinite loop
loop_func_name = re.search(r"\(function\(\w+,\s?\w+,\s?\w+,\s?\w+\)\{var\s(\w+)=", cleaner_code).group(1)
cleaner_code = cleaner_code.replace(loop_func_name + "();", "")
# Paypal will try to create an infinite loop to make the parse fail, based on different
# weird things like a check of 'ind\\u0435xOf' vs 'indexOf'.
cleaner_code = cleaner_code.replace(r"'ind\\u0435xOf'", "'indexOf'")
# It also calls "data" which is undefined instead of a return (next call is an infinite
# recursive function). This should theorically not happen if window.domain is correctly set
# to "paypal.com" though.
cleaner_code = cleaner_code.replace("data;", "return;")
# Add a function that returns the token
......@@ -166,22 +169,18 @@ def get_account(self, _id):
def get_accounts(self):
accounts = {}
content = self.doc.xpath('//div[@id="moneyPage" or @id="MoneyPage"]')[0]
content = self.doc.xpath('//section[@id="contents"]')[0]
# Multiple accounts
lines = content.xpath('(//div[@class="col-md-8 multi-currency"])[1]/ul/li')
lines = content.xpath('.//ul[@class="multiCurrency-container"][1]/li')
for li in lines:
account = Account()
account.iban = NotAvailable
account.type = Account.TYPE_CHECKING
currency_code = CleanText().filter((li.xpath('./span[@class="currencyUnit"]/span') or li.xpath('./span[1]'))[0])
currency = Currency.get_currency(currency_code)
if not currency:
self.logger.warning('Unable to find currency %r', currency_code)
continue
currency = CleanText().filter(li.xpath('.//span[contains(@class, "multiCurrency-label_alignMiddle")]')[0])
account.id = currency
account.currency = currency
account.balance = CleanDecimal(replace_dots=True).filter(li.xpath('./span[@class="amount"]/text()'))
account.balance = CleanDecimal(replace_dots=True).filter(li.xpath('.//span[contains(@class, "multiCurrency-label_right")]/text()')[0])
account.label = u'%s %s*' % (self.browser.username, account.currency)
accounts[account.id] = account
self.browser.account_currencies.append(account.currency)
......