puresoft/jibimo-api-laravel

此软件包已被弃用,不再维护。没有建议的替代软件包。

此软件包将使您能够在Laravel应用程序中使用Jibimo API。

v1.0.0 2019-06-16 00:28 UTC

This package is auto-updated.

Last update: 2021-04-16 04:35:46 UTC


README

欢迎使用Jibimo API的Laravel包,此包将使您在使用Laravel应用程序中的Jibimo API时更加轻松。

GitHub release PHP from Packagist

🎁 快速入门

此包将使用Jibimo PHP库,该库可在https://github.com/J-TAG/jibimo-api-php-lib找到。

您需要做的唯一事情是将composer需求添加到您的项目中,然后在项目中发布Jibimo配置。

🎩 安装

使用以下composer命令简单地安装此包

composer require puresoft/jibimo-api-laravel --prefer-stable

因此,这将安装原始Jibimo PHP库和Laravel软件包到您的应用程序中。

现在,您需要使用以下命令发布Jibimo配置

php artisan vendor:publish --provider=puresoft\jibimo\laravel\JibimoServiceProvider

这将在您的配置文件夹中创建一个jibimo.php文件,现在您可以在.env文件中设置环境变量,如下所示

JIBIMO_BASE_URL="https://jibimo.com/api"
JIBIMO_API_TOKEN="..." #Your Jibimo API token

现在,您可以使用位于puresoft\jibimo\laravelJibimo静态类,如puresoft\jibimo\laravel\Jibimo::pay(),或者您可以像这样将其注入到您的函数中

    public function myMethod(Jibimo $jibimo)
    {
        $response = $jibimo->pay(...);
        // ...
    }

💵 从人们那里请求金钱

要使用Jibimo金钱请求API,您首先应启动交易并引导用户到网关,从网关返回后,您**必须**验证交易,如果交易有效且被接受,则设置完成,并且用户已正确地支付了您。

以下是一些说明

👍 启动交易并引导用户到网关

使用以下代码启动请求交易并引导用户到网关

$mobile = "09366061280";
$amountInToman = 8500;
$privacyLevel = JibimoPrivacyLevel::PUBLIC;
$trackerId = "xxxx"; // Anything like a factor number or maybe a UUID, it's up to you
$description = "Thank you for using our service :)"; // Optional, this will show up in Jibimo feed
$returnUrl = "http://mywebsite.com/callback/?something=somethingelse"; // Optional, after payment, Jibimo will redirect user to this URL. If you omit it, Jibimo will redirect user to your company homepage

$response = Jibimo::request($mobile, $amountInToman, $privacyLevel, $trackerId, $description, $returnUrl);

// Status of transaction must be `Pending`
if(JibimoTransactionStatus::PENDING === $response->getStatus()) {

    // Save Jibimo transaction ID to database or whatever to use that to verify transaction later
    // $response->getTransactionId();

    // Now, redirect user to Jibimo gateway
    $redirect = $response->getRedirectUrl();
    // Redirect code ...
}

在将用户引导到Jibimo网关后,他们将看到一个网页,通过Jibimo账户或普通银行网关支付给您金钱。

✔️ 验证请求交易

之后,他们将返回到您提供的$returnUrl,因此您可以在那里验证他们的交易

$transactionId = X; // You should get this transaction ID from where you saved it when you were creating the request in the previous step
$mobile = "09366061280";
$amountInToman = 8500;
$trackerId = "xxxx"; //Tracker ID of main transaction


$validationResult = Jibimo::validateRequest($transactionId, $mobile, $amountInToman, $trackerId);

// Validate and check status of transaction in Jibimo
if($validationResult->isAccepted()) {
    // Transaction was successful, user paid money correctly
}
// Otherwise, there is a problem. You can get raw response or handle exceptions to find out why there is still problem

💲 向人们支付金钱

使用Jibimo支付API很简单。

您只需支付金钱并验证它。没有像请求金钱以显示网关或对用户进行任何其他操作之类的额外步骤。

📫 使用Jibimo Pay API

使用以下代码向可能或可能未在Jibimo注册的移动号码付款。如果移动号码已在Jibimo注册,则金钱将立即转移到其Jibimo账户,否则将挂起,直到用户在Jibimo注册。Jibimo将向他们发送短信以通知付款。

$mobile = "09366061280";
$amountInToman = 8500;
$privacyLevel = JibimoPrivacyLevel::PUBLIC;
$trackerId = "xxxx"; // Anything like a factor number or maybe a UUID, it's up to you
$description = "Thank you for using our service :)"; // Optional, this will show up in Jibimo feed

$response = Jibimo::pay($mobile, $amountInToman, $privacyLevel, $trackerId, $description);

// Here you should save transaction ID to verify it later
// $response->getTransactionId();

if(JibimoTransactionStatus::ACCEPTED === $response->getStatus()) {
    // Money was paid immediately
} else if(JibimoTransactionStatus::PENDING === $response->getStatus()) {
    // The user was not registered in Jibimo, so it will be pending until user being registered in Jibimo
}

// For other problems and errors, you can see the raw response or catch exceptions

✔️ 验证付款交易

验证付款交易很简单。您可以使用以下代码

$transactionId = X; // You should get this transaction ID from where you saved it when you were creating the request in the previous step
$mobile = "09366061280";
$amountInToman = 8500;
$trackerId = "xxxx"; // Tracker ID of main transaction

$validationResult = Jibimo::validatePay($transactionId, $mobile, $amountInToman, $trackerId);

// Validate and check status of transaction in Jibimo
if($validationResult->isAccepted()) {
    // Transaction was successful, user received money
}
// Otherwise, there is a problem. You can get raw response or handle exceptions to find out why there is still problem

🚄 扩展支付即直接支付API

使用Jibimo 扩展支付 API,您可以通过结合他们的手机号码和IBAN(Sheba)号码直接向人们的银行账户付款。

此方法与正常付款方法的不同之处在于IBAN(Sheba)号码,以及扩展付款。在这种情况下,资金将直接转账到用户的原始银行账户,而在正常付款中,资金将转账到用户的Jibimo账户。因此,即使用户未在Jibimo注册,也能收到资金,甚至无需与Jibimo的任何服务接触。

🌈 使用Jibimo扩展支付API

使用以下代码向手机号码和IBAN(Sheba)号码的组合付款,这些号码可能已在Jibimo注册,也可能未注册。在此方法中,资金将通过Paya直接转账到用户的原始银行账户。

$mobile = "09366061280";
$amountInToman = 8500;
$iban = "IR140570028870010133089001"; // This is my real IBAN(Sheba), so keep your head up to not pay to it mistakenly, I will not return back your money to you ! :D
$privacyLevel = JibimoPrivacyLevel::PUBLIC;
$trackerId = "xxxx"; // Anything like a factor number or maybe a UUID, it's up to you
$description = "Thank you for using our service :)"; // Optional, this will show up in Jibimo feed
$name = "حسام"; // Optional, The first name of IBAN(Sheba) owner
$family = "غلامی"; // Optional, The last name of IBAN(Sheba) owner

$response = Jibimo::extendedPay($mobile, $amountInToman, $privacyLevel, $iban, $trackerId,
            $description, $name, $family);

// Here you should save transaction ID to verify it later
// $response->getTransactionId();

if(JibimoTransactionStatus::ACCEPTED === $response->getStatus()) {
    // Money was paid successfully
}

// For other problems and errors, you can see the raw response or catch exceptions

✔️ 验证扩展支付交易

验证扩展支付交易很简单。您可以使用以下代码

$transactionId = X; // You should get this transaction ID from where you saved it when you were creating the request in the previous step
$mobile = "09366061280";
$amountInToman = 8500;
$trackerId = "xxxx"; // Tracker ID of main transaction


$validationResult = Jibimo::validateExtendedPay($transactionId, $mobile, $amountInToman, $trackerId);

// Validate and check status of transaction in Jibimo
if($validationResult->isAccepted()) {
    // Transaction was successful, user received money
}
// Otherwise, there is a problem. You can get raw response or handle exceptions to find out why there is still problem

这就完成了!希望这个快速入门能帮助您快速上手。

如果您在这个包中发现任何问题,请随时发布问题。

📃 Jibimo API规范

为了更好地理解Jibimo API规范,您可以在以下API文档中查看:[https://jibimo.com/api/documentaion](https://jibimo.com/api/documentaion)。但在这里您可以找到一个简单的速查表来使用。

🎭 隐私级别

Jibimo有3个隐私级别来向用户显示交易。

😃 个人

这意味着交易只对参与其中的双方可见,即付款人和收款人。因此,只有这两个人可以看到这笔交易。

👪 朋友

这意味着交易只对参与其中的双方及其朋友可见,即付款人、收款人以及付款人的Jibimo朋友和收款人的Jibimo朋友。

注意 在此隐私级别中,交易金额对付款人和收款人以外的人不可见。

🏦 公开

这意味着任何在Jibimo注册的人都可以看到这笔交易。因此,它可以在社交媒体等类型的推送中作为推广产品的良好点。

注意 在此隐私级别中,交易金额对付款人和收款人以外的人不可见。

🚦 交易状态

在Jibimo API中,交易有三种不同的状态。

⛔️ 被拒绝

这意味着一方拒绝接受交易或交易存在问题。

例如,在请求资金API中,如果用户点击取消按钮,交易状态将设置为被拒绝。或者如果您向无效的IBAN(Sheba)号码付款,银行对Jibimo的失败响应后,交易状态将变为被拒绝

🕞 待定

此状态表示交易正在等待其他事情发生。

例如,如果您使用正常支付API向未在Jibimo注册的用户付款,交易将处于待定状态,直到用户加入Jibimo。

✅ 已接受

此状态表示交易成功,一切顺利。

📱 手机号码格式

此包将尝试规范化您的手机号码,以满足Jibimo API的要求。

在Jibimo API中,手机号码必须采用以下格式

+989366061280

但在此包中,您也可以使用以下格式

9366061280 09366061280 989366061280 +989366061280

以上所有格式都受支持。

📊 IBAN (Sheba) 格式

与手机号码一样,此包也将尝试规范化您的IBAN(Sheba)号码。

在Jibimo API中,IBAN(Sheba)号码必须采用以下格式

140570028870010133089001

但在此包中,您可以使用两种格式,无论是否带有前缀IR

140570028870010133089001 IR140570028870010133089001

以上所有格式都受支持。

💝 贡献

如果您喜欢这个项目,请考虑为它做出贡献,让它变得更好。

并且请不要忘记为这个项目加星。

谢谢,祝您编码愉快!