Why am I getting this error trying to write credit cards into sales orders?

I am following the example in Knowledgebase article 85796 regarding how to add cards to an existing order. I just want to capture the card information as a zero dollar deposit.

SalesOrderNo = "W123456"

PaymentType = "MC/V"

ccNo = "4111111111111111"

ExpirationDateYear = "2022"

ExpirationDateMonth = "06"

TransactionAmt = 0

r = o.nSetKeyValue("SalesOrderNo$", SalesOrderNo)
r = o.nSetKey()

r = o.oPaymentObj.nAddDeposit()

r = o.oPaymentObj.nAddNewCreditCard(PaymentType,CCNo,ExpirationDateYear,ExpirationDateMonth)

r = o.oPaymentObj.nSetValue("SaveCreditCard$", "Y")

r = o.oPaymentObj.nSetValue("TransactionAmt", TransactionAmt)

r = o.oPaymentObj.nWrite()

r = o.nWrite()

My return value from the nAddDeposit function is 2. However I get an error message "The  is invalid" and the cards are not writing. (There are two spaces in between the word "The" and the word "is". I'm not sure why this is happening.