28 set_include_path(
$_SERVER[
'DOCUMENT_ROOT'].
'/htdocs');
30 require
'../master.inc.php';
31 require_once NUSOAP_PATH.
'/nusoap.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ws.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
40 dol_syslog(
"Call Dolibarr webservices interfaces");
45 if (empty($conf->global->MAIN_MODULE_WEBSERVICES))
47 $langs->load(
"admin");
49 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
50 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
51 print $langs->trans(
"ToActivateModule");
56 $server =
new nusoap_server();
57 $server->soap_defencoding =
'UTF-8';
58 $server->decode_utf8 =
false;
59 $ns =
'http://www.dolibarr.org/ns/';
60 $server->configureWSDL(
'WebServicesDolibarrPayment', $ns);
61 $server->wsdl->schemaTargetNamespace = $ns;
65 $server->wsdl->addComplexType(
72 'dolibarrkey' => array(
'name'=>
'dolibarrkey',
'type'=>
'xsd:string'),
73 'sourceapplication' => array(
'name'=>
'sourceapplication',
'type'=>
'xsd:string'),
74 'login' => array(
'name'=>
'login',
'type'=>
'xsd:string'),
75 'password' => array(
'name'=>
'password',
'type'=>
'xsd:string'),
76 'entity' => array(
'name'=>
'entity',
'type'=>
'xsd:string')
80 $server->wsdl->addComplexType(
87 'result_code' => array(
'name'=>
'result_code',
'type'=>
'xsd:string'),
88 'result_label' => array(
'name'=>
'result_label',
'type'=>
'xsd:string'),
93 $server->wsdl->addComplexType(
100 'amount' => array(
'name'=>
'amount',
'type'=>
'xsd:double'),
101 'num_payment' => array(
'name'=>
'num_payment',
'type'=>
'xsd:string'),
102 'thirdparty_id' => array(
'name'=>
'thirdparty_id',
'type'=>
'xsd:int'),
103 'bank_account' => array(
'name'=>
'bank_account',
'type'=>
'xsd:int'),
104 'payment_mode_id' => array(
'name'=>
'payment_mode_id',
'type'=>
'xsd:int'),
105 'invoice_id' => array(
'name'=>
'invoice_id',
'type'=>
'xsd:int'),
106 'int_label' => array(
'name'=>
'int_label',
'type'=>
'xsd:string'),
107 'emitter' => array(
'name'=>
'emitter',
'type'=>
'xsd:string'),
108 'bank_source' => array(
'name'=>
'bank_source',
'type'=>
'xsd:string'),
116 $styleuse =
'encoded';
123 array(
'authentication'=>
'tns:authentication',
'payment'=>
'tns:payment'),
125 array(
'result'=>
'tns:result',
'id'=>
'xsd:string',
'ref'=>
'xsd:string',
'ref_ext'=>
'xsd:string'),
127 $ns.
'#createPayment',
130 'WS to create a new payment'
147 dol_syslog(
"Function: createPayment login=".$authentication[
'login'].
" id=".$payment->id.
148 ", ref=".$payment->ref.
", ref_ext=".$payment->ref_ext);
150 if ($authentication[
'entity']) $conf->entity = $authentication[
'entity'];
153 $objectresp = array();
160 if (empty($payment[
'amount']) && empty($payment[
'thirdparty_id'])) {
163 $errorlabel =
"You must specify the amount and the third party's ID.";
169 $soc->fetch($payment[
'thirdparty_id']);
172 $new_payment->amount = doubleval($payment[
'amount']);
173 $new_payment->num_payment = $payment[
'num_payment'];
174 $new_payment->fk_account = intval($payment[
'bank_account']);
175 $new_payment->paiementid = !empty($payment[
'payment_mode_id']) ? intval($payment[
'payment_mode_id']) : $soc->mode_reglement_id;
176 $new_payment->datepaye = $now;
177 $new_payment->author = $payment[
'thirdparty_id'];
178 $new_payment->amounts = array();
180 if (intval($payment[
'invoice_id']) > 0) {
181 $new_payment->amounts[$payment[
'invoice_id']] = $new_payment->amount;
185 $result = $new_payment->create($fuser,
true);
187 if ($payment[
'bank_account']) {
188 $new_payment->addPaymentToBank($fuser,
'payment', $payment[
'int_label'], $payment[
'bank_account'], $payment[
'emitter'], $payment[
'bank_source']);
199 $objectresp = array(
'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
'id'=>$new_payment->id);
205 $errorlabel = $new_payment->error;
206 dol_syslog(
"Function: createInvoice error while creating".$errorlabel);
212 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
219 $server->service(file_get_contents(
"php://input"));
check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
Check authentication array and set error, errorcode, errorlabel.
dol_now($mode= 'auto')
Return date for now.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
Class to manage payments of customer invoices.
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
createPayment($authentication, $payment)
Create a payment.