Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
woob
woob
Compare revisions
4f1f89b9e4de4c24fc8ef64116a3a2c29d819cc6 to 9fa7cb75713ae4bbf0989000494b933cf9c02049
Commits on Source (2)
[paypal] Fix login
· a2a703b2
Frandeboeuf Nicolas
authored
Oct 05, 2019
and
hydrargyrum
committed
Oct 26, 2019
a2a703b2
[paypal] Fix accounts list retrieval
· 9fa7cb75
Frandeboeuf Nicolas
authored
Oct 05, 2019
and
hydrargyrum
committed
Oct 26, 2019
9fa7cb75
Hide whitespace changes
Inline
Side-by-side
modules/paypal/browser.py
View file @
9fa7cb75
...
...
@@ -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
)
...
...
modules/paypal/pages.py
View file @
9fa7cb75
...
...
@@ -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=
"
M
on
eyPage
"
]
'
)[
0
]
content
=
self
.
doc
.
xpath
(
'
//
section[
@id=
"
c
on
tents
"
]
'
)[
0
]
# Multiple accounts
lines
=
content
.
xpath
(
'
(
//
div
[@class=
"
col-md-8
multi
-c
urrency
"
]
)
[1]/
ul/
li
'
)
lines
=
content
.
xpath
(
'
.
//
ul
[@class=
"
multi
C
urrency
-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=
"
amoun
t
"
]/text()
'
))
account
.
balance
=
CleanDecimal
(
replace_dots
=
True
).
filter
(
li
.
xpath
(
'
./
/
span[
contains(@class,
"
multiCurrency-label_righ
t
"
)
]/text()
'
)
[
0
]
)
account
.
label
=
u
'
%s %s*
'
%
(
self
.
browser
.
username
,
account
.
currency
)
accounts
[
account
.
id
]
=
account
self
.
browser
.
account_currencies
.
append
(
account
.
currency
)
...
...