lundi 5 février 2018

Post to a third party API via PayPal it's IPN listener

I'm trying to push some data into a third party API called AcuityScheduling via PayPal it's IPN listener when a payment was done. I installed the IPN scripts on my server and everything works so far (the script logs the information it receives from PayPal - so everything's fine).

My Problem:

When I try to call my function after the if ($verfied) nothing happens on my third party dashboard. When I call the function on it's own on an extra page, the code works. Can you tell me why?

<?php

include('AcuityScheduling.php');
include('IpnListener.php');
use dezlov\PayPal\IpnListener;
$listener = new IpnListener();
$listener->use_sandbox = true;
$error = null;
$verified = $listener->tryProcessIpn(null, $error);
$report = $listener->getTextReport();
ipn_log($verified, $report, $error);
function ipn_log($verified, $report, $error)

$userId = 'xxx';
$apiKey = 'xxx';

$acuity = new AcuityScheduling(array(
  'userId' => $userId,
  'apiKey' => $apiKey
));

{
    if ($verified)
    {
        $filename = 'ipn_verified.log';
        $content = $report;

        function submitToAcuity() { 

            $appointment = $acuity->request('/certificates', array(
          'method' => 'POST',
          'data' => array(
            'productID'     => 425193,
            'email'       => 'test@test.de'
          )
            ));
    }
    submitToAcuity();   
    }

    else
    {
        $filename = 'ipn_errors.log';
        $content = 'ERROR: '.$error.PHP_EOL.$report;
    }
    file_put_contents($filename, $content, FILE_APPEND | LOCK_EX);
}

Aucun commentaire:

Enregistrer un commentaire