Skip to content

Instantly share code, notes, and snippets.

@azraai
Created July 6, 2015 07:23
Show Gist options
  • Save azraai/161d5d3b0c64d22810c9 to your computer and use it in GitHub Desktop.
Save azraai/161d5d3b0c64d22810c9 to your computer and use it in GitHub Desktop.
Ebpg.php
<?php
class Ebpg {
public $hash_key;
public $merchant_id;
public $prefix;
public $order_number;
public $amount;
public $signature;
public $prefix_number;
private $signature_string;
public function __construct($attributes)
{
foreach($attributes as $key => $value)
{
$this->{$key} = $value;
}
$this->prefix_number = $this->prefix . $this->order_number;
}
public function sign()
{
$this->signature_string = "{$this->hash_key}{$this->merchant_id}{$this->prefix_number}{$this->amount}";
$this->signature = hash('sha512', $this->signature_string);
}
public function __get($property) {
if (property_exists($this, $property)) {
return $this->$property;
}
}
public function __set($property, $value) {
if($property == 'amount') {
$this->amount = sprintf('%2.f', $value);
}
if (property_exists($this, $property)) {
$this->$property = $value;
}
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment