All Projects → PHPJunior → Laravel 2c2p

PHPJunior / Laravel 2c2p

Licence: mit
Laravel 2C2P package

Labels

Projects that are alternatives of or similar to Laravel 2c2p

Laravel Response Macros
Extra response macro's for Laravel
Stars: ✭ 35 (-10.26%)
Mutual labels:  laravel
Laravel Support
Rinvex common support helpers, contracts, and traits required by various Rinvex packages. Validator functionality, and basic controller included out-of-the-box.
Stars: ✭ 36 (-7.69%)
Mutual labels:  laravel
Laravel Queue Database Ph4
Laravel Database Queue with Optimistic locking
Stars: ✭ 37 (-5.13%)
Mutual labels:  laravel
Laravel Weather
🌤️ A wrapper around Open Weather Map API (Current weather)
Stars: ✭ 36 (-7.69%)
Mutual labels:  laravel
Scrutiny
Ensure your laravel-based project is running in the correct server environment
Stars: ✭ 36 (-7.69%)
Mutual labels:  laravel
Time Traveller
Time travel for your Laravel Models.
Stars: ✭ 36 (-7.69%)
Mutual labels:  laravel
Nideadmin
【未完成】NideAdmin - 基于 Vue.js + Egg.js 的微信小程序后台框架
Stars: ✭ 35 (-10.26%)
Mutual labels:  laravel
Api Tester
API tester for laravel-admin
Stars: ✭ 38 (-2.56%)
Mutual labels:  laravel
Ys Tinify Laravel
Tinify API support with laravel
Stars: ✭ 36 (-7.69%)
Mutual labels:  laravel
Stationery Cms
💡基于laravel-admin1.6.0开发的办公用品管理系统,含excel导出、查询快递功能
Stars: ✭ 37 (-5.13%)
Mutual labels:  laravel
Lynnhosting
Open Source, Web Hosting Automation built with Laravel
Stars: ✭ 36 (-7.69%)
Mutual labels:  laravel
Laravel Qrcode Ecommerce
This is a complete laravel project that handles qrcodes, payments, api/microservices, and ecommerce
Stars: ✭ 36 (-7.69%)
Mutual labels:  laravel
Nuswhispers
NUSWhispers source.
Stars: ✭ 36 (-7.69%)
Mutual labels:  laravel
Validator
Client-side javascript validator library ports from Laravel 5.2
Stars: ✭ 35 (-10.26%)
Mutual labels:  laravel
Mingyuyue
古诗词取名后台
Stars: ✭ 37 (-5.13%)
Mutual labels:  laravel
Htmlcache
Laravel middleware to cache the rendered html
Stars: ✭ 35 (-10.26%)
Mutual labels:  laravel
Laravel Personality Insights
👩 👱 Using IBM Watson Personality Insights Service with Laravel 5
Stars: ✭ 36 (-7.69%)
Mutual labels:  laravel
Lara Eye
Filter your Query\Builder using a structured query language
Stars: ✭ 39 (+0%)
Mutual labels:  laravel
Revision
Revisions for Eloquent Models
Stars: ✭ 37 (-5.13%)
Mutual labels:  laravel
Laravel Ip Gateway
Laravel IP Gateway
Stars: ✭ 37 (-5.13%)
Mutual labels:  laravel

Laravel 2C2P Redirect API , Payment Gateway Api & 123 Api

StyleCI Latest Stable Version Total Downloads

Laravel 2C2P package

Laravel version 5.x.x

Installation

Install using composer:

composer require php-junior/laravel-2c2p

Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php

PhpJunior\Laravel2C2P\Laravel2C2PServiceProvider::class,

And

php artisan vendor:publish --provider="PhpJunior\Laravel2C2P\Laravel2C2PServiceProvider" --force

This is the contents of the published config file:

return [
    'merchant_id' => 'JT01',
    'secret_key' => '7jYcp4FxFdf0',

    'private_key_pass' => '2c2p',
    'private_key_path' => storage_path('cert/private.pem'),
    'public_key_path' => storage_path('cert/public.crt'),

    'redirect_access_url' => 'https://demo2.2c2p.com/2C2PFrontEnd/RedirectV3/payment',

    'access_url' => 'https://demo2.2c2p.com/2C2PFrontEnd/SecurePayment/PaymentAuth.aspx',
    'secure_pay_script' => 'https://demo2.2c2p.com/2C2PFrontEnd/SecurePayment/api/my2c2p.1.6.9.min.js',

    'currency_code' => 702, // Ref: http://en.wikipedia.org/wiki/ISO_4217
    'country_code' => 'MMR',

    '123_merchant_id' => '[email protected]',
    '123_api_secret_key' => 'M5WCTP59J544IRRUBTJE0Q7Z2PAJX3CT',
    '123_public_key_path' => storage_path('cert/123.pem'), // 123' Certificate file
    '123_currency_code' => 'MMK',
    '123_country_code' => 'MMR',
    '123_agent_code' => 'ABC',
    '123_channel_code' => 'OVERTHECOUNTER',
    '123_merchant_url' => 'merchant url',
    '123_api_call_url' => 'api call url',
    '123_access_url' => 'https://demo3.2c2p.com/123MM/Payment/Pay/Slip'

    //QuickPay 
    'direct_api' => 'http://demo2.2c2p.com/2C2PFrontEnd/QuickPay/DirectAPI',
    'delivery_api' => 'http://demo2.2c2p.com/2C2PFrontEnd/QuickPay/DeliveryAPI'
];

Payment Request [ Using the Payment Gateway API and SecurePay ]

Construct Payment Form

Add the data-encrypt fields into the form to capture card information securely.

<form id="2c2p-payment-form" action="" method="POST">
    <input type="text" data-encrypt="cardnumber" maxlength="16" placeholder="Credit Card Number"><br/>
    <input type="text" data-encrypt="month" maxlength="2" placeholder="MM"><br/>
    <input type="text" data-encrypt="year" maxlength="4" placeholder="YYYY"><br/>
    <input type="password" data-encrypt="cvv" maxlength="4" autocomplete="off" placeholder="CVV2/CVC2" ><br/>
    <input type="submit" value="Submit">
</form>

<script type="text/javascript" src="{{ config('laravel-2c2p.secure_pay_script') }}"></script>
<script type="text/javascript">
    My2c2p.onSubmitForm("2c2p-payment-form", function(errCode,errDesc){
        if(errCode!=0){ 
            alert(errDesc);
        }
    });
</script>

Submit the request your back end code will receives the encrypted credit card details from the checkout page

Preparation
$payload = \Payment2C2P::paymentRequest([
         'desc' => '1 room for 2 nights',
         'uniqueTransactionCode' => "Invoice".time(),
         'amt' => '1000000',
         'currencyCode' => '702',
         'cardholderName' => 'Card holder Name',
         'cardholderEmail' => '[email protected]',
         'panCountry' => 'SG',
         'encCardData' => $request->input('encryptedCardInfo'), // Retrieve encrypted credit card data 
         'userDefined1' => 'userDefined1',
         'userDefined2' => 'userDefined2'
     ]);

Submit the Payment Request:

<!-- POST method to submit the form -->
<form action='{{ config('laravel-2c2p.access_url') }}' method='POST' name='paymentRequestForm'>
    Processing payment request, Do not close the browser, press back or refresh the page.
    <input type="hidden" name="paymentRequest" value="{{ $payload }}">
</form>
<script language="JavaScript">
    document.paymentRequestForm.submit();
</script>

Processing the response

   $response = \Payment2C2P::getData($request->get('paymentResponse'))
   
   dd($response)

Payment Request [ Using 123 API ]

$onwTwoThreeReq = \Payment2C2P::OneTwoThreeRequest([
       'MessageID' => '222222',
       'InvoiceNo' => 'QW232142',
       'Amount'    => 24444,
       'Discount'    => 10,
       'ShippingFee'    => 10,
       'ServiceFee'    => 10,
       'ProductDesc' => '1 room for 2 nights',
       'PayerName' => 'Name',
       'PayerEmail' => '[email protected]',
       'ShippingAddress' => 'Yangon',
       'PayInSlipInfo' => 'Hello World',
       'PaymentItems' => [
           [
               'id' => 1212,
               'name' => 'Bla Bla',
               'price' => 12222,
               'quantity' => 1
           ],
           [
               'id' => 12,
               'name' => 'Bla Bla#2',
               'price' => 12222,
               'quantity' => 1
           ]
       ]
   ]);

Submit the Payment Request:

<!-- POST method to submit the form -->
<form action='{{ config('laravel-2c2p.123_access_url') }}' method='POST' name='paymentRequestForm'>
    Processing payment request, Do not close the browser, press back or refresh the page.
    <input type="hidden" name="OneTwoThreeReq" value="{{ $onwTwoThreeReq }}">
</form>
<script language="JavaScript">
    document.paymentRequestForm.submit();
</script>

Processing the response

   $response = \Payment2C2P::getData($request->get('OneTwoThreeRes'))
   
   dd($response)

Payment Request [ Using Redirect API ]

<form action="{{ config('laravel-2c2p.redirect_access_url') }}"  method="POST">
    {!! \Payment2C2P::redirectRequest([
            'payment_description' => '2 room 2 night',
            'order_id' => 'QWERZX1234',
            'invoice_no' => 'ZXCQW123',
            'currency' => '840',
            'amount' => '1000',
            'customer_email' => '[email protected]',
            'result_url_1' => 'http://127.0.0.1:8888/payment/complete'
    ]) !!}
    <button type="submit">Submit</button>
</form>

QuickPay for Card Payments

QuickPay for Card Payments offers the following options

  • QuickPay Direct API - Generate a new QuickPay URL, Merchant to deliver URL to customer (aka white label)
  • QuickPay Delivery API - Generate and Send a QuickPay URL to an eMail or mobile phone

QuickPay Request [ Using Direct API ]

    $requestMsg = Payment2C2P::quickPayRequest([
        'orderIdPrefix' => 'QP-zzzz2202',
        'description' => 'asasas',
        'currency' => 'USD',
        'amount' => '10',
        'allowMultiplePayment' => 'N',
        'expiry' => '16092017',
        'resultUrl1' => 'http://61.91.121.190/2c2pfrontend/uat/demomerchant/v3uifrontendurl.aspx', //	Front end return URL
        'resultUrl2' => 'http://61.91.121.190/2c2pfrontend/uat/demomerchant/v3uibackendurl.aspx',  //	Back end return URL
    ], 'generate' );

     $curl = curl_init();
     curl_setopt_array($curl, array(
       CURLOPT_URL => config('laravel-2c2p.direct_api'),
       CURLOPT_RETURNTRANSFER => true,
       CURLOPT_POSTFIELDS => $requestMsg,
     ));

     $response = curl_exec($curl);
     $err = curl_error($curl);
    
     curl_close($curl);
    
     if ($err) {
       dd("cURL Error #:" . $err);
     } else {
       dd(base64_decode($response)) ;
     }

QuickPay Request [ Using Delivery API ]

    $requestMsg = Payment2C2P::quickPayRequest([
        'orderIdPrefix' => 'QP-zzzz2202',
        'description' => 'asasas',
        'currency' => 'USD',
        'amount' => '10',
        'allowMultiplePayment' => 'N',
        'expiry' => '16092017',
        'resultUrl1' => 'http://61.91.121.190/2c2pfrontend/uat/demomerchant/v3uifrontendurl.aspx', //	Front end return URL
        'resultUrl2' => 'http://61.91.121.190/2c2pfrontend/uat/demomerchant/v3uibackendurl.aspx',  //	Back end return URL
        'toEmails' => '[email protected]',
        'emailSubject' => 'Email Subject',
        'emailMessage' => 'Message'
    ], 'generate-send' );

     $curl = curl_init();
     curl_setopt_array($curl, array(
       CURLOPT_URL => config('laravel-2c2p.delivery_api'),
       CURLOPT_RETURNTRANSFER => true,
       CURLOPT_POSTFIELDS => $requestMsg,
     ));

     $response = curl_exec($curl);
     $err = curl_error($curl);
    
     curl_close($curl);
    
     if ($err) {
       dd("cURL Error #:" . $err);
     } else {
       dd(base64_decode($response)) ;
     }

Send an existing Quickpay URL to an email or mobile phone.

    $requestMsg = Payment2C2P::quickPayRequest([
        'qpID' => '121212',
        'toEmails' => '[email protected]',
        'emailSubject' => 'Email Subject',
        'emailMessage' => 'Message'
    ], 'send-url' );

     $curl = curl_init();
     curl_setopt_array($curl, array(
       CURLOPT_URL => config('laravel-2c2p.delivery_api'),
       CURLOPT_RETURNTRANSFER => true,
       CURLOPT_POSTFIELDS => $requestMsg,
     ));

     $response = curl_exec($curl);
     $err = curl_error($curl);
    
     curl_close($curl);
    
     if ($err) {
       dd("cURL Error #:" . $err);
     } else {
       dd(base64_decode($response)) ;
     }

QuickPay Query - allows to check the status of an existing QuickPay transaction

    $requestMsg = Payment2C2P::quickPayRequest([
        'qpID' => '12122',
    ], 'check' );

     $curl = curl_init();
     curl_setopt_array($curl, array(
       CURLOPT_URL => config('laravel-2c2p.direct_api'),
       CURLOPT_RETURNTRANSFER => true,
       CURLOPT_POSTFIELDS => $requestMsg,
     ));

     $response = curl_exec($curl);
     $err = curl_error($curl);
    
     curl_close($curl);
    
     if ($err) {
       dd("cURL Error #:" . $err);
     } else {
       dd(base64_decode($response)) ;
     }

QuickPay Update - allows a modification of an existing QuickPay transaction

    $requestMsg = Payment2C2P::quickPayRequest([
        'qpID' => '1212',
        'description' => 'asasas',
        'currency' => 'USD',
        'amount' => '10',
    ], 'update' );

     $curl = curl_init();
     curl_setopt_array($curl, array(
       CURLOPT_URL => config('laravel-2c2p.direct_api'),
       CURLOPT_RETURNTRANSFER => true,
       CURLOPT_POSTFIELDS => $requestMsg,
     ));

     $response = curl_exec($curl);
     $err = curl_error($curl);
    
     curl_close($curl);
    
     if ($err) {
       dd("cURL Error #:" . $err);
     } else {
       dd(base64_decode($response)) ;
     }

QuickPay Delete - allows deletion of an existing QuickPay transaction

    $requestMsg = Payment2C2P::quickPayRequest([
        'qpID' => '121212',
    ], 'delete' );

     $curl = curl_init();
     curl_setopt_array($curl, array(
       CURLOPT_URL => config('laravel-2c2p.direct_api'),
       CURLOPT_RETURNTRANSFER => true,
       CURLOPT_POSTFIELDS => $requestMsg,
     ));

     $response = curl_exec($curl);
     $err = curl_error($curl);
    
     curl_close($curl);
    
     if ($err) {
       dd("cURL Error #:" . $err);
     } else {
       dd(base64_decode($response)) ;
     }

Api Variables

  • Redirect Api variable from here.
  • Payment Gateway Api variable from here.
  • 123 Api from here
  • QuickPay variable from here

Full Documentation

Read Full Documentation here

License

The MIT License (MIT). Please see License File for more information.

Support on Beerpay

Hey dude! Help me out for a couple of 🍻!

Beerpay Beerpay

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].