Initial import: Carteasy Shop (Dev-Stand)
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
require_once '../Klarna.php';
|
||||
|
||||
// Dependencies from http://phpxmlrpc.sourceforge.net/
|
||||
require_once dirname(dirname(__FILE__)) .
|
||||
'/transport/xmlrpc-3.0.0.beta/lib/xmlrpc.inc';
|
||||
require_once dirname(dirname(__FILE__)) .
|
||||
'/transport/xmlrpc-3.0.0.beta/lib/xmlrpc_wrappers.inc';
|
||||
|
||||
/**
|
||||
* 1. Initialize and setup the Klarna instance.
|
||||
*/
|
||||
|
||||
$k = new Klarna();
|
||||
|
||||
$k->config(
|
||||
123456, // Merchant ID
|
||||
'sharedSecret', // Shared Secret
|
||||
KlarnaCountry::SE, // Country
|
||||
KlarnaLanguage::SV, // Language
|
||||
KlarnaCurrency::SEK, // Currency
|
||||
Klarna::BETA, // Server
|
||||
'json', // PClass Storage
|
||||
'/srv/pclasses.json', // PClass Storage URI path
|
||||
true, // SSL
|
||||
true // Remote logging of response times of xmlrpc calls
|
||||
);
|
||||
|
||||
// OR you can set the config to loads from a file, for example /srv/klarna.json:
|
||||
// $k->setConfig(new KlarnaConfig('/srv/klarna.json'));
|
||||
|
||||
/**
|
||||
* 2. Update goods quantity.
|
||||
*/
|
||||
|
||||
// Here you enter the invoice number you got from addTransaction():
|
||||
$invNo = '123456';
|
||||
|
||||
try {
|
||||
$result = $k->updateGoodsQty(
|
||||
$invNo, // Invoice number
|
||||
'MG200MMS', // ArtNo must be the same as the one you used in
|
||||
// addArticle() when you made the addTransaction() call.
|
||||
2 // New Quantity
|
||||
);
|
||||
|
||||
echo "Result: {$result}\n";
|
||||
/* Article quantity updated successfully, proceed accordingly.
|
||||
$result contains the same invoice number.
|
||||
*/
|
||||
} catch(Exception $e) {
|
||||
// Something went wrong, print the message:
|
||||
echo "{$e->getMessage()} (#{$e->getCode()})\n";
|
||||
}
|
||||
Reference in New Issue
Block a user