private function create_order($data, $response, $status = 3) { $card_type = cc_type_number($data["payflow_cc_num"]); $details = array("Method" => "Paypal Payflow Pro", "Card Type" => $card_type, "Card" => 'XXXX' . substr($data["payflow_cc_num"], -4, 4), "Approval Code" => $response["AUTHCODE"], "Transaction ID" => $response["PNREF"]); $trans = array('status' => $status, 'transaction_id' => $response["PNREF"], 'payment_card' => 'XXXX' . substr($data["payflow_cc_num"], -4, 4), 'payment_type' => 'Authorize', 'amount' => $data["order_total"], 'details' => serialize($details), 'approval' => $response["RESPMSG"]); return $trans; }
public function process($data, $config) { // Pass the store currency to the gateway $config["currency_code"] = $this->_config["currency"]; // Create instance of the phpPayPal class $paypal = new phpPayPal($config); // (required) $paypal->ip_address = $_SERVER['REMOTE_ADDR']; // Order Totals (amount_total is required) $paypal->amount_total = $data["order_total"]; $paypal->amount_tax = $data["cart_tax"]; $paypal->amount_shipping = $data["cart_shipping"]; // Credit Card Information (required) $paypal->credit_card_number = $data["autho_cc_num"]; #$paypal->credit_card_type = 'Visa'; $paypal->cvv2_code = $data["autho_cc_code"]; $paypal->expire_date = $data["autho_cc_month"] . $data["autho_cc_year"]; // Billing Details (required) $paypal->first_name = $data["br_billing_fname"]; $paypal->last_name = $data["br_billing_lname"]; $paypal->address1 = $data["br_billing_address1"]; $paypal->address2 = $data["br_billing_address2"]; $paypal->city = $data["br_billing_city"]; $paypal->state = $data["br_billing_state"]; $paypal->postal_code = $data["br_billing_zip"]; $paypal->phone_number = $data["br_billing_phone"]; $paypal->country_code = $data["br_billing_country"]; // Shipping Details (NOT required) #$paypal->email = '*****@*****.**'; $paypal->shipping_name = $data["br_shipping_fname"] . ' ' . $data["br_shipping_lname"]; $paypal->shipping_address1 = $data["br_shipping_address1"]; $paypal->shipping_address2 = $data["br_shipping_address2"]; $paypal->shipping_city = $data["br_shipping_city"]; $paypal->shipping_state = $data["br_shipping_state"]; $paypal->shipping_postal_code = $data["br_shipping_zip"]; $paypal->shipping_country_code = $data["br_shipping_country"]; // Add Order Items (NOT required) - Name, Number, Qty, Tax, Amt // Repeat for each item needing to be added $total = 0; foreach ($data["cart"]["items"] as $item) { $p = number_format($item["price"], 2); $paypal->addItem($item["title"], $item["product_id"], $item["quantity"], 0, $p); $total += $item["quantity"] * $p; } if ($data["cart_discount"] != 0) { $d = number_format($data["cart_discount"] * -1, 2); $paypal->addItem('Discount', 'Discount', 1, 0, $d); $total += $d; } // Perform the payment $paypal->do_direct_payment(); $resp = $paypal->Response; // Get the card type from the number $card_type = cc_type_number($data["autho_cc_num"]); if (strtoupper($resp["ACK"]) != "SUCCESS" && strtoupper($resp["ACK"]) != "SUCCESSWITHWARNING") { $trans = array('error' => $resp["L_LONGMESSAGE0"]); } else { //Check for subscriptions $subscription = array(); foreach ($data["cart"]["items"] as $item) { if ($item["type_id"] == 6) { $subResp = $this->create_subscription($item, $data, $config); $subArr = $this->_parse_return($subResp); if ($subArr[1] == 'Ok') { $subscription[] = array_merge($item, $subArr); } else { #debug print_r($arr); } } } // Set the transaction details into // a serialized array for posting to // the order $details = array("Method" => "PayPal Pro", "Card Type" => $card_type, "Card" => 'XXXX' . substr($data["autho_cc_num"], -4, 4), "Approval Code" => $resp["CORRELATIONID"], "Transaction ID" => $resp["TRANSACTIONID"]); // Return the trans details $trans = array('status' => 3, 'transaction_id' => $resp["TRANSACTIONID"], 'payment_card' => 'XXXX' . substr($data["autho_cc_num"], -4, 4), 'payment_type' => 'Authorize', 'amount' => $data["order_total"], 'details' => serialize($details), 'approval' => $resp["CORRELATIONID"], 'subscription' => $subscription); } return $trans; }