import { axios } from "@pipedream/platform";
import dayjs from "dayjs";
import crypto from "crypto";
export default defineComponent({
props: {
verifone: {
type: "app",
app: "verifone",
}
},
async run({steps, $}) {
let requestDateTime = new Date();
requestDateTime = dayjs(requestDateTime).format("YYYY-MM-DD hh:mm:ss");
const algo = "sha256";
let hash = this.verifone.$auth.vendor_code.length
+ this.verifone.$auth.vendor_code
+ requestDateTime.toString().length
+ requestDateTime;
hash = crypto.createHmac(algo, this.verifone.$auth.secret_key)
.update(hash)
.digest('hex');
return await axios($, {
url: `https://api.2checkout.com/rest/6.0/products/`,
headers: {
"X-Avangate-Authentication": `code="${this.verifone.$auth.vendor_code}" date="${requestDateTime}" hash="${hash}" algo="${algo}"`,
Accept: "application/json"
},
})
},
})
Verifone uses API keys for authentication. When you connect your Verifone account, Pipedream securely stores the keys so you can easily authenticate to Verifone APIs in both code and no-code steps.
To retrieve your Merchant Code and Secret Key,