Adds CGraphing for Merchant Pms with all the possible filters applicable as described below.
Testing Scenarios
// Testing for scenario 0:
// MCA1 -> Stripe configured with ideal config = { country = "NL", currency = "EUR" }
// MCA2 -> Cybersource configured with credit config = { currency = "USD" }
// Payment is done with currency as EUR and no billing address
// The resultant Payment Method list should only have ideal with stripe
// Testing for scenario 1:
// MCA1 -> Stripe configured with ideal mca = { country = "NL", currency = "EUR" }
// MCA2 -> Cybersource configured with credit mca = { currency = "USD" }
// Payment is done with currency as INR and no billing address
// The resultant Payment Method list shouldn't have any payment method
// Testing for scenario 2:
// MCA1 -> Stripe configured with credit mca = { country = "US" }
// MCA2 -> Cybersource configured with credit mca = { country = "US" }
// Payment is done with country as US and currency as USD
// The resultant Payment Method list should have both Stripe and cybersource
// Testing for scenario 3:
// MCA1 -> Stripe configured with ideal config = { country = "NL", currency = "EUR" }
// MCA2 -> Cybersource configured with ideal config = { country = "NL", currency = "EUR" }
// Payment is done with country as US and currency as EUR
// The resultant Payment Method list shouldn't have anything
// Testing for scenario 4:
// MCA1 -> Stripe configured with card credit no configs present
// MCA1 -> Cybersource configured with card credit config = { currency = "USD" }
// and ideal (default config present as = { country = "NL", currency = "EUR" } )
// Payment is done with country as IN and currency as USD
// The resultant Payment Method list should have
// Stripe and cybersource both for credit and none for ideal
Cypress Tests
Addressed in this PR:
1 Creation of Constraint Graph for Merchant Payment Method List:
Created a Constraint Graph with the following filters/Nodes:
From configs and MCA:
Countries Filter
Currency Filter
Supported for Mandates Filter
Allowed Payment Method Types
Supported for Update Mandates Filter
Capture Method Used
From Req:
Recurring Enabled
Installment Enabled
Amount Based
After Applying all these Filters and creating a Graph for a Merchant MCA with 2 PMT enabled (Credit and Debit) with one connector(Cybersource), We will get a graph equivalent to this
Henceforth, we will verify the constraints by constructing Context from our PaymentIntent and PaymentAttempt.
PM List for Merchant curl:
We have even implemented Moka(In memory) Cashing mechanism for our CGraph to minimize the latency. So for every request first the cache value will be checked if present, derived and used else CGraph will be constructed and the cache will be refreshed.
Additional Changes
[ ] This PR modifies the API contract
[ ] This PR modifies the database schema
[ ] This PR modifies application configuration/environment variables
Motivation and Context
How did you test it?
Testing requires creation/refactoring of our configs:
The configs followed are as follows:-
Response
Google pay won't come as we have added in configs allowed country as CN
Payment Type Card(Credit) also won't come as the configs for credit has not_available_flows = manual
Card shouldn't include credit as we have changed the allowed country as IQ(Iraq) but the intent created is from USA.
AfterPayClearPay shouldn't be present as well, as it is only for GBP currency in our case we have USD.
Type of Change
Description
Adds CGraphing for Merchant Pms with all the possible filters applicable as described below.
Testing Scenarios
Cypress Tests
Addressed in this PR:
1 Creation of Constraint Graph for Merchant Payment Method List:
Created a Constraint Graph with the following filters/Nodes:
From configs and MCA:
From Req:
After Applying all these Filters and creating a Graph for a Merchant MCA with 2 PMT enabled (Credit and Debit) with one connector(Cybersource), We will get a graph equivalent to this
Henceforth, we will verify the constraints by constructing Context from our PaymentIntent and PaymentAttempt. PM List for Merchant curl:
2 Moka Caching of Pm Filter Graph:
We have even implemented Moka(In memory) Cashing mechanism for our CGraph to minimize the latency. So for every request first the cache value will be checked if present, derived and used else CGraph will be constructed and the cache will be refreshed.
Additional Changes
Motivation and Context
How did you test it?
Testing requires creation/refactoring of our configs: The configs followed are as follows:-
Flow followed
Request 1: mca create request (Cybersource)
Request 2: mca create request (Stripe)
Request 3: Payment Create Request (with
capture_method = manual
)Request 4: List Merchant Payment Methods
Response Google pay won't come as we have added in configs allowed country as CN Payment Type Card(Credit) also won't come as the configs for credit has
not_available_flows = manual
Bug Resolution Testcase
Config of Adyen
MCA(Adyen) creation without allowed_currencies/countries
List PM Response
Card shouldn't include credit as we have changed the allowed country as IQ(Iraq) but the intent created is from USA. AfterPayClearPay shouldn't be present as well, as it is only for GBP currency in our case we have USD.
Checklist
cargo +nightly fmt --all
cargo clippy