Skip to content

Commit

Permalink
update code
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrax committed Feb 4, 2023
1 parent 8941b4d commit 58d5b76
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 6 deletions.
16 changes: 15 additions & 1 deletion config/config.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
<?php


return [];
return [

"access_code" => env("CARD_PAYMENT_ACCESS_CODE"),

"payment_url" => env("CARD_PAYMENT_URL"),

"secure_secret" => env("CARD_PAYMENT_SECURE_SECRET"),

"merchant_id" => env("CARD_PAYMENT_MERCHANT_ID"),

"redirect_url" => env("CARD_PAYMENT_REDIRECT_URL")



];
31 changes: 28 additions & 3 deletions src/Crdb.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
<?php

namespace Epmnzava\CrdbBankMastercardVisaLaravel;
namespace Epmnzava\Crdb;

class CrdbBankMastercardVisaLaravel
use Epmnzava\Crdb\Libs\OnlineCard;

class Crdb
{


public function excecutepay()
public function makepayment($cardtype, $order_referenceid, $amount, $currency)
{

$card = new OnlineCard;


$params = [
"vpc_AccessCode" => config("crdb.access_code"),
"vpc_Amount" => floatval($amount) * 100,
"vpc_Command" => "pay",
"vpc_Currency" => $currency,
"vpc_Locale" => "en",
"vpc_MerchTxnRef" => $order_referenceid,
"vpc_Merchant" => config("crdb.merchant_id"),
"vpc_OrderInfo" => $order_referenceid,
"vpc_ReturnURL" => config("crdb.redirect_url"),
"vpc_Version" => 1,
"vpc_SecureHashType" => "SHA256",
"vpc_card" => $cardtype,
"vpc_gateway" => "ssl"

];
$redirect = $card->execute($params);

return $redirect;
}
}
4 changes: 2 additions & 2 deletions src/CrdbServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function boot()

if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__ . '/../config/config.php' => config_path('Crdb.php'),
__DIR__ . '/../config/config.php' => config_path('crdb.php'),
], 'config');

// Publishing the views.
Expand Down Expand Up @@ -50,7 +50,7 @@ public function boot()
public function register()
{
// Automatically apply the package configuration
$this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'Crdb');
$this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'crdb');

// Register the main class to use with the facade
$this->app->singleton('Crdb', function () {
Expand Down
41 changes: 41 additions & 0 deletions src/Libs/OnlineCard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Epmnzava\Crdb\Libs;



class OnlineCard
{
public function __construct()
{
}


public function execute($params)
{
//$conn = new VPCPaymentConnection();

$md5hash = config("crdb.access_code");
$md5hash1 = '';
$url = config("crdb.payment_url");
$SECURE_SECRET = config("crdb.secure_secret");

ksort($params);
foreach ($params as $key => $val) {
if (strlen($val) > 0) {
$qstr[] = urlencode($key) . "=" . urlencode($val);
$md5hash .= $val;
if ((strlen($val) > 0) && ((substr($key, 0, 4) == "vpc_") || (substr($key, 0, 5) == "user_"))) {
if (in_array($key, array('vpc_SecureHash', 'vpc_SecureHashType')))
continue;
$md5hash1 .= $key . "=" . $val . "&";
}
}
}
$md5hash1 = rtrim($md5hash1, '&');
$vpc_url = $url . '?' . implode("&", $qstr);
$vpc_url .= "&vpc_SecureHash=" . strtoupper(hash_hmac('SHA256', $md5hash1, pack('H*', $SECURE_SECRET)));

return $vpc_url;
}
}

0 comments on commit 58d5b76

Please sign in to comment.