Skip to content

Commit

Permalink
First working project
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Siong Chan committed Apr 1, 2016
1 parent 0b0b1fb commit 4d0cb3f
Show file tree
Hide file tree
Showing 21 changed files with 1,347 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/vendor
composer.lock
composer.phar
phpunit.xml
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm

before_script:
- composer install -n --dev --prefer-source

script: vendor/bin/phpcs --standard=PSR2 -n src && vendor/bin/phpunit --coverage-text
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Contributing Guidelines

* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a future version unintentionally.
* Commit just the modifications, do not mess with the composer.json or CHANGELOG.md files.
* Ensure your code is nicely formatted in the [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
style and that all tests pass.
* Send the pull request.
* Check that the Travis CI build passed. If not, rinse and repeat.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Lee Siong Chan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
64 changes: 62 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,62 @@
# omnipay-molpay
MOLPay driver for the Omnipay PHP payment processing library
# Omnipay: MOLPay

**MOLPay driver for the Omnipay PHP payment processing library**

[![Build Status](https://travis-ci.org/leesiongchan/omnipay-molpay.png?branch=master)](https://travis-ci.org/leesiongchan/omnipay-molpay)
[![Latest Stable Version](https://poser.pugx.org/leesiongchan/omnipay-molpay/v/stable)](https://packagist.org/packages/leesiongchan/omnipay-molpay)
[![Total Downloads](https://poser.pugx.org/leesiongchan/omnipay-molpay/downloads)](https://packagist.org/packages/leesiongchan/omnipay-molpay)
[![Latest Unstable Version](https://poser.pugx.org/leesiongchan/omnipay-molpay/v/unstable)](https://packagist.org/packages/leesiongchan/omnipay-molpay)
[![License](https://poser.pugx.org/leesiongchan/omnipay-molpay/license)](https://packagist.org/packages/leesiongchan/omnipay-molpay)

[Omnipay](https://github.com/thephpleague/omnipay) is a framework agnostic, multi-gateway payment
processing library for PHP 5.3+. This package implements MOLPay support for Omnipay.

[MOLPay](http://www.molpay.com) is a payment gateway offering from MOLPay Sdn Bhd. This package follows the **MOLPay API Specification (Version 12.1: Updated on 12 April 2015)**.

## Installation

Omnipay is installed via [Composer](http://getcomposer.org/). To install, simply add it
to your `composer.json` file:

```json
{
"require": {
"leesiongchan/omnipay-molpay": "~2.0"
}
}
```

And run composer to update your dependencies:

$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update

## Basic Usage

The following gateways are provided by this package:

* MOLPay (MOLPay Payment)

For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay)
repository.

## Usage

Coming soon...

## Out Of Scope

Omnipay does not cover recurring payments or billing agreements, and so those features are not included in this package. Extensions to this gateway are always welcome.

## Support

If you are having general issues with Omnipay, we suggest posting on
[Stack Overflow](http://stackoverflow.com/). Be sure to add the
[omnipay tag](http://stackoverflow.com/questions/tagged/omnipay) so it can be easily found.

If you want to keep up to date with release anouncements, discuss ideas for the project,
or ask more detailed questions, there is also a [mailing list](https://groups.google.com/forum/#!forum/omnipay) which
you can subscribe to.

If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/leesiongchan/omnipay-molpay/issues),
or better yet, fork the library and submit a pull request.
39 changes: 39 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "leesiongchan/omnipay-molpay",
"type": "library",
"description": "MOLPay gateway for Omnipay payment processing library",
"keywords": [
"gateway",
"merchant",
"molpay",
"omnipay",
"pay",
"payment",
"purchase"
],
"homepage": "https://github.com/leesiongchan/omnipay-molpay",
"license": "MIT",
"authors": [
{
"name": "Lee Siong Chan",
"email": "[email protected]"
}
],
"autoload": {
"psr-4": { "Omnipay\\MOLPay\\" : "src/" }
},
"autoload-dev": {
"psr-4": { "Omnipay\\MOLPay\\Tests\\": "tests/" }
},
"require": {
"omnipay/common": "~2.0"
},
"require-dev": {
"omnipay/tests": "~2.0"
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
}
}
25 changes: 25 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
<testsuites>
<testsuite name="Omnipay Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="Mockery\Adapter\Phpunit\TestListener" file="vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/TestListener.php" />
</listeners>
<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>
</phpunit>
14 changes: 14 additions & 0 deletions src/Exception/InvalidCreditCardDetailsException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Omnipay\MOLPay\Exception;

use Omnipay\Common\Exception\OmnipayException;

/**
* Invalid Credit Card Details Exception.
*
* Thrown when a credit card details is invalid or missing required fields.
*/
class InvalidCreditCardDetailsException extends \Exception implements OmnipayException
{
}
14 changes: 14 additions & 0 deletions src/Exception/InvalidPaymentMethodException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Omnipay\MOLPay\Exception;

use Omnipay\Common\Exception\OmnipayException;

/**
* Invalid Payment Method Exception.
*
* Thrown when a payment method is invalid.
*/
class InvalidPaymentMethodException extends \Exception implements OmnipayException
{
}
163 changes: 163 additions & 0 deletions src/Gateway.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
<?php

namespace Omnipay\MOLPay;

use Omnipay\Common\AbstractGateway;

class Gateway extends AbstractGateway
{
/**
* Get the name of the gateway.
*
* @return string
*/
public function getName()
{
return 'MOLPay';
}

/**
* Get the gateway parameters.
*
* @return array
*/
public function getDefaultParameters()
{
return array(
'enableIPN' => false,
'locale' => 'en',
'testMode' => false,
);
}

/**
* Get enableIPN.
*
* @return bool
*/
public function getEnableIPN()
{
return $this->getParameter('enableIPN');
}

/**
* Set enableIPN.
*
* @param bool $value
*
* @return $this
*/
public function setEnableIPN($value)
{
return $this->setParameter('enableIPN', $value);
}

/**
* Get the locale.
*
* The default language is English.
*
* @return string
*/
public function getLocale()
{
return $this->getParameter('locale');
}

/**
* Set the locale.
*
* The default language is English.
*
* @param string $value
*
* @return $this
*/
public function setLocale($value)
{
return $this->setParameter('locale', $value);
}

/**
* Get merchantId.
*
* @return string
*/
public function getMerchantId()
{
return $this->getParameter('merchantId');
}

/**
* Set merchantId.
*
* @param string $value
*
* @return $this
*/
public function setMerchantId($value)
{
return $this->setParameter('merchantId', $value);
}

/**
* Get verifyKey.
*
* @return string
*/
public function getVerifyKey()
{
return $this->getParameter('verifyKey');
}

/**
* Set verifyKey.
*
* @param string $value
*
* @return $this
*/
public function setVerifyKey($value)
{
return $this->setParameter('verifyKey', $value);
}

/**
* Create a purchase request.
*
* @param array $parameters
*
* @return \Omnipay\MOLPay\Message\PurchaseRequest
*/
public function purchase(array $parameters = array())
{
return $this->createRequest('\Omnipay\MOLPay\Message\PurchaseRequest', $parameters);
}

/**
* Complete a purchase request.
*
* @param array $parameters
*
* @return \Omnipay\MOLPay\Message\CompletePurchaseRequest
*/
public function completePurchase(array $parameters = array())
{
return $this->createRequest(
'\Omnipay\MOLPay\Message\CompletePurchaseRequest',
array_merge(
$parameters,
array(
'appCode' => $this->httpRequest->request->get('appcode'),
'domain' => $this->httpRequest->request->get('domain'),
'errorMessage' => $this->httpRequest->request->get('error_desc'),
'nbcb' => $this->httpRequest->request->get('nbcb'),
'payDate' => $this->httpRequest->request->get('paydate'),
'sKey' => $this->httpRequest->request->get('skey'),
'status' => $this->httpRequest->request->get('status'),
'transactionReference' => $this->httpRequest->request->get('tranID'),
)
)
);
}
}
Loading

0 comments on commit 4d0cb3f

Please sign in to comment.