phpCOIN

  Reply to this topicStart new topicStart Poll

> Do_auto_create_payment, Decission to call this function
soulbriski
Posted: January 31, 2014 12:07 am
Quote Post


Member
**

Group: Members
Posts: 15
Member No.: 4,583
Joined: November 01, 2012



I was trying to get to grips with PayPal some time ago and had to abandon things due to more pressing family matters.

I return to it now and still having an issue getting the auto create payment to work.

In brief, my IPN settings, Paylinks, Vendors, Products are all configured correctly as the IPN and PP logs confirm for me and everything is happening as you would expect. However the final matter of the return from billing is not creating the credit transaction and setting the invoice to paid as I believe it wants to.

I can't get my head round this line of code for orders_funcs_order.php

Of course I understand it from a code point of view but why is it checking !$vdata['vendor_use_ipn']? Surely it should not be NOT

CODE
IF ($_CCFG['ORDER_AUTO_CREATE_INVOICE'] && $adata['ord_id'] && !$vdata['vendor_use_ipn']) {
    $tempvar = do_auto_create_payment($adata['ord_id']);
   }


Surely it should read

CODE
IF ($_CCFG['ORDER_AUTO_CREATE_INVOICE'] && $adata['ord_id'] && $vdata['vendor_use_ipn']) {
    $tempvar = do_auto_create_payment($adata['ord_id']);
   }


Please read the above code in conjunction with the topic below which I thought was really funny by the way

http://forums.phpcoin.com/index.php?showto..._create_payment
PMEmail Poster
Top
lightman
Posted: January 31, 2014 05:59 am
Quote Post


The Janitor
***

Group: Admin
Posts: 3,639
Member No.: 3
Joined: August 25, 2006



QUOTE
CODE
IF ($_CCFG['ORDER_AUTO_CREATE_INVOICE'] && $adata['ord_id'] && !$vdata['vendor_use_ipn']) {
   $tempvar = do_auto_create_payment($adata['ord_id']);
  }


As I understand the code, this is looking to see if the IPN flag is in use - if it NOT then set the invoice to 'paid' - if it is IS then wait for the IPN to return confirmation of payment from PayPal before setting the invoice to 'paid'.

The post you refer to appears to apply to a much earlier version of phpCOIN that used to have the IPN as an add-on, so I'm not sure it has much relevance to the current version that has the IPN functions already built in. smile.gif


--------------------
***** Unless otherwise stated, all replies refer to the following *****
====================================================================
--- The latest unmodified version of phpCOIN available from the phpCOIN download page on the date and time of this post.
--- All relevant HotFix files applied - One of the four included unmodified themes - The original language files .
--- Help will be given to install/configure/use phpCOIN, but not programming help to modify phpCOIN operations. If you are competent enough to make programming changes, you should be competent enough to read the source code and figure things out :)
PM
Top
soulbriski
Posted: February 03, 2014 12:09 am
Quote Post


Member
**

Group: Members
Posts: 15
Member No.: 4,583
Joined: November 01, 2012



Thanks for your reply lightman

Yes, the post I referred to was an earlier version and I included it partly because it came up in my searches on do_auto_create_payment and partly because I found it funny.

The tests that I have carried out seem to suggest that waiting for the IPN to return confirmation of payment from PayPal before setting the invoice to 'paid' never takes place!

The code exceprt that I included is nested inside another IF condition that Checks the return parameters for "buy" indicator (Line 1619 in orders_funcs_order.php)

When the "buy" indicator comes back as "0", the invoice does not get paid because the user cancelled out of the PayPal process so this is what we want.

When the "buy" indicator comes back as "1", the invoice does still not get paid because the IPN flag is in use so the
CODE
$_CCFG['ORDER_AUTO_CREATE_INVOICE'] && $adata['ord_id'] && !$vdata['vendor_use_ipn']
returns false

This is the full code extract

CODE
 # Check return parameters for "buy" indicator.
  IF (($adata[$vdata['vendor_buy_parm']] == $vdata['vendor_buy_parm_val']) && $adata['ord_prod_id'] > 0) {
   $_ret_result = $_LANG['_ORDERS']['ORD_P06_EMAIL_YES'];
   $_ret_flag = 'Yes';
   IF (!$adata['ord_id']) {$adata['ord_id'] = $adata['os_ord_id'];}
   IF ($_CCFG['ORDER_AUTO_CREATE_INVOICE'] && $adata['ord_id'] && !$vdata['vendor_use_ipn']) {
    $tempvar = do_auto_create_payment($adata['ord_id']);
   }
  } ELSE {
   $_ret_result = $_LANG['_ORDERS']['ORD_P06_EMAIL_NO'];
   $_ret_flag = 'No';
  }


In order to prove the theory to myself, I have simply "echoed" the various variable names and corresponding values on return form billing under various scenarios. i.e. Cancel before completing PayPal, completing the PayPal payment

In essence, everything is behaving exactly as you would expect with all parameters, flags and return values correctly set.

It just seems that the final check before do_auto_create_payment will always return false unless you turn the IPN flag off.

Your further thoughts would be much appreciated lightman.

I would also be interested to hear from anyone else who is using PayPal and having sucess in this area
PMEmail Poster
Top
lightman
Posted: February 03, 2014 05:20 am
Quote Post


The Janitor
***

Group: Admin
Posts: 3,639
Member No.: 3
Joined: August 25, 2006



If you are using a PayPal sandbox to test this - don't expect a call-back from PayPal unless you have manually approved the payment from inside the sandbox itself (I haven't tried this for a while so I don't know if it still works !!) PayPal may have changed the way it sends it's call-backs - but we seem to get IPN via the eMail cron on our own sites without any issues.

If you are using a live PayPal account:

If your IPN is not receiving the call-back from PayPal, the invoice will never be paid - check:-

1) Your logs to see if PayPal is sending you back the data
2) If it is - that the data is matchable against an invoice

If you are getting no call-back - you might want to try and use the paypal.php on a cron to check an eMail inbox for the eMail receipt from PayPal (works similarly to the helpdesk import) or check that your firewall is not blocking the call-backs.

It is also possible that the security hotfix broke the IPN - in that case try the paypal.php cron to check incoming eMails.


--------------------
***** Unless otherwise stated, all replies refer to the following *****
====================================================================
--- The latest unmodified version of phpCOIN available from the phpCOIN download page on the date and time of this post.
--- All relevant HotFix files applied - One of the four included unmodified themes - The original language files .
--- Help will be given to install/configure/use phpCOIN, but not programming help to modify phpCOIN operations. If you are competent enough to make programming changes, you should be competent enough to read the source code and figure things out :)
PM
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll

 


Inscrita el Registro Mercantil de Mallorca Tomo 2140, Hoja No. PM-51034, Folio 135
This website owned and operated by: Technology Services RPVW S.L. CIF# B57345084
Avda Constitucion 48 Bajos Alaro 07340 Baleares SPAIN
Tel:+34 971518362    Fax: +34 971518368    eMail: support@phpcoin.com