Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

As a User I want to know if SISP payment was processed with success or not #10

Open
FredSoares opened this issue Sep 9, 2021 · 0 comments
Labels
Documentation Improvements or additions to documentation Engineering Review

Comments

@FredSoares
Copy link
Contributor

FredSoares commented Sep 9, 2021

Description
When user submit their payments, they want to know if the payment was processed with success or not.

Documentation/README Requirements

  • Document how to get payment response from SISP.
  • Document success cases and how to access those data.
  • Document error cases.
  • Document basic example of implementation.
  • Provide links to relevant SISP documentation and/or resources.

Documentation/README

Validate Payment Response

When we submit the payment to the SISP we need to know whether the payment was processed successfully or not, and SISP suggests that we create an End Point (URL to receive the payment response) that they will call when processing the payment.
When SISP calls this End Point, we will receive all information about our payment.

  1. Success Message Type

    If the payment was successfully processed, SISP will send us a success message type that we can access in req.body.message Type, and this message can be one of the following types:
    // SUCCESS RESPONSE CONSTANTS
	const successMessageType = ["8", "10", "M", "P"];
  1. Validate fingerprint of the result

    In addition to checking the messageType field, it is necessary to check if the FingerPrint received in the resultFingerPrint field is the same as expected, which is calculated according to the use of the function GenerateFingerPrintResponseSuccessful
		/*VALIDATE SUCCESS FINGERPRINT*/
		if(req.body.resultFingerPrint === calculatedFingerPrint)
			// Handle Successful Payment
		else
            // Handle Unsuccessful Payment: Invalid Response Finger Print	
  1. Unsuccessful payment

    We can get unsuccessful payment if success message type doesn't include any of the type that was described in the point 1, or if the result Fingerprint is different from the calculated fingerprint as showed in point 2 and other error we can get is if the users cancel their payments as the example below:
if(req.body.UserCancelled == "true") {
    // User canceled purchase requisition
}

Basic example

app.post("/payment-response", urlencodedParser, function(req, res) {

    // SUCCESS RESPONSE CONSTANTS
    const successMessageType = ["8", "10", "M", "P"];

    if(successMessageType.includes(req.body.messageType)) {
        const posAutCode = "123456789A";
        const fingerPrintCalculado = GenerateFingerPrintResponseSuccessful(
            posAutCode,
            req.body.messageType,
            req.body.merchantRespCP,
            req.body.merchantRespTid,
            req.body.merchantRespMerchantRef,
            req.body.merchantRespMerchantSession,
            req.body.merchantRespPurchaseAmount,
            req.body.merchantRespMessageID,
            req.body.merchantRespPan,
            req.body.merchantResp,
            req.body.merchantRespTimeStamp,
            req.body.merchantRespReferenceNumber,
            req.body.merchantRespEntityCode,
            req.body.merchantRespClientReceipt,
            trim(req.body.merchantRespAdditionalErrorMessage),
            req.body.merchantRespReloadCode
            );
            /*ATTENTION: VALIDATE SUCCESS FRINGERPRINT TO OBTAIN A BETTER SECURITY GUARANTEE*/
            if(req.body.resultFingerPrint == fingerPrintCalculado)
                res.send("Successful Payment");
            else
                res.send("Unsuccessful Payment: Invalid Response Finger Print");
    } else if(req.body.UserCancelled == "true") {
        res.send("User canceled purchase requisition"); 
    } else {
        res.send("Unsuccessful payment");
    }
});
@nnascim nnascim modified the milestones: Backlog, MVP Sep 9, 2021
@nnascim nnascim modified the milestones: MVP, Backlog Sep 9, 2021
@FredSoares FredSoares added Documentation Improvements or additions to documentation Engineering Review labels Sep 10, 2021
@nnascim nnascim added Documentation Improvements or additions to documentation and removed Documentation Improvements or additions to documentation labels Sep 17, 2021
@nnascim nnascim removed this from the Backlog milestone Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Improvements or additions to documentation Engineering Review
Projects
None yet
Development

No branches or pull requests

2 participants