/** * function do_webpayment * @params : $array : array. the array keys are : * payment, returnURL, cancelURL, order, notificationURL,customPaymentTemplateURL, contracts, * customPaymentPageCode, languageCode, securityMode, buyer, address, recurring * @params : $debug : boolean . TRUE/FALSE or 0/1 * @return : Array. Array from a payline server response object. * @description : Do a payment request **/ public function do_webpayment($array, $debug = 0) { try { if ($array && is_array($array)) { if (isset($array['cancelURL']) && strlen($array['cancelURL'])) { $this->cancelURL = $array['cancelURL']; } if (isset($array['notificationURL']) && strlen($array['notificationURL'])) { $this->notificationURL = $array['notificationURL']; } if (isset($array['returnURL']) && strlen($array['returnURL'])) { $this->returnURL = $array['returnURL']; } if (isset($array['customPaymentTemplateURL']) && strlen($array['customPaymentTemplateURL'])) { $this->customPaymentTemplateURL = $array['customPaymentTemplateURL']; } if (isset($array['customPaymentPageCode']) && strlen($array['customPaymentPageCode'])) { $this->customPaymentPageCode = $array['customPaymentPageCode']; } if (isset($array['languageCode']) && strlen($array['languageCode'])) { $this->languageCode = $array['languageCode']; } if (isset($array['securityMode']) && strlen($array['securityMode'])) { $this->securityMode = $array['securityMode']; } if (!isset($array['payment'])) { $array['payment'] = null; } if (!isset($array['contracts']) || !strlen($array['contracts'][0])) { $array['contracts'] = explode(";", CONTRACT_NUMBER_LIST); } if (!isset($array['buyer'])) { $array['buyer'] = null; } if (!isset($array['address'])) { $array['address'] = null; } if (!isset($array['recurring'])) { $array['recurring'] = null; } $doWebPaymentRequest = array('payment' => $this->payment($array['payment']), 'returnURL' => $this->returnURL, 'cancelURL' => $this->cancelURL, 'order' => $this->order($array['order']), 'notificationURL' => $this->notificationURL, 'customPaymentTemplateURL' => $this->customPaymentTemplateURL, 'selectedContractList' => $this->contracts($array['contracts']), 'privateDataList' => $this->privates, 'languageCode' => $this->languageCode, 'customPaymentPageCode' => $this->customPaymentPageCode, 'buyer' => $this->buyer($array['buyer'], $array['address']), 'securityMode' => $this->securityMode); //ajout des recurring dans les cas de paiement REC ou NX if (isset($array['payment']['mode'])) { if ($array['payment']['mode'] == "REC" || $array['payment']['mode'] == "NX") { $doWebPaymentRequest['recurring'] = $this->recurring($array['recurring']); } } if ($debug) { return util::responseToArray($doWebPaymentRequest); } else { $client = new SoapClient($this->WSDL_SOAP, $this->header_soap); $doWebPaymentResponse = $client->doWebPayment($doWebPaymentRequest); return util::responseToArray($doWebPaymentResponse); } } } catch (Exception $e) { echo '<strong>ERROR : ' . $e->getMessage() . '</strong><br/>'; } }
private function webServiceRequest($array, $WSRequest, $PaylineAPI, $Method) { $reqTrace = "webServiceRequest - Location : " . $this->webServicesEndpoint . $PaylineAPI . " - {$Method}"; $resTrace = ''; try { $client = new SoapClient(dirname(__FILE__) . '/' . paylineSDK::WSDL, $this->header_soap); $client->__setLocation($this->webServicesEndpoint . $PaylineAPI); if (isset($array['version']) && strlen($array['version'])) { $WSRequest['version'] = $array['version']; } else { $WSRequest['version'] = ''; } if (isset($array['media']) && strlen($array['media'])) { $WSRequest['media'] = $array['media']; } else { $WSRequest['media'] = ''; } switch ($Method) { case 'createMerchant': $WSresponse = $client->createMerchant($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'createWallet': $WSresponse = $client->createWallet($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'createWebWallet': $WSresponse = $client->createWebWallet($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'updatePaymentRecord': $WSresponse = $client->updatePaymentRecord($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'getBillingRecord': $WSresponse = $client->getBillingRecord($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'updateBillingRecord': $WSresponse = $client->updateBillingRecord($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'disablePaymentRecord': $WSresponse = $client->disablePaymentRecord($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'disableWallet': $WSresponse = $client->disableWallet($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'doAuthorization': $WSresponse = $client->doAuthorization($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'doCapture': $WSresponse = $client->doCapture($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'doCredit': $WSresponse = $client->doCredit($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'doDebit': $WSresponse = $client->doDebit($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'doImmediateWalletPayment': $WSresponse = $client->doImmediateWalletPayment($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'doReAuthorization': $WSresponse = $client->doReAuthorization($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'doRecurrentWalletPayment': $WSresponse = $client->doRecurrentWalletPayment($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'doRefund': $WSresponse = $client->doRefund($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'doReset': $WSresponse = $client->doReset($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'doScheduledWalletPayment': $WSresponse = $client->doScheduledWalletPayment($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'doScoringCheque': $WSresponse = $client->doScoringCheque($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'doWebPayment': $reqTrace .= '(order.ref = ' . $array['order']['ref'] . ')'; $WSresponse = $client->doWebPayment($WSRequest); $response = paylineUtil::responseToArray($WSresponse); if ($response['result']['code'] == '00000') { $resTrace = ' - token = ' . $response['token']; } break; case 'enableWallet': $WSresponse = $client->enableWallet($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'getAlertDetails': $WSresponse = $client->getAlertDetails($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'getBalance': $WSresponse = $client->getBalance($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'getCards': $WSresponse = $client->getCards($WSRequest); $response = paylineUtil::responseToArrayForGetCards($WSresponse); break; case 'getEncryptionKey': $WSresponse = $client->getEncryptionKey($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'getMerchantSettings': $WSresponse = $client->getMerchantSettings($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'getPaymentRecord': $WSresponse = $client->getPaymentRecord($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'getToken': $WSresponse = $client->getToken($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'getTransactionDetails': $WSresponse = $client->getTransactionDetails($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'getWallet': $WSresponse = $client->getWallet($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'getWebPaymentDetails': $reqTrace .= '(token = ' . $array['token'] . ')'; $WSresponse = $client->getWebPaymentDetails($WSRequest); $response = paylineUtil::responseToArray($WSresponse); if (isset($response['transaction']['id'])) { $resTrace = ' - transactionId = ' . $response['transaction']['id']; } break; case 'getWebWallet': $WSresponse = $client->getWebWallet($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'manageWebWallet': $WSresponse = $client->manageWebWallet($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'transactionsSearch': $WSresponse = $client->transactionsSearch($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'unBlock': $WSresponse = $client->unBlock($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'updateWallet': $WSresponse = $client->updateWallet($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'updateWebWallet': $WSresponse = $client->updateWebWallet($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'verifyAuthentication': $WSresponse = $client->verifyAuthentication($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; case 'verifyEnrollment': $WSresponse = $client->verifyEnrollment($WSRequest); $response = paylineUtil::responseToArray($WSresponse); break; } $this->writeTrace($reqTrace); $this->writeTrace('Response : code = ' . $response['result']['code'] . $resTrace); return $response; } catch (Exception $e) { $this->writeTrace($reqTrace); $this->writeTrace("Exception : " . $e->getMessage()); $ERROR = array(); $ERROR['result']['code'] = paylineSDK::ERR_CODE; $ERROR['result']['longMessage'] = $e->getMessage(); $ERROR['result']['shortMessage'] = $e->getMessage(); return $ERROR; } }