{"action":"created","issue":{"url":"https://api.github.com/repos/VivaPayments/API/issues/150","repository_url":"https://api.github.com/repos/VivaPayments/API","labels_url":"https://api.github.com/repos/VivaPayments/API/issues/150/labels{/name}","comments_url":"https://api.github.com/repos/VivaPayments/API/issues/150/comments","events_url":"https://api.github.com/repos/VivaPayments/API/issues/150/events","html_url":"https://github.com/VivaPayments/API/issues/150","id":167623504,"number":150,"title":"Native checkout transaction id","user":{"login":"yperaksia","id":18322837,"avatar_url":"https://avatars.githubusercontent.com/u/18322837?v=3","gravatar_id":"","url":"https://api.github.com/users/yperaksia","html_url":"https://github.com/yperaksia","followers_url":"https://api.github.com/users/yperaksia/followers","following_url":"https://api.github.com/users/yperaksia/following{/other_user}","gists_url":"https://api.github.com/users/yperaksia/gists{/gist_id}","starred_url":"https://api.github.com/users/yperaksia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yperaksia/subscriptions","organizations_url":"https://api.github.com/users/yperaksia/orgs","repos_url":"https://api.github.com/users/yperaksia/repos","events_url":"https://api.github.com/users/yperaksia/events{/privacy}","received_events_url":"https://api.github.com/users/yperaksia/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-26T14:36:37Z","updated_at":"2016-07-26T14:40:18Z","closed_at":null,"body":"Καλησπέρα,\r\n\r\nέχω ενσωματώσει τους κώδικες σε php ιστοσελίδα και έχω ακολουθήσει τα βήματα που περιγράφονται και όλες τις οδηγίες πιστεύω πιστά και σωστά. \r\nΤο πρώτο πρόβλημα το οποίο αντιμετώπισα ήταν ότι δεν γινόταν ασφαλής μετάβαση των δεδομένων στο js και για αυτό μετέτρεψα όλα τα redirection σε https. Μετά από αυτό ολοκληρώνεται η διαδικασία χωρίς error response σε κανένα επίπεδο.\r\n\r\nΤο πρόβλημα τώρα είναι ότι δεν παίρνω πίσω transaction id, σαν να μην δουλεύει δηλαδή το NativeCheckoutClass.php\r\nδεν δίνει πίσω ούτε transaction id ούτε error και είναι null\r\nσε συνδυασμό, δεν γίνεται καμία χρέωση ούτε σε demo περιβάλλον ούτε σε πραγματικό ούτε με δική μου κάρτα ούτε με την 41111....\r\n\r\nΣημείωση: Το $cardToken, το $installments και το $amount μεταφέρονται μέχρι το τέλος της διαδικασίας άριστα.\r\n\r\nΣας επισυνάπτω παρακάτω το NativeCheckoutClass όπως έχει ολοκληρωθεί και παρακαλώ θερμά για όποια βοήθεια στο σχετικό θέμα επειδή είναι πολύ σοβαρή η επίλυσή του.\r\n\r\n\r\n<?php\r\n \r\n class OrderRequest {}\r\n class PaymentRequest {}\r\n \r\n class NativeCheckout {\r\n \r\n\tprivate $merchantId = '123456789-1234-1234-1234-123456789012';\r\n\tprivate $apiKey = '123456'; \r\n \tprivate $baseApiUrl = \"https://demo.vivapayments.com\";\r\n     private $paymentsUrl = \"/api/transactions\";\r\n     private $paymentsCreateOrderUrl = \"/api/orders\";\r\n  \r\n \tprivate $nativeCheckoutSourceCode = \"Native\";\r\n\tprivate $resultObj = \"\";\r\n \t\r\n \tpublic function MakePayment($amount,$cardToken,$installments){\r\n \t\t\r\n \t\t$orderCode=$this->CreateOrder($amount,$installments);\r\n \t\t\r\n \t\t$obj=new PaymentRequest();\r\n \t\t\r\n \t\t$obj->Amount=$amount;\r\n \t\t$obj->OrderCode=$orderCode;\r\n \t\t$obj->SourceCode=$this->nativeCheckoutSourceCode;\r\n\t\t$obj->CreditCard[\"Token\"]=$cardToken;\r\n \t\t$obj->Installments=$installments;\r\n \t\t\r\n \t\t$resultObj = $this->ExecuteCall($this->baseApiUrl.$this->paymentsUrl,$obj);\r\n \t\t\t\t\r\n \t\tif ($resultObj->ErrorCode==0){\t//success when ErrorCode = 0\r\n \t\t\treturn $resultObj->TransactionId;\r\n \t\t}\r\n \t\telse{\r\n \t\t\techo 'The following error occured: ' . $resultObj->ErrorText;\r\n \t\t\treturn '0';\r\n \t\t}\t\r\n \t}\r\n \t\r\n \tprivate function CreateOrder($amount,$installments){\r\n \t\r\n \t\t$obj=new OrderRequest();\r\n \t\t\r\n \t\t$obj->Amount=$amount;\r\n \t\t$obj->SourceCode=$this->nativeCheckoutSourceCode;\r\n \t\t$obj->MaxInstallments=$installments;\r\n \t\t\t\t\r\n \t\t$resultObj = $this->ExecuteCall($this->baseApiUrl.$this->paymentsCreateOrderUrl,$obj);\r\n \t\t\r\n \t\tif ($resultObj->ErrorCode==0){\t//success when ErrorCode = 0\r\n \t\t\treturn $resultObj->OrderCode;\r\n \t\t}\r\n \t\telse{\r\n \t\t\techo 'The following error occured: ' . $resultObj->ErrorText;\r\n \t\t\treturn 0;\r\n \t\t}\t\r\n \t}\t\r\n \t\r\n \tprivate function ExecuteCall($postUrl,$postobject){\r\n \t\r\n \t\t$postargs=json_encode($postobject);\r\n \t\r\n \t\t// Get the curl session object\r\n \t\t$session = curl_init($postUrl);\r\n \t\t\r\n \t\t// Set the POST options.\r\n \t\tcurl_setopt($session, CURLOPT_POST, true);\r\n \t\tcurl_setopt($session, CURLOPT_POSTFIELDS, $postargs);\r\n \t\tcurl_setopt($session, CURLOPT_HTTPHEADER, array(                                                                          \r\n \t\t\t'Content-Type: application/json',                                                                                \r\n \t\t\t'Content-Length: ' . strlen($postargs))                                                                       \r\n \t\t);   \r\n \t\tcurl_setopt($session, CURLOPT_RETURNTRANSFER, true);\r\n \t\tcurl_setopt($session, CURLOPT_USERPWD, $this->merchantId.':'.$this->apiKey);\r\n \t\tcurl_setopt($session, CURLOPT_SSL_CIPHER_LIST, 'TLSv1');\r\n \t\t\r\n \t\tcurl_setopt($session, CURLOPT_HEADER, true);\r\n \t\t\r\n \t\t// Do the POST and then close the session\r\n \t\t$response = curl_exec($session);\r\n \t\t\r\n \t\t// Separate Header from Body\r\n \t\t$header_len = curl_getinfo($session, CURLINFO_HEADER_SIZE);\r\n \t\t$resHeader = substr($response, 0, $header_len);\r\n \t\t$resBody =  substr($response, $header_len);\r\n \t\t\r\n \t\t// Parse the JSON response\r\n \t\ttry {\r\n \t\t\tif(is_object(json_decode($resBody))){\r\n \t\t\t\t$resultObj=json_decode($resBody);\r\n \t\t\t}else{\r\n \t\t\t\tpreg_match('#^HTTP/1.(?:0|1) [\\d]{3} (.*)$#m', $resHeader, $match);\r\n \t\t\t\tthrow new Exception(trim($match[1]));\r\n \t\t\t}\r\n \t\t} catch( Exception $e ) {\r\n \t\t\techo $e->getMessage();\r\n \t\t}\r\n \t\t\r\n \t\tcurl_close($session);\r\n \t\treturn $resultObj;\r\n \t}\r\n \t\r\n }\r\n?>"},"comment":{"url":"https://api.github.com/repos/VivaPayments/API/issues/comments/235288818","html_url":"https://github.com/VivaPayments/API/issues/150#issuecomment-235288818","issue_url":"https://api.github.com/repos/VivaPayments/API/issues/150","id":235288818,"user":{"login":"yperaksia","id":18322837,"avatar_url":"https://avatars.githubusercontent.com/u/18322837?v=3","gravatar_id":"","url":"https://api.github.com/users/yperaksia","html_url":"https://github.com/yperaksia","followers_url":"https://api.github.com/users/yperaksia/followers","following_url":"https://api.github.com/users/yperaksia/following{/other_user}","gists_url":"https://api.github.com/users/yperaksia/gists{/gist_id}","starred_url":"https://api.github.com/users/yperaksia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yperaksia/subscriptions","organizations_url":"https://api.github.com/users/yperaksia/orgs","repos_url":"https://api.github.com/users/yperaksia/repos","events_url":"https://api.github.com/users/yperaksia/events{/privacy}","received_events_url":"https://api.github.com/users/yperaksia/received_events","type":"User","site_admin":false},"created_at":"2016-07-26T14:40:18Z","updated_at":"2016-07-26T14:40:18Z","body":"Συμπληρώνω ότι στη σελίδα προορισμού όπου καλείται το NativeCheckoutClass.php με POST έχω τα εξής: \r\n\r\n<?php\r\nrequire_once(\"NativeCheckoutClass.php\");\r\n\t\t\t\t\t if (count($_POST)>0){\r\n\t\t\t \t$page=new NativeCheckout();\r\n\t\t\t \t$amount=$_POST['sum3']; // in cents\r\n\t\t\t \t$cardToken=$_POST[\"hidToken\"];\r\n\t\t\t \t$installments=$_POST[\"drpInstallments\"];\r\n\t\t\t\t$transactionId=$page->MakePayment($amount,$cardToken,$installments);};\r\n?>\r\n"}}
{"actor":{"display_login":"yperaksia"}}