send amount variable to the route.php in payfort api

245 Views Asked by At

I'm trying to set up Payfort I have a config file with this code (https://github.com/payfort/payfort-php-sdk)

[UPDATE]: How to modify the php files from this link to make the amount, customer , item name, email and merchant_identifier (order id) dynamic values not static in the PayfortIntegration.php file?

$objFort->merchantIdentifier = 'my_id';
$objFort->accessCode         = 'my_access_code';
$objFort->SHARequestPhrase   = 'request_phrase';
$objFort->SHAResponsePhrase = 'response_phrase@545';

In the main class in PayfortIntegration.php

class PayfortIntegration
{

public  $merchantIdentifier, $accessCode, $SHARequestPhrase, $SHAResponsePhrase, $amount;
}

Then with every call to the route.php file i changed to something like this (if the amount is not set in the route.php file I get 'invalid amount error')

public function getMerchantPageData() //inside the main class in PayfortIntegration.php
{
    $amount = $this->amount; //to get the amount value sent to the class from index.php
    $merchantReference = $this->generateMerchantReference();
    $returnUrl = $this->getUrl('route.php?r=merchantPageReturn&amount='.$amount);
}

in index.php

require_once 'PayfortIntegration.php';
$objFort = new PayfortIntegration();

require 'config.php';
$amount = $_POST['amount'];
$objFort->amount = amount;

in route.php

require_once 'PayfortIntegration.php';
$objFort = new PayfortIntegration();
require 'config.php';
$amount = $_REQUEST['amount'];
$objFort->amount = $amount;

But I get 'invalid amount' error. The question is how to send the amount parameter to the route.php in a correct way?

0

There are 0 best solutions below