Problems, need help? Have a tip or advice? Post it here.
12 posts Page 1 of 2
Ok, here is what I have. I am using the simple PayPal buttons provided by Couch.


Everything works fine, except that the success/confirmation email is not sent.


Here is the code:

Code: Select all
<cms:paypal_processor>
    <cms:if k_paypal_success>
        <cms:send_mail from=pp_receiver_email to=pp_payer_email subject='Thank you for your purchase!' >
            Dear <cms:show pp_first_name /> <cms:show pp_last_name />,

            Thank you for buying <cms:show pp_item_name />.
           
            Please allow up to 3 days for vouchers to be sent to your address.
        </cms:send_mail>
    </cms:if>

    <cms:if k_paypal_error>
        <cms:set msg="ERROR: <cms:show k_paypal_error/>" />
        <cms:log msg />
    </cms:if>
</cms:paypal_processor>



The email never arrives. This should be straightforward stuff, not sure why it is not working :?


p.s. On a side note, when using
Code: Select all
k_email_from
and
Code: Select all
k_email_to
in
Code: Select all
send_mail
tag, that email never arrives.

When I use hardcoded values, that same email works? Why is that? I am talking about regular contact form here, not paypal related. :!: :?:

Hi,

You need to troubleshoot this one step at a time -
before getting to mail, first make sure that the <cms:paypal_processor> block is getting executed (remove mail from it and put in a simple cms:log).

Once you are sure the IPN is indeed being received, check the mail part.
For that place the cms:send_mail outside the processor block (so that it gets executed everytime the template is accessed) and use hard coded values. If the mail does does not go through, switch over to phpmailer addon (viewtopic.php?f=5&t=10750) with debug setting. It should show you exactly what is going wrong.

Hope this helps.

I think I missed something trivial in my setup of PayPal buttons. I tried dozens of combinations, but I can't get anything written to log file. That is why I think that I missed something basic.


Could you please confirm that my setup is fine, cause I am 99% sure that it is not.


I have a page called Vouchers that displays five paypal buttons, one for each voucher. The buttons are pulled from product-vouchers.php template.


This is the code from Vouchers page, to show how I am pulling the buttons in. Just two buttons for reference.

Code: Select all
    <div class="paypal-button">
                        <cms:pages masterpage="product-vouchers.php" page_name="cakemash-voucher">
                        <cms:paypal_button image="8" show_shipping="1"/>
                        </cms:pages>
                        </div>

   <div class="paypal-button">
                        <cms:pages masterpage="product-vouchers.php" page_name="newborn-baby-voucher">
                        <cms:paypal_button image="8" show_shipping="1"/>
                        </cms:pages>
                        </div>




And here is the product-vouchers.php template. I am not sure if the paypal_processor tag should be inside the template tag or outside?

Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title="Product Vouchers" clonable="1">
<cms:editable name='pp_price' label='Price' desc='Amount in GBP'
    maxlength='10'
    search_type='decimal'
    validator='non_negative_decimal'
    type='text' />
   
   

</cms:template>
<cms:paypal_processor>
    <cms:if k_paypal_success>
        <cms:send_mail from='noreply@wish-photography.co.uk' to=pp_payer_email subject='Thank you for your purchase!' >
            Dear <cms:show pp_first_name /> <cms:show pp_last_name />,

            Thank you for buying <cms:show pp_item_name />.
           
            Please allow up to 3 days for vouchers to be sent to your address.
        </cms:send_mail>
    </cms:if>

    <cms:if k_paypal_error>
        <cms:set msg="ERROR: <cms:show k_paypal_error/>" />
        <cms:log msg />
    </cms:if>
</cms:paypal_processor>
<cms:paypal_button image="8"/>
<?php COUCH::invoke(); ?>



I am pretty sure something is wrong here, otherwise I would at least get the log file to be written.
I found this thread https://www.couchcms.com/forum/viewtopic.php?f=4&t=8614, and by using the PayPal test IPN, I get some info written to paypal.log file.


It says IPN is invalid. Maybe this is a step forward :)

Code: Select all

=======================[2017-11-04 18:50:44]=======================
Received paypal IPN:

payment_type = instant
payment_date = Sat Nov 04 2017 14:13:59 GMT+0100 (Central European Standard Time)
payment_status = Completed
address_status = confirmed
payer_status = verified
first_name = John
last_name = Smith
payer_email = buyer@paypalsandbox.com
payer_id = TESTBUYERID01
address_name = John Smith
address_country = United States
address_country_code = US
address_zip = 95131
address_state = CA
address_city = San Jose
address_street = 123 any street
business = seller@paypalsandbox.com
receiver_email = seller@paypalsandbox.com
receiver_id = seller@paypalsandbox.com
residence_country = US
item_name1 = something
item_number1 = AK-1234
tax = 2.02
mc_currency = USD
mc_fee = 0.44
mc_gross = 12.34
mc_gross_1 = 12.34
mc_handling = 2.06
mc_handling1 = 1.67
mc_shipping = 3.02
mc_shipping1 = 1.02
txn_type = cart
txn_id = 171839205
notify_version = 2.1
custom = xyz123
invoice = abc1234
test_ipn = 1
verify_sign = AYhQpDXPiPebyJswwnaVc8Soek4BACoVS4p8jGQkhnS5MSH92HSdZUOU


=======================[2017-11-04 18:50:44]=======================
Connecting to paypal for verification..

=======================[2017-11-04 18:50:44]=======================
POST /cgi-bin/webscr HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: www.paypal.com
Connection: close
User-Agent: abc-company-name
Content-Length: 940



=======================[2017-11-04 18:50:44]=======================
Connected

=======================[2017-11-04 18:50:44]=======================
Paypal says IPN is INVALID

=======================[2017-11-04 18:50:44]=======================
Response headers:
HTTP/1.1 200 OK
Server: Apache
X-Frame-Options: SAMEORIGIN
HTTP_X_PP_AZ_LOCATOR: dcg13.slc
Paypal-Debug-Id: d34f18d3536c1
Cache-Control: max-age=0, no-cache, no-store, must-revalidate
Pragma: no-cache
Content-Type: text/html; charset=UTF-8
DC: phx-origin-www-2.paypal.com
X-EdgeConnect-MidMile-RTT: 110
X-EdgeConnect-Origin-MEX-Latency: 500
Date: Sat, 04 Nov 2017 13:20:44 GMT
Content-Length: 7
Connection: close
Set-Cookie: cwrClyrK4LoCV1fydGbAxiNL6iG=xMeVmd84_ZbsJ4KA5kDXGtLEK__hDN8jL6ylOJE4-G7aeoUAX8Bu-9Ajc76sl1LNY5ElmM8pZMdsiU9rYCYW3mEQ_FBUwnCXhv5szqr7oLqhIsmuzD3_gE6nfdMfJVhQ7fSBlr3DZv3vZNtfZhh3mQz-07RCgUdPkoednGxr7Q7ZellqPvyw6tRPscz4SYPkulHsJAGtjQIAz3bOrQYdsfHyYU0xCMSMnYNNMe1_LzNspkHaPXSjuFCQbqmhMsBoNlbszETKC7-BP-pBt6jexcJuZc2lphVL4B_vYZb3CB1nbP4F4VSna5IqUwXuo_BftYiuWQ_XsKh1G39lTaMBRyN7CdOAEk9gSHWLqjhl7u8kOfjQuK9OjIoKNW0U6pk38eLEAVqP7FNSlBFV4FpAW_z0i6LO-sw38qwRbLFau-dx3nP426nPMyitVtS; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: cookie_check=yes; expires=Tue, 02-Nov-2027 13:20:44 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: navcmd=_notify-validate; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: navlns=0.0; expires=Mon, 04-Nov-2019 13:20:44 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: X-PP-SILOVER=name%3DLIVE3.WEB.1%26silo_version%3D880%26app%3Dappdispatcher%26TIME%3D2898197849%26HTTP_X_PP_AZ_LOCATOR%3Ddcg13.slc; Expires=Sat, 04 Nov 2017 13:50:44 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT
Set-Cookie: AKDC=phx-origin-www-2.paypal.com; expires=Sat, 04-Nov-2017 13:50:44 GMT; path=/; secure
Set-Cookie: akavpau_ppsd=1509802244~id=479d19fc79b3b96d3e5a8848d6570608; Path=/
Strict-Transport-Security: max-age=63072000

INVALID

=======================[2017-11-04 18:50:44]=======================
Exiting

One thing from the log caught my attention -
=======================[2017-11-04 18:50:44]=======================
Connecting to paypal for verification..

=======================[2017-11-04 18:50:44]=======================
POST /cgi-bin/webscr HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: www.paypal.com
Connection: close
User-Agent: abc-company-name
Content-Length: 940

Your transaction was done by a 'sandbox' user (buyer@paypalsandbox.com) so the highlighted URL should actually be 'www.sandbox.paypal.com' and not the real paypal.

Please check your couch/config.php file and make sure K_PAYPAL_USE_SANDBOX is set to '1'.
Try again and let me know how it goes.
Here is the response when setting sandbox to 1 :


Code: Select all
=======================[2017-11-04 20:23:44]=======================
Received paypal IPN:

payment_type = instant
payment_date = Sat Nov 04 2017 15:53:37 GMT+0100 (Central European Standard Time)
payment_status = Completed
address_status = confirmed
payer_status = verified
first_name = John
last_name = Smith
payer_email = buyer@paypalsandbox.com
payer_id = TESTBUYERID01
address_name = John Smith
address_country = United States
address_country_code = US
address_zip = 95131
address_state = CA
address_city = San Jose
address_street = 123 any street
business = seller@paypalsandbox.com
receiver_email = seller@paypalsandbox.com
receiver_id = seller@paypalsandbox.com
residence_country = US
item_name1 = something
item_number1 = AK-1234
tax = 2.02
mc_currency = USD
mc_fee = 0.44
mc_gross = 12.34
mc_gross_1 = 12.34
mc_handling = 2.06
mc_handling1 = 1.67
mc_shipping = 3.02
mc_shipping1 = 1.02
txn_type = cart
txn_id = 537754609
notify_version = 2.1
custom = xyz123
invoice = abc1234
test_ipn = 1
verify_sign = AQ8ezXyrvBanm9DAW206.4y9q6M2AfcmTnJwB.mmmqOTkVkBSiyThtgg


=======================[2017-11-04 20:23:44]=======================
Connecting to paypal for verification..

=======================[2017-11-04 20:23:44]=======================
POST /cgi-bin/webscr HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: www.sandbox.paypal.com
Connection: close
User-Agent: abc-company-name
Content-Length: 940



=======================[2017-11-04 20:23:45]=======================
Connected

=======================[2017-11-04 20:23:45]=======================
VERIFIED

=======================[2017-11-04 20:23:45]=======================
Couch validating transaction..

=======================[2017-11-04 20:23:45]=======================
ERROR: Invalid item number()

=======================[2017-11-04 20:23:45]=======================
Response headers:
HTTP/1.1 200 OK
Date: Sat, 04 Nov 2017 14:53:45 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Set-Cookie: c9MWDuvPtT9GIMyPc3jwol1VSlO=pZJq5g6mOo3515bYD_ghu2XMD7hMW8N18bEpJPn4w186FAv-pgp4WtkY3-qFlAzWLVOBmlTCGpJisrKPheVf5635K9GQFz4Qh6ngHFpWfXVgEhDvaPFS3QfhLl_O3MmgHTSWvLEiuActw-hpqISGTBvIGlJ1s_YXv6BY-kwD-DE8RdHTRq4IgSD5DplLy0AOyJOfxV8-KYsOnuXeSsh9JXtbbcIQh2rxCSZ81xwcQACtGu-1oL3o_1H30xxVoXLB98rYxRTLV41BYreXhmXNGUOVoWJVJEqWtgcytvZ7v3q691Pk0IewolY_WemwQT7588q87MZpx_5dIkUKNJbFuWrmeSuPeoMFpaBgkUNhsPW5X5CInRbCZUq750PrRXDadKvtkEzgZf6lBxPwzvPm-Onc4S8pudzzveO6ngFlTa8CM__YoEKu7tgfDRq; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: cookie_check=yes; expires=Tue, 02-Nov-2027 14:53:45 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: navcmd=_notify-validate; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: navlns=0.0; expires=Mon, 04-Nov-2019 14:53:45 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: Apache=10.72.108.11.1509807225385818; path=/; expires=Mon, 28-Oct-47 14:53:45 GMT
Vary: Accept-Encoding,User-Agent
Connection: close
HTTP_X_PP_AZ_LOCATOR: sandbox.slc
Paypal-Debug-Id: 31f75a05b276
Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.WEB.1%26silo_version%3D1880%26app%3Dappdispatcher%26TIME%3D2044001625%26HTTP_X_PP_AZ_LOCATOR%3Dsandbox.slc; Expires=Sat, 04 Nov 2017 15:23:45 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8
Strict-Transport-Security: max-age=63072000

8
VERIFIED
0



=======================[2017-11-04 20:23:45]=======================
Exiting



It seems that there is no more "Paypal says IPN is INVALID" error and the new status is VERIFIED, which is a good thing.

Is the problem in this line " ERROR: Invalid item number()" ? This also gets logged into log.txt file present in root of the website. I've set debug="1" on paypal_processor tag.

The data returned through the IPN is supposed to have (of other things) the item_name and item_number - the two should be your cloned page's k_page_name and k_page_id respectively.

Going by the code you are using for the buttons, the item_name should be either cakemash-voucher or newborn-baby-voucher.
<cms:pages masterpage="product-vouchers.php" page_name="cakemash-voucher">
<cms:paypal_button image="8" show_shipping="1"/>
</cms:pages>

<cms:pages masterpage="product-vouchers.php" page_name="newborn-baby-voucher">
<cms:paypal_button image="8" show_shipping="1"/>
</cms:pages>

I don't see those two keys in the IPN you posted.
Are you sure you are using those buttons to get back the IPN?

I'd like to take a look at the code generated by the paypal_button, Please do a view_source and copy/paste the form code each paypal_button expands to.
Here is the code for each button:

Code: Select all
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="client@yahoo.co.uk">
<input type="hidden" name="item_name" value="Cake Smash Voucher">
<input type="hidden" name="item_number" value="53">
<input type="hidden" name="amount" value="1">
<input type="hidden" name="undefined_quantity" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="CZK">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="custom" value="">
<input type="hidden" name="return" value="http://wish-photography.co.uk/vouchers.php">
<input type="hidden" name="cancel_return" value="http://wish-photography.co.uk/vouchers.php">
<input type="hidden" value="http://wish-photography.co.uk/vouchers.php?paypal_ipn=1" name="notify_url">
<input type="image" border="0" alt="Make payments with PayPal - it's fast, free and secure!" name="submit" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif"><img width="1" height="1" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" alt="">
</form>

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="client@yahoo.co.uk">
<input type="hidden" name="item_name" value="Newborn Baby Voucher">
<input type="hidden" name="item_number" value="54">
<input type="hidden" name="amount" value="50">
<input type="hidden" name="undefined_quantity" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="CZK">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="custom" value="">
<input type="hidden" name="return" value="http://wish-photography.co.uk/vouchers.php">
<input type="hidden" name="cancel_return" value="http://wish-photography.co.uk/vouchers.php">
<input type="hidden" value="http://wish-photography.co.uk/vouchers.php?paypal_ipn=1" name="notify_url">
<input type="image" border="0" alt="Make payments with PayPal - it's fast, free and secure!" name="submit" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif"><img width="1" height="1" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" alt="">
</form>

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="business" value="client@yahoo.co.uk">
    <input type="hidden" name="item_name" value="Bump to Baby Voucher">
    <input type="hidden" name="item_number" value="55">
    <input type="hidden" name="amount" value="75">
    <input type="hidden" name="undefined_quantity" value="1">
    <input type="hidden" name="no_note" value="1">
    <input type="hidden" name="currency_code" value="CZK">
    <input type="hidden" name="rm" value="2">
    <input type="hidden" name="custom" value="">
    <input type="hidden" name="return" value="http://wish-photography.co.uk/vouchers.php">
    <input type="hidden" name="cancel_return" value="http://wish-photography.co.uk/vouchers.php">
    <input type="hidden" value="http://wish-photography.co.uk/vouchers.php?paypal_ipn=1" name="notify_url">
    <input type="image" border="0" alt="Make payments with PayPal - it's fast, free and secure!" name="submit" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif"><img width="1" height="1" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" alt="">
</form>

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="business" value="client@yahoo.co.uk">
    <input type="hidden" name="item_name" value="Family and Generation Voucher">
    <input type="hidden" name="item_number" value="56">
    <input type="hidden" name="amount" value="35">
    <input type="hidden" name="undefined_quantity" value="1">
    <input type="hidden" name="no_note" value="1">
    <input type="hidden" name="currency_code" value="CZK">
    <input type="hidden" name="rm" value="2">
    <input type="hidden" name="custom" value="">
    <input type="hidden" name="return" value="http://wish-photography.co.uk/vouchers.php">
    <input type="hidden" name="cancel_return" value="http://wish-photography.co.uk/vouchers.php">
    <input type="hidden" value="http://wish-photography.co.uk/vouchers.php?paypal_ipn=1" name="notify_url">
    <input type="image" border="0" alt="Make payments with PayPal - it's fast, free and secure!" name="submit" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif"><img width="1" height="1" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" alt="">
</form>

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="business" value="client@yahoo.co.uk">
    <input type="hidden" name="item_name" value="Kids Portrait Voucher">
    <input type="hidden" name="item_number" value="57">
    <input type="hidden" name="amount" value="40">
    <input type="hidden" name="undefined_quantity" value="1">
    <input type="hidden" name="no_note" value="1">
    <input type="hidden" name="currency_code" value="CZK">
    <input type="hidden" name="rm" value="2">
    <input type="hidden" name="custom" value="">
    <input type="hidden" name="return" value="http://wish-photography.co.uk/vouchers.php">
    <input type="hidden" name="cancel_return" value="http://wish-photography.co.uk/vouchers.php">
    <input type="hidden" value="http://wish-photography.co.uk/vouchers.php?paypal_ipn=1" name="notify_url">
    <input type="image" border="0" alt="Make payments with PayPal - it's fast, free and secure!" name="submit" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif"><img width="1" height="1" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" alt="">
</form>

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="business" value="client@yahoo.co.uk">
    <input type="hidden" name="item_name" value="Pets Portrait Voucher">
    <input type="hidden" name="item_number" value="58">
    <input type="hidden" name="amount" value="40">
    <input type="hidden" name="undefined_quantity" value="1">
    <input type="hidden" name="no_note" value="1">
    <input type="hidden" name="currency_code" value="CZK">
    <input type="hidden" name="rm" value="2">
    <input type="hidden" name="custom" value="">
    <input type="hidden" name="return" value="http://wish-photography.co.uk/vouchers.php">
    <input type="hidden" name="cancel_return" value="http://wish-photography.co.uk/vouchers.php">
    <input type="hidden" value="http://wish-photography.co.uk/vouchers.php?paypal_ipn=1" name="notify_url">
    <input type="image" border="0" alt="Make payments with PayPal - it's fast, free and secure!" name="submit" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif"><img width="1" height="1" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" alt="">
</form>

Seems ok to me.

If you could PM me the FTP+Couch access creds, I can take a look at the issue first-hand. Thanks.

@KK PM-ed you with details.
12 posts Page 1 of 2