27if (!defined(
'NOCSRFCHECK')) {
28 define(
'NOCSRFCHECK',
'1');
30if (!defined(
'NOTOKENRENEWAL')) {
31 define(
'NOTOKENRENEWAL',
'1');
33if (!defined(
'NOREQUIREMENU')) {
34 define(
'NOREQUIREMENU',
'1');
36if (!defined(
'NOREQUIREHTML')) {
37 define(
'NOREQUIREHTML',
'1');
39if (!defined(
'NOREQUIREAJAX')) {
40 define(
'NOREQUIREAJAX',
'1');
42if (!defined(
"NOLOGIN")) {
43 define(
"NOLOGIN",
'1');
45if (!defined(
"NOSESSION")) {
46 define(
"NOSESSION",
'1');
49require
'../main.inc.php';
50require_once NUSOAP_PATH.
'/nusoap.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/lib/ws.lib.php';
53require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
56require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
59dol_syslog(
"Call Dolibarr webservices interfaces");
65 $langs->load(
"admin");
67 dol_syslog(
"Call Dolibarr webservices interfaces with module webservices disabled");
68 print $langs->trans(
"WarningModuleNotActive",
'WebServices').
'.<br><br>';
69 print $langs->trans(
"ToActivateModule");
74$server =
new nusoap_server();
75$server->soap_defencoding =
'UTF-8';
76$server->decode_utf8 =
false;
77$ns =
'http://www.dolibarr.org/ns/';
78$server->configureWSDL(
'WebServicesDolibarrPayment', $ns);
79$server->wsdl->schemaTargetNamespace = $ns;
83$server->wsdl->addComplexType(
90 'dolibarrkey' => array(
'name'=>
'dolibarrkey',
'type'=>
'xsd:string'),
91 'sourceapplication' => array(
'name'=>
'sourceapplication',
'type'=>
'xsd:string'),
92 'login' => array(
'name'=>
'login',
'type'=>
'xsd:string'),
93 'password' => array(
'name'=>
'password',
'type'=>
'xsd:string'),
94 'entity' => array(
'name'=>
'entity',
'type'=>
'xsd:string')
98$server->wsdl->addComplexType(
105 'result_code' => array(
'name'=>
'result_code',
'type'=>
'xsd:string'),
106 'result_label' => array(
'name'=>
'result_label',
'type'=>
'xsd:string'),
111$server->wsdl->addComplexType(
118 'amount' => array(
'name'=>
'amount',
'type'=>
'xsd:double'),
119 'num_payment' => array(
'name'=>
'num_payment',
'type'=>
'xsd:string'),
120 'thirdparty_id' => array(
'name'=>
'thirdparty_id',
'type'=>
'xsd:int'),
121 'bank_account' => array(
'name'=>
'bank_account',
'type'=>
'xsd:int'),
122 'payment_mode_id' => array(
'name'=>
'payment_mode_id',
'type'=>
'xsd:int'),
123 'invoice_id' => array(
'name'=>
'invoice_id',
'type'=>
'xsd:int'),
124 'int_label' => array(
'name'=>
'int_label',
'type'=>
'xsd:string'),
125 'emitter' => array(
'name'=>
'emitter',
'type'=>
'xsd:string'),
126 'bank_source' => array(
'name'=>
'bank_source',
'type'=>
'xsd:string'),
134$styleuse =
'encoded';
141 array(
'authentication'=>
'tns:authentication',
'payment'=>
'tns:payment'),
143 array(
'result'=>
'tns:result',
'id'=>
'xsd:string',
'ref'=>
'xsd:string',
'ref_ext'=>
'xsd:string'),
145 $ns.
'#createPayment',
148 'WS to create a new payment'
165 dol_syslog(
"Function: createPayment login=".$authentication[
'login'].
" id=".$payment->id.
166 ", ref=".$payment->ref.
", ref_ext=".$payment->ref_ext);
168 if ($authentication[
'entity']) {
169 $conf->entity = $authentication[
'entity'];
173 $objectresp = array();
180 if (empty($payment[
'amount']) && empty($payment[
'thirdparty_id'])) {
183 $errorlabel =
"You must specify the amount and the third party's ID.";
188 $soc->fetch($payment[
'thirdparty_id']);
191 $new_payment->amount = (float) $payment[
'amount'];
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();
199 if (intval($payment[
'invoice_id']) > 0) {
200 $new_payment->amounts[$payment[
'invoice_id']] = $new_payment->amount;
204 $result = $new_payment->create($fuser,
true);
206 if ($payment[
'bank_account']) {
207 $new_payment->addPaymentToBank($fuser,
'payment', $payment[
'int_label'], $payment[
'bank_account'], $payment[
'emitter'], $payment[
'bank_source']);
216 $objectresp = array(
'result'=>array(
'result_code'=>
'OK',
'result_label'=>
''),
'id'=>$new_payment->id);
221 $errorlabel = $new_payment->error;
222 dol_syslog(
"Function: createInvoice error while creating".$errorlabel);
227 $objectresp = array(
'result'=>array(
'result_code' => $errorcode,
'result_label' => $errorlabel));
234$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.