Page 2 of 2

Re: Cart/Subscription Advice needed

Posted: Fri Mar 18, 2016 8:40 am
by simonmlewis
Invalid Regular period. You must specify valid values for the A3, P3 and T3 parameters for a subscription.

Code: Select all

<form action='https://www.paypal.com/cgi-bin/webscr' method='post'>
    <input type='hidden' name='cmd' value='_xclick-subscriptions'>
    <input type='hidden' name='item_name' value='Page Subscription'>
    <input type='hidden' name='item_number' value='1'>
    <input type='hidden' name='currency_code' value='GBP'>
    <input type='hidden' name='business' value='sales@site.co.uk'>
    <input type='hidden' name='notify_url' value=''>
    <input type='hidden' name='return' value='https://example.com/payment/thankyou'>
    <input type='hidden' name='cancel_return' value='https://example.com/payment/cancel'>
<input type='hidden' name='period1' value='0.00'>
    <input type='hidden' name='period1' value='1M'>
    <input type='hidden' name='period2' value='1M'>
    <input type='hidden' name='mc_amount1' value='0'>
    <input type='hidden' name='mc_amount2' value='£5.00'>
    <input type='submit' value='Pay with PayPal'>
</form>
What's wrong with this? Ignoring the "test" wording and URLS....

Re: Cart/Subscription Advice needed

Posted: Fri Mar 18, 2016 9:10 am
by Celauran
You need a notify URL. Can be the same as return URL, but I don't think it can be empty. PayPal used to use a3, p3, and t3. Didn't realize they still did. a3 is the amount, p3 the period (D, M, Y, etc), and t3 the period count. a1/p1/t1 should be your free month values, though I'd confirm with PayPal docs.

Re: Cart/Subscription Advice needed

Posted: Fri Mar 18, 2016 6:31 pm
by simonmlewis

Code: Select all

        <form action='https://www.paypal.com/cgi-bin/webscr' method='post'>
    <input type='hidden' name='cmd' value='_xclick-subscriptions'>
    <input type='hidden' name='item_name' value='Page Subscription'>
    <input type='hidden' name='item_number' value='1'>
    <input type='hidden' name='currency_code' value='GBP'>
    <input type='hidden' name='business' value='sales@site.org.uk'>
    <input type='hidden' name='notify_url' value='https://example.com/payment/thankyou'>
    <input type='hidden' name='return' value='https://example.com/payment/thankyou'>
    <input type='hidden' name='cancel_return' value='https://example.com/payment/cancel'>
<input type='hidden' name='period1' value='0.00'>
    <input type='hidden' name='period1' value='1M'>
    <input type='hidden' name='period2' value='1M'>
    <input type='hidden' name='mc_amount1' value='0'>
    <input type='hidden' name='mc_amount2' value='�5.00'>
    <input type='submit' value='Proceed to PayPal' class='paypal-submit'>
</form>
What am I still missing?
I get the same error.

That notify URL - does PayPal use that URL to check if the price somewhere on there, is the same as what is posted (like in some ajax way)...?? Bit lost there.

Re: Cart/Subscription Advice needed

Posted: Sat Mar 19, 2016 8:33 am
by Celauran
simonmlewis wrote:What am I still missing?
I get the same error.
The error said you were missing a3, p3, and t3 values. I still don't see them. See my previous post. You need to replace period with a combination of t and p, and replace mc_amount with a.

Re: Cart/Subscription Advice needed

Posted: Sat Mar 19, 2016 4:11 pm
by simonmlewis
Sorry but I don't get it. a3, p3, t3... what do they mean? You say "replace period with a combination of t and p"... you are talking in riddles to me.

Re: Cart/Subscription Advice needed

Posted: Sat Mar 19, 2016 4:32 pm
by simonmlewis

Code: Select all

 <form action='https://www.paypal.com/cgi-bin/webscr' method='post'>
    <input type='hidden' name='cmd' value='_xclick-subscriptions'>
    <input type='hidden' name='item_name' value='Page Subscription'>
    <input type='hidden' name='item_number' value='1'>
    <input type='hidden' name='currency_code' value='GBP'>
    <input type='hidden' name='business' value='sales@site.org.uk'>
    <input type='hidden' name='notify_url' value='https://example.com/payment/thankyou'>
    <input type='hidden' name='return' value='https://example.com/payment/thankyou'>
    <input type='hidden' name='cancel_return' value='https://example.com/payment/cancel'>
<input type='hidden' name='period1' value='0.00'>
    <input type='hidden' name='t2' value='1M'>
    <input type='hidden' name='a3' value='£5'>
    <input type='hidden' name='t3' value='M'>
    <input type='submit' value='Proceed to PayPal' class='paypal-submit'>
</form>
Still wrong ?

Re: Cart/Subscription Advice needed

Posted: Tue Mar 22, 2016 4:02 am
by simonmlewis
I'm having trouble working this code out. I keep getting the errors.
So I went to use the PayPal Create Button option as this is for just one sort of product.

I can enter the notify_url option in the advanced variables, but I have a question about it.

The way I think it works, is that PayPal runs it "behind the scenes", so I have put in the session start, and queried if there is a Session active. If there is, it gets the session userid, and then updates the database and sets the pending value to "paid".

Would this work? Or does the backend notify script not identify the user is in a session, since it doesn't work or get triggered on their PC ??

Re: Cart/Subscription Advice needed

Posted: Tue Mar 22, 2016 7:29 am
by Celauran
I wouldn't rely on sessions. Add the user ID to the order if you can, as a custom variable. If not, generate an actual order on your end to store the relevant information in and pass that order ID to the form.

Re: Cart/Subscription Advice needed

Posted: Tue Mar 22, 2016 7:39 am
by simonmlewis
Poss easier then to just slap the userid on the end of the notify_url and use that to trigger it.
So the Return URL is /cart&success=y, but the notify_url secretly updates their pending field to "ready".

I assume therefore that the notify_url php file needs to run via PayPal, and without any local site logins. Because the user's browser isn't actually running it.

Re: Cart/Subscription Advice needed

Posted: Tue Mar 22, 2016 7:47 am
by Celauran
PayPal sends a POST request to your notify_url so definitely don't expect or require a login to reach that route. I'd still recommend keeping an orders table to record outgoing orders and a transactions table to record incoming PayPal transactions.

Re: Cart/Subscription Advice needed

Posted: Tue Mar 22, 2016 7:59 am
by simonmlewis
Problem.... if I use the PayPal "create button" method it won't work as I have no control over dyanmically populating that URL.

I have to go back to that original code you was talking about, but I cannot see how to make it work as I stll get those A, P errors..