Created
July 6, 2015 07:23
-
-
Save azraai/161d5d3b0c64d22810c9 to your computer and use it in GitHub Desktop.
Ebpg.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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