Ошибка QuickBooks при добавлении клиента

7001: [сообщение = подписка для компании истекла или используется неверный целевой URL. Компания Sandbox работает с URL-адресом Sandbox, а компания Production — с URL-адресом Production .; ERRORCODE = 007001; statusCode = 400,]

Я получаю вышеуказанную ошибку при запуске следующего URL
Http: //localhost/quickbooks/docs/partner_platform/example_app_ipp_v3/example_customer_add.php

/**
* Intuit Partner Platform configuration variables
*
* See the scripts that use these variables for more details.
*
* @package QuickBooks
* @subpackage Documentation
*/

// Turn on some error reporting
error_reporting(E_ALL);
ini_set('display_errors', 1);

// Require the library code
require_once dirname(__FILE__) . '/../../../QuickBooks.php';

// Your OAuth token (Intuit will give you this when you register an Intuit Anywhere app)
$token = '95555248baf11b43fbb944ab97de9134ad85';

// Your OAuth consumer key and secret (Intuit will give you both of these when you register an Intuit app)
//
// IMPORTANT:
//  To pass your tech review with Intuit, you'll have to AES encrypt these and
//  store them somewhere safe.
//
// The OAuth request/access tokens will be encrypted and stored for you by the
//  PHP DevKit IntuitAnywhere classes automatically.
$oauth_consumer_key = 'qyprdfkqo3bikN2vLrLu4FWHv6GbQp';
$oauth_consumer_secret = 'WDH56afDb1jr0ismQZAwdPuq4oDqpTmrKXc0oORz';

// If you're using DEVELOPMENT TOKENS, you MUST USE SANDBOX MODE!!!  If you're in PRODUCTION, then DO NOT use sandbox.
$sandbox = true;     // When you're using development tokens
//$sandbox = false;    // When you're using production tokens

// This is the URL of your OAuth auth handler page
$quickbooks_oauth_url = 'http://localhost/quickbooks/docs/partner_platform/example_app_ipp_v3/oauth.php';

// This is the URL to forward the user to after they have connected to IPP/IDS via OAuth
$quickbooks_success_url = 'http://localhost/quickbooks/docs/partner_platform/example_app_ipp_v3/success.php';

// This is the menu URL script
$quickbooks_menu_url = 'http://localhost/quickbooks/docs/partner_platform/example_app_ipp_v3/menu.php';

// This is a database connection string that will be used to store the OAuth credentials
// $dsn = 'pgsql://username:password@hostname/database';
// $dsn = 'mysql://username:password@hostname/database';
$dsn = 'mysqli://root:@localhost/example_app_ipp_v3';
//$dsn = 'mysqli://forthera_demo:[email protected]/forthera_test';
// You should set this to an encryption key specific to your app
$encryption_key = 'bcde1234';

// Do not change this unless you really know what you're doing!!!  99% of apps will not require a change to this.
$the_username = 'DO_NOT_CHANGE_ME';

// The tenant that user is accessing within your own app
$the_tenant = 12345;

// Initialize the database tables for storing OAuth information
if (!QuickBooks_Utilities::initialized($dsn))
{
// Initialize creates the neccessary database schema for queueing up requests and logging
QuickBooks_Utilities::initialize($dsn);
}

// Instantiate our Intuit Anywhere auth handler
//
// The parameters passed to the constructor are:
//  $dsn
//  $oauth_consumer_key     Intuit will give this to you when you create a new Intuit Anywhere application at AppCenter.Intuit.com
//  $oauth_consumer_secret  Intuit will give this to you too
//  $this_url               This is the full URL (e.g. http://path/to/this/file.php) of THIS SCRIPT
//  $that_url               After the user authenticates, they will be forwarded to this URL
//
$IntuitAnywhere = new QuickBooks_IPP_IntuitAnywhere($dsn, $encryption_key, $oauth_consumer_key, $oauth_consumer_secret, $quickbooks_oauth_url, $quickbooks_success_url);

// Are they connected to QuickBooks right now?
if ($IntuitAnywhere->check($the_username, $the_tenant) and
$IntuitAnywhere->test($the_username, $the_tenant))
{
// Yes, they are
$quickbooks_is_connected = true;

// Set up the IPP instance
$IPP = new QuickBooks_IPP($dsn);

// Get our OAuth credentials from the database
$creds = $IntuitAnywhere->load($the_username, $the_tenant);

// Tell the framework to load some data from the OAuth store
$IPP->authMode(
QuickBooks_IPP::AUTHMODE_OAUTH,
$the_username,
$creds);

if ($sandbox)
{
// Turn on sandbox mode/URLs
$IPP->sandbox(true);
}

// Print the credentials we're using
//print_r($creds);

// This is our current realm
$realm = $creds['qb_realm'];

// Load the OAuth information from the database
$Context = $IPP->context();

// Get some company info
$CompanyInfoService = new QuickBooks_IPP_Service_CompanyInfo();
$quickbooks_CompanyInfo = $CompanyInfoService->get($Context, $realm);
}
else
{
// No, they are not
$quickbooks_is_connected = false;
}

Это мой файл config.php, где я изменил свой токен и секретные ключи.

мой файл example_customer_add.php

<?php

require_once dirname(__FILE__) . '/config.php';

require_once dirname(__FILE__) . '/views/header.tpl.php';

?>

<pre>

<?php

// Set up the IPP instance
$IPP = new QuickBooks_IPP($dsn);

// Get our OAuth credentials from the database
$creds = $IntuitAnywhere->load($the_username, $the_tenant);
// Tell the framework to load some data from the OAuth store
$IPP->authMode(
QuickBooks_IPP::AUTHMODE_OAUTH,
$the_username,
$creds);

// Print the credentials we're using
//print_r($creds);

// This is our current realm
$realm = $creds['qb_realm'];
// Load the OAuth information from the database
if ($Context = $IPP->context())
{
// print_r($Context);
$IPP->version(QuickBooks_IPP_IDS::VERSION_3);

$CustomerService = new QuickBooks_IPP_Service_Customer();
print($CustomerService->lastRequest($Context));
print($CustomerService->lastResponse($Context));exit;
$Customer = new QuickBooks_IPP_Object_Customer();
$Customer->setTitle('Ms');
$Customer->setGivenName('Sandeep');
$Customer->setMiddleName('D');
$Customer->setFamilyName('Reddy');
$Customer->setDisplayName('Sandeep D Reddy' . mt_rand(0, 1000));
// Terms (e.g. Net 30, etc.)
$Customer->setSalesTermRef(4);

// Phone #
$PrimaryPhone = new QuickBooks_IPP_Object_PrimaryPhone();
$PrimaryPhone->setFreeFormNumber('860-532-0089');
$Customer->setPrimaryPhone($PrimaryPhone);

// Mobile #
$Mobile = new QuickBooks_IPP_Object_Mobile();
$Mobile->setFreeFormNumber('860-532-0089');
$Customer->setMobile($Mobile);

// Fax #
$Fax = new QuickBooks_IPP_Object_Fax();
$Fax->setFreeFormNumber('860-532-0089');
$Customer->setFax($Fax);

// Bill address
$BillAddr = new QuickBooks_IPP_Object_BillAddr();
$BillAddr->setLine1('72 E Blue Grass Road');
$BillAddr->setLine2('Suite D');
$BillAddr->setCity('Mt Pleasant');
$BillAddr->setCountrySubDivisionCode('MI');
$BillAddr->setPostalCode('48858');
$Customer->setBillAddr($BillAddr);

// Email
$PrimaryEmailAddr = new QuickBooks_IPP_Object_PrimaryEmailAddr();
$PrimaryEmailAddr->setAddress('[email protected]');
$Customer->setPrimaryEmailAddr($PrimaryEmailAddr);

if ($resp = $CustomerService->add($Context, $realm, $Customer))
{
print('Our new customer ID is: [' . $resp . '] (name "' . $Customer->getDisplayName() . '")');
}
else
{
print($CustomerService->lastError($Context));
}

/*
print('<br><br><br><br>');
print("\n\n\n\n\n\n\n\n");
print('Request [' . $IPP->lastRequest() . ']');
print("\n\n\n\n");
print('Response [' . $IPP->lastResponse() . ']');
print("\n\n\n\n\n\n\n\n\n");
*/
}
else
{
die('Unable to load a context...?');
}?>

</pre>

<?php

require_once dirname(__FILE__) . '/views/footer.tpl.php';

пока я пытался print_r ($ Context), я получил следующий вывод.

QuickBooks_IPP Object
(
[_test:protected] =>
[_key:protected] =>
[_username:protected] =>
[_password:protected] =>
[_ticket:protected] =>
[_token:protected] =>
[_dbid:protected] =>
[_flavor:protected] =>
[_baseurl:protected] =>
[_sandbox:protected] =>
[_authmode:protected] => oauth
[_authuser:protected] => DO_NOT_CHANGE_ME
[_authcred:protected] => Array
(
[quickbooks_oauth_id] => 1
[app_username] => DO_NOT_CHANGE_ME
[app_tenant] => 12345
[oauth_request_token] => qyprdWOXU3PLf73TRCi9HijjtCcNJSI4TUukCeOc0vlHJ01k
[oauth_request_token_secret] => R46vV6bolaZ13p6xcpsXS5eCVdRk77MNbPYLI3xB
[oauth_access_token] => qyprdkY9wV2nKB8CsITcV2r0A69dMmHtyHM56260NM9vh7Jx
[oauth_access_token_secret] => i7NldF676khb8YWK31WjsJRbQagT4AH0f7EXFqpR
[qb_realm] => 396652311
[qb_flavor] => QBO
[qb_user] =>
[request_datetime] => 2015-03-12 13:20:42
[access_datetime] => 2015-03-12 13:21:24
[touch_datetime] => 2015-03-13 05:51:55
[oauth_consumer_key] => qyprdOMSkgvrLqR3PmV3yXMWsufQaB
[oauth_consumer_secret] => SoVpK5TGyFE0vVG3FtHFibUTiUuLwYTn64X2LfJg
)

[_authsign:protected] =>
[_authkey:protected] =>
[_debug:protected] =>
[_last_request:protected] =>
[_last_response:protected] =>
[_last_debug:protected] => Array
(
)

[_masking:protected] => 1
[_driver:protected] => QuickBooks_Driver_SQL_Mysqli Object
(
[_conn:protected] => mysqli Object
(
[affected_rows] => 1
[client_info] => mysqlnd 5.0.11-dev - 20120503 - $Id: bf9ad53b11c9a57efdb1057292d73b928b8c5c77 $
[client_version] => 50011
[connect_errno] => 0
[connect_error] =>
[errno] => 0
[error] =>
[error_list] => Array
(
)

[field_count] => 0
[host_info] => localhost via TCP/IP
[info] => Rows matched: 1  Changed: 1  Warnings: 0
[insert_id] => 0
[server_info] => 5.6.16
[server_version] => 50616
[stat] => Uptime: 1402  Threads: 3  Questions: 53  Slow queries: 0  Opens: 71  Flush tables: 1  Open tables: 64  Queries per second avg: 0.037
[sqlstate] => 00000
[protocol_version] => 10
[thread_id] => 7
[warning_count] => 0
)

[_res:protected] =>
[_log_level:protected] => 1
[_last_error] =>
[_hooks:protected] => Array
(
)

[_dbname:protected] => /example_app_ipp_v3
[_max_log_history:protected] => -1
[_max_queue_history:protected] => -1
[_max_ticket_history:protected] => -1
[_loglevel:protected] => 1
)

[_certificate:protected] =>
[_errcode:protected] => 0
[_errtext:protected] =>
[_errdetail:protected] =>
[_cookies:protected] => Array
(
)

[_ids_parser:protected] => 1
[_ids_version:protected] => v3
)
7001: [message=Subscription for company has lapsed or Invalid destination URL is used. Sandbox company works with Sandbox URL and Production company works with Production URL.; errorCode=007001; statusCode=400, ]

-1

Решение

Что означает ошибка:

Обычно вы получаете эту ошибку, если отправляете данные в действующую компанию из приложения для разработки или в компанию-песочницу из действующего приложения.

Используете ли вы токены разработки? Если это так, убедитесь, что вы отправляете данные по URL-адресу разработки / песочницы (https://sandbox-quickbooks.api.intuit.com/v3 для dev / sandbox vs https://quickbooks.api.intuit.com/v3 для жизни)

Если вы используете этот код:

Затем вы можете заставить библиотеку использовать URL песочницы, установив это:

$IPP->sandbox(true);

Дальнейшее устранение неисправностей:

Если после этого у вас по-прежнему будут проблемы, вам нужно будет опубликовать отладочную информацию, чтобы мы могли помочь вам в дальнейшем.

Для этого позвоните ->lastRequest() а также ->lastResponse() методы в вашем экземпляре Service, поэтому получите необработанный XML, отправленный в QuickBooks, и необработанный XML, полученный вами из QuickBooks. например.:

print($CustomerService->lastRequest($Context));
print($CustomerService->lastResponse($Context));

Отправьте это здесь (или на форумах поддержки для этой библиотеки: http://www.consolibyte.com/forum/) и мы можем помочь вам в дальнейшем.

1

Другие решения

Я скачал последнюю версию с https://github.com/consolibyte/quickbooks-php и это работает нормально для меня сейчас.

Отдельное спасибо Китаю Палмеру-Консолибайте за его большие усилия.

0

По вопросам рекламы [email protected]