-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
unknown
committed
Apr 27, 2016
0 parents
commit ba34745
Showing
3 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace ramzyvirani\Authorizenet; | ||
|
||
class AuthorizeNetSIM_Form extends \AuthorizeNetSIM_Form | ||
{ | ||
/** | ||
* Generates a fingerprint needed for a hosted order form or DPM. | ||
* | ||
* @param string $api_login_id Login ID. | ||
* @param string $transaction_key API key. | ||
* @param string $amount Amount of transaction. | ||
* @param string $fp_sequence An invoice number or random number. | ||
* @param string $fp_timestamp Timestamp. | ||
* @param string $fp_currency_code Currency Code. | ||
* | ||
* @return string The fingerprint. | ||
*/ | ||
public static function getFingerprint($api_login_id, $transaction_key, $amount, $fp_sequence, $fp_timestamp, $fp_currency_code=null) | ||
{ | ||
$api_login_id = ($api_login_id ? $api_login_id : (defined('AUTHORIZENET_API_LOGIN_ID') ? AUTHORIZENET_API_LOGIN_ID : "")); | ||
$transaction_key = ($transaction_key ? $transaction_key : (defined('AUTHORIZENET_TRANSACTION_KEY') ? AUTHORIZENET_TRANSACTION_KEY : "")); | ||
$currency_code = (!is_null($fp_currency_code)) ? $fp_currency_code : ""; | ||
if (function_exists('hash_hmac')) { | ||
return hash_hmac("md5", $api_login_id . "^" . $fp_sequence . "^" . $fp_timestamp . "^" . $amount . "^" . $currency_code , $transaction_key); | ||
} | ||
return bin2hex(mhash(MHASH_MD5, $api_login_id . "^" . $fp_sequence . "^" . $fp_timestamp . "^" . $amount . "^" . $currency_code, $transaction_key)); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
YII2 Authorizenet Gateway Extensions | ||
==================================== | ||
YII2 Authorizenet Payment Gateway Extension | ||
|
||
Installation | ||
------------ | ||
|
||
The preferred way to install this extension is through [composer](http://getcomposer.org/download/). | ||
|
||
Either run | ||
|
||
``` | ||
php composer.phar require ramzyvirani/yii2-authorizenet "*" | ||
``` | ||
|
||
or add | ||
|
||
``` | ||
"ramzyvirani/yii2-authorizenet": "*" | ||
``` | ||
|
||
to the require section of your `composer.json` file. | ||
|
||
|
||
How to call? | ||
----- | ||
You just have to include any of the class in your code before using it and other code you can use exactly the same as authorizenet PHP SDK. | ||
|
||
use AuthorizeNetAIM; | ||
use AuthorizeNetARB; | ||
use AuthorizeNetCIM; | ||
use AuthorizeNetCP; | ||
use AuthorizeNetDPM; | ||
use AuthorizeNetSIM; | ||
use AuthorizeNetSOAP; | ||
use AuthorizeNetTD; | ||
|
||
|
||
|
||
Usage Examples | ||
----- | ||
Once the extension is installed, simply use it in your code by : | ||
|
||
````php | ||
use AuthorizeNetAIM; | ||
define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN"); | ||
define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY"); | ||
define("AUTHORIZENET_SANDBOX", true); | ||
|
||
$sale = new AuthorizeNetAIM; | ||
$sale->amount = "5.99"; | ||
$sale->card_num = '4111111111111111'; | ||
$sale->exp_date = '0418'; | ||
$response = $sale->authorizeAndCapture(); | ||
if ($response->approved) { | ||
echo "Success! Transaction ID:" . $response->transaction_id; | ||
} else { | ||
echo "ERROR:" . $response->error_message; | ||
} | ||
```` | ||
|
||
For more examples visit https://github.com/AuthorizeNet/sdk-php | ||
|
||
## License | ||
|
||
**yii2-authorizenet** is released under the BSD 3-Clause License. See the bundled `LICENSE.md` for details. | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "ramzyvirani/yii2-authorizenet", | ||
"description": "YII2 Authorizenet Gateway Extension", | ||
"type": "yii2-extension", | ||
"keywords": ["yii2 authorize.net extension"], | ||
"license": "Apache-2.0", | ||
"authors": [ | ||
{ | ||
"name": "Ramzy Virani", | ||
"email": "ramzy.rhv@gmail.com" | ||
} | ||
], | ||
"require": { | ||
"yiisoft/yii2": "^2.0", | ||
"authorizenet/authorizenet": "~1.8" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"ramzyvirani\\authorizenet\\": "" | ||
} | ||
} | ||
|
||
} |