Ejegg has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/366870 )

Change subject: PayPal EC recurring: initial donation is async
......................................................................

PayPal EC recurring: initial donation is async

After we set up a subscription, the initial donation isn't immediately
charged. So we don't have a donation to send to the queue here, just
a subscr_id. We're stashing this in the pending queue now, for potential
use later.

Note that this is actually how all donations work with the legacy PayPal
integration - the payments cluster just sets things up and lets the IPN
listener handle the payment notifications and getting stuff into Civi.

Bug: T170478
Change-Id: I5f80586485d6a0cef53c5d19ce8913e61c258121
---
M paypal_gateway/express_checkout/paypal_express.adapter.php
M tests/phpunit/Adapter/PayPal/PayPalExpressTest.php
M 
tests/phpunit/includes/Responses/paypal_ec/CreateRecurringPaymentsProfile_Recurring-OK.testresponse
3 files changed, 11 insertions(+), 50 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface 
refs/changes/70/366870/1

diff --git a/paypal_gateway/express_checkout/paypal_express.adapter.php 
b/paypal_gateway/express_checkout/paypal_express.adapter.php
index 6eabf1b..5c6f0fd 100644
--- a/paypal_gateway/express_checkout/paypal_express.adapter.php
+++ b/paypal_gateway/express_checkout/paypal_express.adapter.php
@@ -343,8 +343,7 @@
                        'response' => array(
                                # FIXME: Make sure this gets passed as 
subscription_id in the message
                                'PROFILEID',
-                               'PROFILESTATUS',
-                               'TRANSACTIONID',
+                               'PROFILESTATUS'
                        ),
                );
 
@@ -408,20 +407,16 @@
                        case 'CreateRecurringPaymentsProfile':
                                $this->checkResponseAck( $response );
 
-                               // Grab the subscription ID and transaction ID 
for the
-                               // initial charge.
+                               // Grab the subscription ID
                                $this->addResponseData( $this->unstageKeys( 
$response ) );
-                               // FIXME: Silly to store this thing in two 
places.
-                               // The queue message functions look for it in 
transaction_response.
-                               // We should make all the gateways store it in 
the standard
-                               // data fields and get rid of the 
transaction_response field.
-                               
$this->transaction_response->setGatewayTransactionId(
-                                       $this->getData_Unstaged_Escaped( 
'gateway_txn_id' )
-                               );
 
-                               // FIXME: Not a satisfying ending.  Parse the 
PROFILESTATUS
-                               // response and sort it into complete or 
pending.
-                               $this->finalizeInternalStatus( 
FinalStatus::COMPLETE );
+                               // We've created a subscription, but we haven't 
got an initial
+                               // payment yet, so we leave the details in the 
pending queue.
+                               // The IPN listener will push the donation 
through to Civi when
+                               // it gets notifications from PayPal.
+                               // TODO: it would be nice to send the 
subscr_start message to
+                               // the recurring queue here.
+                               $this->finalizeInternalStatus( 
FinalStatus::PENDING );
                                $this->postProcessDonation();
                                break;
                        case 'SetExpressCheckout':
diff --git a/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php 
b/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php
index a2a3e63..b13db0c 100644
--- a/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php
+++ b/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php
@@ -203,41 +203,7 @@
                ) );
 
                $message = DonationQueue::instance()->pop( 'donations' );
-               $this->assertNotNull( $message, 'Not sending a message to the 
donations queue' );
-               self::unsetVariableFields( $message );
-               $expected = array(
-                       'contribution_tracking_id' => 
$init['contribution_tracking_id'],
-                       'country' => 'US',
-                       'fee' => '0',
-                       'gateway' => 'paypal_ec',
-                       'gateway_txn_id' => '5EJ123456T987654S',
-                       'gateway_session_id' => 'EC-4V987654XA123456V',
-                       'language' => 'en',
-                       'order_id' => $init['contribution_tracking_id'] . '.0',
-                       'payment_method' => 'paypal',
-                       'payment_submethod' => '',
-                       'response' => false,
-                       'user_ip' => '127.0.0.1',
-                       'utm_source' => '..rpaypal',
-                       'city' => 'San Francisco',
-                       'currency' => 'USD',
-                       'email' => 'do...@generous.net',
-                       'first_name' => 'Fezziwig',
-                       'gross' => '1.55',
-                       'last_name' => 'Fowl',
-                       'recurring' => '1',
-                       'state_province' => 'CA',
-                       'street_address' => '123 Fake Street',
-                       'postal_code' => '94105',
-                       'source_name' => 'DonationInterface',
-                       'source_type' => 'payments',
-                       'subscr_id' => 'I-88J1M3DLSF0',
-               );
-               $this->assertEquals( $expected, $message );
-               $this->assertNull(
-                       DonationQueue::instance()->pop( 'donations' ),
-                       'Sending extra messages to donations queue!'
-               );
+               $this->assertNull( $message, 'Recurring should not send a 
message to the donations queue' );
        }
 
        /**
diff --git 
a/tests/phpunit/includes/Responses/paypal_ec/CreateRecurringPaymentsProfile_Recurring-OK.testresponse
 
b/tests/phpunit/includes/Responses/paypal_ec/CreateRecurringPaymentsProfile_Recurring-OK.testresponse
index 7617c93..77d7506 100644
--- 
a/tests/phpunit/includes/Responses/paypal_ec/CreateRecurringPaymentsProfile_Recurring-OK.testresponse
+++ 
b/tests/phpunit/includes/Responses/paypal_ec/CreateRecurringPaymentsProfile_Recurring-OK.testresponse
@@ -1 +1 @@
-TRANSACTIONID=5EJ123456T987654S&PROFILEID=I%2d88J1M3DLSF0&PROFILESTATUS=ActiveProfile&TIMESTAMP=2017%2d04%2d18T16%3a45%3a29Z&CORRELATIONID=4312c123aa0f2&ACK=Success&VERSION=204&BUILD=25237094
+PROFILEID=I%2d88J1M3DLSF0&PROFILESTATUS=ActiveProfile&TIMESTAMP=2017%2d04%2d18T16%3a45%3a29Z&CORRELATIONID=4312c123aa0f2&ACK=Success&VERSION=204&BUILD=25237094

-- 
To view, visit https://gerrit.wikimedia.org/r/366870
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5f80586485d6a0cef53c5d19ce8913e61c258121
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Ejegg <ej...@ejegg.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to