Hi,
I have been having a very difficult time connecting to "Cybersource" - a
large Credit Card processor.
Their WSDL and XSD seems in order but there are 2 issues:
1. If I create objects without specifying "ns0:" then the create cannot
resolve the objects.
2. If I do specify the "ns0:" then the XML that cybersource digests is
considered invalid - yes I know they should fix that but the main
problem is that SUDS is not using the targetNamespace that is provided.
I messed around with ImportDoctor until I was blue in the face. About
the only thing I could get it to do was do a recursive fetch :)
Take a gander at:
https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/
I am stumped. I think it would work if I could tell something to either
ignore new namespaces or make it be a subset and not create a new
namespace.
Thanks!
Here is the ouput of the print of the client:
---------------
Suds (
https://fedorahosted.org/suds/ ) version: 0.4 GA build:
R699-20100913
Service ( TransactionProcessor )
tns="urn:schemas-cybersource-com:transaction-data:TransactionProcessor"
Prefixes (1)
ns0 = "urn:schemas-cybersource-com:transaction-data-1.60"
Ports (1):
(portXML)
Methods (1):
runTransaction(xs:string merchantID, xs:string
merchantReferenceCode, ns0:boolean debtIndicator, xs:string
clientLibrary, xs:string clientLibraryVersion, xs:string
clientEnvironment, xs:string clientSecurityLibraryVersion, xs:string
clientApplication, xs:string clientApplicationVersion, xs:string
clientApplicationUser, xs:string routingCode, xs:string comments,
xs:string returnURL, ns0:InvoiceHeader invoiceHeader, ns0:BillTo billTo,
ns0:ShipTo shipTo, ns0:ShipFrom shipFrom, ns0:Item[] item,
ns0:PurchaseTotals purchaseTotals, ns0:FundingTotals fundingTotals,
ns0:DCC dcc, ns0:Pos pos, ns0:Installment installment, ns0:Card card,
ns0:Check check, ns0:BML bml, ns0:GECC gecc, ns0:UCAF ucaf,
ns0:FundTransfer fundTransfer, ns0:BankInfo bankInfo, ns0:Subscription
subscription, ns0:RecurringSubscriptionInfo recurringSubscriptionInfo,
ns0:DecisionManager decisionManager, ns0:OtherTax otherTax, ns0:PayPal
paypal, ns0:MerchantDefinedData merchantDefinedData,
ns0:MerchantSecureData merchantSecureData, ns0:JPO jpo, xs:string
orderRequestToken, xs:string linkToRequest, ns0:CCAuthService
ccAuthService, ns0:CCCaptureService ccCaptureService,
ns0:CCCreditService ccCreditService, ns0:CCAuthReversalService
ccAuthReversalService, ns0:CCAutoAuthReversalService
ccAutoAuthReversalService, ns0:CCDCCService ccDCCService,
ns0:ECDebitService ecDebitService, ns0:ECCreditService ecCreditService,
ns0:ECAuthenticateService ecAuthenticateService,
ns0:PayerAuthEnrollService payerAuthEnrollService,
ns0:PayerAuthValidateService payerAuthValidateService, ns0:TaxService
taxService, ns0:AFSService afsService, ns0:DAVService davService,
ns0:ExportService exportService, ns0:FXRatesService fxRatesService,
ns0:BankTransferService bankTransferService,
ns0:BankTransferRefundService bankTransferRefundService,
ns0:BankTransferRealTimeService bankTransferRealTimeService,
ns0:DirectDebitMandateService directDebitMandateService,
ns0:DirectDebitService directDebitService, ns0:DirectDebitRefundService
directDebitRefundService, ns0:DirectDebitValidateService
directDebitValidateService, ns0:PaySubscriptionCreateService
paySubscriptionCreateService, ns0:PaySubscriptionUpdateService
paySubscriptionUpdateService, ns0:PaySubscriptionEventUpdateService
paySubscriptionEventUpdateService, ns0:PaySubscriptionRetrieveService
paySubscriptionRetrieveService, ns0:PaySubscriptionDeleteService
paySubscriptionDeleteService, ns0:PayPalPaymentService
payPalPaymentService, ns0:PayPalCreditService payPalCreditService,
ns0:VoidService voidService, ns0:BusinessRules businessRules,
ns0:PinlessDebitService pinlessDebitService,
ns0:PinlessDebitValidateService pinlessDebitValidateService,
ns0:PinlessDebitReversalService pinlessDebitReversalService, ns0:Batch
batch, ns0:AirlineData airlineData, ns0:PayPalButtonCreateService
payPalButtonCreateService, ns0:PayPalPreapprovedPaymentService
payPalPreapprovedPaymentService, ns0:PayPalPreapprovedUpdateService
payPalPreapprovedUpdateService, ns0:RiskUpdateService riskUpdateService,
ns0:FraudUpdateService fraudUpdateService, ns0:RequestReserved[]
reserved, xs:string deviceFingerprintID, ns0:PayPalRefundService
payPalRefundService, ns0:PayPalAuthReversalService
payPalAuthReversalService, ns0:PayPalDoCaptureService
payPalDoCaptureService, ns0:PayPalEcDoPaymentService
payPalEcDoPaymentService, ns0:PayPalEcGetDetailsService
payPalEcGetDetailsService, ns0:PayPalEcSetService payPalEcSetService,
ns0:PayPalEcOrderSetupService payPalEcOrderSetupService,
ns0:PayPalAuthorizationService payPalAuthorizationService,
ns0:PayPalUpdateAgreementService payPalUpdateAgreementService,
ns0:PayPalCreateAgreementService payPalCreateAgreementService,
ns0:PayPalDoRefTransactionService payPalDoRefTransactionService,
ns0:ChinaPaymentService chinaPaymentService, ns0:ChinaRefundService
chinaRefundService, ns0:BoletoPaymentService boletoPaymentService,
ns0:boolean ignoreCardExpiration, xs:string reportGroup, )
Types (155):
ns0:AFSReply
ns0:AFSService
ns0:Address
ns0:AirlineData
ns0:BML
ns0:BankInfo
ns0:BankTransferRealTimeReply
ns0:BankTransferRealTimeService
ns0:BankTransferRefundReply
ns0:BankTransferRefundService
ns0:BankTransferReply
ns0:BankTransferService
ns0:Batch
ns0:BillTo
ns0:BoletoPaymentReply
ns0:BoletoPaymentService
ns0:BusinessRules
ns0:CCAuthReply
ns0:CCAuthReversalReply
ns0:CCAuthReversalService
ns0:CCAuthService
ns0:CCAutoAuthReversalReply
ns0:CCAutoAuthReversalService
ns0:CCCaptureReply
ns0:CCCaptureService
ns0:CCCreditReply
ns0:CCCreditService
ns0:CCDCCReply
ns0:CCDCCService
ns0:Card
ns0:Check
ns0:ChinaPaymentReply
ns0:ChinaPaymentService
ns0:ChinaRefundReply
ns0:ChinaRefundService
ns0:DAVReply
ns0:DAVService
ns0:DCC
ns0:DecisionManager
ns0:DecisionManagerTravelData
ns0:DecisionManagerTravelLeg
ns0:DecisionReply
ns0:DeniedPartiesMatch
ns0:DeviceFingerprint
ns0:DirectDebitMandateReply
ns0:DirectDebitMandateService
ns0:DirectDebitRefundReply
ns0:DirectDebitRefundService
ns0:DirectDebitReply
ns0:DirectDebitService
ns0:DirectDebitValidateReply
ns0:DirectDebitValidateService
ns0:ECAuthenticateReply
ns0:ECAuthenticateService
ns0:ECCreditReply
ns0:ECCreditService
ns0:ECDebitReply
ns0:ECDebitService
ns0:ExportReply
ns0:ExportService
ns0:FXQuote
ns0:FXRatesReply
ns0:FXRatesService
ns0:FaultDetails
ns0:FraudUpdateReply
ns0:FraudUpdateService
ns0:FundTransfer
ns0:FundingTotals
ns0:GECC
ns0:Installment
ns0:InvoiceHeader
ns0:Item
ns0:JPO
ns0:Leg
ns0:MerchantDefinedData
ns0:MerchantSecureData
ns0:OtherTax
ns0:PayPal
ns0:PayPalAuthReversalReply
ns0:PayPalAuthReversalService
ns0:PayPalAuthorizationReply
ns0:PayPalAuthorizationService
ns0:PayPalButtonCreateReply
ns0:PayPalButtonCreateService
ns0:PayPalCreateAgreementReply
ns0:PayPalCreateAgreementService
ns0:PayPalCreditReply
ns0:PayPalCreditService
ns0:PayPalDoCaptureReply
ns0:PayPalDoCaptureService
ns0:PayPalDoRefTransactionReply
ns0:PayPalDoRefTransactionService
ns0:PayPalEcDoPaymentReply
ns0:PayPalEcDoPaymentService
ns0:PayPalEcGetDetailsReply
ns0:PayPalEcGetDetailsService
ns0:PayPalEcOrderSetupReply
ns0:PayPalEcOrderSetupService
ns0:PayPalEcSetReply
ns0:PayPalEcSetService
ns0:PayPalPaymentReply
ns0:PayPalPaymentService
ns0:PayPalPreapprovedPaymentReply
ns0:PayPalPreapprovedPaymentService
ns0:PayPalPreapprovedUpdateReply
ns0:PayPalPreapprovedUpdateService
ns0:PayPalRefundReply
ns0:PayPalRefundService
ns0:PayPalUpdateAgreementReply
ns0:PayPalUpdateAgreementService
ns0:PaySubscriptionCreateReply
ns0:PaySubscriptionCreateService
ns0:PaySubscriptionDeleteReply
ns0:PaySubscriptionDeleteService
ns0:PaySubscriptionEvent
ns0:PaySubscriptionEventUpdateReply
ns0:PaySubscriptionEventUpdateService
ns0:PaySubscriptionRetrieveReply
ns0:PaySubscriptionRetrieveService
ns0:PaySubscriptionUpdateReply
ns0:PaySubscriptionUpdateService
ns0:PayerAuthEnrollReply
ns0:PayerAuthEnrollService
ns0:PayerAuthValidateReply
ns0:PayerAuthValidateService
ns0:PinlessDebitReply
ns0:PinlessDebitReversalReply
ns0:PinlessDebitReversalService
ns0:PinlessDebitService
ns0:PinlessDebitValidateReply
ns0:PinlessDebitValidateService
ns0:Pos
ns0:ProfileReply
ns0:PurchaseTotals
ns0:RecurringSubscriptionInfo
ns0:ReplyMessage
ns0:ReplyReserved
ns0:RequestMessage
ns0:RequestReserved
ns0:RiskUpdateReply
ns0:RiskUpdateService
ns0:RuleResultItem
ns0:RuleResultItems
ns0:ShipFrom
ns0:ShipTo
ns0:Subscription
ns0:TaxReply
ns0:TaxReplyItem
ns0:TaxService
ns0:UCAF
ns0:VoidReply
ns0:VoidService
ns0:amount
ns0:boolean
ns0:dateTime
--------------- And here is the test code:
from suds.client import Client
from suds.wsse import UsernameToken, Security
from suds.xsd.doctor import ImportDoctor, Import, TnsFilter
import logging
logging.basicConfig(level=logging.INFO)
def take_payment():
logger = logging.getLogger(__name__)
url =
'https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.60.wsdl'
CYBERSOURCE_ACCOUNT = 'asdfasdfasdf'
CYBERSOURCE_KEY = 'asdfasdfasdfasdf'
token = UsernameToken(CYBERSOURCE_ACCOUNT, CYBERSOURCE_KEY)
security = Security()
client = Client(url)
security.tokens.append(token)
client.set_options(wsse = security)
logger.info("Sending command to Cybersource")
request = client.factory.create('RequestMessage')
request.merchantID = CYBERSOURCE_ACCOUNT
request.merchantReferenceCode = "your_merchant_reference_code"
request.clientLibrary = "SUDS"
request.clientLibraryVersion = '1.0'
request.clientEnvironment = 'Dev'
ccAuthService = client.factory.create('CCAuthService')
ccAuthService._run = "true"
request.ccAuthService = ccAuthService
billTo = client.factory.create('BillTo')
billTo.firstName = "John"
billTo.lastName = "Doe"
billTo.street1 = "1295 Charleston Road"
billTo.city = "Mountain View"
billTo.state = "CA"
billTo.postalCode = "94043"
billTo.country = "US"
billTo.email = "null(a)cybersource.com"
billTo.ipAddress = "10.7.111.111"
request.billTo = billTo
card = client.factory.create('Card')
card.accountNumber = "4111111111111111"
card.expirationMonth = "12"
card.expirationYear = "2020"
request.card = card
purchaseTotals = client.factory.create('PurchaseTotals')
purchaseTotals.currency = "USD"
request.purchaseTotals = purchaseTotals
item0 = client.factory.create('Item')
item0.unitPrice = "12.34"
item0.quantity = "2"
item1 = client.factory.create('Item')
item1.unitPrice = "12.34"
request.item = [item0, item1]
x = client.service.runTransaction(request)
return x
print take_payment()