throw new Exception(curl_error($ch), curl_errno($ch)); } echo $result; } catch (Exception $e) { trigger_error(sprintf('Curl failed with error #%d: %s', $e->getCode(), $e->getMessage()), E_USER_ERROR); } curl_close($ch); } // Globals $config = array("callbackUrl" => "https://example.com/api/swishcb/paymentrequests", "payeeAlias" => "1231181189", "currency" => "SEK", "CAINFO" => 'C:\\wamp\\bin\\apache\\apache2.4.9\\conf\\ssl\\ca.pem', "SSLCERT" => 'C:\\wamp\\bin\\apache\\apache2.4.9\\conf\\ssl\\client.pem', "SSLKEY" => 'C:\\wamp\\bin\\apache\\apache2.4.9\\conf\\ssl\\key.pem', "SSLCERTPASSWD" => 'swish', "SSLKEYPASSWD" => 'swish'); // createPayment("davidBet01", "", "2435", "Test 1", $config); // getPayment("693717E1BAED4E47B715AF5514BFE615", $config); // Location: http://172.31.21.186:8580/swish-cpcapi/api/v1/paymentrequests/693717E1BAED4E47B715AF5514BFE615 // PaymentRequestToken: dFJ4QhlZSqia9RHO1O0D2qHbaGzSjYVz if (isset($_GET["orderId"]) && isset($_GET["phone"])) { echo createPayment($_GET["orderId"], $_GET["phone"], "100", "Test 1", $config); } else { if (isset($_GET["transactionId"])) { // getPayment($_GET["transactionId"], $config); if (isset($_GET["action"]) && $_GET["action"] == "update") { getPayment($_GET["transactionId"], $config); } else { if (isset($_SESSION[$_GET["transactionId"]])) { echo '{"transactionId":"' . $_GET["transactionId"] . '","status":"' . $_SESSION[$_GET["transactionId"]]["status"] . '"}'; } else { echo '{"error":"Callback not received yet", "transactionId":"' . $_GET["transactionId"] . '","status":"unknown"}'; } } } else { // echo '{"transactionId":"693717E1BAED4E47B715AF5514BFE615","status":"unknown"}'; echo '{"error":"Parameter missing"}';
function handleCreatePayment($entity) { createPayment($entity); }
<?php require_once __DIR__ . '/demo.inc.php'; $service = new PayService(); if (isset($_POST) && ($amount = getAmountInPost())) { createPayment($service, $_POST, $amount); } ?> <h1><a href="index.php" >top</a> > Create New Payment</h1> <?php if ($service->service === PayService::PAY_JP) { ?> <form action="" method="post"> <input type="text" name="amount" value="2345" /> <input type="checkbox" name="authorize" value="auth" /> <script src="https://checkout.pay.jp/" class="payjp-button" data-key="<?php echo $service->pub; ?> "></script> </form> <?php } elseif ($service->service === PayService::WEB_PAY) { ?> <form action="" method="post"> <input type="text" name="amount" value="2345" /> <input type="checkbox" name="authorize" value="auth" /> <script src="https://checkout.webpay.jp/v3/" class="webpay-button" data-key="<?php