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)) {
46 $langs->load(
"admin");
48 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
49 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
50 print $langs->trans(
"ToActivateModule");
55 $server =
new nusoap_server();
56 $server->soap_defencoding =
'UTF-8';
57 $server->decode_utf8 =
false;
58 $ns =
'http://www.dolibarr.org/ns/';
59 $server->configureWSDL(
'WebServicesDolibarrPayment', $ns);
60 $server->wsdl->schemaTargetNamespace = $ns;
64 $server->wsdl->addComplexType(
71 'dolibarrkey' => array(
'name'=>
'dolibarrkey',
'type'=>
'xsd:string'),
72 'sourceapplication' => array(
'name'=>
'sourceapplication',
'type'=>
'xsd:string'),
73 'login' => array(
'name'=>
'login',
'type'=>
'xsd:string'),
74 'password' => array(
'name'=>
'password',
'type'=>
'xsd:string'),
75 'entity' => array(
'name'=>
'entity',
'type'=>
'xsd:string')
79 $server->wsdl->addComplexType(
86 'result_code' => array(
'name'=>
'result_code',
'type'=>
'xsd:string'),
87 'result_label' => array(
'name'=>
'result_label',
'type'=>
'xsd:string'),
92 $server->wsdl->addComplexType(
99 'amount' => array(
'name'=>
'amount',
'type'=>
'xsd:double'),
100 'num_payment' => array(
'name'=>
'num_payment',
'type'=>
'xsd:string'),
101 'thirdparty_id' => array(
'name'=>
'thirdparty_id',
'type'=>
'xsd:int'),
102 'bank_account' => array(
'name'=>
'bank_account',
'type'=>
'xsd:int'),
103 'payment_mode_id' => array(
'name'=>
'payment_mode_id',
'type'=>
'xsd:int'),
104 'invoice_id' => array(
'name'=>
'invoice_id',
'type'=>
'xsd:int'),
105 'int_label' => array(
'name'=>
'int_label',
'type'=>
'xsd:string'),
106 'emitter' => array(
'name'=>
'emitter',
'type'=>
'xsd:string'),
107 'bank_source' => array(
'name'=>
'bank_source',
'type'=>
'xsd:string'),
115 $styleuse =
'encoded';
122 array(
'authentication'=>
'tns:authentication',
'payment'=>
'tns:payment'),
124 array(
'result'=>
'tns:result',
'id'=>
'xsd:string',
'ref'=>
'xsd:string',
'ref_ext'=>
'xsd:string'),
126 $ns.
'#createPayment',
129 'WS to create a new payment'
146 dol_syslog(
"Function: createPayment login=".$authentication[
'login'].
" id=".$payment->id.
147 ", ref=".$payment->ref.
", ref_ext=".$payment->ref_ext);
149 if ($authentication[
'entity']) {
150 $conf->entity = $authentication[
'entity'];
154 $objectresp = array();
161 if (empty($payment[
'amount']) && empty($payment[
'thirdparty_id'])) {
164 $errorlabel =
"You must specify the amount and the third party's ID.";
169 $soc->fetch($payment[
'thirdparty_id']);
172 $new_payment->amount = floatval($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']);
197 $objectresp = array(
'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
'id'=>$new_payment->id);
202 $errorlabel = $new_payment->error;
203 dol_syslog(
"Function: createInvoice error while creating".$errorlabel);
208 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
215 $server->service(file_get_contents(
"php://input"));
Class to manage payments of customer invoices.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_now($mode='auto')
Return date for now.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
createPayment($authentication, $payment)
Create a payment.
check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
Check authentication array and set error, errorcode, errorlabel.