function paywith_credit_card() { // print_r($_POST); // exit; if ($_POST) { $is_sandbox = 0; $total_order_price_final = $_POST["total"]; $localized_currency = $_POST["currency"]; $item_name = $_POST["item_name"]; $ccnumber = trim($_POST["ccnumber"]); $return_url = $_POST["return"]; $full_name = $_POST["username"]; //$cc_type = trim($_POST["cc_type"]); $expiration_month = trim($_POST["expiration_month"]); $expiration_year = trim($_POST["expiration_year"]); $monthyear = $expiration_month . $expiration_year; $cvv = trim($_POST["cvv"]); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://api.worldpay.com/v1/tokens", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"reusable\":false,\"paymentMethod\":{\"type\":\"Card\",\"expiryMonth\":\"$expiration_month\",\"name\":\"$full_name\",\"expiryYear\":\"$expiration_year\",\"cardNumber\":\"$ccnumber\",\"cvc\":\"$cvv\"},\"clientKey\":\"T_C_dadb0812-3066-490f-9c02-e09f03657b1e\",\"shopperLanguageCode\":\"EN\"}", CURLOPT_HTTPHEADER => array( 'Content-Type: application/json', "Postman-Token: 0dcc35eb-bc57-4686-9705-3ef0aa2cae01", "cache-control: no-cache" ), )); $curl_response = json_decode(curl_exec($curl)); $err = curl_error($curl); curl_close($curl); if ($err) { $response["result"] = "0"; $response["text"] = $err; } else { $total_order_price_final = $total_order_price_final * 100; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://api.worldpay.com/v1/orders", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\n \"token\" : \"$curl_response->token\",\n \"orderDescription\" : \"$item_name\",\"customerOrderCode\":\"$tracking_code\",\"name\":\"$full_name\",\n \"amount\" : $total_order_price_final,\n \"currencyCode\" : \"$localized_currency\"\n}", CURLOPT_HTTPHEADER => array( "Authorization: T_S_82c9052e-3590-4a62-90b6-b56ac06f3633", "Content-type: application/json", "Postman-Token: 4db09bbb-8d4f-4d67-a61b-589895f8caf0", "cache-control: no-cache" ), )); $curl_response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { $response["result"] = "0"; $response["text"] = $err; } else { $order_response = json_decode($curl_response); $response["result"] = "1"; $response["text"] = '

Thank You very much.

we have received your payment!

'; } } echo json_encode($response); } exit; }