-
ContiPay Account
-
ContiPay Secret and Key
npm install contipay-js
// Import necessary classes
const Contipay = require("contipay-js/src/contipay");
const SimpleDirectMethod = require("contipay-js/src/helpers/simple_direct_method");
const DirectMethod = require("contipay-js/src/helpers/direct_method");
const SimpleRedirectMethod = require("contipay-js/src/helpers/simple_redirect_method");
const RedirectMethod = require("contipay-js/src/helpers/redirect_method");
const contipay = new Contipay("token-here", "secret-here");
const phone = "263782000340";
const payload = new SimpleDirectMethod(merchantCode, webhookUrl)
.setUpProvider("InnBucks", "IB")
.preparePayload(amount, phone);
contipay
.setAppMode("DEV") // LIVE as another option
.setPaymentMethod()
.process(payload)
.then((res) => {
console.log(res);
})
.catch((error) => {
console.error(error);
});
const contipay = new Contipay("token-here", "secret-here");
const phone = "263782000340";
const payload = new SimpleRedirectMethod(
merchantCode,
webhookUrl,
successUrl,
cancelUrl
).preparePayload(amount, phone);
contipay
.setAppMode("DEV") // LIVE as another option
.setPaymentMethod("redirect")
.process(payload)
.then((res) => {
console.log(res);
})
.catch((error) => {
console.error(error);
});
const contipay = new Contipay("token-here", "secret-here");
const phone = "263782000340";
const payload = new DirectMethod(merchantCode, webhookUrl)
.setUpCustomer("Nigel", "Jaure", phone, "ZW", "[email protected]")
.setUpProvider("Ecocash", "EC")
.setUpAccountDetails(phone, "Nigel Jaure")
.setUpTransaction(amount, "USD")
.preparePayload();
contipay
.setAppMode("DEV")
.setPaymentMethod()
.process(payload)
.then((res) => {
console.log(res);
})
.catch((error) => {
console.error(error);
});
const contipay = new Contipay("token-here", "secret-here");
const phone = "263782000340";
const payload = new RedirectMethod(
merchantCode,
webhookUrl,
successUrl,
cancelUrl
)
.setUpCustomer("Nigel", "Jaure", phone, "ZW", "[email protected]")
.setUpTransaction(amount, "USD")
.preparePayload();
contipay
.setAppMode("DEV")
.setPaymentMethod("redirect")
.process(payload)
.then((res) => {
console.log(res);
})
.catch((error) => {
console.error(error);
});
- The
updateURL
method is optional and applicable only if the URL has changed. Use it to update the URLs accordingly. Here's how you can use it:
const contipay = new Contipay("token-here", "secret-here");
// Update URLs if necessary
contipay.updateURL("dev-url", "live-url");
// Process payment with the updated URLs
contipay
.setAppMode("DEV") // LIVE as another option
.setPaymentMethod()
.process(payload)
.then((res) => {
console.log(res);
})
.catch((error) => {
console.error(error);
});
-
Ensure to set the appropriate mode (
DEV
orLIVE
) using thesetAppMode
method before processing payments. -
The provided examples cover basic scenarios, including direct and redirect payment methods, customer information setup, and transaction details.
-
ContiPay PHP Alternative here