If you are not already check connection to PayWay Rest API, you need to do that validation. Follow the below link to test API connection, there you can learn about public and private key.
If you are interested more on PayWay Rest API you can visit the below link:
Below is a PHP script to create credit card payment. Be aware that below code snippet used both private and public key in different section.
<?php include_once "CurlExecutor.php"; define("BASE_URL", "https://api.payway.com.au/rest/v1"); define("MERCHANT_ID", "TEST"); define("PRIVATE_KEY", "T10487_SEC_..."); define("PUBLIC_KEY", "T10487_PUB_..."); createPayment(getSingleUseToken()); function createPayment($token) { $headers[] = "Authorization: Basic " . base64_encode(PRIVATE_KEY . ":"); $headers[] = "Content-Type: application/x-www-form-urlencoded"; $post = array( "singleUseTokenId" => $token, "customerNumber" => "Customer-ID", "transactionType" => "payment", "principalAmount" => "12.34", "currency" => "aud", "orderNumber" => "Sale-Identification", "merchantId" => MERCHANT_ID ); $result = CurlExecutor::execute(BASE_URL . "/transactions", "POST", $post, null, $headers); $result["response"] = json_decode($result["response"]); CurlExecutor::prettyPrint($result); } function getSingleUseToken() { $headers[] = "Authorization: Basic " . base64_encode(PUBLIC_KEY . ":"); $headers[] = "Content-Type: application/x-www-form-urlencoded"; $post = array( "paymentMethod" => "creditCard", "cardNumber" => "5163200000000008", "cardholderName" => "My Mastercard", "cvn" => "070", "expiryDateMonth" => "08", "expiryDateYear" => "20", ); $result = CurlExecutor::execute(BASE_URL . "/single-use-tokens", "POST", $post, null, $headers); $result["response"] = json_decode($result["response"]); if ($result["code"] == 200) { return $result["response"]->singleUseTokenId; } CurlExecutor::prettyPrint($result); die("Error"); } ?>
Below is output of valid payment:
Array ( [code] => 201 [response] => stdClass Object ( [transactionId] => 1957973936 [receiptNumber] => 1957973936 [status] => approved [responseCode] => 08 [responseText] => Honour with identification [transactionType] => payment [customerNumber] => CUSTOMER-ID [customerName] => My Mastercard [orderNumber] => Sale-Identification [currency] => aud [principalAmount] => 12.34 [surchargeAmount] => 0 [paymentAmount] => 12.34 [paymentMethod] => creditCard [creditCard] => stdClass Object ( [cardNumber] => 516320...008 [expiryDateMonth] => 08 [expiryDateYear] => 20 [cardScheme] => mastercard [cardholderName] => My Mastercard ) [merchant] => stdClass Object ( [merchantId] => TEST [merchantName] => Test Merchant [links] => Array ( [0] => stdClass Object ( [rel] => self [href] => https://api.payway.com.au/rest/v1/merchants/TEST ) ) ) [transactionDateTime] => 10 Jun 2017 11:57 AEST [settlementDate] => 10 Jun 2017 [isVoidable] => 1 [isRefundable] => [links] => Array ( [0] => stdClass Object ( [rel] => self [href] => https://api.payway.com.au/rest/v1/transactions/1957973936 ) [1] => stdClass Object ( [rel] => void [href] => https://api.payway.com.au/transactions/1957973936/void ) ) ) )