Jump to content
  • 0

Composer payment SDK in WHMCS


hasajacykacperek

Question

Hello, i added PHP SDK from my payment to modules/gateways

https://github.com/pay-now/paynow-php-sdk

and added code to new file:

<?php

if (!defined("WHMCS")) die("This file cannot be accessed directly");

require_once('vendor/autoload.php');

use Paynow\Client;
use Paynow\Environment;
use Paynow\Exception\PaynowException;
use Paynow\Service\Payment;

function paynow_config() {
    $version = '1.0.0';
    $configarray = array(
     "FriendlyName" => array("Type" => "System", "Value"=>"PayNow"),
     "userid" => array("FriendlyName" => "Identyfikator Punktu Płatności", "Type" => "text", "Size" => "20"),  
     "userkey" => array("FriendlyName" => "Klucz Punktu Płatności", "Type" => "text", "Size" => "20"),
     "buttontext" => array("FriendlyName" => "Tekst Przycisku", "Type" => "text", "Value"=>"Zapłać z paynow", "Size" => "20"),
     "Wersja" => array( "Type" => "html", "Size" => "25", "Description" => $version)
    );

	return $configarray;
}

function paynow_link($params) {
    $client = new Paynow\Client('xd', 'xd', Paynow\Environment::SANDBOX);
    $orderReference = "success_whmcs_".$params['invoiceid'];
    $idempotencyKey = uniqid($orderReference . '_');

    $paymentData = [
        "amount" => $params['amount'],
        "currency" => "PLN",
        "externalId" => $orderReference,
        "description" => $params["description"],
        "buyer" => [
            "email" => $params['clientdetails']['email'],
            'firstName' => $params['clientdetails']['firstname'],
            'lastName' => $params['clientdetails']['lastname']
        ]
    ];

    try {
        $payment = new Payment($client);
        $result = $payment->authorize($paymentData, $idempotencyKey);

        $code = '<a href="'.$result->getRedirectUrl().'">'.$params['buttontext'].'</a>';
        return $code;

    } catch (PaynowException $exception) {
        var_dump($exception);
        return "wystapil bardzo dziwny blad ktorego pewnie nie da sie naprawic XD";
    }
}

and i get this error:

Error: Class 'Paynow\Client' not found in /home/klient.dhosting.pl/lizipiczek/hosting.dkonto.pl/public_html/modules/gateways/paynow.php:27

image.png.02559a178c6d15d102233b4adab1b5e1.png

image.png.1cccd736374b6f7d28ba4eea4df1e43a.png

please help me, thanks

Edited by hasajacykacperek
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated