mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
comment out old code and update callbackUrl
This commit is contained in:
parent
f1c25e678e
commit
bd4b4a6712
@ -52,75 +52,70 @@ class BlockonomicsPaymentDriver extends BaseDriver
|
|||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->api_key = $this->company_gateway->getConfigField('apiKey');
|
$this->api_key = $this->company_gateway->getConfigField('apiKey');
|
||||||
$this->callback_secret = $this->company_gateway->getConfigField('callbackSecret');
|
|
||||||
$this->callback_url = $this->company_gateway->getConfigField('callbackUrl');
|
$this->callback_url = $this->company_gateway->getConfigField('callbackUrl');
|
||||||
// $this->setCallbackUrl();
|
// $this->setCallbackUrl();
|
||||||
return $this; /* This is where you boot the gateway with your auth credentials*/
|
return $this; /* This is where you boot the gateway with your auth credentials*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public function doCurlCall($url, $post_content = '')
|
// public function doCurlCall($url, $post_content = '')
|
||||||
{
|
// {
|
||||||
$ch = curl_init();
|
// $ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
// curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
if ($post_content) {
|
// if ($post_content) {
|
||||||
curl_setopt($ch, CURLOPT_POST, 1);
|
// curl_setopt($ch, CURLOPT_POST, 1);
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_content);
|
// curl_setopt($ch, CURLOPT_POSTFIELDS, $post_content);
|
||||||
}
|
// }
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
|
// curl_setopt($ch, CURLOPT_TIMEOUT, 60);
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
// curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||||
'Authorization: Bearer ' . $this->api_key,
|
// 'Authorization: Bearer ' . $this->api_key,
|
||||||
'Content-type: application/x-www-form-urlencoded',
|
// 'Content-type: application/x-www-form-urlencoded',
|
||||||
]);
|
// ]);
|
||||||
|
// $contents = curl_exec($ch);
|
||||||
|
// if (curl_errno($ch)) {
|
||||||
|
// echo "Error:" . curl_error($ch);
|
||||||
|
// }
|
||||||
|
// $responseObj = json_decode($contents);
|
||||||
|
// $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
|
// curl_close ($ch);
|
||||||
|
// if ($status != 200) {
|
||||||
|
// echo "ERROR: " . $status . ' ' . $responseObj->message;
|
||||||
|
// }
|
||||||
|
// return $responseObj;
|
||||||
|
// }
|
||||||
|
|
||||||
$contents = curl_exec($ch);
|
// public function setCallbackUrl()
|
||||||
if (curl_errno($ch)) {
|
// {
|
||||||
echo "Error:" . curl_error($ch);
|
// $GET_CALLBACKS_URL = 'https://www.blockonomics.co/api/address?&no_balance=true&only_xpub=true&get_callback=true';
|
||||||
}
|
// $SET_CALLBACK_URL = 'https://www.blockonomics.co/api/update_callback';
|
||||||
$responseObj = json_decode($contents);
|
// $get_callback_response = $this->doCurlCall($GET_CALLBACKS_URL);
|
||||||
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
||||||
curl_close ($ch);
|
|
||||||
|
|
||||||
if ($status != 200) {
|
// $callback_url = $this->callback_url;
|
||||||
echo "ERROR: " . $status . ' ' . $responseObj->message;
|
// $xpub = $get_callback_response[0]->address;
|
||||||
}
|
// $post_content = '{"callback": "' . $callback_url . '", "xpub": "' . $xpub . '"}';
|
||||||
return $responseObj;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCallbackUrl()
|
// $responseObj = $this->doCurlCall($SET_CALLBACK_URL, $post_content);
|
||||||
{
|
// return $responseObj;
|
||||||
$GET_CALLBACKS_URL = 'https://www.blockonomics.co/api/address?&no_balance=true&only_xpub=true&get_callback=true';
|
// }
|
||||||
$SET_CALLBACK_URL = 'https://www.blockonomics.co/api/update_callback';
|
|
||||||
$get_callback_response = $this->doCurlCall($GET_CALLBACKS_URL);
|
|
||||||
|
|
||||||
$callback_url = $this->callback_url;
|
// public function findPaymentHashInTransactionReference($transaction_reference)
|
||||||
$xpub = $get_callback_response[0]->address;
|
// {
|
||||||
$post_content = '{"callback": "' . $callback_url . '", "xpub": "' . $xpub . '"}';
|
// $pattern = '/payment hash:\s*([a-zA-Z0-9]+)/';
|
||||||
|
// // Perform the regex match
|
||||||
$responseObj = $this->doCurlCall($SET_CALLBACK_URL, $post_content);
|
// if (preg_match($pattern, $transaction_reference, $matches)) {
|
||||||
return $responseObj;
|
// // Return the matched payment hash
|
||||||
}
|
// return $matches[1];
|
||||||
|
// } else {
|
||||||
|
// // Return null if no match is found
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
public function findPaymentByTxid($txid)
|
public function findPaymentByTxid($txid)
|
||||||
{
|
{
|
||||||
return Payment::whereRaw('BINARY `transaction_reference` LIKE ? AND BINARY `transaction_reference` LIKE ?', [
|
return Payment::whereRaw('BINARY `transaction_reference` LIKE ?', ["%txid: " . $txid])->firstOrFail();
|
||||||
"%payment hash:%",
|
|
||||||
"%txid: " . $txid . "%"
|
|
||||||
])->firstOrFail();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findPaymentHashInTransactionReference($transaction_reference)
|
|
||||||
{
|
|
||||||
$pattern = '/payment hash:\s*([a-zA-Z0-9]+)/';
|
|
||||||
// Perform the regex match
|
|
||||||
if (preg_match($pattern, $transaction_reference, $matches)) {
|
|
||||||
// Return the matched payment hash
|
|
||||||
return $matches[1];
|
|
||||||
} else {
|
|
||||||
// Return null if no match is found
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Returns an array of gateway types for the payment gateway */
|
/* Returns an array of gateway types for the payment gateway */
|
||||||
@ -172,7 +167,7 @@ class BlockonomicsPaymentDriver extends BaseDriver
|
|||||||
}
|
}
|
||||||
|
|
||||||
$payment = $this->findPaymentByTxid($txid);
|
$payment = $this->findPaymentByTxid($txid);
|
||||||
$payment_hash = $this->findPaymentHashInTransactionReference($payment->transaction_reference);
|
// $payment_hash = $this->findPaymentHashInTransactionReference($payment->transaction_reference);
|
||||||
|
|
||||||
switch ($status) {
|
switch ($status) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -24,12 +24,12 @@ class PaymentLibrariesSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
Model::unguard();
|
Model::unguard();
|
||||||
|
|
||||||
$callbackUrl = config('ninja.app_url') . '/client/payments/process/?secret=';
|
|
||||||
$callbackSecret = md5(uniqid(rand(), true));
|
$callbackSecret = md5(uniqid(rand(), true));
|
||||||
|
$callbackUrl = config('ninja.app_url') . "/api/v1/blockonomics/callback/?secret=$callbackSecret";
|
||||||
$blockonomics_fields = "{
|
$blockonomics_fields = "{
|
||||||
\"apiKey\": \"\",
|
\"apiKey\": \"\",
|
||||||
\"callbackUrl\": \"$callbackUrl\",
|
\"callbackUrl\": \"$callbackUrl\",
|
||||||
\"callbackSecret\": \"$callbackSecret\"
|
\"callbackSecret\": \"$callbackSecret\",
|
||||||
}";
|
}";
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user