Page MenuHomePhabricator

Add PendingTransaction::resolve API call that replicates Ingenico orphan rectifier
Closed, ResolvedPublic

Description

Probably put this in the wmf-civicrm module
This is supposed to resolve a single transaction by either capturing it (moving it from status 600 to 800), canceling it, or discarding it (already failed).

  • called with an array of data in the format that is stored in the pending table
  • implements the basic flow from DonationInterface's IngenicoGateway::rectifyOrphan without relying on DonationInterface
    • including canceling pending donations where a contribution already exists with the same contribution tracking ID
    • get hosted checkout status based on gateway_session_id
      • if that status has 'tokens' field and pending message's is_recurring is true, add the token to any output message as recurring_payment_token
    • if status code is 600, check fraud score (see T291230) and decide whether to capture payment
    • send message to antifraud queue with results of fraud score
    • if fraud score is > REJECT threshold, cancel payment
    • if fraud score is fine, call approvePayment and send a message to the donations queue
  • this version only has to work for Ingenico, so for now we can deal with the non-normalized return value from SmashPig's Ingenico\HostedCheckoutProvider::getHostedCheckoutStatus
    • at this point in the year we should probably not refactor SmashPig in a way that affects payments-wiki's Ingenico flow
    • Where possible, still try to write in a gateway-agnostic way. Add TODOs for places that are Ingenico-specific.
    • next year when we rewrite the PayPal integration would be the time to refactor getHostedCheckoutStatus to return a new, normalized PaymentProviderResponse subclass

You can also refer to the SmashPig Civi extension for examples of capturing a payment directly from CiviCRM and sending a message to the donations queue.

Details

SubjectRepoBranchLines +/-
wikimedia/fundraising/SmashPigmaster+107 -3
mediawiki/extensions/DonationInterfacemaster+1 -1
wikimedia/fundraising/SmashPigmaster+2 -2
wikimedia/fundraising/crmmaster+2 -18
wikimedia/fundraising/crmmaster+80 -41
wikimedia/fundraising/crmmaster+161 -11
wikimedia/fundraising/crmmaster+558 -0
wikimedia/fundraising/crmmaster+213 -4
mediawiki/extensions/DonationInterfacemaster+55 -41
wikimedia/fundraising/crmmaster+125 -5
wikimedia/fundraising/SmashPigmaster+16 -3
wikimedia/fundraising/crmmaster+112 -6
wikimedia/fundraising/crmmaster+144 -11
wikimedia/fundraising/crmmaster+40 -6
wikimedia/fundraising/SmashPigmaster+29 -9
wikimedia/fundraising/crmmaster+32 -8
wikimedia/fundraising/crmmaster+71 -28
mediawiki/extensions/DonationInterfacemaster+142 -108
wikimedia/fundraising/SmashPigmaster+23 -10
Show related patches Customize query in gerrit

Event Timeline

Change 722703 had a related patch set uploaded (by Ejegg; author: Ejegg):

[wikimedia/fundraising/crm@master] WIP notes towards moving orphan logic

https://gerrit.wikimedia.org/r/722703

Change 724232 had a related patch set uploaded (by Cstone; author: Cstone):

[wikimedia/fundraising/SmashPig@master] WIP Switch getHostedPaymentStatus to return a PaymentDetailResponse

https://gerrit.wikimedia.org/r/724232

Change 724233 had a related patch set uploaded (by Cstone; author: Cstone):

[mediawiki/extensions/DonationInterface@master] WIP DI part of switching getHostedPaymentStatus to return a PaymentDetailResponse

https://gerrit.wikimedia.org/r/724233

Change 732788 had a related patch set uploaded (by Jgleeson; author: Jgleeson):

[wikimedia/fundraising/SmashPig@master] Updated Ingenico getHostedPaymentStatus response to now return an instance of PaymentDetailResponse.

https://gerrit.wikimedia.org/r/732788

Change 732790 had a related patch set uploaded (by Jgleeson; author: Jgleeson):

[mediawiki/extensions/DonationInterface@master] WIP: Update $result handling for Ingenico getHostedPaymentStatus call as this now returns an instance of PaymentDetailResponse.

https://gerrit.wikimedia.org/r/732790

Change 724232 merged by jenkins-bot:

[wikimedia/fundraising/SmashPig@master] Switch getHostedPaymentStatus to return a PaymentDetailResponse

https://gerrit.wikimedia.org/r/724232

Change 724233 merged by jenkins-bot:

[mediawiki/extensions/DonationInterface@master] DI part of switching getHostedPaymentStatus to return a PaymentDetailResponse

https://gerrit.wikimedia.org/r/724233

Change 736874 had a related patch set uploaded (by Jgleeson; author: Jgleeson):

[wikimedia/fundraising/SmashPig@master] WIP: standardise cancelPayment behaviour

https://gerrit.wikimedia.org/r/736874

Change 736877 had a related patch set uploaded (by Jgleeson; author: Jgleeson):

[mediawiki/extensions/DonationInterface@master] WIP: update cancelPayment response handling

https://gerrit.wikimedia.org/r/736877

I made a start on an Activity Diagram to help explain how the current Ophan Slayer works

orphan.png (1×715 px, 101 KB)

The PNG thumbnail isn't great so to view the complete SVG head over to here

Change 739354 had a related patch set uploaded (by Jgleeson; author: Jgleeson):

[wikimedia/fundraising/crm@master] WIP: Add tests for Pending trxn resolver

https://gerrit.wikimedia.org/r/739354

Change 740661 had a related patch set uploaded (by Jgleeson; author: Jgleeson):

[wikimedia/fundraising/crm@master] WIP: Pending Transaction Resolver Tests

https://gerrit.wikimedia.org/r/740661

Change 740666 had a related patch set uploaded (by Damilare Adedoyin; author: Damilare Adedoyin):

[wikimedia/fundraising/crm@master] WIP: Pending Transaction Resolver Tests

https://gerrit.wikimedia.org/r/740666

Change 740661 abandoned by Jgleeson:

[wikimedia/fundraising/crm@master] WIP: Pending Transaction Resolver Tests

Reason:

squashed into combined test patch

https://gerrit.wikimedia.org/r/740661

Change 740666 abandoned by Jgleeson:

[wikimedia/fundraising/crm@master] WIP: Pending Transaction Resolver Tests

Reason:

squashed into combined test patch

https://gerrit.wikimedia.org/r/740666

Change 740905 had a related patch set uploaded (by Jgleeson; author: Jgleeson):

[wikimedia/fundraising/crm@master] WIP: testContributionTrackingIdIsNotSet pending trxn tests

https://gerrit.wikimedia.org/r/740905

Change 740920 had a related patch set uploaded (by Damilare Adedoyin; author: Damilare Adedoyin):

[wikimedia/fundraising/crm@master] WIP: testContributionIdNotSet pending trxn tests

https://gerrit.wikimedia.org/r/740920

Change 736874 merged by jenkins-bot:

[wikimedia/fundraising/SmashPig@master] Standardise Ingenico cancelPayment behaviour

https://gerrit.wikimedia.org/r/736874

Change 741733 had a related patch set uploaded (by Ejegg; author: Ejegg):

[wikimedia/fundraising/SmashPig@master] Option to return breakdown rows for payments_fraud

https://gerrit.wikimedia.org/r/741733

Change 740905 abandoned by Jgleeson:

[wikimedia/fundraising/crm@master] testContributionTrackingIdIsNotSet pending trxn tests

Reason:

merged into combined test patch

https://gerrit.wikimedia.org/r/740905

Change 740920 abandoned by Jgleeson:

[wikimedia/fundraising/crm@master] WIP: testContributionIdNotSet pending trxn tests

Reason:

merged into combined test patch

https://gerrit.wikimedia.org/r/740920

Change 742530 had a related patch set uploaded (by Jgleeson; author: Jgleeson):

[wikimedia/fundraising/crm@master] WIP: add assertion for payments-init queue message

https://gerrit.wikimedia.org/r/742530

Change 742568 had a related patch set uploaded (by Jgleeson; author: Jgleeson):

[wikimedia/fundraising/crm@master] WIP: testAntiFraudQueueMessageCreatedAfterHostedStatusCall

https://gerrit.wikimedia.org/r/742568

Change 743997 had a related patch set uploaded (by Damilare Adedoyin; author: Damilare Adedoyin):

[wikimedia/fundraising/SmashPig@master] Pending resolve: Add paymentFraudBreakdownDatabase class to manage the payment_fraud_breakdown table.

https://gerrit.wikimedia.org/r/743997

Change 742568 abandoned by Damilare Adedoyin:

[wikimedia/fundraising/crm@master] WIP: testAntiFraudQueueMessageCreatedAfterHostedStatusCall

Reason:

https://gerrit.wikimedia.org/r/742568

Change 743467 had a related patch set uploaded (by Damilare Adedoyin; author: Jgleeson):

[wikimedia/fundraising/crm@master] WIP: testAntiFraudQueueMessageCreatedAfterHostedStatusCall

https://gerrit.wikimedia.org/r/743467

Change 741733 merged by jenkins-bot:

[wikimedia/fundraising/SmashPig@master] Option to return breakdown rows for payments_fraud

https://gerrit.wikimedia.org/r/741733

Change 742530 abandoned by Jgleeson:

[wikimedia/fundraising/crm@master] testResolveCreatesValidPaymentsInitMessage

Reason:

merged into base test/implementation patches

https://gerrit.wikimedia.org/r/742530

From the task description:

Probably put this in the wmf-civicrm module

I think this is intended to refer to the wmf-civicrm Civicrm extension? With the word "module" it sounds like it might mean the drupal module of the same name, but I'm pretty sure that's not it?

Change 736877 merged by jenkins-bot:

[mediawiki/extensions/DonationInterface@master] Update cancelPayment response handling for ingenico.

https://gerrit.wikimedia.org/r/736877

Change 722703 merged by Eileen:

[wikimedia/fundraising/crm@master] Pending Transaction Resolver: Implementation

https://gerrit.wikimedia.org/r/722703

Change 739354 merged by jenkins-bot:

[wikimedia/fundraising/crm@master] Pending Transaction Resolver: Tests

https://gerrit.wikimedia.org/r/739354

Change 743467 merged by jenkins-bot:

[wikimedia/fundraising/crm@master] Pending resolver: fraud db integration

https://gerrit.wikimedia.org/r/743467

Change 748891 had a related patch set uploaded (by Ejegg; author: Ejegg):

[wikimedia/fundraising/crm@master] Fix queue messages for pending resolver

https://gerrit.wikimedia.org/r/748891

Change 748891 merged by jenkins-bot:

[wikimedia/fundraising/crm@master] Fix queue messages for pending resolver

https://gerrit.wikimedia.org/r/748891

Change 749188 had a related patch set uploaded (by Jgleeson; author: Jgleeson):

[wikimedia/fundraising/crm@master] Fix test for paymentsInit message check

https://gerrit.wikimedia.org/r/749188

Change 749188 merged by jenkins-bot:

[wikimedia/fundraising/crm@master] Add 'server' key to payments-init message test and fix array_diff_key usage

https://gerrit.wikimedia.org/r/749188

DStrine set Final Story Points to 4.

Change 732788 abandoned by Jgleeson:

[wikimedia/fundraising/SmashPig@master] Updated Ingenico getHostedPaymentStatus response to now return an instance of PaymentDetailResponse.

Reason:

Looks like this was done in another patch

https://gerrit.wikimedia.org/r/732788

Change 732790 abandoned by Jgleeson:

[mediawiki/extensions/DonationInterface@master] WIP: Update $result handling for Ingenico getHostedPaymentStatus call as this now returns an instance of PaymentDetailResponse.

Reason:

Looks like this got done over in https://gerrit.wikimedia.org/r/c/mediawiki/extensions/DonationInterface/+/724233

https://gerrit.wikimedia.org/r/732790