Skip to content

Instantly share code, notes, and snippets.

@cgi-caesar
Created January 29, 2020 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cgi-caesar/b9f9fa6ec8cd5ed0153f196fb6d5b01f to your computer and use it in GitHub Desktop.
Save cgi-caesar/b9f9fa6ec8cd5ed0153f196fb6d5b01f to your computer and use it in GitHub Desktop.
aMember Plugin: PayPal with SSN payout method
<?php
/**
* @title PayPal Payout with SSN
* @desc add new payout method
* @path application/default/plugins/misc/aff-payout-paypalssn.php
*/
class Am_Plugin_AffPayoutPaypalssn extends Am_Plugin
{
const PLUGIN_STATUS = self::STATUS_BETA;
const PLUGIN_COMM = self::COMM_COMMERCIAL;
const PLUGIN_REVISION = '@@VERSION@@';
protected $_configPrefix = 'misc.';
function onAffGetPayoutOptions(Am_Event $e)
{
$e->addReturn('PayPal (SSN)', 'paypalssn');
}
}
if (Am_Di::getInstance()->modules->isEnabled('aff')) :
class Am_Aff_PayoutMethod_Paypalssn extends Am_Aff_PayoutMethod
{
public function getTitle()
{
return 'PayPal (SSN)';
}
public function export(AffPayout $payout, Am_Query $details, Am_Mvc_Response $response)
{
$q = $details->query();
while ($d = $payout->getDi()->db->fetchRow($q)) {
$d = $payout->getDi()->affPayoutDetailTable->createRecord($d);
/* @var $d AffPayoutDetail */
$aff = $d->getAff();
$rows[] = [
$aff->data()->get('aff_paypalssn_email'),
moneyRound($d->amount),
Am_Currency::getDefault(),
$aff->user_id,
"Affiliate commission to " . amDate($payout->thresehold_date),
$aff->data()->get('aff_paypalssn_ssn'),
];
}
$this->sendCsv("paypal-commission-" . $payout->payout_id . ".csv", $rows, $response);
}
public function addFields(Am_CustomFieldsManager $m)
{
$m->add(new Am_CustomFieldText('aff_paypalssn_email', ___('Affiliate Payout - Paypal E-Mail address'), ___('for affiliate commission payouts')));
$m->add(new Am_CustomFieldText('aff_paypalssn_ssn', ___('Affiliate Payout - SSN'), ___('(optional)')));
}
}
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment