function paypalexpress_orderformcheckout($params) { $orderid = get_query_val("tblorders", "id", array("invoiceid" => $params['invoiceid'])); update_query("tblhosting", array("paymentmethod" => "paypal"), array("orderid" => $orderid, "paymentmethod" => "paypalexpress")); update_query("tblhostingaddons", array("paymentmethod" => "paypal"), array("orderid" => $orderid, "paymentmethod" => "paypalexpress")); update_query("tbldomains", array("paymentmethod" => "paypal"), array("orderid" => $orderid, "paymentmethod" => "paypalexpress")); $finalPaymentAmount = $_SESSION['Payment_Amount']; $postfields = array(); $postfields['TOKEN'] = $_SESSION['paypalexpress']['token']; $postfields['PAYERID'] = $_SESSION['paypalexpress']['payerid']; $postfields['PAYMENTREQUEST_0_PAYMENTACTION'] = "SALE"; $postfields['PAYMENTREQUEST_0_AMT'] = $params['amount']; $postfields['PAYMENTREQUEST_0_CURRENCYCODE'] = $params['currency']; $postfields['IPADDRESS'] = $_SERVER['SERVER_NAME']; $results = paypalexpress_api_call($params, "DoExpressCheckoutPayment", $postfields); $ack = strtoupper($results['ACK']); if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { $transactionId = $results['PAYMENTINFO_0_TRANSACTIONID']; $transactionType = $results['PAYMENTINFO_0_TRANSACTIONTYPE']; $paymentType = $results['PAYMENTINFO_0_PAYMENTTYPE']; $orderTime = $results['PAYMENTINFO_0_ORDERTIME']; $amt = $results['PAYMENTINFO_0_AMT']; $currencyCode = $results['PAYMENTINFO_0_CURRENCYCODE']; $feeAmt = $results['PAYMENTINFO_0_FEEAMT']; $settleAmt = $results['PAYMENTINFO_0_SETTLEAMT']; $taxAmt = $results['PAYMENTINFO_0_TAXAMT']; $exchangeRate = $results['PAYMENTINFO_0_EXCHANGERATE']; $paymentStatus = $results['PAYMENTINFO_0_PAYMENTSTATUS']; if ($paymentStatus == "Completed") { return array("status" => "success", "transid" => $transactionId, "fee" => $feeAmt, "rawdata" => $results); } if ($paymentStatus == "Pending") { return array("status" => "payment pending", "rawdata" => $results); } return array("status" => "invalid status", "rawdata" => $results); } return array("status" => "error", "rawdata" => $results); }
$whmcs->load_function("invoice"); $GATEWAY = getGatewayVariables("paypalexpress"); if (!$GATEWAY['type']) { exit("Module Not Activated"); } $token = ""; if (isset($_REQUEST['token'])) { $token = $_REQUEST['token']; } if (!$token) { logTransaction("PayPal Express Callback", $_REQUEST, "Missing Token"); exit; } $postfields = array(); $postfields['TOKEN'] = $token; $results = paypalexpress_api_call($GATEWAY, "GetExpressCheckoutDetails", $postfields); $ack = strtoupper($results['ACK']); if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") { logTransaction("PayPal Express Callback", $results, "Successful"); $email = $results['EMAIL']; $payerId = $results['PAYERID']; $payerStatus = $results['PAYERSTATUS']; $salutation = $results['SALUTATION']; $firstName = $results['FIRSTNAME']; $middleName = $results['MIDDLENAME']; $lastName = $results['LASTNAME']; $suffix = $results['SUFFIX']; $cntryCode = $results['COUNTRYCODE']; $business = $results['BUSINESS']; $shipToName = $results['PAYMENTREQUEST_0_SHIPTONAME']; $shipToStreet = $results['PAYMENTREQUEST_0_SHIPTOSTREET'];