If you want to get information about coupon and affiliate from coupon code, you can use class
Pap_Features_Coupon_OfflineSaleForm.
<?php
include 'PapApi.class.php'; //the PapApi.class.php can be found at the PAP installation folder, in the 'api' directory
$session = new Pap_Api_Session("https://your_pap_url/scripts/server.php");
if(!$session->login("merchant login","password")) {
die("Cannot login. Message: ". $session->getMessage());
}
$couponCode = 'xxxxxx';
$request = new Gpf_Rpc_FormRequest("Pap_Features_Coupon_OfflineSaleForm", "load", $session);
$request->setField('Id', $couponCode);
try {
$request->sendNow();
} catch(Exception $e) {
die("API call error: ".$e->getMessage());
}
$responseForm = $request->getForm();
if($responseForm->isSuccessful() && $responseForm->existsField('couponcode') && $responseForm->getFieldValue('couponcode') != null) {
echo 'Coupon is valid.';
echo '<br>';
echo 'Coupon code: '.$responseForm->getFieldValue('couponcode');
echo '<br>';
echo 'Coupon name:'.$responseForm->getFieldValue('name');
echo '<br>';
echo 'Coupon description: '.$responseForm->getFieldValue('description');
echo '<br>';
echo 'Banner description: '.$responseForm->getFieldValue('bannerDescription');
echo '<br>';
$userRecord = $responseForm->getFields()->getRecord('userid');
$affiliateValues = $userRecord->get(Gpf_Rpc_Form::FIELD_VALUES);
$affiliateValuesNames = array_flip($affiliateValues[0]);
echo 'User ID: '.$affiliateValues[1][$affiliateValuesNames['userid']];
echo '<br>';
echo 'User login name: '.$affiliateValues[1][$affiliateValuesNames['username']];
echo '<br>';
echo 'User firstname: '.$affiliateValues[1][$affiliateValuesNames['firstname']];
echo '<br>';
echo 'User lastname: '.$affiliateValues[1][$affiliateValuesNames['lastname']];
echo '<br>';
} else {
echo 'Coupon is invalid.';
}
?>