simbacode / moneycake
Pesapal Composer 移动货币库
这个包的规范仓库似乎已经消失,因此该包已被冻结。
1.2.0
2017-03-27 06:23 UTC
Requires
- php: >=5.4.16
This package is auto-updated.
Last update: 2024-07-12 21:41:37 UTC
README
这是一个PHP的移动货币库。
要求
- PHP 5.4.16+
- 启用curl
移动货币网关
- pesapal
如何使用
这是一个Composer库,因此使用起来非常简单。
使用Composer
require: "simbacode/moneycake": "dev-master"
Git克隆
您还可以在vendor文件夹中克隆库,但请记住将其添加到自动运行。
git clone https://github.com/Simbacode/moneycake
Codeigniter PostPesapalDirectOrderV4 示例
<?php $pesapal = new Simbacode\Moneycake\Pesapal(true, "YOUR-KEY", "YOUR-SECRET"); //variables $amount = $this->data['amount']; $description = $this->data['description']; $transaction_id = $this->data['guid']; $email = $this->data['email']; $phone_numer = $this->data['phone']; $first_name = $this->data['firstname']; $last_name = $this->data['lastname']; $currency = "UGX"; if (!empty($amount) && !empty($description) && !empty($transaction_id) && !empty($email) && !empty($phone_numer) && !empty($first_name) && !empty($last_name)) { $urlredirect = base_url() . "index.php/pesapal/purchaseredirect"; $resutl = $pesapal->PostPesapalDirectOrderV4($urlredirect, $amount, $currency, $description, "MERCHANT", $transaction_id, $email, $phone_numer, $first_name, $last_name); //$this->set('iframe', $pesapal->getOauthRequest()); ?> <iframe src="<?php echo $pesapal->getOauthRequest(); ?>" width="100%" height="700px" scrolling="no" frameBorder="0"> <p>Browser unable to load iFrame</p> </iframe> <?php } ?>
Codeigniter IPN 示例
<?php public function IPN() { //FROM PESAPAL $this->data['view'] = 'backend/querypayments'; $this->data['viewstatus'] = 'dashboard'; $reference = null; $pesapal_tracking_id = null; if (isset($_GET['pesapal_merchant_reference'])) $reference = $_GET['pesapal_merchant_reference']; if (isset($_GET['pesapal_transaction_tracking_id'])) $pesapal_tracking_id = $_GET['pesapal_transaction_tracking_id']; $pesapalNotification=$_GET['pesapal_notification_type']; $pesapal = new Simbacode\Moneycake\Pesapal(true, "YOUR-KEY", "YOUR-SECRET"); $pesapal->InstantPaymentNotificationWithCallback($pesapalNotification, $reference, $pesapal_tracking_id, function($status) { if ($status != 'PENDING') { //JUST UPDATE ANY OF THE STATUS eg INVALID if ($this->db->update('pesapal', array('status' => $status), array('reference' => $reference, 'pesapal_tracking_id' => $pesapal_tracking_id))->affected_rows() > 0) { if($status=='COMPLETE'): //FINISH PAYMENTS LOGIC endif; return TRUE; }; } else { return FALSE; } }); $this->load_view($this->data); } ?>