התחברות לפלאקארד מnodejs
-
הנה דוקומנטציה (אם הבנתי מהו פירוש המילה :lol: :lol: )
mabat.net_572_documents_WebService_WebService_Heb.pdf
וגם זה:
ServicesAPI_-Programmer_Manual-_Hebrew.pdfפורסם במקור בפורום CODE613 ב24/09/2015 21:44 (+03:00)
-
המרתי את הקובץ PHP ל NODE
צריך להתקין חבילה. request
פקודה.
npm i request
var request = require("request"); // Submit the data into pelecard servers function do_post_request(operation, params ,callback) { var url = 'https://ws101.pelecard.biz/webservices.asmx/' + operation; request.post(url, { form: params } ,function(error,response,body){ callback(error,body); }); } var params = { 'userName' : 'PeleTest', 'password' : 'Pelecard@Test', 'termNo' : '0962210', 'shopNo' : '001', 'creditCard' : '4580000000000000', 'creditCardDateMmyy' : '0113', 'token' : '', 'total' : '3000', 'currency' : '1', 'paymentsNo' : '3', 'firstPymnt' : '1000', 'cvv2' : '123', 'id' : '060606060', 'authNum' : '', 'parmx' : 'test' }; do_post_request('DebitPaymntsType',params, function(error,body){ console.log(error,body); }); <?php $operation = 'DebitPaymntsType'; $data = array( 'userName' => 'PeleTest', 'password' => 'Pelecard@Test', 'termNo' => '0962210', 'shopNo' => '001', 'creditCard' => '4580000000000000', 'creditCardDateMmyy' => '0113', 'token' => '', 'total' => '3000', 'currency' => '1', 'paymentsNo' => '3', 'firstPymnt' => '1000', 'cvv2' => '123', 'id' => '060606060', 'authNum' => '', 'parmx' => 'test' ## NO TRAILING COMMA ); list ($code, $result) = do_post_request($operation, $data); ## $result is the gateway output. ## ## $code is the first 3 characters of $result. ## Some operations present error codes in the $code. ## READ THE MANUAL echo $code; echo '<br>'; echo $result; echo '<br>'; ## Eample for result code processing for operation DebitRegularType ## Other operations return different error structure. ## READ THE MANUAL if ($code <> '000') { ## ERROR if ($code == '501') { echo 'Wrong username or password'; } elseif ($code == '033' or $code == '039') { echo 'Invalid credit card details'; } elseif ($code == '036') { echo 'Credit card expired'; } else { echo 'Another error ocurred'; } } else { ## OPERATION DebitPaymntsType PROCESSED SUCCESSFULLY echo $result; } ## Submit the data into pelecard servers function do_post_request($operation, $data, $optional_headers = null) { $params = array('http' => array( 'method' => 'POST', 'content' => http_build_query($data) )); $url = 'https://ws101.pelecard.biz/webservices.asmx/'.$operation; if ($optional_headers !== null) { $params['http']['header'] = $optional_headers; } $ctx = stream_context_create($params); $fp = @fopen($url, 'rb', false, $ctx); if (!$fp) { throw new Exception("Problem with $url, $php_errormsg"); } $response = @stream_get_contents($fp); if ($response === false) { throw new Exception("Problem reading data from $url, $php_errormsg"); } return array(substr(trim(strip_tags($response)),0,3), trim(strip_tags($response))); } ?>
פורסם במקור בפורום CODE613 ב27/09/2015 11:46 (+03:00)
-
עשיתי לפי ה PDF השני שהוא הביא.
ServicesAPI_-Programmer_Manual-_Hebrew.pdf
זה נראה יותר טוב בגלל שזה עובד עם JSON.var request = require("request"); // Submit the data into pelecard servers function do_post_request(operation, params ,callback) { var url = 'https://gateway20.pelecard.biz/services/' + operation; request.post(url, { json: params } ,function(error,response,body){ callback(error,body); }); } var params = { "terminalNumber": "0962210", "user": "UserName", "password": "XXXXXXXX", "shopNumber": "001", "creditCard": "458045804580", "creditCardDateMmYy": "1214", "token": "", "total": "100", "currency": "1", "paymentsNumber": "2", "firstPayment": "50", "cvv2": "123", "id": "123456789", "authorizationNumber": "", "paramX": "test" }; do_post_request('DebitRegularType',params, function(error,json){ console.log(error,json); });
פורסם במקור בפורום CODE613 ב27/09/2015 12:02 (+03:00)