Beispiel #1
0
 function paymentPaypal($order_id, $amount = 0)
 {
     global $_ARRAYLANG;
     if (isset($_GET['result'])) {
         $result = $_GET['result'];
         switch ($result) {
             case -1:
                 // Go validate PayPal IPN
                 $this->paymentPaypalIpn($order_id, $amount);
                 die;
             case 0:
                 // Payment failed
                 break;
             case 1:
                 // The payment has been completed.
                 // The notification with result == -1 will update the order.
                 // This case only redirects the customer to the list page with
                 // an appropriate message according to the status of the order.
                 $order_state = self::GetOrderValue('order_state', $order_id);
                 if ($order_state == 1) {
                     $product_id = self::GetOrderValue('order_product', $order_id);
                     return self::getSuccessMessage($product_id);
                 } elseif ($order_state == 0) {
                     if (self::GetSettings('set_paypal_ipn') == 1) {
                         return 'alert("' . $_ARRAYLANG['TXT_EGOV_PAYPAL_IPN_PENDING'] . "\");\n";
                     }
                 }
                 break;
             case 2:
                 // Payment was cancelled
                 return 'alert("' . $_ARRAYLANG['TXT_EGOV_PAYPAL_CANCEL'] . "\");\n";
         }
         return 'alert("' . $_ARRAYLANG['TXT_EGOV_PAYPAL_NOT_VALID'] . "\");\n";
     }
     $product_id = self::getOrderValue('order_product', $order_id);
     if (empty($product_id)) {
         return 'alert("' . $_ARRAYLANG['TXT_EGOV_ERROR_UPDATING_ORDER'] . '");' . "\n";
     }
     // Prepare payment
     $paypalUriIpn = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?section=Egov&handler=paypal&result=-1";
     $paypalUriNok = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?section=Egov&handler=paypal&result=0";
     $paypalUriOk = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?section=Egov&handler=paypal&result=1";
     $objPaypal = new Paypal();
     $product_id = self::GetOrderValue('order_product', $order_id);
     if (empty($product_id)) {
         return 'alert("' . $_ARRAYLANG['TXT_EGOV_ERROR_PROCESSING_ORDER'] . "\");\n";
     }
     $product_name = self::GetProduktValue('product_name', $product_id);
     $product_amount = self::GetProduktValue('product_price', $product_id);
     $quantity = self::GetProduktValue('product_per_day', $product_id) == 'yes' ? intval($_REQUEST['contactFormField_Quantity']) : 1;
     if ($product_amount <= 0) {
         return '';
     }
     $objPaypal->add_field('business', self::GetProduktValue('product_paypal_sandbox', $product_id));
     $objPaypal->add_field('return', $paypalUriOk);
     $objPaypal->add_field('cancel_return', $paypalUriNok);
     $objPaypal->add_field('notify_url', $paypalUriIpn);
     $objPaypal->add_field('item_name', $product_name);
     $objPaypal->add_field('amount', $product_amount);
     $objPaypal->add_field('quantity', $quantity);
     $objPaypal->add_field('currency_code', self::GetProduktValue('product_paypal_currency', $product_id));
     $objPaypal->add_field('custom', $order_id);
     //die();
     $objPaypal->submit_paypal_post();
     die;
 }