cybersource-sdk-java
cybersource-sdk-java copied to clipboard
Provide an environment value to implement BDD test with a mocked cybersource service
I want to implement BDD test on my implementation of Psp Integration.
Usually, I have a mean to tell that the PSP API url point to a Wiremock managed url to send back to my code a controlled answer.
I cannot do that with cybersource SDK and ends up having to really use the test environnement ('CAS'). It means that my test MUST use keys and certificates that will expire, and that they will break at a later time. And it also means that my test are flawed, as I cannot control for sure the content of the answers from cybersource.
⇒ I would like another environment, e.g. called 'MOCK', that would allow a configuration value to store the effective url to use, e.g. 'https://localost:4000/mock/cybs', to be able to implement correctly BDD tests.
Alternatively, we could simply make use of the direct debit to deduct payments and standardise on this as a way of taking payments.
This would make things a bit easier as no extra payment provider would be required to be integrated, however we should be careful to ensure that if the direct debit is used that we properly handle the payment bouncing or otherwise failing (e.g. cancelled direct debit)
You can create payments with meta data that would link it to a database record:
POST: https://api-sandbox.gocardless.com/payments
{
"payments": {
"amount": "150",
"currency": "GBP",
"description": "6mm Laser Plywood",
"links": {
"mandate": "REDACTED"
},
"metadata": {
"member": "example_id",
"product": "123",
"transaction": "test"
}
}
}
Dashboard screenshot:
GoCardless have advised how to create restricted mandates which involves tickkng a box against the customer profile in the advanced settings.
The result however is that for restricted mandates you’ll be asked to approve by GoCardless, for unrestricted mandates you won’t be asked or told about the payment. Subscriptions will notify as usual but similarly require authentication.
Will test this out to see if it just a yes button in the email or requires further authentication like reentering your card details.