$paymentRequest->set_payment_info("Test"); $paymentRequest->set_title("My new Phone"); $paymentRequest->set_description("Buy your favorite Sony Phone!"); $paymentRequest->set_adult_content(false); $paymentRequest->set_roaming(false); $paymentRequest->set_merchant_id($MerchantId); $paymentRequest->set_cancel_url($BaseReturnUrl . "?uid=43c2&sid=dc0d&purchase=cancel"); $paymentRequest->set_error_url($BaseReturnUrl . "?uid=43c2&sid=dc0d&purchase=error"); $paymentRequest->set_success_url($BaseReturnUrl . "?uid=43c2&sid=dc0d&purchase=success"); $paymentRequest->set_cp_service_id("xys-323-gh-ff"); $paymentRequest->set_cp_subscription_id("23hkb379oh"); $paymentRequest->set_cp_user_id("vghv5678"); $paymentRequest->set_image_url("http://lorempixel.com/300/200"); $paymentRequest->set_content_type("App"); $paymentRequest->set_store_source("Easypay-City"); $config = new Easypay_config(); $config->set_basepath("/charging-engine-checkout"); $config->set_host("easypay-staging.swisscom.ch"); $config->set_merchant_id($MerchantId); $config->set_easypay_secret("KiLgscVNTqAJQ1keGOv_hhKsuf5oftohg17VmncT"); echo json_encode($_GET) . $endOfLine; echo "----------------------------------------------------------" . $endOfLine; if (isset($_GET['buy'])) { echo "Buy Action" . "<br/>"; if (isset($_GET['amount'])) { $paymentRequest->set_amount($_GET['amount']); } if (isset($_GET['paymentInfo'])) { $paymentRequest->set_payment_info($_GET['paymentInfo']); } $url = Easypay_request::get_checkout_page_url($config, $paymentRequest);
ini_set('display_errors', 'On'); error_reporting(E_ALL); include '../easypay.lib/Direct_payment_request.php'; include '../easypay.lib/Checkout_page_request.php'; include '../easypay.lib/Easypay_config.php'; include '../easypay.lib/Easypay_request.php'; include '../easypay.lib/Signature.php'; use easpaylib\Checkout_page_request; use easpaylib\Easypay_config; use easpaylib\Easypay_request; use easpaylib\Signature; $paymentRequest = new Checkout_page_request(); $paymentRequest->set_adult_content(false); $paymentRequest->set_amount(50); $paymentRequest->set_payment_info("Test"); $config = new Easypay_config(); $config->set_basepath("/test-service"); $config->set_host("easypay-test.swisscom.ch"); $config->set_merchant_id("test-merchant"); $config->set_easypay_secret("test-secret-987654321"); echo "<h3>Test Signature</h3>"; $data = json_encode(array("key" => "test-value", "adultContent" => false, "amount" => 50.5)); $secret = $config->get_easypay_secret(); $signature = base64_encode(Signature::sign($data, $secret)); $expected = "Zq3zcquJgdNNK/3HhFmVBTNX2+Y="; $actual = $signature; $assert = $expected == $actual ? "PASSED" : "FAILED"; echo "expected " . $expected . $endOfLine; echo "actual " . $actual . $endOfLine; echo "Test Signature: " . $assert . $endOfLine; echo "--------------------------------------------------------------------" . $endOfLine;