Coder Social home page Coder Social logo

rm-php-sdk's Introduction

RevenueMonster PHP SDK

πŸͺ£ Minimum Requirements

πŸ”¨ Installation

composer require revenuemonster/sdk

πŸ“» Legacy Support

  • If you using php5.7, please refer to branch php5.7
  • If you using php7, please refer to branch php7

✨ Covered Functions

  • Client Credentials (Authentication)
  • Refresh Token (Authentication)
  • Get Merchant Profile
  • Get Merchant Subscriptions
  • Get Stores
  • Get Stores By ID
  • Create Store
  • Update Store
  • Delete Store
  • Get User Profile
  • Payment (Transaction QR) - Create Transaction QRCode/URL
  • Payment (Transaction QR) - Get Transaction QRCode/URL
  • Payment (Transaction QR) - Get Transaction QRCode/URL By Code
  • Payment (Transaction QR) - Get Transactions By Code
  • Payment (Quick Pay) - Payment
  • Payment (Quick Pay) - Refund
  • Payment (Quick Pay) - Reverse
  • Payment (Quick Pay) - Get All Payment Transactions
  • Payment (Quick Pay) - Get All Payment Transaction By ID
  • Payment (Quick Pay) - Daily Settlement Report
  • Payment (Checkout) - Create Web/Mobile Payment (New UI support)
  • Give Loyalty Point
  • Get Loyalty Members
  • Get Loyalty Member
  • Get Loyalty Member Point History
  • Issue Voucher
  • Void Voucher
  • Get Voucher By Code
  • Get Voucher Batches
  • Get Voucher Batch By Key
  • Send Notification (Merchant)
  • Send Notification (Store)
  • Send Notification (User)
  • eKYC - Mykad Prediction
  • eKYC - Face Verification

πŸ“ Examples

require __DIR__.'/vendor/autoload.php';

use RevenueMonster\SDK\RevenueMonster;
use RevenueMonster\SDK\Exceptions\ApiException;
use RevenueMonster\SDK\Exceptions\ValidationException;
use RevenueMonster\SDK\Request\WebPayment;
use RevenueMonster\SDK\Request\QRPay;
use RevenueMonster\SDK\Request\QuickPay;

// Initialise sdk instance
$rm = new RevenueMonster([
  'clientId' => '5499912462549392881',
  'clientSecret' => 'pwMapjZzHljBALIGHxfGGXmiGLxjWbkT',
  'privateKey' => file_get_contents(__DIR__.'/private_key.pem'),
  'isSandbox' => false,
]);

// Get merchant profile
try {
  $response = $rm->merchant->profile();
} catch(ApiException $e) {
  echo "statusCode : {$e->getCode()}, errorCode : {$e->getErrorCode()}, errorMessage : {$e->getMessage()}";
} catch(Exception $e) {
  echo $e->getMessage();
}

// Get merchant subscriptions
try {
  $response = $rm->merchant->subscriptions();
} catch(ApiException $e) {
  echo "statusCode : {$e->getCode()}, errorCode : {$e->getErrorCode()}, errorMessage : {$e->getMessage()}";
} catch(Exception $e) {
  echo $e->getMessage();
}

// Get merchant's stores
try {
  $response = $rm->store->paginate(10);
} catch(ApiException $e) {
  echo "statusCode : {$e->getCode()}, errorCode : {$e->getErrorCode()}, errorMessage : {$e->getMessage()}";
} catch(Exception $e) {
  echo $e->getMessage();
}

// Get transactions by QR Code
try {
  $qrCode = '732eb1e935983d274695f250dee9eb75';
  $response = $rm->payment->transactionsByQrCode($qrCode);
} catch(ApiException $e) {
  echo "statusCode : {$e->getCode()}, errorCode : {$e->getErrorCode()}, errorMessage : {$e->getMessage()}";
} catch(Exception $e) {
  echo $e->getMessage();
}

// Get transactions
try {
  $response = $rm->payment->paginate(5);
} catch(ApiException $e) {
  echo "statusCode : {$e->getCode()}, errorCode : {$e->getErrorCode()}, errorMessage : {$e->getMessage()}";
} catch(Exception $e) {
  echo $e->getMessage();
}

// Find transaction by transaction id
try {
  $transactionId = '100922222732432874823';
  $response = $rm->payment->find($transactionId);
} catch(ApiException $e) {
  echo "statusCode : {$e->getCode()}, errorCode : {$e->getErrorCode()}, errorMessage : {$e->getMessage()}";
} catch(Exception $e) {
  echo $e->getMessage();
}

// Find transaction by order id
try {
  $orderId = '1234';
  $response = $rm->payment->findByOrderId($orderId);
} catch(ApiException $e) {
  echo "statusCode : {$e->getCode()}, errorCode : {$e->getErrorCode()}, errorMessage : {$e->getMessage()}";
} catch(Exception $e) {
  echo $e->getMessage();
}

// create QR pay
try {
  $qrPay = new QRPay();
  $qrPay->currencyType = 'MYR';
  $qrPay->amount = 100;
  $qrPay->isPreFillAmount = true;
  $qrPay->order->title = '服劑费';
  $qrPay->order->detail = 'testing';
  $qrPay->method = [];
  $qrPay->redirectUrl = 'https://shop.v1.mamic.asia/app/index.php?i=6&c=entry&m=ewei_shopv2&do=mobile&r=order.pay_rmwxpay.complete&openid=ot3NT0dxs4A8h4sVZm-p7q_MUTtQ&fromwechat=1';
  $qrPay->storeId = '1553067342153519097';
  $qrPay->type = 'DYNAMIC';
  $response = $rm->payment->qrPay($qrPay);
} catch(ApiException $e) {
  echo "statusCode : {$e->getCode()}, errorCode : {$e->getErrorCode()}, errorMessage : {$e->getMessage()}";
} catch(Exception $e) {
  echo $e->getMessage();
}

// create Web payment
try {
  $wp = new WebPayment;
  $wp->order->id = '10020';
  $wp->order->title = 'Testing Web Payment';
  $wp->order->currencyType = 'MYR';
  $wp->order->amount = 100;
  $wp->order->detail = '';
  $wp->order->additionalData = '';
  $wp->storeId = "1553067342153519097";
  $wp->redirectUrl = 'https://google.com';
  $wp->notifyUrl = 'https://google.com';
  $wp->layoutVersion = 'v1';

  $response = $rm->payment->createWebPayment($wp);
  echo $response->checkoutId; // Checkout ID
  echo $response->url; // Payment gateway url
} catch(ApiException $e) {
  echo "statusCode : {$e->getCode()}, errorCode : {$e->getErrorCode()}, errorMessage : {$e->getMessage()}";
} catch(ValidationException $e) {
  var_dump($e->getMessage());
} catch(Exception $e) {
  echo $e->getMessage();
}

// create Quick pay
try {
  $qp = new QuickPay;
  $qp->authCode = '281011026026517778602435';
  $qp->order->id = '443';
  $qp->order->title = 'γ€εŽŸε‘³η³»εˆ—γ€‘ ηŒ«ε±±ηŽ‹ζ¦΄';
  $qp->order->currencyType = 'MYR';
  $qp->order->amount = 10;
  $qp->order->detail = '';
  $qp->order->additionalData = 'SH20190819100656262762';
  $qp->ipAddress = '8.8.8.8';
  $qp->storeId = "1553067342153519097";

  $response = $rm->payment->quickPay($qp);
} catch(ApiException $e) {
  echo "statusCode : {$e->getCode()}, errorCode : {$e->getErrorCode()}, errorMessage : {$e->getMessage()}";
} catch(ValidationException $e) {
  var_dump($e->getMessage());
} catch(Exception $e) {
  echo $e->getMessage();
}

eKYC Module

The Revenue Monster eKYC (Electronic Know Your Customer) module provides features to complete the onboarding experience.

All the methods in this module accepts only the data portion in a base64 data url.

For example, you might have a base64 string as below, just send us the data part.

Format - data:[<mediatype>][;base64],<data>

Example - data:image/jpeg;base64,/9j/4AAQSkZJRgABAQE......

Data Portion - /9j/4AAQSkZJRgABAQE......

eKYC MyKad

This method will accept a mykad image and return a request ID to be used in the liveness SDK.

try {
  $mykad = new EkycMyKad();
  $mykad->base64Image = file_get_contents(__DIR__.'/mykad.txt');
  $response = $rm->ekyc->call($mykad);
} catch(Exception $e) {
  echo $e->getMessage();
}

Face Verification

This method will recognize and verify if the human face present on 2 images are the same person or not.

try {
  $image = file_get_contents(__DIR__.'/face.txt');
  $face = new VerifyFace();
  $face->base64Image1 = $image;    // image 1
  $face->base64Image2 = $image;    // image 2
  $response = $rm->ekyc->call($face);
} catch(Exception $e) {
  echo $e->getMessage();
}

Get eKYC Result

This method accepts the ekycId parameter returned from the Liveness SDK. It will return the complete eKYC result.

try {
  $request = new EkycGetResult();
  $request->id = "62201d52239b18052126e289";
  $ekycResult = $rm->ekyc->call($request);
} catch(Exception $e) {
  echo $e->getMessage();
}

Get MyKad Result

This method accepts the id parameter returned from the EkycMyKad method, or mykadRequestId parameter from the EkycGetResult method. It will return the complete data recognized from the MyKad.

try {
  $request = new EkycGetMyKadResult();
  $request->id = $ekycResult->mykadRequestId;
  $response = $rm->ekyc->call($request);
} catch(Exception $e) {
  echo $e->getMessage();
}

rm-php-sdk's People

Contributors

dependabot[bot] avatar falconeri avatar icebay avatar jk-gan avatar myussufz avatar rexlow avatar si3nloong avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rm-php-sdk's Issues

Problem when switch to development sandbox mode

Hi there, when i try to switch to mode to sandbox which is 'isSandbox' => true, it throwing this error, and i had double check all of my config was correct.

Fatal error: Uncaught RevenueMonster\SDK\Exceptions\ApiException: Invalid client in /home/anthubcom/public_html/portal/vendor/revenuemonster/sdk/src/RevenueMonster.php:81 Stack trace: #0 /home/anthubcom/public_html/portal/vendor/revenuemonster/sdk/src/RevenueMonster.php(61): RevenueMonster\SDK\RevenueMonster->oauth() #1 /home/anthubcom/public_html/portal/classes-payment/LogicRevenueMonster.class.php(35): RevenueMonster\SDK\RevenueMonster->__construct(Array) #2 /home/anthubcom/public_html/portal/apps/agent/topup-payment-gateway-debug.php(53): LogicRevenueMonster->__construct(Array, true) #3 /home/anthubcom/public_html/portal/include/router.inc.php(124): include_once('/home/anthubcom...') #4 /home/anthubcom/public_html/portal/include/router.inc.php(81): find_route('agent', 'topup-payment-g...') #5 /home/anthubcom/public_html/portal/include/init.inc.php(18): require_once('/home/anthubcom...') #6 /home/anthubcom/public_html/portal/index.php(13): require_once('/home/anthubcom...') #7 {main} thrown in /home/anthubcom/public_html/portal/vendor/revenuemonster/sdk/src/RevenueMonster.php on line 81

QuickPay example

We are planning to integrate with our POS system, which we can just scan customer barcode to complete the transaction. But we cannot find any coding regarding this. Thanks~

RM v1.2.1 Class doesn't exist error

Hi,

I have the following structure in my project

root/apps/classes-payment/RevenueMonsterWrapper.class.php

in the top of the file i have included the namespaces

require_once 'vendor/autoload.php';
use RevenueMonster\SDK\RevenueMonster;
use RevenueMonster\SDK\Exceptions\ApiException;
use RevenueMonster\SDK\Exceptions\ValidationException;
use RevenueMonster\SDK\Request\WebPayment;
use RevenueMonster\SDK\Request\QRPay;
use RevenueMonster\SDK\Request\QuickPay;

However, i am getting the error 'Class doesn't exist : RevenueMonster' whenever the autoload.php is loaded in. This means that any other places that uses other packages would also encounter this error.

This error only occurs on the server but not local development, and I have checked that all are using PHP 7.3 and files are in sync

How to verify content received from web-hook?

Document Description

Private Keys are required to sign API request(s) contents. Public Keys are used to verify content received.

Question

How to use public key to verify what web hook receives?

Required parameter $url follows optional parameter $version

Hi, i got an error Deprecated function when use php 8.

public function getOpenApiUrl(string $version = 'v1', string $url, string $usage = 'api')
    {
        $url = trim($url, '/');
        $uri = "{$this->getDomain($usage)}/$version/$url";
        if ($this->isSandbox) {
            $uri = "sb-$uri";
        }
        return "https://$uri";
    }

autoload.php

Hi, I am new to develop this. Where to find require DIR.'/vendor/autoload.php'; ? Thanks~

Verify Signature from Notify URL

Since there are no verify signature method in this sdk, based on the document, after constructing plain text token, what would the next step be?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.