Results 1 to 3 of 3

Thread: Paypal integration - php change url when submitting

  1. #1
    Sencha User
    Join Date
    Dec 2012
    Posts
    6
    Answers
    1
    Vote Rating
    0
      0  

    Default Answered: Paypal integration - php change url when submitting

    Hi There,

    I have a single and simple form which display a list of available subscriptions and a button submitting the selected values.

    Everything works fine, except that php function try to change the url to redirect it to paypal.

    Once checked, the php function try to do this :

    PHP Code:
        if("sandbox" === $environment || "beta-sandbox" === $environment) {        $payPalURL "https://www.$environment.paypal.com/webscr&cmd=_express-checkout&token=$token";    }    header("Location: $payPalURL"); 
    Is there a way to let the php change the URL before success ?
    I may probably not use submit, or retrieve the URL on success and load it ?

    Any help would be welcomed.
    David

    Code:
    function paypal(){
    
         // Set up a model to use in our Store
         Ext.define('Sub', {
        extend: 'Ext.data.Model',
        fields: [
           {name: 'SubId'},
           {name: 'Description'},
           {name: 'PrixM',  type: 'int'},
           {name: 'PrixA',  type: 'int'}
        ],
        idProperty: 'SubId'
        });
    
    
         var mySub = Ext.create('Ext.data.ArrayStore', {
         model: 'Sub',
         async: false,
         proxy: {
             type: 'ajax',
             url: 'php/ajax_get_sub.php',
             reader: {
                 type: 'json',
                 root: 'items'
             }
         },
         autoLoad: true,
         buffered: false
      });
    
    
     var formPaypal = Ext.widget('form', {
            renderTo: 'paypal',
        id:'tip_paypal',
            frame: true,
            width: 380,
        margin: '0 0 0 0',
    //    padding: {0 0 0 0},
            bodyPadding: 10,
            bodyBorder: false,
            title: 'Paypal',
    
            defaults: {
                anchor: '100%'
            },
            fieldDefaults: {
                labelAlign: 'left',
                msgTarget: 'none',
                invalidCls: '' //unset the invalidCls so individual fields do not get styled as invalid
            },
        
    
            items: [{
        xtype: 'grid',
        id: 'MyGrid',
            store: mySub,
            stateful: true,
            collapsible: false,
        height : 110,
            multiSelect: false,
        listeners: {
                selectionchange: function(selModel, selected) {
                        formPaypal.down('#BAbo').setDisabled(false);
                    }
            },
            //stateId: 'stateGrid',
            columns: [
                {
      xtype: 'rownumberer',
      width: 40,
      id: 'SubId',
                    sortable : false,
       hidden : false,
                    dataIndex: 'SubId'
                },
                {
                    text     : 'Abonnement(s)', 
      id: 'Description', 
      width: 110,                  
      sortable : true,
                    dataIndex: 'Description'
                },
                {
                    text     : 'Mensuel',
      id: 'PrixM',
                    width    : 80,
                    sortable : true,
      align : 'right',
                    dataIndex: 'PrixM'
                },
                {
                    text     : 'Annuel',
      id: 'PrixA',
                    width    : 80,
                    sortable : true,
      align : 'right',
                    dataIndex: 'PrixA'
                }
            ]
    
    
            }
    
    ],
    
            dockedItems: [{
                xtype: 'container',
                dock: 'bottom',
                padding: '10 10 5 115',
    
                items: [{
                    xtype: 'button',
                    disabled: true,
      id: 'BAbo',
                    text: 'Je m\'abonne',
                    width: 140,
                    handler: function() {
          var form = this.up('form').getForm();
          var grid = formPaypal.getComponent('MyGrid');
    
          var params = grid.getSelectionModel().getSelection();
          var pSubId = params[0].get('SubId');
          var pDesc = params[0].get('Description');
          var pPrixA = params[0].get('PrixA');
          var pPrixM = params[0].get('PrixM');
    
    
                        // Normally we would submit the form to the server here and handle the response...
                        form.submit({
                            clientValidation: true,
        //waitMsg: 'Veuillez patienter ...',
                            url: 'php/Paypal/ECSetExpressCheckout.php',
       params: {
       SubId: pSubId,
       Description : pDesc,
       PrixM : pPrixM,
       PrixA : pPrixA
       },
       async: false,
                            success: function(form, action) {
          console.log('call php ok');
    
                            },
                            failure: function(form, action) {
    
        Ext.MessageBox.show({
         title : 'Warning',
         msg : 'Votre paiment n\'a pas t accept.',
         buttons : Ext.MessageBox.OK,
         icon : Ext.MessageBox.WARNING,
         fn : null
        });
        
     
                            }
                        }); 
                        
                    }
                }]
            }]
        });
    
    
    }

  2. Why not use the different urls in the client code?

  3. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,316
    Answers
    3881
    Vote Rating
    1290
      0  

    Default

    Why not use the different urls in the client code?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Dec 2012
    Posts
    6
    Answers
    1
    Vote Rating
    0
      0  

    Default Sol ce

    The issue was the callback to the fonction, as Paypal ask for return and cancel urls ....

    I did solve the issue by implementing a function called when the button is pressed ... Then a php file redirecting to the website ...

    Thanks for your time and help

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •