ajuchacko/payumoney

PHP的PayUMoney库

1.1 2020-05-11 04:37 UTC

This package is auto-updated.

Last update: 2024-09-17 22:52:08 UTC


README

一个用于轻松将payumoney集成到您的laravel/php应用的库,具有简单的界面。

安装

使用包管理器composer安装包。

composer install ajuchacko/payumoney

用法

<?php

use Ajuchacko\Payu\PayuGateway;


$params = [
    'txnid'       => '134',
    'amount'      => 12.00,
    'productinfo' => 'Iphone',
    'firstname'   => 'Jon Doe',
    'email'       => 'jon@mail.com',
    'phone'       => '9895309090',
    'surl'        => 'https://example.com/success',
    'furl'        => 'https://example.com/failure',
    'udf1'        => 'Secret value',
];

$payu = new PayuGateway([
    "merchant_key"=> "testMerchantKey",
    "secret_key"  => "testSecret",
    "merchant_id" => "7974556",
    "test_mode"   => true,
]);

$payu->pay($params); // Redirects to PayUMoney

// OR

$hash = $payu->newChecksum($params);
$payu->toArray(); // Returns array or parameters which can be submitted via web/mobile app.

获取:测试凭据

支付响应

<?php

use Ajuchacko\Payu\PayuGateway;
use Ajuchacko\Payu\Exceptions\PaymentFailedException;
use Ajuchacko\Payu\Exceptions\InvalidChecksumException;

$payu = new PayuGateway([
    "merchant_key"=> "testMerchantKey",
    "secret_key"  => "testSecret",
    "merchant_id" => "7974556",
    "test_mode"   => true,
]);

try {
    
    $response = $payu->paymentSuccess($request->all())
    // $response->toArray();
    // $response->txnid // retrive response params as attributes

} catch (PaymentFailedException $e) {

    $response = $payu->getPaymentResponse($request->all());

} catch (InvalidChecksumException $e) {
    // Checksum is tampered
}

贡献

欢迎提交拉取请求。对于重大更改,请先提交一个问题以讨论您想进行的更改。

请确保适当地更新测试。