Skip to content

Commit a0983d4

Browse files
author
zhaque
committed
Added sample code - RecurringBilling/create-subscription
1 parent 7e00de2 commit a0983d4

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
from authorizenet import apicontractsv1
2+
from authorizenet.apicontrollers import *
3+
from decimal import *
4+
from datetime import *
5+
# Setting the merchant details
6+
merchantAuth = apicontractsv1.merchantAuthenticationType()
7+
merchantAuth.name = '5KP3u95bQpv'
8+
merchantAuth.transactionKey = '4Ktq966gC55GAX7S'
9+
# Setting payment schedule
10+
paymentschedule = apicontractsv1.paymentScheduleType()
11+
paymentschedule.interval = apicontractsv1.CTD_ANON()
12+
paymentschedule.interval.length = 1
13+
paymentschedule.interval.unit = apicontractsv1.ARBSubscriptionUnitEnum.months
14+
paymentschedule.startDate = datetime(2020, 8, 30)
15+
paymentschedule.totalOccurrences = 12
16+
paymentschedule.trialOccurrences = 1
17+
# Giving the credit card info
18+
creditcard = apicontractsv1.creditCardType()
19+
creditcard.cardNumber = "4111111111111111"
20+
creditcard.expirationDate = "2020-12"
21+
payment = apicontractsv1.paymentType()
22+
payment.creditCard = creditcard
23+
# Setting billing information
24+
billto = apicontractsv1.nameAndAddressType()
25+
billto.firstName = "John"
26+
billto.lastName = "Smith"
27+
# Setting subscription details
28+
subscription = apicontractsv1.ARBSubscriptionType()
29+
subscription.name = "Sample Subscription"
30+
subscription.paymentSchedule = paymentschedule
31+
subscription.amount = Decimal('22.29')
32+
subscription.trialAmount = Decimal('0.00')
33+
subscription.billTo = billto
34+
subscription.payment = payment
35+
# Creating the request
36+
request = apicontractsv1.ARBCreateSubscriptionRequest()
37+
request.merchantAuthentication = merchantAuth
38+
request.subscription = subscription
39+
# Creating and executing the controller
40+
controller = ARBCreateSubscriptionController(request)
41+
controller.execute()
42+
# Getting the response
43+
response = controller.getresponse()
44+
45+
if (response.messages.resultCode=="Ok"):
46+
print "SUCCESS:"
47+
print "Message Code : %s" % response.messages.message[0].code
48+
print "Message text : %s" % response.messages.message[0].text
49+
print "Subscription ID : %s" % response.subscriptionId
50+
else:
51+
print "ERROR:"
52+
print "Message Code : %s" % response.messages.message[0].code
53+
print "Message text : %s" % response.messages.message[0].text
54+
55+
56+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy