FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sample-code-python/RecurringBilling/create-subscription.py at master · ramittal/sample-code-python · GitHub
ramittal
/
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
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
sample-code-python
/
RecurringBilling
/
create-subscription.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
65 lines (59 loc) · 2.61 KB
Breadcrumbs
sample-code-python
/
RecurringBilling
/
create-subscription.py
Copy path
File metadata and controls
65 lines (59 loc) · 2.61 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
61
62
63
64
65
import
os
,
sys
import
imp
from
authorizenet
import
apicontractsv1
from
authorizenet
.
apicontrollers
import
*
constants
=
imp
.
load_source
(
'modulename'
,
'constants.py'
)
from
decimal
import
*
from
datetime
import
*
def
create_subscription
(
amount
,
days
):
# Setting the merchant details
merchantAuth
=
apicontractsv1
.
merchantAuthenticationType
()
merchantAuth
.
name
=
constants
.
apiLoginId
merchantAuth
.
transactionKey
=
constants
.
transactionKey
# Setting payment schedule
paymentschedule
=
apicontractsv1
.
paymentScheduleType
()
paymentschedule
.
interval
=
apicontractsv1
.
paymentScheduleTypeInterval
()
#apicontractsv1.CTD_ANON() #modified by krgupta
paymentschedule
.
interval
.
length
=
days
paymentschedule
.
interval
.
unit
=
apicontractsv1
.
ARBSubscriptionUnitEnum
.
days
paymentschedule
.
startDate
=
datetime
(
2020
,
8
,
30
)
paymentschedule
.
totalOccurrences
=
12
paymentschedule
.
trialOccurrences
=
1
# Giving the credit card info
creditcard
=
apicontractsv1
.
creditCardType
()
creditcard
.
cardNumber
=
"4111111111111111"
creditcard
.
expirationDate
=
"2020-12"
payment
=
apicontractsv1
.
paymentType
()
payment
.
creditCard
=
creditcard
# Setting billing information
billto
=
apicontractsv1
.
nameAndAddressType
()
billto
.
firstName
=
"John"
billto
.
lastName
=
"Smith"
# Setting subscription details
subscription
=
apicontractsv1
.
ARBSubscriptionType
()
subscription
.
name
=
"Sample Subscription"
subscription
.
paymentSchedule
=
paymentschedule
subscription
.
amount
=
amount
subscription
.
trialAmount
=
Decimal
(
'0.00'
)
subscription
.
billTo
=
billto
subscription
.
payment
=
payment
# Creating the request
request
=
apicontractsv1
.
ARBCreateSubscriptionRequest
()
request
.
merchantAuthentication
=
merchantAuth
request
.
subscription
=
subscription
# Creating and executing the controller
controller
=
ARBCreateSubscriptionController
(
request
)
controller
.
execute
()
# Getting the response
response
=
controller
.
getresponse
()
if
(
response
.
messages
.
resultCode
==
"Ok"
):
print
(
"SUCCESS:"
)
print
(
"Message Code : %s"
%
response
.
messages
.
message
[
0
][
'code'
].
text
)
print
(
"Message text : %s"
%
str
(
response
.
messages
.
message
[
0
][
'text'
].
text
))
print
(
"Subscription ID : %s"
%
response
.
subscriptionId
)
else
:
print
(
"ERROR:"
)
print
(
"Message Code : %s"
%
response
.
messages
.
message
[
0
][
'code'
].
text
)
print
(
"Message text : %s"
%
response
.
messages
.
message
[
0
][
'text'
].
text
)
return
response
if
(
os
.
path
.
basename
(
__file__
)
==
os
.
path
.
basename
(
sys
.
argv
[
0
])):
create_subscription
(
constants
.
amount
,
constants
.
days
)
Back
|
FazBrowse Home
|
New Git URL