Credit Request
Credit is responsible sending a B2C or B2B based on accountType
either CUSTOMER
and MERCHANT
.
Once you have configured the payment handlers, you can utilize this configuration when making requests using the Marupay SDK. The configuration ensures that the SDK has the required credentials to interact with the specified payment systems.
Here's a quick example of how you can use the configuration when making a credit request:
app.get('/credit', async (req, res) => {
try {
const chosenHandler: HandlerName = 'edahab';
const handler = getPaymentHandler(chosenHandler)(paymentConfig[chosenHandler]!);
const paymentInfo = await handler.credit({
accountNumber: "+2526512312341", // must start with `+` followed by country code
amount: 500,
currency: Currency.SLSH,
description: "Test purchase",
accountType: 'CUSTOMER'
});
res.send(paymentInfo);
} catch (e) {
console.log(e);
res.status(500).send("Internal Server Error");
}
});
The credit
method returns a PaymentInfo
object. It'll return these details:
-
transactionId
: This identifier is obtained from the vendor's transaction ID. It uniquely identifies the transaction in the vendor's system. -
paymentStatus
: The payment status is also retrieved from the vendor's response. It indicates the current status of the payment transaction in the vendor's system. -
referenceId
: The reference ID is specific to Marupay and is provided in Marupay's response. It serves as a unique identifier for the transaction within Marupay's system. -
raw
: This will return unfiltered response details from the vendor.
These details are essential for tracking and reconciling transactions between your application, the vendor, and Marupay. Ensure that you appropriately handle and store these values for accurate record-keeping and future reference.