From 14c2ee5854752da94aa159230509a7091204ad42 Mon Sep 17 00:00:00 2001
From: Regis Houssin <regis@dolibarr.fr>
Date: Wed, 25 May 2011 14:01:42 +0000
Subject: [PATCH] Works on paypal module Fix: force to credit card

---
 htdocs/compta/paiement.php        | 2 +-
 htdocs/paypal/ajaxtransaction.php | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php
index 5dff8710940..5aca37bd243 100644
--- a/htdocs/compta/paiement.php
+++ b/htdocs/compta/paiement.php
@@ -311,7 +311,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
 
         // Payment mode
         print '<tr><td><span class="fieldrequired">'.$langs->trans('PaymentMode').'</span></td><td>';
-        $html->select_types_paiements(GETPOST('paiementcode'),'paiementcode','',2);
+        $html->select_types_paiements((GETPOST('paiementcode')?GETPOST('paiementcode'):$facture->mode_reglement_code),'paiementcode','',2);
         print "</td>\n";
         print '<td rowspan="'.$rowspan.'" valign="top">';
         print '<textarea name="comment" wrap="soft" cols="60" rows="'.ROWS_4.'">'.(empty($_POST['comment'])?'':$_POST['comment']).'</textarea></td>';
diff --git a/htdocs/paypal/ajaxtransaction.php b/htdocs/paypal/ajaxtransaction.php
index f97e01efb66..4eed07e977f 100644
--- a/htdocs/paypal/ajaxtransaction.php
+++ b/htdocs/paypal/ajaxtransaction.php
@@ -160,9 +160,11 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti
             $object->socid=$soc->id;
             $object->fetch_thirdparty();
 
-            $object->date		= dol_now();
-            $object->ref_int	= $_SESSION[$_GET['transaction_id']]['TRANSACTIONID'];
-            $shipamount			= ($_SESSION[$_GET['transaction_id']]['SHIPPINGAMT']?$_SESSION[$_GET['transaction_id']]['SHIPPINGAMT']:$_SESSION[$_GET['transaction_id']]['SHIPAMOUNT']);
+            $object->date				= dol_now();
+            $object->mode_reglement_id 	= 6; // Credit card by default
+            $object->cond_reglement_id	= 1;
+            $object->ref_int			= $_SESSION[$_GET['transaction_id']]['TRANSACTIONID'];
+            $shipamount					= ($_SESSION[$_GET['transaction_id']]['SHIPPINGAMT']?$_SESSION[$_GET['transaction_id']]['SHIPPINGAMT']:$_SESSION[$_GET['transaction_id']]['SHIPAMOUNT']);
 
             $object_id = $object->create($user);
             if ($object_id > 0)
-- 
GitLab