How to use reference_token method in wpt

Best JavaScript code snippet using wpt

Usedcarpayment.js

Source:Usedcarpayment.js Github

copy

Full Screen

1import React, { Component } from 'react';2import { Foloosi } from 'react-foloosi-widget';3import axios from 'axios';4import { withRouter } from 'react-router-dom';5import qs from 'qs';6class App extends Component {7 constructor(props) {8 super(props);9 this.state = {10 foloosiOpen: false,11 reference_token: '',12 merchant_key:13 'test_$2y$10$kPeOAbvKV--fh4RxMbjkbOztdu25WTs0IELEEJO-WaT.N9vG3iUm6',14 customer_name: '',15 customer_email: '',16 customer_mobile: '',17 customer_address: '',18 customer_city: '',19 };20 this.foloosiHandler = this.foloosiHandler.bind(this);21 }22 foloosiHandler(e) {23 if (e.data.status === 'success') {24 console.log(e.data);25 console.log(e.data.data.transaction_no);26 // Send axios request to the server with all details27 /*let { customer_name, customer_email, transaction_amount, currency, product_id } = qs.parse(this.props.location.search, { ignoreQueryPrefix: true });*/28 //console.log(qs.parse(this.props.location.search, { ignoreQueryPrefix: true }));29 let {30 customer_name,31 customer_email,32 transaction_amount,33 currency,34 product_id,35 category,36 category_parent,37 } = qs.parse(this.props.location.search, { ignoreQueryPrefix: true });38 let transaction_no = e.data.data.transaction_no;39 let payment_status = e.data.status || null;40 console.log('This is requested data.');41 //console.log(e.data);42 // Put all togather43 const sendWithData = {44 customer_name: customer_name,45 customer_email: customer_email,46 transaction_amount: transaction_amount,47 currency: currency,48 product_id: product_id,49 transaction_no: transaction_no,50 payment_status: payment_status,51 };52 //con53 // Send axious request54 console.log('fuck yo');55 console.log(sendWithData);56 axios({57 method: 'post',58 url: '/api/usedcarforsale/payment',59 data: sendWithData,60 })61 .then(response => {62 // Check response status63 if (response.status === 200) {64 // Payment sucessfully save to db65 // Redirect to the page where says add is live66 window.location.replace(67 `/dashboard/category/${category}/${category_parent}/upload/${product_id}/uploaded`68 );69 }70 })71 .catch(function(error) {72 console.log('Error', error);73 });74 }75 if (e.data.status === 'error') {76 console.log(e.data);77 console.log(e.data.data.payment_status);78 }79 }80 componentDidMount() {81 let {82 customer_name,83 customer_email,84 currency,85 product_id,86 customer_mobile,87 customer_address,88 customer_city,89 category,90 category_parent,91 } = qs.parse(this.props.location.search, { ignoreQueryPrefix: true });92 console.log('this is props');93 console.log(this.props.location.search);94 // /dashboard/category/95 // Required fileds96 if (97 typeof customer_name === 'undefined' ||98 customer_name === '' ||99 typeof customer_email === 'undefined' ||100 customer_email === '' ||101 typeof currency === 'undefined' ||102 currency === '' ||103 typeof product_id === 'undefined' ||104 product_id === ''105 ) {106 console.log('Can not process many data required to process the request.');107 return false;108 }109 // Validate email110 var re = /^[a-zA-Z0-9]+@[a-zA-Z0-9]+\.[A-Za-z]+$/;111 // JSON.stringify()112 if (!re.test(customer_email)) {113 console.log('Invalid email address');114 return false;115 }116 // Product id must be mongo id117 var checkForHexRegExp = new RegExp('^[0-9a-fA-F]{24}$');118 if (!checkForHexRegExp.test(product_id)) {119 console.log('Invalid mongo product id.');120 return false;121 }122 ///dashboard/category/${firstcategory}/${secoundcategory}123 //upload/${product_id}/uploaded124 try {125 axios({126 method: 'post',127 url: 'https://foloosi.com/api/v1/api/initialize-setup',128 headers: {129 merchant_key: this.state.merchant_key,130 },131 data: {132 redirect_url: `/dashboard/category/${category}/${category_parent}/upload/${product_id}/uploaded`,133 transaction_amount: 100,134 currency: currency,135 customer_name: customer_name,136 customer_email: customer_email,137 customer_mobile: customer_mobile,138 customer_address: customer_address,139 customer_city: customer_city,140 },141 })142 .then(response => {143 console.log('response', response);144 if (response.status === 200) {145 console.log(`Reference token` + response.data.data.reference_token);146 this.setState(147 { reference_token: response.data.data.reference_token },148 () => {149 this.setState({ foloosiOpen: true });150 }151 );152 }153 })154 .catch(function(error) {155 console.log('error', error);156 });157 } catch (error) {158 console.log(error);159 }160 }161 componentDidUpdate() {162 window.addEventListener('message', this.foloosiHandler);163 }164 foloosiOpen() {165 this.setState({ foloosiOpen: true });166 }167 render() {168 return (169 <div>170 <span onClick={e => this.foloosiOpen(e)}>Foloosi</span>171 <Foloosi172 foloosiOpen={this.state.foloosiOpen}173 foloosiClose={true}174 reference_token={this.state.reference_token}175 merchant_key={this.state.merchant_key}176 getState={this.props}177 />178 }179 </div>180 );181 }182}...

Full Screen

Full Screen

Folosi.js

Source:Folosi.js Github

copy

Full Screen

1import React, { Component } from "react";2import { Foloosi } from "react-foloosi-widget";3import "../Folosi/Folosi.css";4import { Form, Card, Row, Col } from "react-bootstrap";5import { CustomButton } from "../customFormElements/customButton";6import { CustomNavLink } from "../NavItem/NavItem";7class FolosiComponent extends Component {8 state = {9 foloosiOpen: false,10 reference_token:11 "test_$2y$10$uund0cR.UJuo83HY2EtURu3uysxD5wOAfvnEC4qE7k8WXD4BYF-wq",12 merchant_key:13 "test_$2y$10$bvRheRygCuck6ibyO4mK6OzLoULqyDoB-MRoJ7Kld.NVjs2nxS6WW",14 price: "50", /// GET it from Redux Later,15 name: "",16 email: "",17 mobile: "",18 currency: "AED",19 qr_data: "",20 qr_url: "",21 };22 foloosiHandler(e) {23 if (e.data.status === "success") {24 console.log(e.data);25 console.log(e.data.data.transaction_no);26 }27 if (e.data.status === "error") {28 console.log(e.data);29 console.log(e.data.data.payment_status);30 }31 }32 componentDidUpdate() {33 window.addEventListener("message", this.foloosiHandler);34 }35 foloosiOpen() {36 this.setState({ foloosiOpen: true });37 }38 confirmClicked = () => {39 fetch("https://foloosi.com/api/v1/api/initialize-setup", {40 headers: {41 merchant_key: this.state.merchant_key,42 "content-type": "application/json",43 },44 method: "POST",45 body: JSON.stringify({46 redirect_url: "/projects/storically/book/payment/pdf",47 transaction_amount: 50,48 currency: this.state.currency,49 customer_name: this.state.name,50 customer_email: this.state.email,51 customer_mobile: this.state.mobile,52 }),53 })54 .then((res) => res.json())55 .then((data) =>56 this.setState({57 reference_token: data.data.reference_token,58 qr_data: data.data.payment_qr_data,59 qr_url: data.data.payment_qr_url,60 foloosiOpen: true,61 })62 );63 };64 handleInputs = (e, type) => {65 if (type === "name") {66 this.setState({ name: e.target.value });67 }68 if (type === "email") {69 this.setState({ email: e.target.value });70 }71 if (type === "mobile") {72 this.setState({ mobile: e.target.value });73 }74 };75 render() {76 return (77 <section className="my-5">78 <div className="mx-auto welcome">79 <h3 className="text-center">80 Welcome to our Secure Payement Gateway81 </h3>82 <Row>83 <Col84 md={12}85 className="d-flex justify-content-center align-items-center"86 >87 <Form>88 <Form.Group>89 <Form.Label className="custtomLabel">Name</Form.Label>90 <Form.Control91 type="text"92 required93 placeholder="Enter Your Name"94 onChange={(e) => this.handleInputs(e, "name")}95 />96 </Form.Group>97 </Form>98 </Col>99 <Col100 md={12}101 className="d-flex justify-content-center align-items-center"102 >103 <Form>104 <Form.Group>105 <Form.Label className="custtomLabel">Email</Form.Label>106 <Form.Control107 type="text"108 required109 placeholder="Enter Your Email"110 onChange={(e) => this.handleInputs(e, "email")}111 />112 </Form.Group>113 </Form>114 </Col>115 <Col116 md={12}117 className="d-flex justify-content-center align-items-center"118 >119 <Form>120 <Form.Group>121 <Form.Label className="custtomLabel">Mobile</Form.Label>122 <Form.Control123 type="text"124 required125 placeholder="Enter Phone Number"126 onChange={(e) => this.handleInputs(e, "mobile")}127 />128 </Form.Group>129 </Form>130 </Col>131 <Col132 md={12}133 className="d-flex justify-content-center align-items-center"134 >135 <p>Please Click below Button for payement </p>136 </Col>137 <Col className="d-flex justify-content-center align-items-center">138 <CustomButton139 teal140 disabled={141 this.state.name === "" ||142 this.state.email === "" ||143 this.state.mobile === ""144 }145 onClick={() => this.confirmClicked()}146 >147 Continue148 </CustomButton>149 </Col>150 </Row>151 {/* <label>Name</label>152 <input onChange={(e) => this.handleInputs(e, "name")}></input>153 <label>Email</label>154 <input onChange={(e) => this.handleInputs(e, "email")}></input>155 <label>Mobile</label>156 <input onChange={(e) => this.handleInputs(e, "mobile")}></input> */}157 <CustomNavLink to="/projects/storically/book/payment/pdf">158 GO to PDF159 </CustomNavLink>160 </div>161 <Foloosi162 foloosiOpen={this.state.foloosiOpen}163 foloosiClose={true}164 reference_token={this.state.reference_token}165 merchant_key={this.state.merchant_key}166 customer_email="ahsdua"167 />168 </section>169 );170 }171}...

Full Screen

Full Screen

new-pilot.js

Source:new-pilot.js Github

copy

Full Screen

1const PilotTemplate = artifacts.require("PilotTemplate")2const Token = artifacts.require("Token")3const DAO_ID = "pilot" + Math.random() // Note this must be unique for each deployment, change it for subsequent deployments4const NETWORK_ARG = "--network"5const DAO_ID_ARG = "--daoid"6const argValue = (arg, defaultValue) => process.argv.includes(arg) ? process.argv[process.argv.indexOf(arg) + 1] : defaultValue7const network = () => argValue(NETWORK_ARG, "local")8const daoId = () => argValue(DAO_ID_ARG, DAO_ID)9const pilotTemplateAddress = () => {10 if (network() === "rinkeby") {11 const Arapp = require("../arapp")12 return Arapp.environments.rinkeby.address13 } else if (network() === "mainnet") {14 const Arapp = require("../arapp")15 return Arapp.environments.mainnet.address16 } else if (network() === "xdai") {17 const Arapp = require("../arapp")18 return Arapp.environments.xdai.address19 } else {20 const Arapp = require("../arapp_local")21 return Arapp.environments.devnet.address22 }23}24const DAYS = 24 * 60 * 6025const ONE_HUNDRED_PERCENT = 1e1826const ONE_TOKEN = 1e1827const scale = n => parseInt(n * 10 ** 7)28// Create dao transaction one config29const REFERENCE_TOKEN = "0x34c99d7026d54a4e312d86b10abb097815ce0da5" // staging token30// const REFERENCE_TOKEN = "0x1ea885084dd4747be71da907bd71fc9484af618d" // Test HNY from rinkeby.aragon.org/#/honey31// const REFERENCE_TOKEN = "0x8cf8196c14A654dc8Aceb3cbb3dDdfd16C2b652D" // Test ANT from Court deployment32const SNAPSHOT_BLOCK = 0 // Use 0 if you want to snapshot at the current blockheight.33const ADMIN = "0x625236038836CecC532664915BD0399647E7826b"34const HALFTIME = 0.25 * DAYS //35const BLOCKTIME = 15 // 15 rinkeby, 13 mainnet, 5 xdai36// const DECAY= 9999652 // 72 hours halftime37const CONVERTED_TIME = 1/BLOCKTIME * HALFTIME38const DECAY = 1/2 ** (1/CONVERTED_TIME) // alpha39const MAX_RATIO = 0.25 // 25 percent40const MIN_THRESHOLD = 0.05 // 5 percent41const WEIGHT = MAX_RATIO ** 2 * MIN_THRESHOLD // determine weight based on MAX_RATIO and MIN_THRESHOLD42const MIN_EFFECTIVE_SUPPLY = 0.0025 * ONE_HUNDRED_PERCENT // 0.25% minimum effective supply43const CONVICTION_SETTINGS = [scale(DECAY), scale(MAX_RATIO), scale(WEIGHT), MIN_EFFECTIVE_SUPPLY]44module.exports = async (callback) => {45 try {46 const pilotTemplate = await PilotTemplate.at(pilotTemplateAddress())47 const createDaoTxOneReceipt = await pilotTemplate.createDaoTxOne(48 REFERENCE_TOKEN,49 SNAPSHOT_BLOCK,50 ADMIN,51 CONVICTION_SETTINGS52 );53 console.log(`Tx One Complete. DAO address: ${createDaoTxOneReceipt.logs.find(x => x.event === "DeployDao").args.dao} Gas used: ${createDaoTxOneReceipt.receipt.gasUsed} `)54 const createDaoTxTwoReceipt = await pilotTemplate.createDaoTxTwo(55 ADMIN56 );57 console.log(`Tx Two Complete. Gas used: ${createDaoTxTwoReceipt.receipt.gasUsed} `)58 } catch (error) {59 console.log(error)60 }61 callback()...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wptAPI = new wpt('www.webpagetest.org');3var testOptions = {4 videoParams: {5 }6};7wptAPI.runTest(testURL, testOptions, function(err, data) {8 if (err) {9 console.log(err);10 } else {11 console.log(data);12 wptAPI.getTestResults(data.data.testId, function(err, data) {13 if (err) {14 console.log(err);15 } else {16 console.log(data);17 }18 });19 }20});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var fs = require('fs');3var request = require('request');4var util = require('util');5var api = new wpt('www.webpagetest.org', 'A.0d6f1f6c8a6a1b6c3b6f3f6f3f6f3f6f');6var options = {

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var test_options = {4};5var wpt = new WebPageTest('www.webpagetest.org');6wpt.runTest(test_url, test_options, function(err, data) {7 if (err) return console.error(err);8 console.log('Test submitted to WebPagetest for: ' + data.data.testUrl);9 console.log('Test ID: ' + data.data.testId);10 var testId = data.data.testId;11 wpt.getTestResults(testId, function(err, data) {12 if (err) return console.error(err);13 console.log('Test results for: ' + data.data.testUrl);14 console.log('First View: Speed Index ' + data.data.average.firstView.SpeedIndex);15 console.log('First View: Fully Loaded ' + data.data.average.firstView.fullyLoaded);16 console.log('First View: Time to First Byte ' + data.data.average.firstView.TTFB);17 console.log('First View: Start Render ' + data.data.average.firstView.render);18 console.log('First View: First Visual Change ' + data.data.average.firstView.fullyLoaded);19 console.log('First View: Last Visual Change ' + data.data.average.firstView.fullyLoaded);20 console.log('First View: DOM Elements ' + data.data.average.firstView.fullyLoaded);21 });22 wpt.getTestResults(testId, function(err, data) {23 if (err) return console.error(err);24 console.log('Test results for: ' + data.data.testUrl);25 console.log('First View: Speed Index ' + data.data.average.firstView.SpeedIndex);26 console.log('First View: Fully Loaded ' + data.data.average.firstView.fullyLoaded);27 console.log('First View: Time to First Byte ' + data.data.average.firstView.TTFB);28 console.log('First View: Start Render ' + data.data.average.firstView.render);29 console.log('

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var webpagetest = new wpt('www.webpagetest.org', 'A.8c3d7b0f3c2a7f3b9b1f7b3d7b0f3c2a');3 if (err) return console.error(err);4 console.log(data);5});6var wpt = require('webpagetest');7var webpagetest = new wpt('www.webpagetest.org', 'A.8c3d7b0f3c2a7f3b9b1f7b3d7b0f3c2a');8 if (err) return console.error(err);9 console.log(data);10});11var wpt = require('webpagetest');12var webpagetest = new wpt('www.webpagetest.org', 'A.8c3d7b0f3c2a7f3b9b1f7b3d7b0f3c2a');13webpagetest.getTestStatus('140709_2Q_6b5d0c5c5d6b5e5b5c5d5b5d5e5b5c5d', function(err, data) {14 if (err) return console.error(err);15 console.log(data);16});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var client = wpt('www.webpagetest.org', 'A.1d0b7e9c8b8f9b2d0c0f7b0e8c8b7e9f');3var params = {4};5client.runTest(params, function(err, data) {6 if (err) {7 console.log('Error: ' + err);8 } else {9 console.log('Test ID: ' + data.data.testId);10 console.log('Test Status: ' + data.data.statusText);11 console.log('Test URL: ' + data.data.userUrl);12 console.log('Test Results URL: ' + data.data.summaryCSV);13 }14});

Full Screen

Using AI Code Generation

copy

Full Screen

1var Wpt = require('wpt-api');2var wpt = new Wpt('A.8d9a9a1b5f0c1a4d8c4e4da4e4a4a4a4');3var testId;4var testResults;5var testURL = 'www.google.com';6var testResultsURL;7var testResultsJSON;8var testResultsHTML;9var testResultsPNG;10var testResultsCSV;11var testResultsXML;12var testResultsJSON2;13wpt.runTest(testURL, {14 videoParams: {15 }16}, function(err, data) {17 if (err) {18 console.log(err);19 } else {20 testId = data.data.testId;21 console.log('Test ID: ' + testId);22 console.log('Test URL: ' + testURL);23 wpt.getTestResults(testId, function(err, data) {24 if (err) {25 console.log(err);26 } else {27 testResults = data.data;28 console.log('Test Results: ' + testResults);29 testResultsURL = testResults.data.jsonUrl;30 console.log('Test Results URL: ' + testResultsURL);31 wpt.getTestResults(testResultsURL, function(err, data) {32 if (err) {33 console.log(err);34 } else {35 testResultsJSON = data;36 console.log('Test Results JSON: ' + testResultsJSON);37 testResultsHTML = testResultsJSON.data.runs[1].firstView.html;38 console.log('Test Results HTML: ' + testResultsHTML);39 testResultsPNG = testResultsJSON.data.runs[1].firstView.png;40 console.log('Test Results PNG: ' + testResultsPNG);41 testResultsCSV = testResultsJSON.data.runs[1].firstView.csv;42 console.log('Test Results CSV: ' + testResultsCSV);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3};4var wpt = new WebPageTest('www.webpagetest.org', 'A.9c9c1b1f4b4c8f1e6d0e6b0f6b3d2c2c');5 if (err) return console.log(err);6 console.log('Test status:', data.statusText);7 console.log('Test ID:', data.data.testId);8 console.log('Test URL:', data.data.userUrl);9 console.log('Test results:', data.data.summary);10 console.log('Test results:', data.data.median.firstView);11 console.log('Test results:', data.data.median.firstView.SpeedIndex);12 console.log('Test results:', data.data.median.firstView.SpeedIndex);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful