承接 moeen-basra/omnipay-jazzcash 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

moeen-basra/omnipay-jazzcash

最新稳定版本:1.0.2

Composer 安装命令:

composer require moeen-basra/omnipay-jazzcash

包简介

Jazzcash driver for the Omnipay PHP payment processing library

README 文档

README

Jazz Jazzcash gateway for the Omnipay PHP payment processing library

Omnipay is a framework agnostic, multi-gateway payment processing library for PHP 5.3+. This package implements jazzcash support for Omnipay.

Install

Via Composer

$ composer require moeen-basra/omnipay-jazzcash

Usage

This gateway provides seamless integration with jazzcash hosted paged integration.

Purchase Request

use Omnipay\Omnipay;

/** @var \Omnipay\Jazzcash\Gateway $gateway */
$gateway = Omnipay::create('Jazzcash');

// initialize with array
$gateway->initialize([
    'merchantId' => 'your-merchant-id',
    'password' => 'your-password',
    'secretKey' => 'your-secret-key',
]);

// or individual properties setter

$gateway->setMerchantId('your-merchant-id')
    ->setPassword('your-password')
    ->setSecretKey('your-secret-key');

// set the test mode if needed
$gateway->setTestMode(true);

$date = CarbonImmutable::now('Asia/Karachi');

try {
    $parameters = [
        [
            'paymentMethod' => 'MWALLET', // 'MWALLET' | 'OTC' | 'MPAY' 
            'transactionTimestamp' => new \DateTime(), // make sure not past date also check your server timezone
            'transactionExpiryTimestamp' => new \DateTime(), // cab be future date
            'billReference' => (string) $date->timestamp,
            'description' => 'Test Order',
            'amount' => '20',
            'language' => 'EN',
            'currency' => 'PKR',
            'transactionId' => $date->timestamp,
            'extra' => [
                'field_1' => 'value_1',
                'field_2' => 'value_2',
                'field_3' => 'value_3',
                'field_4' => 'value_4',
                'field_5' => 'value_5'
            ],
            'returnUrl' => 'https://exmpale.com/return',
        ]
    ];
    
    $response = $gateway->purchase($parameters)->send();
    
    // var_dump($response->getData());
    
    if ($response->isSuccessful() && $response instanceof RedirectIn) {
        // do the redirect here you can do it auto using the following return statement
        // return $response->getRedirectResponse();
    } else {
    // handle failed response
    }
} catch (\Throwable $exception) {
    var_dump($exception);
}

Note: Check this class for more redirect logic PurchaseResponse.php

Complete Purchase

use Omnipay\Omnipay;

$gateway = Omnipay::create('Jazzcash');

// initialize with array
$gateway->initialize([
    'merchantId' => 'your-merchant-id',
    'password' => 'your-password',
    'secretKey' => 'your-secret-key',
]);

try {
    $response = $gateway->completePurchase()->send();
    
    if (!$response->isSuccessful()) {
        // handle failed logic
    }
    
    // always good option to cross-check the response data with gateway
    $inquiryResponse = $gateway->fetchTransaction([
        'transactionReference' => $response->getData()['pp_TxnRefNo'],
    ])
    
    // see next step for more details
    
} catch (\Throwable $exception) {
    var_dump($exception);
}

$response = $gateway->completePurchase()

Inquiry Request

use Omnipay\Omnipay;

$gateway = Omnipay::create('Jazzcash');

// initialize with array
$gateway->initialize([
    'merchantId' => 'your-merchant-id',
    'password' => 'your-password',
    'secretKey' => 'your-secret-key',
]);

try {
    $parameters = [
        'transactionReference' => '<pp_TxnRefNo>',
    ];
    
    $response = $gateway->fetchTransaction($parameters)->send();
    
    // var_dump($response->getData());
    
    if ($response->isSuccessful()) {
        if ($response->getData()['pp_Status'] === 'Complete') {
            // the transaction is success
        } else {
            
        }
     // handle success response
    } else {
    // handle failed response
    }
} catch (\Throwable $exception) {
    var_dump($exception);
}

Note: Check FetchTransactionResponse.php for more response statuses

NOTE: You can check the tests Mock for sample response data.

License

This package is released under the MIT License. See the LICENSE file for details.

Contact

You can reach me here moeen.basra@gamil.com

统计信息

  • 总下载量: 8
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-10-14