Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { PayTechService, PaytechRegisterRequest } from './paytech-service';
- // Get an instance of the service
- const paytechService = PayTechService();
- /**
- * Example 1: Register a new customer
- */
- async function registerExample() {
- const registerRequest: PaytechRegisterRequest = {
- fname: "Moussa",
- lname: "Ndour",
- phone: "+221777679700",
- countryCode: "sn",
- adress: "Almadies",
- pass: "azerty",
- confPass: "azerty",
- business_name: "Mon Business",
- website: "https://github.com/touskar", //optionnel can send ""
- type_acount: "simple", // simple => Business(Pas de site web), pro => Site E-Commerce (Pour les sites web)
- promo_code: "",
- day_get_funds: "Mardi"//Mardi, Vendredi
- };
- try {
- const response = await paytechService.register(registerRequest);
- if (response.isSuccess) {
- console.log("Registration successful!");
- console.log("Message:", response.message);
- } else {
- console.error("Registration failed!");
- console.error("Error message:", response.message);
- }
- } catch (error) {
- console.error("Exception occurred during registration:", error);
- }
- }
- /**
- * Example 2: Login to get customer information
- */
- async function loginExample() {
- const password = "azerty";
- try {
- const response = await paytechService.getCustomerInfo(email, password);
- if (response.isSuccess && response.customerInfo) {
- console.log("Login successful!");
- console.log("Customer name:", `${response.customerInfo.customer.firstName} ${response.customerInfo.customer.lastName}`);
- console.log("Business name:", response.customerInfo.customer.businessName);
- console.log("Account balance:", response.customerInfo.customer.balance.amount);
- console.log("Account type:", response.customerInfo.customer.accountType);
- } else {
- console.error("Login failed!");
- console.error("Error message:", response.message);
- }
- } catch (error) {
- console.error("Exception occurred during login:", error);
- }
- }
- // Run the examples
- (async () => {
- console.log("===== Register Example =====");
- await registerExample();
- console.log("\n===== Login Example =====");
- await loginExample();
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement