Socket
Socket
Sign inDemoInstall

payfort-node

Package Overview
Dependencies
47
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    payfort-node

Unofficial payfort node client


Version published
Weekly downloads
36
increased by100%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Payfort Payment API

Basic useful feature list:

  • Allows you to make Payfort Credit/Debit card Payment API
  • PayAtHome method not yet supported
  • If you have experience with SOAP Client on Node.JS then please contact me we can do payfort-PayAtHOme API for this module.

Install

npm install payfort-node --save

And here's some code! :+1:

// initialize the client
var payfort = require("payfort-node");
// create client
var client = payfort.create_client("development", {
  access_code : "your_access_code",
  merchant_identifier : "your_merchant_identifier",
  passphrase : "your_passphrase"
  purchase_url : "send this only to override default urls"
});
// default URLs
// Authorization/Purchase URLs
// Test Environment URL: https://sbcheckout.payfort.com/FortAPI/paymentPage
// Production Environment URL: https://checkout.payfort.com/FortAPI/paymentPage
// purchase data to be sent to payfort
var purchaseData = {
  "amount": data.amount,
  "command" : "PURCHASE", // PURCHASE OR AUTHORIZATION
  "currency": data.currency,
  "customer_email": data.email,
  "customer_name": data.name,
  "language": "ar",
  "return_url": "https://your_website.com/packages/v1/callback",
  "merchant_reference": data.order_id
};
//call payfort API
payfort.send_request(client, purchaseData, function(err, response){
  if(err){
      //error stuff
    }
    //handle response
})

When you get the callback from payfort you can use the following code to validate the data sent by payfort.

// Callback will be a get request so below valiable 'get_request' will the decoded Query Parameters

var get_request = {
  // decoded query params
};
var original_signature = get_request.signature;
delete response.signature;
var new_signature = payfort.create_signature("your_passphrase", get_request);

if(original_signature == new_signature){
  // valid data
}else{
  // invalid data
}

FAQs

Last updated on 26 Dec 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc