// with a valid ApiContext (See bootstrap.php for more on `ApiContext`) // The return object contains the state. try { $payment->create($apiContext); //Update Order in database $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $order_id = ''; for ($j = 0; $j < 6; $j++) { $order_id .= $characters[rand(0, $charactersLength - 1)]; } date_default_timezone_set('Asia/Singapore'); $payment_time = date('Y-m-d H:i:s'); foreach ($orderList as $order) { //Add order information into database $orderMgr->addOrder($order_id, $order["customer_id"], $order["product_id"], $order["quantity"], $payment_time, $order["price"]); if ($order["product_id"] != "gift") { //Update Customer Shopping cart $productMgr->updateShoppingCartPayTime($order["customer_id"], $order["product_id"], $order["add_to_cart_time"]); } } } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY //ResultPrinter::printError('Create Payment Using Credit Card. If 500 Exception, try creating a new Credit Card using <a href="https://ppmts.custhelp.com/app/answers/detail/a_id/750">Step 4, on this link</a>, and using it.', 'Payment', null, $request, $ex); $redirectUrl = $payment->getRedirectUrls(); var_dump($redirectUrl->getCancelUrl()); //header("Location: ".$redirectUrl->getCancelUrl()); exit(1); } $redirectUrl = $payment->getRedirectUrls(); header("location: " . $redirectUrl->getReturnUrl());