Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mpaannddreew committed Apr 18, 2019
0 parents commit aef8379
Show file tree
Hide file tree
Showing 8 changed files with 765 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.idea
/vendor
20 changes: 20 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "fannypack/momo",
"description": "MTN MOMO api implementation",
"type": "library",
"require": {
"guzzlehttp/guzzle": "^6.3",
"ramsey/uuid": "^3.8"
},
"authors": [
{
"name": "Mpande Andrew",
"email": "[email protected]"
}
],
"autoload": {
"psr-4": {
"FannyPack\\Momo\\": "src"
}
}
}
291 changes: 291 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions src/Products/Collection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* Created by PhpStorm.
* User: Mpande Andrew
* Date: 18/04/2019
* Time: 19:15
*/

namespace FannyPack\Momo\Products;

/**
* Class Collection
* @package FannyPack\Momo\Products
*/
class Collection extends Product
{
const REQUEST_TO_PAY_URI = "/v1_0/requesttopay";

const PRE_APPROVAL_URI = "/v1_0/preapproval";

protected $preApproval = false;

protected function transactionUrl() {
return $this->getProductBaseUrl() . ($this->preApproval ? self::PRE_APPROVAL_URI: self::REQUEST_TO_PAY_URI);
}

protected function transactionStatusUrl() {
return $this->getProductBaseUrl() . ($this->preApproval ? self::PRE_APPROVAL_URI: self::REQUEST_TO_PAY_URI);
}

/**
* Start request to pay transaction
*
* @param $externalId
* @param $partyId
* @param $amount
* @param $currency
* @param string $payerMessage
* @param string $payeeNote
* @return mixed
* @throws \Exception
*/
public function requestToPay($externalId, $partyId, $amount, $currency, $payerMessage = '', $payeeNote = '') {
return $this->transact($externalId, $partyId, $amount, $currency, $payerMessage, $payeeNote);
}

/**
* Get request to pay transaction status
*
* @param $paymentRef
* @return mixed
* @throws \Exception
*/
public function getRequestToPayStatus($paymentRef) {
return $this->getTransactionStatus($paymentRef);
}
}
Loading

0 comments on commit aef8379

Please sign in to comment.