Problems, need help? Have a tip or advice? Post it here.
10 posts Page 1 of 1
Is there any way I can have someone fill out a form, then pay with Paypal, and only have the form submitted after the payment is processed through Paypal?

Thanks!
Mako88 wrote: Is there any way I can have someone fill out a form, then pay with Paypal, and only have the form submitted after the payment is processed through Paypal?

Thanks!


Could you tell me more about the process? In essence, submitted form data can be saved in a clonable page.

Then visitor goes to paypal with paypal button and pays. After paypal receives payment, it initiates another connection to your server, asynchronously in the background and asks for the page with the Pp button. At this moment couch tag cms:paypal_processor processes the message from the payment system and sets error or success and here you can do whatever desired with the previously saved form data. Send a mail or whatever.

Just make sure your code stays in 'success block', because the template is not processed outside paypal_processor tag, because this was not a visitor and browser, but a separate hidden request.

Let me know if I could clarify more at some point.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
How would I save the form data in a cloneable page?

Basically I have a membership form that requires a fee. I'd like the users to be able to fill out the form, then click a "pay with Paypal" button. Then after they enter their paypal info and confirm the amount, have the form submitted and bring them back to the form page with a "thank you, your payment has been processed and your membership form submitted" message.

Thanks!
Mako88 wrote: How would I save the form data in a cloneable page?

Basically I have a membership form that requires a fee. I'd like the users to be able to fill out the form, then click a "pay with Paypal" button. Then after they enter their paypal info and confirm the amount, have the form submitted and bring them back to the form page with a "thank you, your payment has been processed and your membership form submitted" message.

Thanks!


To save form data we use data-bound form concept.

Basically, when visitor hits 'pay with pp' button, instead of 'send' you store whatever is inputted and send user to paypal. You can't guarantee that user comes back. There is no automation of this, unfortunately, because couch is not a payment gate, where user is thrown back on success. Paypal does not require users go back.

Once the payment is complete, paypal sends a message to your template hiddeenly (as described in previous post). Upon receipt of that message from paypal you can send user an email and express gratitude. Do not send mail upon visitor clicking 'buy', because payment is not completed yet and not verified by paypal_processor.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
So can I put the paypal processor tag inside the k_success tag of a form and use the variables set by the form inside it to send an email?
Mako88 wrote: So can I put the paypal processor tag inside the k_success tag of a form and use the variables set by the form inside it to send an email?

Not at all. Please, read again in docs what paypal_processor tag does. Shortly put, it is sitting somewhere in your template and waits for a call from paypal's server itself.

What happens if you put paypal_processor in k_success block inside the form? Well, paypal will not be able to communicate to your server that transaction is completed. Because, form will not be triggered at all and therefore no k_success would be available.

Instead, use paypal_processor's own k_success block, with no relation to your form at all.
Basic structure would look like this:
Code: Select all
            <cms:paypal_processor debug='1' file='_logs/log-paypal.html' >
              <cms:log "<cms:dump />" file='_logs/log-inside.html' /><cms:hide>variables available on outside call</cms:hide>

              <cms:if k_paypal_success>
                   
                         <cms:send_mail from=pp_receiver_email
                                        to=pp_payer_email
                                        bcc=k_email_to
                                        subject='Thank you for your purchase at my store!'
                                        debug='1'
                                        logfile='_logs/log-mail.html'
                                        html='0' >
                                Dear <cms:show pp_first_name /> <cms:show pp_last_name />,

                                Thank you for purchasing <cms:show pp_item_name />.

                                Please, reply to this message.

                                Regards, Admin

                         </cms:send_mail>
             

              </cms:if><cms:hide>/end of k_paypal_success</cms:hide>
              <cms:if k_paypal_error>
                  <cms:set msg="******************PAYPAL ERROR: <cms:show k_paypal_error/>***********************" />
                  <cms:log msg />
                   
              </cms:if>
            </cms:paypal_processor>
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
After reading the documentation and such here's the problem I'm running into:

The <cms:paypal_button /> tag creates its own form with the action parameter pointing to the paypal site. Now the issue is, I can't submit the data bound form at the same time as the paypal form.

So I see two possibilities:

Either the user has to click submit twice (once to submit the data bound form, then have it show the paypal button which would direct them to paypal). I'd rather not do that, cause I'd like them to only have to hit it once and then enter their paypal info.

The other option I can see is to not use couch's paypal integration, but create my own form with both the fields I need AND the hidden paypal fields. Then on submit, have it redirected to a custom php page which saves the data (either in the database or in a text file), and then redirects to paypal. I'd then also have to manually code the IPN page to send the email on successful payment. I can do this, but I feel like there's got to be a better way. Any thoughts?

Btw trendoman, thanks for all your help so far :)
Mako88, I thought about your desired setup and I think, there is a possibility to save data and then redirect to paypal using one single page and one single form without going back and forth.

I searched and found a very nice explanation of the process. Please take a look at this short conversation, it might be helpful.
viewtopic.php?f=2&t=8275&p=14976

Take a look and, please, let us know your thoughts.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Yeah, that's what it looks like it would take :/

For this use-case it's not worth that amount of work, so I'm just gonna not worry about it.

Thanks again for all your help!
Mako88 wrote: Yeah, that's what it looks like it would take :/

For this use-case it's not worth that amount of work, so I'm just gonna not worry about it.

Thanks again for all your help!


Sure, you are always welcome.

With any custom logic it's like this - rarely things are available out of the box. I am glad we have this forum with solutions and great documentation, so sooner or later people figure out how to do anything beyond the common stuff. Very often, though, simpler solutions turn out to be more reliable in many ways :)
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
10 posts Page 1 of 1