Jump to content

[Commerce] IPN while commerce is offline


Ahmad E.

Recommended Posts

Hello everyone,

so I've had a client contact me due to the following issue:

When someone pays for some product (let's say an ad) through my commerce gateway (Coinpayments in this case), the ad is never created. The transaction shows up and is marked as approved but what the package is supposed to do, doesn't happen (be it create an ad, move into customer group etc.).

Now after debugging I found out what the issue is:

The commerce app was disabled except for some groups, what happens in this case is the following:

  1. IPN is received by the gateway - all ok
  2. Gateway tries to approve the transaction by calling "$transaction->approve()"
  3. In applications/nexus/sources/Transaction/Transaction.php:651 the invoice is marked as paid
  4. In applications/nexus/sources/Invoice/Invoice.php:1690 the foreach triggers the "current()" method in the items iterator
  5. "current()" method is in applications/nexus/sources/Invoice/ItemsIterator.php:246
  6. In the "arrayToObject()" method on line 59 all commerce extensions are retrieved

The bit of (problematic?) code is:

foreach ( \IPS\Application::allExtensions( 'nexus', 'Item', TRUE, NULL, NULL, FALSE ) as $ext )

When the IPN request is asynchronous, the user is gonna be a guest for which commerce is disabled and thus the commerce extensions aren't included in the result.
Which in turn leads to commerce not using the correct package class but the default one "IPS\nexus\extensions\nexus\Item\MiscellaneousCharge".

The client said PayPal worked just fine - which is correct but that's because the IPN is called synchronously in the user request when the user is still authenticated.

Now my question is:

Is this the desired behavior? I can just do something like this in my gateway:

 if ($transaction->member ) {
    \IPS\Session::i()->setMember( $transaction->member );
}

Which works fine but I want to make sure there isn't a bug in IPS which may be affecting other users.

Best Regards,
Ahmad E.

Link to comment
Share on other sites

  • 4 months later...

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...