Error E00003 The element 'subscription' in namespace 'AnetApi/sml/v1/schema/AnetApiSchema.xsd' has invalid child element 'cusotmer' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'shipTo', profile' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.
Getting this error when trying to add an ARB subscription. We're not using profiles, but according to the API docs, "customer" should be a valid sub element of "subscription".
https://developer.authorize.net/api/reference/#recurring-billing-create-a-subscription
Full code:
<?php
...
public function create_subscription($transaction) {
global $custom_options;
if(isset($transaction) and $transaction instanceof Transaction) {
$usr = $transaction->user();
$prd = $transaction->product();
$sub = $transaction->subscription();
}
else {
throw new CustomGatewayException( 'Payment was unsuccessful, please check your payment details and try again.' );
}
$invoice = $this->create_new_order_invoice($sub);
// Default to 9999 for infinite occurrences
$total_occurrences = $sub->limit_cycles ? $sub->limit_cycles_num : 9999;
$args = array( "refId" => $invoice,
"subscription" => array(
"name" => $prd->post_title,
"paymentSchedule" => array(
"interval" => $this->arb_subscription_interval($sub),
"startDate" => Utils::get_date_from_ts((time() + (($sub->trial)?Utils::days($sub->trial_days):0)), 'Y-m-d'),
"totalOccurrences" => $total_occurrences,
),
"amount" => Utils::format_float($sub->total),
"payment" => array(
"creditCard" => array(
"cardNumber" => sanitize_text_field($_POST['custom_cc_num']),
"expirationDate" => sanitize_text_field($_POST['custom_cc_exp_month']) . '-' . sanitize_text_field($_POST['custom_cc_exp_year']),
"cardCode" => sanitize_text_field($_POST['custom_cvv_code'])
)
),
"order" => array(
"invoiceNumber" => $invoice,
"description" => $prd->post_title
),
"billTo" => array(
"firstName" => $usr->first_name,
"lastName" => $usr->last_name
),
"customer" => array(
"email" => $usr->user_email
)
)
);
if($custom_options->show_address_fields && $custom_options->require_address_fields) {
$args['subscription']['billTo'] =
array_merge($args['subscription']['billTo'],
array("address" => str_replace('&', '&', get_user_meta($usr->ID, 'custom-address-one', true)),
"city" => get_user_meta($usr->ID, 'custom-address-city', true),
"state" => get_user_meta($usr->ID, 'custom-address-state', true),
"zip" => get_user_meta($usr->ID, 'custom-address-zip', true),
"country" => get_user_meta($usr->ID, 'custom-address-country', true)));
}
$res = $this->send_arb_request('ARBCreateSubscriptionRequest', $args);
...
protected function send_arb_request($method, $args, $http_method = 'post') {
$args = array_merge(
array(
"merchantAuthentication" => array(
"name" => $this->settings->login_name,
"transactionKey" => $this->settings->transaction_key
)
),
$args
);
$content = $this->arb_array_to_xml($method, $args);
$remote_array = array('method' => strtoupper($http_method),
'timeout' => 30,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true,
'headers' => array('content-type' => 'application/xml'),
'body' => $content,
'cookies' => array());
$response = wp_remote_post('https://api2.authorize.net/xml/v1/request.api', $remote_array);
...
Is the (https://api2.authorize.net/xml/v1/request.api) endpoint the problem?
Thanks for any help!