npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@payfast/core

v0.2.3

Published

Easy to use node library to intergrate into payfast

Downloads

20

Readme

Payfast API

Minimum Requirements

At a minimum, the following must be provided to gain access to the API ecosystem:

  • A valid and an API enabled PayFast merchant account
  • A passphrase as set on the merchant account settings page
  • PayFast merchant ID
  • The version of the API you want to interact with
  • A valid merchant signature
  • A timestamp included in the request
  • Whitelist IP Address in integration settings

Step 1: Install npm module

npm i --save @payfast/core

This will install the current stable version of @payfast/core in your node_modules directory and save the entry in package.json.

Step 2: Import @payfast/core

const payfast = require('@payfast/core');
...

Documentation

Ping

const payfast = require('@payfast/core');

const response = await payfast.ping({
  "version":      "v1",
  "timestamp":    "2020-01-01T00:00:00",
  "passphrase":   "xxx",
  "merchant-id":  "xxx"
});

console.log(response);

"Payfast API"

Validate Sender

const payfast = require('@payfast/core');

const response = await payfast.validate.sender(req.headers.referer); // 'www.payfast.co.za'

console.log(response);

{
  "valid": true
}

Validate Request

const payfast = require('@payfast/core');

const response = await payfast.validate.request({
  "token":              "xxx",
  "name_last":          "",
  "item_name":          "xxx",
  "signature":          "xxx",
  "amount_fee":         "0.00",
  "amount_net":         "0.00",
  "name_first":         "",
  "custom_str1":        "",
  "custom_str2":        "",
  "custom_str3":        "",
  "custom_str4":        "",
  "custom_str5":        "",
  "custom_int1":        "",
  "custom_int2":        "",
  "custom_int3":        "",
  "custom_int4":        "",
  "custom_int5":        "",
  "merchant_id":        "xxx",
  "m_payment_id":       "xxx",
  "billing_date":       "2020-01-01",
  "amount_gross":       "0.00",
  "pf_payment_id":      "xxx",
  "email_address":      "[email protected]",
  "payment_status":     "COMPLETE",
  "item_description":   ""
});

console.log(response);

{
  "valid": true
}

Get All Transaction History

const payfast = require('@payfast/core');

const response = await payfast.transactions.history({
  "to":           "2020-01-01T00:00:00",
  "from":         "2020-05-20T00:00:00",
  "version":      "v1",
  "timestamp":    "2020-01-01T00:00:00",
  "passphrase":   "xxx",
  "merchant-id":  "xxx"
});

console.log(response);

[
    {
        "fee":              0.00,
        "net":              0.00,
        "date":             "2020-01-01T00:00:00",
        "type":             "xxx",
        "sign":             "xxx",
        "name":             "xxx",
        "party":            "xxx",
        "gross":            0.00,
        "balance":          0.00,
        "currency":         "ZAR",
        "custom_str1":      "xxx",
        "custom_int1":      "xxx",
        "custom_str2":      "xxx",
        "custom_int2":      "xxx",
        "custom_str3":      "xxx",
        "custom_str4":      "xxx",
        "custom_str5":      "xxx",
        "custom_int3":      "xxx",
        "custom_int4":      "xxx",
        "custom_int5":      "xxx",
        "description":      "xxx",
        "funding_type":     "xxx",
        "m_payment_id":     "xxx",
        "pf_payment_id":    "xxx",
    }
]

Get Daily Transaction History

const payfast = require('@payfast/core');

const response = await payfast.transactions.daily({
  "date":         "2020-05-20",
  "version":      "v1",
  "timestamp":    "2020-01-01T00:00:00",
  "passphrase":   "xxx",
  "merchant-id":  "xxx"
});

console.log(response);

[
    {
        "fee":              0.00,
        "net":              0.00,
        "date":             "2020-01-01T00:00:00",
        "type":             "xxx",
        "sign":             "xxx",
        "name":             "xxx",
        "party":            "xxx",
        "gross":            0.00,
        "balance":          0.00,
        "currency":         "ZAR",
        "custom_str1":      "xxx",
        "custom_int1":      "xxx",
        "custom_str2":      "xxx",
        "custom_int2":      "xxx",
        "custom_str3":      "xxx",
        "custom_str4":      "xxx",
        "custom_str5":      "xxx",
        "custom_int3":      "xxx",
        "custom_int4":      "xxx",
        "custom_int5":      "xxx",
        "description":      "xxx",
        "funding_type":     "xxx",
        "m_payment_id":     "xxx",
        "pf_payment_id":    "xxx",
    }
]

Get WeeklyTransaction History

const payfast = require('@payfast/core');

const response = await payfast.transactions.weekly({
  "date":         "2020-05-20",
  "version":      "v1",
  "timestamp":    "2020-01-01T00:00:00",
  "passphrase":   "xxx",
  "merchant-id":  "xxx"
});

console.log(response);

[
    {
        "fee":              0.00,
        "net":              0.00,
        "date":             "2020-01-01T00:00:00",
        "type":             "xxx",
        "sign":             "xxx",
        "name":             "xxx",
        "party":            "xxx",
        "gross":            0.00,
        "balance":          0.00,
        "currency":         "ZAR",
        "custom_str1":      "xxx",
        "custom_int1":      "xxx",
        "custom_str2":      "xxx",
        "custom_int2":      "xxx",
        "custom_str3":      "xxx",
        "custom_str4":      "xxx",
        "custom_str5":      "xxx",
        "custom_int3":      "xxx",
        "custom_int4":      "xxx",
        "custom_int5":      "xxx",
        "description":      "xxx",
        "funding_type":     "xxx",
        "m_payment_id":     "xxx",
        "pf_payment_id":    "xxx",
    }
]

Get Monthly Transaction History

const payfast = require('@payfast/core');

const response = await payfast.transactions.monthly({
  "date":         "2020-05-20",
  "version":      "v1",
  "timestamp":    "2020-01-01T00:00:00",
  "passphrase":   "xxx",
  "merchant-id":  "xxx"
});

console.log(response);

[
    {
        "fee":              0.00,
        "net":              0.00,
        "date":             "2020-01-01T00:00:00",
        "type":             "xxx",
        "sign":             "xxx",
        "name":             "xxx",
        "party":            "xxx",
        "gross":            0.00,
        "balance":          0.00,
        "currency":         "ZAR",
        "custom_str1":      "xxx",
        "custom_int1":      "xxx",
        "custom_str2":      "xxx",
        "custom_int2":      "xxx",
        "custom_str3":      "xxx",
        "custom_str4":      "xxx",
        "custom_str5":      "xxx",
        "custom_int3":      "xxx",
        "custom_int4":      "xxx",
        "custom_int5":      "xxx",
        "description":      "xxx",
        "funding_type":     "xxx",
        "m_payment_id":     "xxx",
        "pf_payment_id":    "xxx",
    }
]

Fetch Subscription

const payfast = require('@payfast/core');

const response = await payfast.subscriptions.fetch({
  "token":        "xxx",
  "version":      "v1",
  "timestamp":    "2020-01-01T00:00:00",
  "passphrase":   "xxx",
  "merchant-id":  "xxx"
});

console.log(response);

{
  "token":            "xxx",
  "amount":           20,
  "cycles":           10,
  "status":           1,
  "run_date":         "2020-01-01",
  "frequency":        3,
  "status_text":      "",
  "status_reason":    "",
  "cycles_complete":  2
}

Pause Subscription

const payfast = require('@payfast/core');

const response = await payfast.subscriptions.pause({
  "token":        "xxx",
  "cycles":       1,
  "version":      "v1",
  "timestamp":    "2020-01-01T00:00:00",
  "passphrase":   "xxx",
  "merchant-id":  "xxx"
});

console.log(response);

{
  "response": true
}

Unpause Subscription

const payfast = require('@payfast/core');

const response = await payfast.subscriptions.unpause({
  "token":        "xxx",
  "version":      "v1",
  "timestamp":    "2020-01-01T00:00:00",
  "passphrase":   "xxx",
  "merchant-id":  "xxx"
});

console.log(response);

{
  "response": true
}

Update Subscription

const payfast = require('@payfast/core');

const response = await payfast.subscriptions.update({
  "token":        "xxx",
  "cycles":       12,
  "amount":       30,
  "run_date":     "2020-01-01",
  "frequency":    4,
  "version":      "v1",
  "timestamp":    "2020-01-01T00:00:00",
  "passphrase":   "xxx",
  "merchant-id":  "xxx"
});

console.log(response);

{
  "response": true
}

Cancel Subscription

const payfast = require('@payfast/core');

const response = await payfast.subscriptions.cancel({
  "token":        "xxx",
  "version":      "v1",
  "timestamp":    "2020-01-01T00:00:00",
  "passphrase":   "xxx",
  "merchant-id":  "xxx"
});

console.log(response);

{
  "response": true
}

License

MIT License