FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sample-code-python/PayPalExpressCheckout/void.py at master · calebfreeman/sample-code-python · GitHub
calebfreeman
/
sample-code-python
Public
forked from
AuthorizeNet/sample-code-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
sample-code-python
/
PayPalExpressCheckout
/
void.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
60 lines (49 loc) · 2.68 KB
Breadcrumbs
sample-code-python
/
PayPalExpressCheckout
/
void.py
Copy path
File metadata and controls
60 lines (49 loc) · 2.68 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import
os
,
sys
import
imp
from
authorizenet
import
apicontractsv1
from
authorizenet
.
apicontrollers
import
*
constants
=
imp
.
load_source
(
'modulename'
,
'constants.py'
)
from
decimal
import
*
def
void
(
refTransId
):
merchantAuth
=
apicontractsv1
.
merchantAuthenticationType
()
merchantAuth
.
name
=
constants
.
apiLoginId
merchantAuth
.
transactionKey
=
constants
.
transactionKey
paypal
=
apicontractsv1
.
payPalType
()
payment
=
apicontractsv1
.
paymentType
()
payment
.
payPal
=
paypal
transactionrequest
=
apicontractsv1
.
transactionRequestType
()
transactionrequest
.
transactionType
=
apicontractsv1
.
transactionTypeEnum
.
voidTransaction
transactionrequest
.
refTransId
=
refTransId
transactionrequest
.
payment
=
payment
request
=
apicontractsv1
.
createTransactionRequest
()
request
.
merchantAuthentication
=
merchantAuth
request
.
refId
=
"Sample"
request
.
transactionRequest
=
transactionrequest
controller
=
createTransactionController
(
request
)
controller
.
execute
()
response
=
controller
.
getresponse
()
if
response
is
not
None
:
if
response
.
messages
.
resultCode
==
"Ok"
:
if
hasattr
(
response
.
transactionResponse
,
'messages'
)
==
True
:
print
(
'Successfully created transaction with Transaction ID: %s'
%
response
.
transactionResponse
.
transId
)
print
(
'Transaction Response Code: %s'
%
response
.
transactionResponse
.
responseCode
)
print
(
'Message Code: %s'
%
response
.
transactionResponse
.
messages
.
message
[
0
].
code
)
print
(
'Description: %s'
%
response
.
transactionResponse
.
messages
.
message
[
0
].
description
)
else
:
print
(
'Failed Transaction.'
)
if
hasattr
(
response
.
transactionResponse
,
'errors'
)
==
True
:
print
(
'Error Code: %s'
%
str
(
response
.
transactionResponse
.
errors
.
error
[
0
].
errorCode
))
print
(
'Error message: %s'
%
response
.
transactionResponse
.
errors
.
error
[
0
].
errorText
)
else
:
print
(
'Failed Transaction.'
)
if
hasattr
(
response
,
'transactionResponse'
)
==
True
and
hasattr
(
response
.
transactionResponse
,
'errors'
)
==
True
:
print
(
'Error Code: %s'
%
str
(
response
.
transactionResponse
.
errors
.
error
[
0
].
errorCode
))
print
(
'Error message: %s'
%
response
.
transactionResponse
.
errors
.
error
[
0
].
errorText
)
else
:
print
(
'Error Code: %s'
%
response
.
messages
.
message
[
0
][
'code'
].
text
)
print
(
'Error message: %s'
%
response
.
messages
.
message
[
0
][
'text'
].
text
)
else
:
print
(
'Null Response.'
)
return
response
if
(
os
.
path
.
basename
(
__file__
)
==
os
.
path
.
basename
(
sys
.
argv
[
0
])):
void
(
constants
.
transactionId
)
Back
|
FazBrowse Home
|
New Git URL