echo 'payment/init failed, reason: ' . curl_error($ch); return; } $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($httpCode != 200) { echo 'payment/init failed, http response: ' . $httpCode; return; } curl_close($ch); echo "payment/init result:\n" . $result . "\n\n"; $result_array = json_decode($result, true); if (is_null($result_array['resultCode'])) { echo 'payment/init failed, missing resultCode'; return; } if (verifyResponse($result_array, $publicKey, "payment/init verify") == false) { echo 'payment/init failed, unable to verify signature'; return; } if ($result_array['resultCode'] != '0') { echo 'payment/init failed, reason: ' . $result_array['resultMessage']; return; } $payId = $result_array['payId']; $params = createGetParams($merchantId, $payId, $dttm, $privateKey, $privateKeyPassword); ?> </pre> <a href="<?php echo $url . NativeApiMethod::$process . $params; ?> ">payment/process</a><br/>
$getAllArray = array('2169122', '2169130'); echo "\n Get ALL Form Verification"; verifyAllResponse($getAllResponse, $getAllArray); // GET SINGLE call to api and verified against Test_Form_1. $getSingleUrl = 'https://www.formstack.com/api/v2/form/2169122.json'; $getSingleResponse = callApi($getSingleUrl); echo "\n Single Form Verification"; verifyResponse($getSingleResponse, $getSingleArray); // POST to make a copy and verified against original form. $copySingleUrl = 'https://www.formstack.com/api/v2/form/2169122/copy.json'; $copyResponse = callApi($copySingleUrl, "POST"); $copiedId = $copyResponse['id']; $copiedName = $copyResponse['name']; $getCopyArray = array('id' => "{$copiedId}", 'name' => "{$copiedName}"); echo "\n Copied Form Verification"; verifyResponse($copyResponse, $getCopyArray); // DELETE to the copied form id and verification against correct array. $newCopyUrl = "https://www.formstack.com/api/v2/form/{$copiedId}.json"; $deleteResponse = callApi($newCopyUrl, "DELETE"); $deletedName = $deleteResponse['name']; $deletedId = $deltedResponse['id']; $getDeleteArray = array('id' => "{$copiedId}", 'success' => "1"); echo "\n Deleted Form Verification"; verifyDeleteResponse($deleteResponse, $getDeleteArray); // Function calls api // // $url - the url to call // $type - GET, PUT, POST, DELETE\ // #data - array of data to send to the api // function callApi($url, $type = "GET", $data = array())
return; } $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); echo "http status: " . $httpCode . "\n\n"; if ($httpCode != 200) { echo 'payment/' . $action . ' failed, http response: ' . $httpCode; return; } curl_close($ch); echo 'response: ' . $result . "\n\n"; $result_array = json_decode($result, true); if (is_null($result_array['resultCode'])) { echo 'payment/' . $action . ' failed, missing resultCode'; return; } if (verifyResponse($result_array, $publicKey, "payment/" . $action . " verify") == false) { echo 'payment/' . $action . ' failed, unable to verify signature'; return; } if ($result_array['resultCode'] != '0') { echo 'payment/' . $action . ' failed, reason: ' . $result_array['resultMessage']; } } ?> </pre> <a href="<?php echo $url . NativeApiMethod::$process . $params; ?> ">payment/process</a><br/> <a href="payment.php?action=status&merchant_id=<?php echo $merchantId;
function verifyPaymentResponseSignature($response, $publicKey, $logMsg) { return verifyResponse($response, $publicKey, $logMsg); }