Osclass Support Forums

Osclass plugin support => Osclass Pay Plugin => Topic started by: Lyubomir Minchev on February 11, 2018, 07:25:59 PM

Title: paypal standbox test payment does not mark the listing as premium
Post by: Lyubomir Minchev on February 11, 2018, 07:25:59 PM
Hello,


I've set a paypal sandbox test users to check the payment plugin. After a successful payment the original site does not move further, but only shows the following message:

"We are processing your payment, if it did not finish in a few seconds, please contact us"

and stays as it is.

At the same time I receive a debug mail :

Code: [Select]
array (
 'extra' => 'user,21|itemid,3|email,123@123|amount,3|random,770',
 'mc_gross' => '3.00',
 'protection_eligibility' => 'Ineligible',
 'address_status' => 'confirmed',
 'payer_id' => 'GRAC9Q3XQ78XA',
 'address_street' => 'ESpachstr. 1',
 'payment_date' => '10:13:23 Feb 11, 2018 PST',
 'payment_status' => 'Pending',
 'charset' => 'windows-1252',
 'address_zip' => '79111',
 'first_name' => 'Lyubo',
 'address_country_code' => 'DE',
 'address_name' => 'Lyubo Minchev',
 'notify_version' => '3.8',
 'custom' => 'user,21|itemid,3|email,123@123|amount,3|random,770',
 'payer_status' => 'unverified',
 'address_country' => 'Germany',
 'address_city' => 'Freiburg',
 'quantity' => '1',
 'verify_sign' => 'ALxGJYdzDSvPgFHgC84ph2vBgxZUAwn9.eMqWp-N8gz-7.k75FwuYAIU',
 'payer_email' => '[email protected]',
 'txn_id' => '7P5784144H8732827',
 'payment_type' => 'instant',
 'last_name' => 'Minchev',
 'address_state' => 'Empty',
 'receiver_email' => '123@123',
 'pending_reason' => 'unilateral',
 'txn_type' => 'web_accept',
 'item_name' => 'Pay fee 3.00EUR for item 3',
 'mc_currency' => 'EUR',
 'item_number' => '901x2x3',
 'residence_country' => 'DE',
 'test_ipn' => '1',
 'transaction_subject' => '',
 'payment_gross' => '',
 'ipn_track_id' => '904ce17ce7',
)\n\n ---------------- \n\ncmd=_notify-validate&mc_gross=3.00&protection_eligibility=Ineligible&address_status=confirmed&payer_id=GRAC9Q3XQ78XA&address_street=ESpachstr.+1&payment_date=10%3A13%3A23+Feb+11%2C+2018+PST&payment_status=Pending&charset=windows-1252&address_zip=79111&first_name=Lyubo&address_country_code=DE&address_name=Lyubo+Minchev&notify_version=3.8&custom=user%2C21%7Citemid%2C3%7Cemail%2Clyubomir%40minchev.bg%7Camount%2C3%7Crandom%2C770&payer_status=unverified&address_country=Germany&address_city=Freiburg&quantity=1&verify_sign=ALxGJYdzDSvPgFHgC84ph2vBgxZUAwn9.eMqWp-N8gz-7.k75FwuYAIU&payer_email=test2%40muzikalnik.com&txn_id=7P5784144H8732827&payment_type=instant&last_name=Minchev&address_state=Empty&receiver_email=123%40123&pending_reason=unilateral&txn_type=web_accept&item_name=Pay+fee+3.00EUR+for+item+3&mc_currency=EUR&item_number=901x2x3&residence_country=DE&test_ipn=1&transaction_subject=&payment_gross=&ipn_track_id=904ce17ce7

I'v set a German account to test the Euro currency. That is the reason paypal site is dispayed in German language. Unfortunately paypal does not support BGN at all...

Any idea what could be the issue ?
Title: Re: paypal standbox test payment does not mark the listing as premium
Post by: MB Themes on February 11, 2018, 08:52:50 PM
Why you paid 3€ if your cart is 1.8€?
Can you see some error in your error log?
Title: Re: paypal standbox test payment does not mark the listing as premium
Post by: Lyubomir Minchev on February 11, 2018, 09:05:16 PM
Why you paid 3€ if your cart is 1.8€?
>> I 've made around 10 tests today and these 2 screenshots must have been from two different tests

I can do a new one to clear it up.

In error.log I can see just a single warning message logged:

[Sun Feb 11 19:46:07.213725 2018] [:error] [pid 23023] [client 80.72.82.97:54577] PHP Warning:  explode() expects parameter 2 to be string, array given in /var/www/html/muzikalnik/oc-content/plugins/osclass_pay/functions.php on line 1759, referer: https://xn--80andbicfdo8c.xn--90ae/osclasspay/item


function osp_cart_update($user_id, $content) {
....
..
   foreach($cart as $c) {
            $c = explode('x', $c);  <--- 1759 line


But nothing seem to be logging while performing the test payment, just the array being sent to the mail.
Title: Re: paypal standbox test payment does not mark the listing as premium
Post by: MB Themes on February 11, 2018, 09:16:07 PM
@Lyubomir
It would be nice to see what is array is in $c variable, as there should be none.
Title: Re: paypal standbox test payment does not mark the listing as premium
Post by: Lyubomir Minchev on February 11, 2018, 09:27:34 PM
I've just performed another test with another paypal account. I am attaching screenshots


Debug mail:

Code: [Select]
array (
 'extra' => 'user,21|itemid,4|email,123@123|amount,3.28|random,685',
 'mc_gross' => '3.28',
 'protection_eligibility' => 'Ineligible',
 'address_status' => 'confirmed',
 'payer_id' => 'WFJWZLSNYBX9Y',
 'address_street' => '1 Main St',
 'payment_date' => '12:17:20 Feb 11, 2018 PST',
 'payment_status' => 'Pending',
 'charset' => 'windows-1252',
 'address_zip' => '95131',
 'first_name' => 'test',
 'address_country_code' => 'US',
 'address_name' => 'test buyer',
 'notify_version' => '3.8',
 'custom' => 'user,21|itemid,4|email,123@123|amount,3.28|random,685',
 'payer_status' => 'verified',
 'address_country' => 'United States',
 'address_city' => 'San Jose',
 'quantity' => '1',
 'verify_sign' => 'AHp9oiqluE95fA8uzGJk82F5I2lNAG8BhlUd8vRqd34U4j.tKP5mkLzD',
 'payer_email' => [email protected]',
 'txn_id' => '7NJ90892A5651642K',
 'payment_type' => 'instant',
 'last_name' => 'buyer',
 'address_state' => 'CA',
 'receiver_email' => '123@123',
 'pending_reason' => 'unilateral',
 'txn_type' => 'web_accept',
 'item_name' => 'Pay fee 3.28EUR for item 4',
 'mc_currency' => 'EUR',
 'item_number' => '901x2x4',
 'residence_country' => 'US',
 'test_ipn' => '1',
 'transaction_subject' => '',
 'payment_gross' => '',
 'ipn_track_id' => '722939909ca44',
)\n\n ---------------- \n\ncmd=_notify-validate&mc_gross=3.28&protection_eligibility=Ineligible&address_status=confirmed&payer_id=WFJWZLSNYBX9Y&address_street=1+Main+St&payment_date=12%3A17%3A20+Feb+11%2C+2018+PST&payment_status=Pending&charset=windows-1252&address_zip=95131&first_name=test&address_country_code=US&address_name=test+buyer&notify_version=3.8&custom=user%2C21%7Citemid%2C4%7Cemail%2Clyubomir%40minchev.bg%7Camount%2C3.28%7Crandom%2C685&payer_status=verified&address_country=United+States&address_city=San+Jose&quantity=1&verify_sign=AHp9oiqluE95fA8uzGJk82F5I2lNAG8BhlUd8vRqd34U4j.tKP5mkLzD&payer_email=123-buyer%40gmail.com&txn_id=7NJ90892A5651642K&payment_type=instant&last_name=buyer&address_state=CA&receiver_email=123%40123&pending_reason=unilateral&txn_type=web_accept&item_name=Pay+fee+3.28EUR+for+item+4&mc_currency=EUR&item_number=901x2x4&residence_country=US&test_ipn=1&transaction_subject=&payment_gross=&ipn_track_id=722939909ca44


Around the warning message timestamp I've tried performing a payment with a real user and there was a misleading error at Paypal side....


Let me see if I will manage to print the $c variable and will write back.
Title: Re: paypal standbox test payment does not mark the listing as premium
Post by: Lyubomir Minchev on February 11, 2018, 10:45:10 PM
I have finally managed to print the $c variable.

I've added:

Code: [Select]
error_log("c array is: " .  $c);
at 3 times in the functions.php , one at the end of the script.

Here is what is logged in error.log:


Code: [Select]
[Sun Feb 11 23:31:55.549978 2018] [:error] [pid 25116] [client 80.72.82.97:57029] c array is: , referer: https://xn--80andbicfdo8c.xn--90ae/user/items
[Sun Feb 11 23:31:58.440651 2018] [:error] [pid 25116] [client 80.72.82.97:57029] c array is: , referer: https://xn--80andbicfdo8c.xn--90ae/%d0%a3%d0%b4%d0%b0%d1%80%d0%bd%d0%b8/%d0%90%d0%ba%d1%83%d1%81%d1%82%d0%b8%d1%87%d0%bd%d0%b8-%d0%b1%d0%b0%d1%80%d0%b0%d0%b1%d0%b0%d0%bd%d0%b8/%d0%a4%d0%b5%d0%b9%d0%b7%d1%8a%d1%80_i4
[Sun Feb 11 23:31:58.480630 2018] [:error] [pid 25116] [client 80.72.82.97:57029] c array is: , referer: https://xn--80andbicfdo8c.xn--90ae/%d0%a3%d0%b4%d0%b0%d1%80%d0%bd%d0%b8/%d0%90%d0%ba%d1%83%d1%81%d1%82%d0%b8%d1%87%d0%bd%d0%b8-%d0%b1%d0%b0%d1%80%d0%b0%d0%b1%d0%b0%d0%bd%d0%b8/%d0%a4%d0%b5%d0%b9%d0%b7%d1%8a%d1%80_i4
[Sun Feb 11 23:32:38.353008 2018] [:error] [pid 25219] [client 173.0.82.126:39465] c array is:
[Sun Feb 11 23:33:00.613193 2018] [:error] [pid 25114] [client 80.72.82.97:57068] c array is: , referer: https://www.sandbox.paypal.com/webapps/hermes?token=9NS91094HT396620B&useraction=commit&rm=2&mfid=1518384721734_9c2fe59c8f7d0
[Sun Feb 11 23:33:00.802165 2018] [:error] [pid 25114] [client 80.72.82.97:57068] c array is: , referer: https://xn--80andbicfdo8c.xn--90ae/oc-content/plugins/osclass_pay/payments/paypl/return.php?extra=user,21|itemid,4|email,[email protected]|amount,3.28|random,152

So, it seems like right after the successfull payment it gets no value ( no output in the log ).
The last 2 lines from the log are logged after clicking the button, which returns to the original page.
Title: Re: paypal standbox test payment does not mark the listing as premium
Post by: MB Themes on February 12, 2018, 01:08:21 PM
On your site if you open this link:
oc-content/plugins/osclass_pay/payments/paypl/return.php?extra=user,21|itemid,4|email,[email protected]|amount,3.28|random,152

Do you get any error?
Title: Re: paypal standbox test payment does not mark the listing as premium
Post by: Lyubomir Minchev on February 12, 2018, 01:13:09 PM
It says: "We are processing your payment, if it did not finish in a few seconds, please contact us"
The same flash message in green, but displayed at the main page.
Site is still accessible on https://xn--80andbicfdo8c.xn--90ae
( I've migrated it to IDN domain in the last few days. )

Here is the link to reproduce:

Code: [Select]
https://xn--80andbicfdo8c.xn--90ae/oc-content/plugins/osclass_pay/payments/paypl/return.php?extra=user,21|itemid,4|email,[email protected]|amount,3.28|random,152
Title: Re: paypal standbox test payment does not mark the listing as premium
Post by: MB Themes on February 12, 2018, 01:15:59 PM
This one is incorrect link:
https://xn--80andbicfdo8c.xn--90ae/oc-content/plugins/osclass_pay/payments/paypl/return.phpextra=user,21|itemid,4|email,[email protected]|amount,3.28|random,152

This one is correct (there should be ? before extra):
https://xn--80andbicfdo8c.xn--90ae/oc-content/plugins/osclass_pay/payments/paypl/return.php?extra=user,21|itemid,4|email,[email protected]|amount,3.28|random,152
Title: Re: paypal standbox test payment does not mark the listing as premium
Post by: Lyubomir Minchev on February 13, 2018, 07:38:43 PM
I am really happy to share that I have found out a workaround !

If I switch off the button:

"Use "Standard Payments" if "Digital Goods" is not available in your country"

then a small paypal window is popping up and after filling in the credentials I get a successfull payment:

"Payment processed correctly"


Before I was redirected to a paypal site at the same browser tab. No small popup windows. It seems like it falls back to a standard payment, which can not proceed it further.


I suspect all this should come from the block below:


Code: [Select]
if(osp_param('paypal_standard') == 1) {
 20     $product_type = explode('x', Params::getParam('item_number'));
 21     $tx = Params::getParam('txn_id') <> '' ? Params::getParam('txn_id') : Params::getParam('tx');
 22     $payment = ModelOSP::newInstance()->getPaymentByCode($tx, 'PAYPAL');
 23     
 24     if (isset($payment['pk_i_id'])) {
 25       osc_add_flash_ok_message(sprintf(__('Success! Please write down this transaction ID in case you have any problem: %s', 'osclass_pay'), $tx));
 26     } else {
 27       osc_add_flash_info_message(sprintf(__('We are processing your payment, if it did not finish in a few seconds, please contact us', 'osclass_pay'), $tx));
 28     }

The same behaviour when buying packs.

Cheers!
Lyubo
Title: Re: paypal standbox test payment does not mark the listing as premium
Post by: MB Themes on February 14, 2018, 01:02:53 PM
@Lyubomir
If I understand correctly, it works for standard payment and does not work for digital goods?
Title: Re: paypal standbox test payment does not mark the listing as premium
Post by: Lyubomir Minchev on February 14, 2018, 03:38:29 PM
Right opposite.

It works with digital goods, but it does not with the standard, when the standard payment is enabled in admin panel.

I am not very familiar what is the actual difference. I find Paypal documentation and all their sites confusing and not well summarized.
If I understand correctly API credentials are being used for Digital Goods or express payment/micro-payments.
Title: Re: paypal standbox test payment does not mark the listing as premium
Post by: MB Themes on February 14, 2018, 08:12:09 PM
@Lyubomir
Digital goods should be used just for very small amount and are not enabled in each country.
I am using standard payments and never got such issue.

Mail me login to your FTP and we can try to investigate it bit more.
Title: Re: paypal standbox test payment does not mark the listing as premium
Post by: Lyubomir Minchev on February 25, 2018, 03:23:04 PM
Today I did a real payment from my personal credit card and found out this behavior is the same.
I have also tried changing from


Code: [Select]
if(osp_param('paypal_standard') == 1) {
    $product_type = explode('x', Params::getParam('item_number'));
    $tx = Params::getParam('txn_id') <> '' ? Params::getParam('txn_id') : Params::getParam('tx');
    $payment = ModelOSP::newInstance()->getPaymentByCode($tx, 'PAYPAL');
    error_log(print_r($tx));   
    error_log(gettype($tx));   
    if (isset($payment['pk_i_id'])) {
      osc_add_flash_ok_message(sprintf(__('Success! Please write down this transaction ID in case you have any problem: %s', 'osclass_pay'), $tx));
    } else {
      osc_add_flash_info_message(sprintf(__('We are processing your payment, if it did not finish in a few seconds, please contact us', 'osclass_pay'), $tx));
    }

    $status = PaypalPayment::processPayment();
    osp_js_redirect_to(osp_pay_url_redirect($product_type));

to

Code: [Select]
if(osp_param('paypal_standard') == 1) {
    $status = PaypalPayment::processPayment();
    $product_type = explode('x', Params::getParam('item_number'));
    $tx = Params::getParam('txn_id') <> '' ? Params::getParam('txn_id') : Params::getParam('tx');
    $payment = ModelOSP::newInstance()->getPaymentByCode($tx, 'PAYPAL');
    error_log(print_r($tx));   
    error_log(gettype($tx));   
    if (isset($payment['pk_i_id'])) {
      osc_add_flash_ok_message(sprintf(__('Success! Please write down this transaction ID in case you have any problem: %s', 'osclass_pay'), $tx));
    } else {
      osc_add_flash_info_message(sprintf(__('We are processing your payment, if it did not finish in a few seconds, please contact us', 'osclass_pay'), $tx));
    }

    osp_js_redirect_to(osp_pay_url_redirect($product_type));

with no results.

I can not believe I am the only one who does not have the paypal standard working.
Is it working for you guys ?


Thanks
Title: Re: paypal standbox test payment does not mark the listing as premium
Post by: MB Themes on February 25, 2018, 08:01:10 PM
@Lyubomir
We use it at osclasspoint.com and everything works allright, but it does not mean something is wrong there.
Do please one more test and before that, do this modification.

Above line osp_js_redirect_to put following:
Code: [Select]
      $emailtext = "status => " . $status . "\r\n";
      $emailtext .= osp_array_to_string($product_type). "\r\n";
      $emailtext .= osp_array_to_string($tx). "\r\n";
      $emailtext .= osp_array_to_string(Params::getParamsAsArray());
      mail(osc_contact_email() , 'OSCLASS PAY - PAYPAL DEBUG RESPONSE (RETURN TEST)', $emailtext);

This will mail you parameters of payment, please put it there (take care if there are no personal data inside ;) )
Title: Re: paypal standbox test payment does not mark the listing as premium
Post by: Lyubomir Minchev on February 25, 2018, 11:25:42 PM
Hope this would help


Code: [Select]
array (
 'extra' => 'user,21|itemid,13|email,xxxx@xxxx|amount,0.5|random,195',
 'mc_gross' => '0.50',
 'protection_eligibility' => 'Ineligible',
 'address_status' => 'confirmed',
 'payer_id' => 'WFJWZLSNYBX9Y',
 'address_street' => '1 Main St',
 'payment_date' => '14:02:24 Feb 25, 2018 PST',
 'payment_status' => 'Pending',
 'charset' => 'windows-1252',
 'address_zip' => '95131',
 'first_name' => 'test',
 'address_country_code' => 'US',
 'address_name' => 'test buyer',
 'notify_version' => '3.9',
 'custom' => 'user,21|itemid,13|email,xxx@xxx|amount,0.5|random,195',
 'payer_status' => 'verified',
 'address_country' => 'United States',
 'address_city' => 'San Jose',
 'quantity' => '1',
 'verify_sign' => 'Ai2wvIVeSssqwxVcMK9XcafWsgAPAK3dfgz-CtZZ9Y07-GVt1GHf9O-E',
 'payer_email' => '[email protected]',
 'txn_id' => '8G734104119921723',
 'payment_type' => 'instant',
 'last_name' => 'buyer',
 'address_state' => 'CA',
 'receiver_email' => 'xxx@xxx',
 'pending_reason' => 'unilateral',
 'txn_type' => 'web_accept',
 'item_name' => 'Pay fee 0.50EUR for item 13',
 'mc_currency' => 'EUR',
 'item_number' => '901x2x13',
 'residence_country' => 'US',
 'test_ipn' => '1',
 'transaction_subject' => '',
 'payment_gross' => '',
 'ipn_track_id' => 'f1eb74ab492a8',
)\n\n ---------------- \n\ncmd=_notify-validate&mc_gross=0.50&protection_eligibility=Ineligible&address_status=confirmed&payer_id=WFJWZLSNYBX9Y&address_street=1+Main+St&payment_date=14%3A02%3A24+Feb+25%2C+2018+PST&payment_status=Pending&charset=windows-1252&address_zip=95131&first_name=test&address_country_code=US&address_name=test+buyer&notify_version=3.9&custom=user%2C21%7Citemid%2C13%7Cemail%2Clxxxx%40xxxx%7Camount%2C0.5%7Crandom%2C195&payer_status=verified&address_country=United+States&address_city=San+Jose&quantity=1&verify_sign=Ai2wvIVeSssqwxVcMK9XcafWsgAPAK3dfgz-CtZZ9Y07-GVt1GHf9O-E&payer_email=lyubomir-buyer%40gmail.com&txn_id=8G734104119921723&payment_type=instant&last_name=buyer&address_state=CA&receiver_email=xxx%40xxx&pending_reason=unilateral&txn_type=web_accept&item_name=Pay+fee+0.50EUR+for+item+13&mc_currency=EUR&item_number=901x2x13&residence_country=US&test_ipn=1&transaction_subject=&payment_gross=&ipn_track_id=f1eb74ab492a8
Title: Re: paypal standbox test payment does not mark the listing as premium
Post by: MB Themes on February 26, 2018, 08:46:14 AM
@Lyubomir
Some values are missing there:
      $emailtext = "status => " . $status . "\r\n";
      $emailtext .= osp_array_to_string($product_type). "\r\n";


But I think problem is there:
'payment_status' => 'Pending',

How it happen that instant payment is in pending state?

In plugin you can update pending payments to be accepted as well.
In file:
oc-content/plugins/osclass_pay/payments/paypl/Paypl.php

find:
Code: [Select]
if (Params::getParam('payment_status') == 'Completed' || Params::getParam('st') == 'Completed') {

change into:
Code: [Select]
      $payment_status = strtolower(Params::getParam('payment_status') <> '' ? Params::getParam('payment_status') : Params::getParam('st'));
 
      if($payment_status == 'completed' || $payment_status == 'pending') {
Title: Re: paypal standbox test payment does not mark the listing as premium
Post by: Lyubomir Minchev on February 26, 2018, 03:35:29 PM
Thank you for your workaround.

I have also noticed this weird 'payment_status' => 'Pending' at the initial debug report.
I am starting to suspect that it must be the Paypal which doesn't work well with IDN domains and thus, it doesn't return the payment confirmation properly. This must be the reason why it only fails for me, because I have migrated to IDN domain.

Yesterday I found out that their mail confirmation link doesn't work if mail address contains IDN domain.

I will try to research more on this and if nothing found will implement the workaround as a last resort.


Thank you
Title: Re: paypal standbox test payment does not mark the listing as premium
Post by: Lyubomir Minchev on March 01, 2018, 12:04:02 AM
I am happy to share that I managed to get it working without applying the workaround.
It is the PayPal, who does not return the payment confirmation ( IPN ) properly. Nothing wrong with the plugin!

The below article

https://stackoverflow.com/questions/4298117/paypal-ipn-always-return-payment-status-pending-on-sandbox

gave me some hints to the resolution. In my case it must have been the different currencies ( price in EUR account in US ) or not correctly set a merchant email address.

I've performed two tests:

1. Standbox account set in Austria to match with the EUR currency of the item price
2. Real payment from my personal paypal account.

And both were successsfull.

I will write down the workaround to have it just in case.

Thank you for all your help!
Title: Re: paypal standbox test payment does not mark the listing as premium
Post by: Ivanko on March 01, 2018, 12:39:16 AM
I am happy to share that I managed to get it working without applying the workaround.
It is the PayPal, who does not return the payment confirmation ( IPN ) properly. Nothing wrong with the plugin!

The below article

https://stackoverflow.com/questions/4298117/paypal-ipn-always-return-payment-status-pending-on-sandbox

gave me some hints to the resolution. In my case it must have been the different currencies ( price in EUR account in US ) or not correctly set a merchant email address.

I've performed two tests:

1. Standbox account set in Austria to match with the EUR currency of the item price
2. Real payment from my personal paypal account.

And both were successsfull.

I will write down the workaround to have it just in case.

Thank you for all your help!
dont you have set up in paypal area - accept all currencies with auto convert.(something like this)?
I remember this settings, and it was important one.
Title: Re: paypal standbox test payment does not mark the listing as premium
Post by: schilaci on June 06, 2022, 09:04:55 PM
I'm having same issue with paypal. strip payment working fine but not paypal.

have you fixed it?