jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/345189 )
Change subject: Mark refunds with correct gateway ...................................................................... Mark refunds with correct gateway Express checkout sets the transaction_subject field to an explicit description Legacy puts a tracking number in that field, we can use that to distinguish the proper gateway. Bug: T161121 Change-Id: Ibf14e1083b92d3caa50066315256b6614e77af9c --- M PaymentProviders/PayPal/RefundMessage.php A PaymentProviders/PayPal/Tests/Data/refund_ec.json A PaymentProviders/PayPal/Tests/Data/refund_ec_transformed.json A PaymentProviders/PayPal/Tests/Data/refund_recurring_ec.json A PaymentProviders/PayPal/Tests/Data/refund_recurring_ec_transformed.json M PaymentProviders/PayPal/Tests/phpunit/CaptureIncomingMessageTest.php 6 files changed, 131 insertions(+), 1 deletion(-) Approvals: jenkins-bot: Verified Ejegg: Looks good to me, approved diff --git a/PaymentProviders/PayPal/RefundMessage.php b/PaymentProviders/PayPal/RefundMessage.php index cbac123..98227a6 100644 --- a/PaymentProviders/PayPal/RefundMessage.php +++ b/PaymentProviders/PayPal/RefundMessage.php @@ -13,6 +13,14 @@ } else { $message['type'] = 'refund'; } - $message['gateway'] = 'paypal'; + + // Express checkout puts a description in transaction_subject, Legacy puts a contribution + // tracking ID there. Chargebacks don't set the field at all. + if ( isset( $ipnMessage['transaction_subject'] ) && !is_numeric( $ipnMessage['transaction_subject'] ) ) { + $message['gateway'] = 'paypal_ec'; + } else { + $message['gateway'] = 'paypal'; + } + } } diff --git a/PaymentProviders/PayPal/Tests/Data/refund_ec.json b/PaymentProviders/PayPal/Tests/Data/refund_ec.json new file mode 100644 index 0000000..03b6048 --- /dev/null +++ b/PaymentProviders/PayPal/Tests/Data/refund_ec.json @@ -0,0 +1,37 @@ +{ + "mc_gross": "-150", + "invoice": "46239229.0", + "protection_eligibility": "Ineligible", + "payer_id": "RWASDASJ2AS3A", + "payment_date": "09:34:59 Mar 22, 2017 PDT", + "payment_status": "Refunded", + "charset": "UTF-8", + "first_name": "Testy", + "mc_fee": "-43", + "notify_version": "3.8", + "reason_code": "refund", + "custom": "46239229", + "business": "gi...@takers.org", + "verify_sign": "Ar65LQ8D4i5231dnJnwTy8lT8UaGAoJGWSH0c1M93d3B86D4ZGVpax3T", + "payer_email": "do...@generous.net", + "parent_txn_id": "1V551844CE5526421", + "txn_id": "3HD08833MR473623T", + "payment_type": "instant", + "last_name": "McTesterson", + "receiver_email": "gi...@takers.org", + "payment_fee": "", + "shipping_discount": "0", + "receiver_id": "TWDK67ASD2XXY", + "insurance_amount": "0", + "item_name": "Donation to the Wikimedia Foundation", + "discount": "0", + "mc_currency": "JPY", + "item_number": "", + "residence_country": "US", + "handling_amount": "0", + "shipping_method": "Default", + "transaction_subject": "Donation to the Wikimedia Foundation", + "payment_gross": "", + "shipping": "0", + "ipn_track_id": "4e93f423dd88b" +} diff --git a/PaymentProviders/PayPal/Tests/Data/refund_ec_transformed.json b/PaymentProviders/PayPal/Tests/Data/refund_ec_transformed.json new file mode 100644 index 0000000..06cfd66 --- /dev/null +++ b/PaymentProviders/PayPal/Tests/Data/refund_ec_transformed.json @@ -0,0 +1,20 @@ +{ + "date": 1490200499, + "gateway_parent_id": "1V551844CE5526421", + "gateway_txn_id": "3HD08833MR473623T", + "currency": "JPY", + "type": "refund", + "contribution_tracking_id": "46239229", + "email": "do...@generous.net", + "first_name": "Testy", + "last_name": "McTesterson", + "gross": "-150", + "fee": "-43", + "order_id": "46239229", + "gateway_refund_id": "3HD08833MR473623T", + "gross_currency": "JPY", + "gateway": "paypal_ec", + "source_name": "SmashPig", + "source_type": "listener", + "source_version": "unknown" +} diff --git a/PaymentProviders/PayPal/Tests/Data/refund_recurring_ec.json b/PaymentProviders/PayPal/Tests/Data/refund_recurring_ec.json new file mode 100644 index 0000000..41f7e78 --- /dev/null +++ b/PaymentProviders/PayPal/Tests/Data/refund_recurring_ec.json @@ -0,0 +1,42 @@ +{ + "mc_gross": "-150", + "period_type": " Regular", + "outstanding_balance": "0", + "next_payment_date": "N\/A", + "protection_eligibility": "Ineligible", + "payment_cycle": "Monthly", + "payer_id": "RWASDASJ2AS3A", + "payment_date": "09:33:51 Mar 22, 2017 PDT", + "payment_status": "Refunded", + "product_name": "Monthly donation to the Wikimedia Foundation", + "charset": "UTF-8", + "rp_invoice_id": "45931681", + "recurring_payment_id": "I-DD1FNAAAUU22", + "first_name": "Testy", + "mc_fee": "-43", + "notify_version": "3.8", + "amount_per_cycle": "150", + "reason_code": "refund", + "currency_code": "JPY", + "business": "gi...@takers.org", + "verify_sign": "APvissTSNYxEsF2tvyvfCnTn10fsA3zfe8wcXg8--8099IMv8ObkEkCi", + "payer_email": "do...@generous.net", + "parent_txn_id": "4GV70894MM323713P", + "initial_payment_amount": "0", + "profile_status": "Cancelled", + "amount": "150", + "txn_id": "4CX17568KP793000L", + "payment_type": "instant", + "last_name": "McTesterson", + "receiver_email": "gi...@takers.org", + "payment_fee": "", + "receiver_id": "TWDK67ASD2XXY", + "mc_currency": "JPY", + "residence_country": "US", + "transaction_subject": "Monthly donation to the Wikimedia Foundation", + "payment_gross": "", + "shipping": "0", + "product_type": "1", + "time_created": "16:54:13 Feb 01, 2017 PST", + "ipn_track_id": "d86d241a67ab" +} \ No newline at end of file diff --git a/PaymentProviders/PayPal/Tests/Data/refund_recurring_ec_transformed.json b/PaymentProviders/PayPal/Tests/Data/refund_recurring_ec_transformed.json new file mode 100644 index 0000000..3735881 --- /dev/null +++ b/PaymentProviders/PayPal/Tests/Data/refund_recurring_ec_transformed.json @@ -0,0 +1,21 @@ +{ + "date": 1490200431, + "gateway_parent_id": "4GV70894MM323713P", + "gateway_txn_id": "4CX17568KP793000L", + "currency": "JPY", + "type": "refund", + "contribution_tracking_id": "45931681", + "email": "do...@generous.net", + "first_name": "Testy", + "last_name": "McTesterson", + "gross": "-150", + "fee": "-43", + "order_id": "45931681", + "gateway_refund_id": "4CX17568KP793000L", + "gross_currency": "JPY", + "gateway": "paypal_ec", + "subscr_id": "I-DD1FNAAAUU22", + "source_name": "SmashPig", + "source_type": "listener", + "source_version": "unknown" +} diff --git a/PaymentProviders/PayPal/Tests/phpunit/CaptureIncomingMessageTest.php b/PaymentProviders/PayPal/Tests/phpunit/CaptureIncomingMessageTest.php index 1a64a11..1f91150 100644 --- a/PaymentProviders/PayPal/Tests/phpunit/CaptureIncomingMessageTest.php +++ b/PaymentProviders/PayPal/Tests/phpunit/CaptureIncomingMessageTest.php @@ -31,6 +31,8 @@ 'subscr_payment.json' => 'recurring', 'recurring_payment.json' => 'recurring', 'refund.json' => 'refund-new', + 'refund_ec.json' => 'refund-new', + 'refund_recurring_ec.json' => 'refund-new', 'chargeback_settlement.json' => 'refund-new', // this should not actually get written to // TODO 'new_case.json' => 'no-op', -- To view, visit https://gerrit.wikimedia.org/r/345189 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ibf14e1083b92d3caa50066315256b6614e77af9c Gerrit-PatchSet: 7 Gerrit-Project: wikimedia/fundraising/SmashPig Gerrit-Branch: master Gerrit-Owner: XenoRyet <dkozlow...@wikimedia.org> Gerrit-Reviewer: Awight <awi...@wikimedia.org> Gerrit-Reviewer: Cdentinger <cdentin...@wikimedia.org> Gerrit-Reviewer: Ejegg <eeggles...@wikimedia.org> Gerrit-Reviewer: XenoRyet <dkozlow...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits