We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18913
    • 654 Posts
    Okay. Well, I haven’t tried this, but I guess you could just remove the lines that deal with "userid" in the code posted above and substitute some logic to determine that the order info is in fact in the Shopkeeper module:
          //$user = $modx->userLoggedIn();
          //$userId = $user['id'];
          //$user_purchase_query = $modx->db->select("*", $dbprefix."web_user_settings", "webuser = $userId", "", "");
          //if($modx->db->getRecordCount($user_purchase_query)>0){
          if ( additional_logic_here ) {
    	// Specify the product information
    	$myPaypal->addField('item_name', $order_id);
    	$myPaypal->addField('amount', $price);
    	//$myPaypal->addField('item_number', $userId);
    
    	// Specify any custom value
    	//$myPaypal->addField('custom', 'SHK test '.$userId);
         }
    


    But that’s just a guess on my part ...
    MattC
      • 8345
      • 147 Posts
      Thanks mate:) I made it now! Getting headache getting Shopkeeper working multilingual with YAMS snippet or whatever can do it.
        • 8345
        • 147 Posts
        Do you have an idea how to make the PayPal optional? So you can choose PayPal or bank transfer. If bank transfer then next page will tell the account number, etc.
          • 18913
          • 654 Posts
          I’m not sure I can help with that. What gateway do bank transfers use?
          MattC
            • 8345
            • 147 Posts
            Bank transfer just means that bank account number is given and customer must make bank transfer himself.

            I actually thought that maybe someone knows how to make it so that if I choose at checkout from drop-down menu "PayPal" then it will take me to the page with [!shk_paypal!] call and if "Wire transfer" then to the page with bank details but at the moment I solved it "cheaply" so that after ordering page it just says: "Thank you! Your order is sent. If you chose PayPal as payment method then click here" and then if clicked it will take to the page with [!shk_paypal!
              • 9995
              • 1,613 Posts
              hi, i have a question, is it possible to add the Amount popup when order/add a product will always be visible? I'd like to be able to select the amount first and then click on Add.

                Evolution user, I like the back-end speed and simplicity smiley
                • 36613
                • 328 Posts
                Quote from: mconsidine at Dec 11, 2009, 12:54 PM
                Hi,
                Here's what I did. No doubt there's a better way wink (I'll assume you're okay to the point of getting the Shopkeeper orderform correctly called.

                - For the gateway code, I used what is found here :

                http://www.phpfour.com/blog/2009/02/php-payment-gateway-library-for-paypal-authorizenet-and-2checkout/

                - I created the following folder
                assets/snippets/payments
                and put the contents of the ZIP file found at the location above there. So that is where Paypal.php,
                PaymentGateway.php, et. al. live.
                - In MODx, I created a snippet called

                shk_paypal

                - The contents of the snippet are what was referred to above. But I'll include it again here anyway :
                <!--?php
                //MattC start
                //function sendOrderToPayPal() {
                 global $modx;
                 $base_dir = $modx--->config['rb_base_dir'];
                
                  $dbname = $modx->db->config['dbase'];
                  $dbprefix = $modx->db->config['table_prefix'];
                  $mod_table = $dbprefix."manager_shopkeeper";
                  $mod_config_table = $dbprefix."manager_shopkeeper_config";
                  $reportTpl = $_SESSION['reporttpl'] ? $_SESSION['reporttpl'] : $fields['reportTpl'];
                  $userLogged =  isset($_SESSION['webValidated']) ? true : false;
                
                    //Get online payment info
                    $order_id = $_SESSION['shk_order_id'];
                    $fields['payment'] = $_SESSION['shk_payment_method'];
                    $price = $_SESSION['shk_order_price'];
                    $currency = $_SESSION['shk_currency'];
                    $userId = $_SESSION['shk_order_user_id'];
                
                  require_once $base_dir."snippets/payment/PaymentGateway.php";
                  require_once $base_dir."snippets/payment/Paypal.php";
                
                	// Create an instance of the paypal library
                	$myPaypal = new Paypal();
                	// Specify your paypal email
                	$myPaypal->addField('business', 'your_developer_paypal_test_store_email');
                	// Specify the currency
                	$myPaypal->addField('currency_code', 'USD');
                	// Specify the url where paypal will send the user on success/failure
                	$myPaypal->addField('return', 'http://your_MODx_website/index.php?id=88');
                	$myPaypal->addField('cancel_return', 'http://your_MODx_website/index.php?id=95');
                	// Specify the url where paypal will send the IPN
                	$myPaypal->addField('notify_url', 'http://your_MODx_website/index.php?id=96');
                
                
                      $user = $modx->userLoggedIn();
                      $userId = $user['id'];
                      $user_purchase_query = $modx->db->select("*", $dbprefix."web_user_settings", "webuser = $userId", "", "");
                      if($modx->db->getRecordCount($user_purchase_query)>0){
                
                	// Specify the product information
                	$myPaypal->addField('item_name', $order_id);
                	$myPaypal->addField('amount', $price);
                	$myPaypal->addField('item_number', $userId);
                
                	// Specify any custom value
                	$myPaypal->addField('custom', 'SHK test '.$userId);
                     }
                
                	// Enable test mode if needed	
                	$myPaypal->enableTestMode();
                
                	// Let's start the train!
                	$myPaypal->submitPayment();
                
                  return true;
                //}
                //MattC end
                ?>
                

                (You'll see that a lot of the values that I used for the fields don't make a lot of sense. I was just trying to get info going out and back. Also, I've never been clear on how the IPN page is supposed to work...)

                - Over in the document pane, I created a new document whose content is
                    [!shk_paypal!]
                

                It's document ID is 97.

                - On my orderform, I changed my call to go to the paypal snippet document instead of the thank you page. So
                "gotoid" was changed to 97 :
                  [!Shopkeeper? &lang=`en` ¤cy=`USD` &cartType=`full` &orderFormPage=`[*id*]`!]
                  [!eForm? &formid=`shopOrderForm`&tpl=`shopOrderForm`&report=`shopOrderReport`&vericode=`1`&ccsender=`1`&gotoid=`97`&subject=`SHK order`&eFormOnBeforeMailSent=`populateOrderData`&eFormOnMailSent=`sendOrderToManager`!]
                

                (The thank you/cancel pages are dealt with in the shk_paypal snippet)

                Finally, note that this is set up so that you have to be logged in as a webuser in order to send an order as the code I pulled from Shopkeeper (if I remember correctly) queries the database for order info that has been entered.

                I think that's it. Hope this helps. Feedback/discussion would be appreciated, particularly as it appears this payment gateway class can handle more than just Paypal.

                Regards,
                MattC

                You can give me gateway code ?