How to payment using keap pro, I am trying to payment but its giveing me an error for payment?

Here is my code please check…
function collide_stripe_create_customer() {
if(empty(session_id())) {
session_start();
}
$infusionsoft = new \Infusionsoft\Infusionsoft(array(
‘clientId’ => ‘ABC’,
‘clientSecret’ => ‘DEF’,
‘redirectUri’ => ‘https://collidedigital.com/dev/infusion’,
));

if(isset(_SESSION['token'])) { if(isset(_SESSION[‘token’])) {
infusionsoft->setToken(unserialize(_SESSION[‘token’]));
}
if(isset($_SESSION[‘token’])) {
$infusionsoft->refreshAccessToken();
}
if (infusionsoft->getToken()) { // Save the serialized token to the current session for subsequent requests _SESSION[‘token’] = serialize($infusionsoft->getToken());

      // MAKE INFUSIONSOFT REQUEST
      $infusionsoft->setToken(unserialize($_SESSION['token']));
  }

  //return array
  $return = [];
  //create contact in infusion soft
  if(isset($_POST['name']) && isset($_POST['last_name']) && isset($_POST['email'])) {
      $search_contact = $infusionsoft->contacts('xml')->findByEmail($_POST['email'], ['Id']);
      if(!empty($search_contact)){
          if(isset($search_contact[0]['Id'])) {
              $return['contact_created'] = 2;
          }
      } else {
          $contact_created = $infusionsoft->contacts('xml')->add(array('FirstName' => $_POST['name'], 'LastName'=>$_POST['last_name'], 'Email' => $_POST['email']), 'Email');

          if(!empty($contact_created)) {
              $return['contact_created'] = 1;
          } else {
              $return['contact_created'] = 0;
          }
      }
  }

     
  //create credit card for contact if contact created successfully
  if(isset($_POST['card_holder']) && isset($_POST['card_no']) && isset($_POST['card_exp_m']) && isset($_POST['card_exp_y']) && isset($_POST['card_cvv']) && isset($_POST['country'])){
      if($return['contact_created'] == 1){
          if(isset($contact_created)){
            $fname = $_POST['name'];
            $lname = $_POST['last_name'];
            $card_holder_name = $_POST['card_holder'];
            $card_type = $_POST['card_type'];
            $card_no = $_POST['card_no'];
            $card_exp_m = $_POST['card_exp_m'];
            $card_exp_y = $_POST['card_exp_y'];
            $card_cvv = $_POST['card_cvv'];
            $address1 = $_POST['address1'];
            $city = $_POST['city'];
            $zip = $_POST['zip'];
            $state = $_POST['state'];
            $country = $_POST['country'];
            $table = 'CreditCard';
            $email = $_POST['email'];
            $values = array(
              'ContactId'  => $contact_created,
              'CardType'  =>  "$card_type",
              'NameOnCard' =>  "$card_holder_name",
              'CardNumber' => $card_no,
              'FirstName'  => $fname,
              'LastName' => $lname,
              'ExpirationMonth' => $card_exp_m,
              'ExpirationYear' => $card_exp_y,
              'CVV2' => $card_cvv,
              'BillCountry' => $country,
              'BillZip' => $zip,
              'BillCity' => $city,
              'BillState' => $state,
              'Status' => 3,
              'Email' => $email,
              'BillAddress1' => $address1,
            );	

            $card = $infusionsoft->data()->add($table, $values);
              if($card) {
                  $return['contact_credit_card'] = 1;
                  $card_valid = $infusionsoft->invoices()->validateCreditCard($card_type, $card_no, $contact_created, $card_exp_m, $card_exp_y, $card_cvv);
                  if($card_valid['Valid']){
                      $return['contact_credit_card_valid'] = 1;
                  } else {
                      $return['contact_credit_card_valid'] = 0;
                  }
              } else {
                  $return['contact_credit_card'] = 0;
              }
          }
      }
  }

 


  //check for subscription plan
  $plan_id = 0;
  if(isset($_POST['start_date']) && isset($_POST['payment_frequency']) && isset($_POST['payment_cycle']) && isset($_POST['plan_id'])){
      $product_selected        = $_POST['plan_id'];
      $start_date              = $_POST['start_date'];
      $payment_frequency = $_POST['payment_frequency'];
      $payment_cycle = $_POST['payment_cycle'];
      $plan_exist = false;
      if($return['contact_created'] == 1){
          if(isset($contact_created)){
              $subscription_plans = $infusionsoft->data()->query("SubscriptionPlan", 1000, 0, ['ProductId' => $product_selected], ['Id', 'Cycle', 'NumberOfCycles', 'PlanPrice'], 'Id', false);
              if(!empty($subscription_plans)) {
                  foreach($subscription_plans as $subscription_plan) {
                      if($subscription_plan['NumberOfCycles'] == $payment_cycle && $subscription_plan['Cycle'] == $payment_frequency) {
                          $plan_id = $subscription_plan['Id'];
                          break;
                      }
                  }
              }
              if($plan_id != 0) {
                  $return['subscription_plan_added'] = 2;
              } else {
                  $product = $infusionsoft->data()->query("Product", 10, 0, ['Id' => $product_selected], ['Id', 'ProductName', 'ProductPrice'], 'Id', false);
                  $table = 'SubscriptionPlan';
                  $values = array(
                      'Active' => true,
                      'Cycle' => $payment_frequency,
                      'Frequency' => 1,
                      'NumberOfCycles' => $payment_cycle,
                      'PlanPrice' => $product[0]['ProductPrice'],
                      'ProductId' => $product_selected,
                  );
                  $subs_added = $infusionsoft->data()->add($table, $values);
                  if($subs_added) {
                      $return['subscription_plan_added'] = 1;
                  } else {
                      $return['subscription_plan_added'] = 0;
                  }
              }
          }
      }
  } 

   //Create an order for the user and start subscription for the product
  if($return['subscription_plan_added'] == 2) {
      $product_selected =  $_POST['plan_id'];
      if($return['contact_created'] == 1) {
          if(isset($contact_created)){
              if($plan_id != 0) {
                  $contactID = $contact_created;
                  //get contact credit card
                  $credit_card = $infusionsoft->data()->query("CreditCard", 10, 0, ['ContactId' => $contactID], ['Id'], 'Id', false);
                  $cardID = $credit_card[0]['Id'];
                  //plan ID
                  $planID = 0;
                  //products ID array
                  $productIDs = array();
                  //subscription ID array for user subscription
                  $subscriptionIDs = array($plan_id);
                  //Process Specical
                  $processSpecials = false;
                  //promo code array
                  $promoCodes = array();
                  //lead affiliate ID
                  $leadAffiliateID = 0;
                  //sale affiliate ID
                  $saleAffiliateID = 0;

                 $create_order = $infusionsoft->orders('xml')->placeOrder($contactID, $cardID, $planID, $productIDs, $subscriptionIDs, $processSpecials, $promoCodes, $leadAffiliateID, $saleAffiliateID);

                  if($create_order) {
                       //Payment
                        $invoiceId = $create_order['InvoiceId'];
                        $plan_price = $_POST['plan_price'];
                        $notes = 'payment made';
                        $creditCardID = $cardID;
                        $merchantAccountID = 0;
                        $bypassComissions = false;
                        $charge = $infusionsoft->invoices('xml')->addManualPayment((int)$invoiceId, (float)$plan_price, date('Ymd\TH:i:s'), 'API', 'A Manual Payment from the API' $bypassComissions);
                       // $charge = $infusionsoft->invoices('xml')->chargeInvoice($invoiceId, 'Test payment', $creditCardID, false);
                        if($charge) {
                          $return['payment_made'] = 1;
                        } else {
                          $return['payment_made'] = 0;
                        }
                        
                      $return['order_and_subcription_added'] = 1;
                      
                  } else {
                      $return['order_and_subcription_added'] = 0;
                  }
              }
          }
      }
  }else {
      if($return['subscription_plan_added'] == 1) {
          $product_selected =  $_POST['plan_id'];
          if($return['contact_created'] == 1) {
              if(isset($contact_created)){
                  if($plan_id == 0) {
                      $contactID = $contact_created;
                      //get contact credit card
                      $credit_card = $infusionsoft->data()->query("CreditCard", 10, 0, ['ContactId' => $contactID], ['Id'], 'Id', false);
                      $cardID = $credit_card[0]['Id'];
                      //plan ID
                      $planID = 0;
                      //products ID array
                      $productIDs = array();
                      //subscription ID array for user subscription
                      $subscription_plans = $infusionsoft->data()->query("SubscriptionPlan", 1000, 0, ['ProductId' => $product_selected], ['Id', 'Cycle', 'NumberOfCycles', 'PlanPrice'], 'Id', false);
                      if(!empty($subscription_plans)) {
                          foreach($subscription_plans as $subscription_plan) {
                              if($subscription_plan['NumberOfCycles'] == $payment_cycle && $subscription_plan['Cycle'] == $payment_frequency) {
                                  $plan_id = $subscription_plan['Id'];
                                  break;
                              }
                          }
                      }
                      $subscriptionIDs = array($plan_id);
                      //Process Specical
                      $processSpecials = false;
                      //promo code array
                      $promoCodes = array();
                      //lead affiliate ID
                      $leadAffiliateID = 0;
                      //sale affiliate ID
                      $saleAffiliateID = 0;

                      if($plan_id != 0) {
                          $create_order = $infusionsoft->orders('xml')->placeOrder($contactID, $cardID, $planID, $productIDs, $subscriptionIDs, $processSpecials, $promoCodes, $leadAffiliateID, $saleAffiliateID);
                      } else {
                          $create_order = false;
                      }

                    if($create_order) {
                       //Payment
                        $invoiceId = $create_order['InvoiceId'];
                        $plan_price = $_POST['plan_price'];
                        $notes = 'payment made';
                        $creditCardID = $cardID;
                        $merchantAccountID = 0;
                        $bypassComissions = false;
                         $charge = $infusionsoft->invoices('xml')->addManualPayment((int)$invoiceId,(float)$plan_price, date('Ymd\TH:i:s'), 'API', 'A Manual Payment from the API' $bypassComissions);
                        //$charge = $infusionsoft->invoices('xml')->chargeInvoice((int)$invoiceID, $notes, $creditCardID, $merchantAccountID, $bypassComissions);
                        if($charge) {
                          $return['payment_made'] = 1;
                        } else {
                          $return['payment_made'] = 0;
                        }
                        
                      $return['order_and_subcription_added'] = 1;
                      
                  } else {
                          $return['order_and_subcription_added'] = 0;
                      }
                  }
              }
          }
      }
  }

}
echo json_encode($return);
die();
}
add_action(‘wp_ajax_collide_stripe_create_customer’, ‘collide_stripe_create_customer’);
add_action(‘wp_ajax_nopriv_collide_stripe_create_customer’, ‘collide_stripe_create_customer’);