29if (!defined(
'NOCSRFCHECK')) {
30 define(
'NOCSRFCHECK',
'1');
32if (!defined(
'NOTOKENRENEWAL')) {
33 define(
'NOTOKENRENEWAL',
'1');
35if (!defined(
'NOREQUIREMENU')) {
36 define(
'NOREQUIREMENU',
'1');
38if (!defined(
'NOREQUIREHTML')) {
39 define(
'NOREQUIREHTML',
'1');
41if (!defined(
'NOREQUIREAJAX')) {
42 define(
'NOREQUIREAJAX',
'1');
44if (!defined(
"NOLOGIN")) {
45 define(
"NOLOGIN",
'1');
47if (!defined(
"NOSESSION")) {
48 define(
"NOSESSION",
'1');
51require
'../main.inc.php';
52require_once NUSOAP_PATH.
'/nusoap.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
54require_once DOL_DOCUMENT_ROOT.
'/core/lib/ws.lib.php';
55require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
57require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
58require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
65dol_syslog(
"Call Dolibarr webservices interfaces");
71 $langs->load(
"admin");
73 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
74 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
75 print $langs->trans(
"ToActivateModule");
80$server =
new nusoap_server();
81$server->soap_defencoding =
'UTF-8';
82$server->decode_utf8 =
false;
83$ns =
'http://www.dolibarr.org/ns/';
84$server->configureWSDL(
'WebServicesDolibarrPayment', $ns);
85$server->wsdl->schemaTargetNamespace = $ns;
89$server->wsdl->addComplexType(
96 'dolibarrkey' => array(
'name' =>
'dolibarrkey',
'type' =>
'xsd:string'),
97 'sourceapplication' => array(
'name' =>
'sourceapplication',
'type' =>
'xsd:string'),
98 'login' => array(
'name' =>
'login',
'type' =>
'xsd:string'),
99 'password' => array(
'name' =>
'password',
'type' =>
'xsd:string'),
100 'entity' => array(
'name' =>
'entity',
'type' =>
'xsd:string')
104$server->wsdl->addComplexType(
111 'result_code' => array(
'name' =>
'result_code',
'type' =>
'xsd:string'),
112 'result_label' => array(
'name' =>
'result_label',
'type' =>
'xsd:string'),
117$server->wsdl->addComplexType(
124 'amount' => array(
'name' =>
'amount',
'type' =>
'xsd:double'),
125 'num_payment' => array(
'name' =>
'num_payment',
'type' =>
'xsd:string'),
126 'thirdparty_id' => array(
'name' =>
'thirdparty_id',
'type' =>
'xsd:int'),
127 'bank_account' => array(
'name' =>
'bank_account',
'type' =>
'xsd:int'),
128 'payment_mode_id' => array(
'name' =>
'payment_mode_id',
'type' =>
'xsd:int'),
129 'invoice_id' => array(
'name' =>
'invoice_id',
'type' =>
'xsd:int'),
130 'int_label' => array(
'name' =>
'int_label',
'type' =>
'xsd:string'),
131 'emitter' => array(
'name' =>
'emitter',
'type' =>
'xsd:string'),
132 'bank_source' => array(
'name' =>
'bank_source',
'type' =>
'xsd:string'),
140$styleuse =
'encoded';
147 array(
'authentication' =>
'tns:authentication',
'payment' =>
'tns:payment'),
149 array(
'result' =>
'tns:result',
'id' =>
'xsd:string',
'ref' =>
'xsd:string',
'ref_ext' =>
'xsd:string'),
151 $ns.
'#createPayment',
154 'WS to create a new payment'
171 dol_syslog(
"Function: createPayment login=".$authentication[
'login'].
" id=".$payment->id.
172 ", ref=".$payment->ref.
", ref_ext=".$payment->ref_ext);
174 if ($authentication[
'entity']) {
175 $conf->entity = $authentication[
'entity'];
179 $objectresp = array();
186 if (empty($payment[
'amount']) && empty($payment[
'thirdparty_id'])) {
189 $errorlabel =
"You must specify the amount and the third party's ID.";
194 $soc->fetch($payment[
'thirdparty_id']);
197 $new_payment->num_payment = $payment[
'num_payment'];
198 $new_payment->fk_account = intval($payment[
'bank_account']);
199 $new_payment->paiementid = !empty($payment[
'payment_mode_id']) ? intval($payment[
'payment_mode_id']) : $soc->mode_reglement_id;
200 $new_payment->datepaye = $now;
201 $new_payment->author = $payment[
'thirdparty_id'];
202 $new_payment->amounts = array($payment[
'invoice_id'] => (
float) $payment[
'amount']);
205 $result = $new_payment->create($fuser,
true);
207 if ($payment[
'bank_account']) {
208 $new_payment->addPaymentToBank($fuser,
'payment', $payment[
'int_label'], $payment[
'bank_account'], $payment[
'emitter'], $payment[
'bank_source']);
217 $objectresp = array(
'result' => array(
'result_code' =>
'OK',
'result_label' =>
''),
'id' => $new_payment->id);
222 $errorlabel = $new_payment->error;
223 dol_syslog(
"Function: createInvoice error while creating".$errorlabel);
228 $objectresp = array(
'result' => array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
235$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 a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
createPayment($authentication, $payment)
Create a payment.
check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
Check authentication array and set error, errorcode, errorlabel.