28if (!defined(
'NOCSRFCHECK')) {
29 define(
'NOCSRFCHECK',
'1');
31if (!defined(
'NOTOKENRENEWAL')) {
32 define(
'NOTOKENRENEWAL',
'1');
34if (!defined(
'NOREQUIREMENU')) {
35 define(
'NOREQUIREMENU',
'1');
37if (!defined(
'NOREQUIREHTML')) {
38 define(
'NOREQUIREHTML',
'1');
40if (!defined(
'NOREQUIREAJAX')) {
41 define(
'NOREQUIREAJAX',
'1');
43if (!defined(
"NOLOGIN")) {
44 define(
"NOLOGIN",
'1');
46if (!defined(
"NOSESSION")) {
47 define(
"NOSESSION",
'1');
50require
'../main.inc.php';
51require_once NUSOAP_PATH.
'/nusoap.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/lib/ws.lib.php';
54require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
56require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
57require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
60dol_syslog(
"Call Dolibarr webservices interfaces");
66 $langs->load(
"admin");
68 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
69 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
70 print $langs->trans(
"ToActivateModule");
75$server =
new nusoap_server();
76$server->soap_defencoding =
'UTF-8';
77$server->decode_utf8 =
false;
78$ns =
'http://www.dolibarr.org/ns/';
79$server->configureWSDL(
'WebServicesDolibarrPayment', $ns);
80$server->wsdl->schemaTargetNamespace = $ns;
84$server->wsdl->addComplexType(
91 'dolibarrkey' => array(
'name' =>
'dolibarrkey',
'type' =>
'xsd:string'),
92 'sourceapplication' => array(
'name' =>
'sourceapplication',
'type' =>
'xsd:string'),
93 'login' => array(
'name' =>
'login',
'type' =>
'xsd:string'),
94 'password' => array(
'name' =>
'password',
'type' =>
'xsd:string'),
95 'entity' => array(
'name' =>
'entity',
'type' =>
'xsd:string')
99$server->wsdl->addComplexType(
106 'result_code' => array(
'name' =>
'result_code',
'type' =>
'xsd:string'),
107 'result_label' => array(
'name' =>
'result_label',
'type' =>
'xsd:string'),
112$server->wsdl->addComplexType(
119 'amount' => array(
'name' =>
'amount',
'type' =>
'xsd:double'),
120 'num_payment' => array(
'name' =>
'num_payment',
'type' =>
'xsd:string'),
121 'thirdparty_id' => array(
'name' =>
'thirdparty_id',
'type' =>
'xsd:int'),
122 'bank_account' => array(
'name' =>
'bank_account',
'type' =>
'xsd:int'),
123 'payment_mode_id' => array(
'name' =>
'payment_mode_id',
'type' =>
'xsd:int'),
124 'invoice_id' => array(
'name' =>
'invoice_id',
'type' =>
'xsd:int'),
125 'int_label' => array(
'name' =>
'int_label',
'type' =>
'xsd:string'),
126 'emitter' => array(
'name' =>
'emitter',
'type' =>
'xsd:string'),
127 'bank_source' => array(
'name' =>
'bank_source',
'type' =>
'xsd:string'),
135$styleuse =
'encoded';
142 array(
'authentication' =>
'tns:authentication',
'payment' =>
'tns:payment'),
144 array(
'result' =>
'tns:result',
'id' =>
'xsd:string',
'ref' =>
'xsd:string',
'ref_ext' =>
'xsd:string'),
146 $ns.
'#createPayment',
149 'WS to create a new payment'
166 dol_syslog(
"Function: createPayment login=".$authentication[
'login'].
" id=".$payment->id.
167 ", ref=".$payment->ref.
", ref_ext=".$payment->ref_ext);
169 if ($authentication[
'entity']) {
170 $conf->entity = $authentication[
'entity'];
174 $objectresp = array();
181 if (empty($payment[
'amount']) && empty($payment[
'thirdparty_id'])) {
184 $errorlabel =
"You must specify the amount and the third party's ID.";
189 $soc->fetch($payment[
'thirdparty_id']);
192 $new_payment->num_payment = $payment[
'num_payment'];
193 $new_payment->fk_account = intval($payment[
'bank_account']);
194 $new_payment->paiementid = !empty($payment[
'payment_mode_id']) ? intval($payment[
'payment_mode_id']) : $soc->mode_reglement_id;
195 $new_payment->datepaye = $now;
196 $new_payment->author = $payment[
'thirdparty_id'];
197 $new_payment->amounts = array($payment[
'invoice_id'] => (
float) $payment[
'amount']);
200 $result = $new_payment->create($fuser,
true);
202 if ($payment[
'bank_account']) {
203 $new_payment->addPaymentToBank($fuser,
'payment', $payment[
'int_label'], $payment[
'bank_account'], $payment[
'emitter'], $payment[
'bank_source']);
212 $objectresp = array(
'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
'id' => $new_payment->id);
217 $errorlabel = $new_payment->error;
218 dol_syslog(
"Function: createInvoice error while creating".$errorlabel);
223 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
230$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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.