Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sales Transaction confusion or bug #148

Open
Pondake opened this issue Jun 20, 2019 · 3 comments
Open

Sales Transaction confusion or bug #148

Pondake opened this issue Jun 20, 2019 · 3 comments

Comments

@Pondake
Copy link

Pondake commented Jun 20, 2019

$connection = new PhpTwinfield\Secure\WebservicesAuthentication($twin_username, $twin_password, $twin_env);

$transaction_factory = new PhpTwinfield\ApiConnectors\TransactionApiConnector($connection);

$invoices_2 = $transaction_factory->get(\PhpTwinfield\SalesTransaction::class, "SLS", "201800260", $office);

What am I doing wrong? I'm not even sure what transactionClassName to use. Documentation is very scarce. It only contains information about retrieving and setting customers (which works fine, btw).

@iranl
Copy link
Contributor

iranl commented Jun 27, 2019

Looks mostly ok.

Notes:
-Depending on your namespace you might need leading slashes in front of PhpTwinfield.
-Is $office an object of \PhpTwinfield\Office?
-Consider switching to OAuth 2 authentication as WebservicesAuthentication has been deprecated by Twinfield and will be removed in the future

Try:

$connection = new \PhpTwinfield\Secure\WebservicesAuthentication($twin_username, $twin_password, $twin_env);

$transaction_factory = new \PhpTwinfield\ApiConnectors\TransactionApiConnector($connection);

$office = \PhpTwinfield\Office::fromCode('Your office code');

$invoices_2 = $transaction_factory->get(\PhpTwinfield\SalesTransaction::class, "SLS", "201800260", $office);

I have written pretty extensive examples for almost all resources, but these (and the updated code they reference) is not part of the main repository (yet). And it so happens Transactions is the last remaining example I have not written yet. Might still give you some help: See here

@Pondake
Copy link
Author

Pondake commented Jul 1, 2019

Looks mostly ok.

Notes:
-Depending on your namespace you might need leading slashes in front of PhpTwinfield.
-Is $office an object of \PhpTwinfield\Office?
-Consider switching to OAuth 2 authentication as WebservicesAuthentication has been deprecated by Twinfield and will be removed in the future

Try:

$connection = new \PhpTwinfield\Secure\WebservicesAuthentication($twin_username, $twin_password, $twin_env);

$transaction_factory = new \PhpTwinfield\ApiConnectors\TransactionApiConnector($connection);

$office = \PhpTwinfield\Office::fromCode('Your office code');

$invoices_2 = $transaction_factory->get(\PhpTwinfield\SalesTransaction::class, "SLS", "201800260", $office);

I have written pretty extensive examples for almost all resources, but these (and the updated code they reference) is not part of the main repository (yet). And it so happens Transactions is the last remaining example I have not written yet. Might still give you some help: See here

$connection = new PhpTwinfield\Secure\WebservicesAuthentication($twin_username, $twin_password, $twin_env);
$office = PhpTwinfield\Office::fromCode('0985');
$invoice_factory = new PhpTwinfield\ApiConnectors\InvoiceApiConnector($connection);
$invoices_2 = $transaction_factory->get(PhpTwinfield\SalesTransaction::class, "SLS", "201800260", $office);

Gives:

Argument 1 passed to PhpTwinfield\Office::setCode() must be of the type string, null given, called in /home/siwontwi/domains/{{DOMAIN}}/public_html/wp-content/themes/{{DOMAIN}}/twinfield/php-twinfield/twinfield/src/Mappers/TransactionMapper.php on line 83

@niektenhoopen
Copy link
Contributor

@Pondake Not sure if you are still looking for a solution, was just browsing around. I would guess that you should use the TransactionApiConnector instead of the InvoiceApiConnector

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants