Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xiaowu Zhang
erp5
Commits
4df644c6
Commit
4df644c6
authored
Feb 20, 2013
by
Rafael Monnerat
Committed by
Xiaowu Zhang
Feb 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include API to query Transactions informations on Paypal
parent
7f82568d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
5 deletions
+61
-5
bt5/erp5_paypal_secure_payment/DocumentTemplateItem/PaypalService.py
...ypal_secure_payment/DocumentTemplateItem/PaypalService.py
+60
-4
bt5/erp5_paypal_secure_payment/bt/revision
bt5/erp5_paypal_secure_payment/bt/revision
+1
-1
No files found.
bt5/erp5_paypal_secure_payment/DocumentTemplateItem/PaypalService.py
View file @
4df644c6
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
##############################################################################
#
#
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
# Copyright (c) 2010
,2013
Nexedi SA and Contributors. All Rights Reserved.
# François-Xavier Algrain <fxalgrain@tiolive.com>
# François-Xavier Algrain <fxalgrain@tiolive.com>
# Gabriel Monnerat <gabriel@nexedi.com>
#
#
# WARNING: This program as such is intended to be used by professional
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# programmers who take the whole responsability of assessing all potential
...
@@ -27,16 +28,71 @@
...
@@ -27,16 +28,71 @@
#
#
##############################################################################
##############################################################################
import
zope
import
zope
from
cgi
import
parse_qsl
from
urllib
import
urlencode
from
urllib
import
urlencode
from
urllib2
import
urlopen
,
Request
from
urllib2
import
urlopen
,
Request
from
zLOG
import
LOG
,
DEBUG
from
zLOG
import
LOG
,
DEBUG
,
WARNING
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type
import
Permissions
,
PropertySheet
,
interfaces
from
Products.ERP5Type
import
Permissions
,
PropertySheet
,
interfaces
from
Products.ERP5Type.XMLObject
import
XMLObject
from
Products.ERP5Type.XMLObject
import
XMLObject
from
Products.ERP5Type.Document
import
newTempDocument
from
Products.ERP5Type.Document
import
newTempDocument
class
PaypalService
(
XMLObject
):
def
response_to_dict
(
response
):
return
dict
(
parse_qsl
(
response
))
class
PaypalWebServiceMixin
:
def
getCredential
(
self
):
return
urlencode
({
"USER"
:
self
.
getServiceUsername
(),
"PWD"
:
self
.
getServicePassword
(),
"SIGNATURE"
:
self
.
getServiceSignature
(),
"VERSION"
:
"65.2"
,})
+
"&"
def
getTransactionIDList
(
self
,
start_date
,
**
kw
):
nvp_link
=
self
.
getNvpLink
()
credential
=
self
.
getCredential
()
parameter_dict
=
{
"METHOD"
:
"TransactionSearch"
,
"STARTDATE"
:
start_date
.
strftime
(
"%Y-%m-%dT%H:%M:%SZ"
)}
for
key
,
value
in
kw
.
iteritems
():
parameter_dict
[
key
]
=
value
query_string
=
credential
+
urlencode
(
parameter_dict
)
response
=
urlopen
(
nvp_link
,
query_string
).
read
()
response_dict
=
response_to_dict
(
response
)
if
response_dict
.
get
(
"ACK"
,
""
)
!=
"Success"
:
LOG
(
"Paypal Failure"
,
WARNING
,
response_dict
)
return
filter
(
lambda
x
:
x
[
0
].
startswith
(
"L_TRANSACTIONID"
),
response_dict
.
items
())
def
getTransactionList
(
self
,
start_date
,
**
kw
):
nvp_link
=
self
.
getNvpLink
()
credential
=
self
.
getCredential
()
transaction_id_list
=
self
.
getTransactionIDList
(
start_date
,
**
kw
)
LOG
(
"Paypal"
,
DEBUG
,
transaction_id_list
)
transaction_dict
=
{}
for
key
,
transaction_id
in
transaction_id_list
:
parameter_dict
=
{
"METHOD"
:
"GetTransactionDetails"
,
"TRANSACTIONID"
:
transaction_id
}
query_string
=
credential
+
urlencode
(
parameter_dict
)
response
=
urlopen
(
nvp_link
,
query_string
).
read
()
response_dict
=
response_to_dict
(
response
)
if
response_dict
[
"ACK"
]
!=
"Success"
:
LOG
(
"Paypal Failure"
,
WARNING
,
response_dict
)
continue
transaction_dict
[
transaction_id
]
=
response_dict
return
transaction_dict
def
getTransaction
(
self
,
transaction_id
):
parameter_dict
=
{
"METHOD"
:
"GetTransactionDetails"
,
"TRANSACTIONID"
:
transaction_id
}
query_string
=
self
.
getCredential
()
+
urlencode
(
parameter_dict
)
response
=
urlopen
(
self
.
getNvpLink
(),
query_string
).
read
()
response_dict
=
response_to_dict
(
response
)
return
response_dict
class
PaypalService
(
XMLObject
,
PaypalWebServiceMixin
):
"""Paypal Service for payment"""
"""Paypal Service for payment"""
meta_type
=
'Paypal Service'
meta_type
=
'Paypal Service'
...
@@ -106,4 +162,4 @@ class PaypalService(XMLObject):
...
@@ -106,4 +162,4 @@ class PaypalService(XMLObject):
LOG
(
"PaypalService status"
,
DEBUG
,
status
)
LOG
(
"PaypalService status"
,
DEBUG
,
status
)
method_id
=
self
.
_getTypeBasedMethod
(
"reportPaymentStatus"
).
id
method_id
=
self
.
_getTypeBasedMethod
(
"reportPaymentStatus"
).
id
getattr
(
self
.
activate
(),
method_id
)(
response_dict
=
REQUEST
.
form
)
getattr
(
self
.
activate
(),
method_id
)(
response_dict
=
REQUEST
.
form
)
return
status
==
"VERIFIED"
return
status
==
"VERIFIED"
\ No newline at end of file
bt5/erp5_paypal_secure_payment/bt/revision
View file @
4df644c6
3
6
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment