Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Siong Chan committed Apr 1, 2016
1 parent 4d0cb3f commit 22f2ca4
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
58 changes: 56 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,63 @@ The following gateways are provided by this package:
For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay)
repository.

## Usage
## Example

### Create a purchase request

The example below explains how you can create a purchase request then send it.

```php
$gateway = Omnipay::create('MOLPay');

$gateway->setCurrency('MYR');
$gateway->setEnableIPN(true); // Optional
$gateway->setLocale('en'); // Optional
$gateway->setMerchantId('test1234');
$gateway->setVerifyKey('abcdefg');

$options = [
'amount' => '10.00',
'card' => new CreditCard(array(
'country' => 'MY',
'email' => '[email protected]',
'name' => 'Lee Siong Chan',
'phone' => '0123456789',
)),
'description' => 'Test Payment',
'transactionId' => '20160331082207680000',
'paymentMethod' => 'credit', // Optional
];

$response = $gateway->purchase($options)->send();

// Get the MOLPay payment URL (https://www.onlinepayment.com.my/MOLPay/pay/...)
$redirectUrl = $response->getRedirectUrl();
```

### Complete a purchase request

When the user submit the payment form, the gateway will redirect you to the return URL that you have specified in MOLPay. The code below gives an example how to handle the server feedback answer.

```php
$response = $gateway->completePurchase($options)->send();

Coming soon...
if ($response->isSuccessful()) {
// Do something
echo $response->getTransactionReference();
} elseif ($response->isPending()) {
// Do something
} elseif ($response->isCancelled()) {
// Do something
} else {
// Error
}

// Check if is a callback notification
if ($response->isCallbackNotification()) {
// Do something
}
```

## Out Of Scope

Expand Down
2 changes: 0 additions & 2 deletions tests/GatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public function setUp()
'description' => 'Test Payment',
'transactionId' => '20160331082207680000',
'paymentMethod' => 'credit',
'returnUrl' => 'https://example.com/return',
'notifyUrl' => 'https://example.com/notify',
);
}

Expand Down

0 comments on commit 22f2ca4

Please sign in to comment.