Dokoncano placevanje preko paypala

This commit is contained in:
pero1203 2020-10-25 10:44:41 +01:00
parent 4c69969d68
commit 2f0964e086
4 changed files with 34 additions and 7 deletions

View File

@ -272,7 +272,7 @@ class ApiNarocilaController{
if(isset($this->data['narocilo_id'])){ if(isset($this->data['narocilo_id'])){
$paypal = new UserNarocilaPaypal($this->data['narocilo_id']); $paypal = new UserNarocilaPaypal($this->data['narocilo_id']);
$this->response = $paypal->paypalCaptureOrder(); $this->response = $paypal->paypalCancelOrder();
} }
else{ else{
$this->response['error'] = 'Napaka! Manjka ID narocila!'; $this->response['error'] = 'Napaka! Manjka ID narocila!';

View File

@ -820,7 +820,7 @@ class UserNarocila{
return $response; return $response;
} }
// Dokoncaj narocilo s placilom preko predracuna - TODO // Dokoncaj narocilo s placilom preko predracuna
private function finishNarociloPaypal($narocilo_id, $narocilo_data){ private function finishNarociloPaypal($narocilo_id, $narocilo_data){
global $lang; global $lang;

View File

@ -102,9 +102,9 @@ class UserNarocilaPaypal{
// Vstavimo plačilo v bazo // Vstavimo plačilo v bazo
$sqlNarocilo = sisplet_query("INSERT INTO user_access_paypal_transaction $sqlNarocilo = sisplet_query("INSERT INTO user_access_paypal_transaction
(transaction_id, narocilo_id, price, currency_type, time) (transaction_id, narocilo_id, price, currency_type, time, status)
VALUES VALUES
('".$paypal_response['transaction_id']."', '".$this->narocilo['id']."', '".$cena_za_placilo."', 'EUR', NOW()) ('".$paypal_response['transaction_id']."', '".$this->narocilo['id']."', '".$cena_za_placilo."', 'EUR', NOW(), 'CREATED')
"); ");
if (!$sqlNarocilo){ if (!$sqlNarocilo){
$response['error'] = 'ERROR! '.mysqli_error($GLOBALS['connect_db']); $response['error'] = 'ERROR! '.mysqli_error($GLOBALS['connect_db']);
@ -242,8 +242,22 @@ class UserNarocilaPaypal{
} }
$response['status'] = $paypal_response->result->status; // Nastavimo narocilo na placano, aktiviramo paket in vrnemo racun
$narocilo = new UserNarocila();
$payment_response = $narocilo->payNarocilo($this->narocilo['id']);
if($payment_response['success'] == true){
$response['racun'] = $payment_response['racun'];
$response['success'] = true;
}
else{
$response['error'] = $payment_response['error'];
$response['success'] = false;
}
$response['narocilo_id'] = $this->narocilo['id'];
$response['success'] = true; $response['success'] = true;
return $response; return $response;
@ -257,7 +271,7 @@ class UserNarocilaPaypal{
// Posodobimo status narocila // Posodobimo status narocila
$sqlNarocilo = sisplet_query("UPDATE user_access_paypal_transaction $sqlNarocilo = sisplet_query("UPDATE user_access_paypal_transaction
SET status='CANCELED' SET status='CANCELLED'
WHERE narocilo_id='".$this->narocilo['id']."' WHERE narocilo_id='".$this->narocilo['id']."'
"); ");
if (!$sqlNarocilo){ if (!$sqlNarocilo){
@ -267,6 +281,15 @@ class UserNarocilaPaypal{
return $response; return $response;
} }
// Nastavimo status narocila na storniran
$sqlNarociloStatus = sisplet_query("UPDATE user_access_narocilo SET status='2' WHERE id='".$this->narocilo['id']."'");
if (!$sqlNarociloStatus){
$response['error'] = 'ERROR! '.mysqli_error($GLOBALS['connect_db']);
$response['success'] = false;
return $response;
}
$response['success'] = true; $response['success'] = true;
return $response; return $response;

View File

@ -9331,3 +9331,7 @@ ALTER TABLE srv_anketa ADD subsequent_answers ENUM('0', '1') NOT NULL DEFAULT '1
INSERT INTO srv_help (help, what) VALUES ('Uporabnik ne more nikoli naknadno urejati svojih odgovorov (npr. s klikom nazaj)', 'srv_subsequent_answers'); INSERT INTO srv_help (help, what) VALUES ('Uporabnik ne more nikoli naknadno urejati svojih odgovorov (npr. s klikom nazaj)', 'srv_subsequent_answers');
UPDATE misc SET value='20.10.20' WHERE what="version"; UPDATE misc SET value='20.10.20' WHERE what="version";
ALTER TABLE user_access_paypal_transaction CHANGE transaction_id transaction_id VARCHAR(100) NOT NULL DEFAULT '';
UPDATE misc SET value='20.10.25' WHERE what="version";