It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency, since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site; Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in - your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
class Am_Paysystem_Bitbayar extends Am_Paysystem_Abstract
{
const PLUGIN_STATUS = self::STATUS_BETA;
const PLUGIN_REVISION = '1.0';
const API_URL = 'https://bitbayar.com/api/create_invoice';
const API_STATUS = 'https://bitbayar.com/api/check_invoice';
//~ Customer View
protected $defaultTitle = 'BitBayar';
protected $defaultDescription = 'paid by bitcoins';
public function _initSetupForm(Am_Form_Setup $form)
{
$form->addText('apiToken', array('size' => 40))
->setLabel(array('Merchant API TOKEN', 'from BitBayar merchant account --> Setting & API --> API TOKEN'))
->addRule('required');
}
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
{
require_once 'bitbayar/bb_lib.php';
$data_pay = array(
'token' => $this->getConfig('apiToken'),
'invoice_id' => $invoice->public_id,
'rupiah' => $invoice->first_total,
'memo' => $invoice->getFirstName().' - Invoice #'.$invoice->public_id,
'callback_url' => $this->getPluginUrl('ipn'),
'url_success' => $this->getReturnUrl(),
'url_failed' => $this->getCancelUrl()
);
$bbInvoice = bbCurlPost(Am_Paysystem_Bitbayar::API_URL, $data_pay);
$response = json_decode($bbInvoice);
if($response->success){
Am_Di::getInstance()->errorLogTable->log("BitBayar New Order #" . $response->invoice_id . " [Amount IDR : ".$response->amount_rp.'] [Amount BTC : '.$response->amount_btc."]");
header('Location: '.$response->payment_url);
exit;
}
else{
exit('BitBayar API Error: '.$response->error_message);
}
}
public function getRecurringType()
{
return self::REPORTS_NOT_RECURRING;
}
public function getReadme()
{
return << BitBayar payment plugin configuration
Bitcoin you receive will be automatically converted into Rupiah without no fee.
For using this plugin:
1. You must obtain an API TOKEN from the BitBayar website and paste it at 'Merchant API TOKEN' option.
Find your API TOKEN by logging into your merchant account and clicking on Setting & API.
Bitbayar.com
CUT;
}
public function createTransaction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
{
return new Am_Paysystem_Transaction_BitBayar($this, $request, $response, $invokeArgs);
}
public function createThanksTransaction(Am_Request $request, Zend_Controller_Response_Http $response, array $invokeArgs)
{
return new Am_Paysystem_Transaction_BitBayar($this, $request, $response, $invokeArgs);
}
}
class Am_Paysystem_Transaction_Bitbayar extends Am_Paysystem_Transaction_Incoming
{
public function getUniqId()
{
return $this->request->getFiltered('id');
}
public function validateSource()
{
//~ Error Log : Looks like an invalid IPN post - no Invoice# passed
return true;
}
public function validateStatus()
{
require_once 'bitbayar/bb_lib.php';
$data_check = array(
'token' => $this->plugin->getConfig('apiToken'),
'id' => $this->request->getFiltered('id')
);
$bbInvoiceStatus = bbCurlPost(Am_Paysystem_Bitbayar::API_STATUS, $data_check);
$response = json_decode($bbInvoiceStatus);
Am_Di::getInstance()->errorLogTable->log("BITBAYAR INVOICE STATUS \n[Invoice ID: " . $response->invoice_id."] [Status: ".$response->status."]");
return $response->status;
}
public function validateTerms()
{
//~ Check IDR Amount
return doubleval($this->invoice->first_total) == doubleval($this->request->get('rp'));
}
public function findInvoiceId()
{
//~ Error Log : Unknown transaction: related invoice not found #[A1B2C3]
return $this->request->getFiltered('invoice_id');
}
public function validate()
{
$this->autoCreate();
if (empty($this->invoice->_autoCreated) && !$this->validateTerms())
throw new Am_Exception_Paysystem_TransactionInvalid("INVALID IDR AMOUNT \n[Invoice Amount : ".$this->invoice->first_total."] [Paid Amount : ".$this->request->get('rp')."]");
if (!$this->validateStatus())
throw new Am_Exception_Paysystem_TransactionInvalid("BITBAYAR STATUS : UNPAID");
}
}