cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

ARB Customer Cancellation error subscriptionId not valid data type

First time trying this and I an using the old version 1 code (AuthnetARB.class.php) - customer doesn't want to pay to update all the code to the new objects right now so I'm stuck

 

Anyway, I am doing this:

 

require_once($_SERVER["DOCUMENT_ROOT"] . '/functions/AuthnetARB.class.php');

$arb = new AuthnetARB();
$arb->setParameter('subscriptionId', $row['subscription_id']);

$arb->deleteAccount();

 

I have verified the data coming out of the databse and that it's being set to the object, here a print_r of the object right after setting the subscription id:

 

AuthnetARB Object ( [test:private] => [params:private] => Array ( [interval_length] => 1 [interval_unit] => months [startDate] => 2013-04-19 [totalOccurrences] => 9999 [trialOccurrences] => 0 [trialAmount] => 0 [subscriptionId] => 16265474 ) [sucess:private] => [error:private] => 1 [xml:private] => [response:private] => [resultCode:private] => [code:private] => [text:private] => [subscrId:private] => [url] => https://api.authorize.net/xml/v1/request.api )

 

You can see the subscriptionId is set (and it is the correct number for the test account)

 

I am getting an error back from Authnet: 

The 'AnetApi/xml/v1/schema/AnetApiSchema.xsd:subscriptionId' element is invalid - The value '' is invalid according to its datatype 'AnetApi/xml/v1/schema/AnetApiSchema.xsd:numericString' - The Pattern constraint failed.

I dug around google for over an hour and everything I find says the data is missing, which in this case it isn't

 

Any ideas? I'm stumped

 

thanks!

dcdalton
Contributor
4 REPLIES 4

Since it is php, could you see what the deleteAccount() is doing?

RaynorC1emen7
Expert

Sure can! written by the master himself:

 

 

public function deleteAccount()
{
$this->xml = "<?xml version='1.0' encoding='utf-8'?>
<ARBCancelSubscriptionRequest xmlns='AnetApi/xml/v1/schema/AnetApiSchema.xsd'>
<merchantAuthentication>
<name>" . self::LOGIN . "</name>
<transactionKey>" . self::TRANSKEY . "</transactionKey>
</merchantAuthentication>
<refId>" . $this->params['refID'] ."</refId>
<subscriptionId>" . $this->params['subscrId'] . "</subscriptionId>
</ARBCancelSubscriptionRequest>";
$this->process();
}

private function parseResults()
{
$this->resultCode = $this->parseXML('<resultCode>', '</resultCode>');
$this->code = $this->parseXML('<code>', '</code>');
$this->text = $this->parseXML('<text>', '</text>');
$this->subscrId = $this->parseXML('<subscriptionId>', '</subscriptionId>');
}

private function ParseXML($start, $end)
{
return preg_replace('|^.*?'.$start.'(.*?)'.$end.'.*?$|i', '$1', substr($this->response, 335));
}

public function setParameter($field = "", $value = null)
{
$field = (is_string($field)) ? trim($field) : $field;
$value = (is_string($value)) ? trim($value) : $value;
if (!is_string($field))
{
throw new AuthnetARBException("setParameter() arg 1 must be a string or integer: " . gettype($field) . " given.");
}
if (!is_string($value) && !is_numeric($value) && !is_bool($value))
{
throw new AuthnetARBException("setParameter() arg 2 must be a string, integer, or boolean value: " . gettype($value) . " given.");
}
if (empty($field))
{
throw new AuthnetARBException("setParameter() requires a parameter field to be named.");
}
if ($value === "")
{
throw new AuthnetARBException("setParameter() requires a parameter value to be assigned: $field");
}
$this->params[$field] = $value;
}

I think that the reason

 

public function deleteAccount()
{
$this->xml = "<?xml version='1.0' encoding='utf-8'?>
<ARBCancelSubscriptionRequest xmlns='AnetApi/xml/v1/schema/AnetApiSchema.xsd'>
<merchantAuthentication>
<name>" . self::LOGIN . "</name>
<transactionKey>" . self::TRANSKEY . "</transactionKey>
</merchantAuthentication>
<refId>" . $this->params['refID'] ."</refId>
<subscriptionId>" . $this->params['subscrId'] . "</subscriptionId>
</ARBCancelSubscriptionRequest>";
$this->process();
}

interesting, I hadn't noticed that and I got the code to call it from John's site.

 

Will give that a shot