lamine-minato/orange-money-gateway 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

lamine-minato/orange-money-gateway

最新稳定版本:v1.0.6

Composer 安装命令:

composer require lamine-minato/orange-money-gateway

包简介

A PHP package to manage payments via Orange Money in your PHP applications.

README 文档

README

A PHP package to manage payments via Orange Money in your PHP applications.

How it work ?

  • Use following command to install:
composer require lamine-minato/orange-money-gateway
  • Create an OrangeMoneyAction object:
$action = new OrangeMoneyAction(
    orangeBearer: "bearer",
    merchantKey: "merchantKey",
    currency: OrangeMoneyCurrency::XOF,
    amount: 10000,
    returnUrl: "https://api.example.com/return",
    cancelUrl: "https://api.example.com/cancel",
    notifUrl: "https://api.example.com/notif",
    lang: "fr",
    reference: "Minato"
);

Make sure to replace variable by the corrects one

  • Call execute method on OrangeMoneyGateway class:
$response = OrangeMoneyGateway::execute($action);

and Voila!

It will return a OrangeMoneyPaymentResponse object containing payToken and paymentUrl

In case of error, it will throw an exception of type OrangeMoneyException

You can also pass a configuration to the execute method of OrangeMoneyGateway if you want to modify the urls for retrieving the payment url

$action = new OrangeMoneyAction(...);

$config = new OrangeMoneyConfig(
    tokenUrl: "https://api.orange.com/oauth/v3/token",
    proccessUrl: "https://api.orange.com/orange-money-webpay/ml/v1/webpayment",
)

```php
$response = OrangeMoneyGateway::execute($action, $config);

Handling Webhooks (Notifications)

When a payment is processed, Orange Money sends a notification to your notifUrl. You can use the handleWebhook method to process this notification.

#[Route('/payment/notif', name: 'payment_notification', methods: ['POST'])]
public function paymentNotification(Request $request): JsonResponse
{
    $payload = $request->toArray();
    $webhookResponse = OrangeMoneyGateway::handleWebhook($payload);

    if ($webhookResponse->isSuccess()) {
        // Update your order status to PAID
        // $webhookResponse->getNotifToken()
        // $webhookResponse->getTransactionId()
    } elseif ($webhookResponse->isFailed()) {
        // Update your order status to FAILED
    }

    return new JsonResponse(['status' => 'ok']);
}

Tip

Pour une intégration plus détaillée dans Symfony (services, sécurité, etc.), consultez le Guide d'intégration Symfony.

$json = file_get_contents('php://input');
$payload = json_decode($json, true);

$webhookResponse = OrangeMoneyGateway::handleWebhook($payload);

if ($webhookResponse->isSuccess()) {
    // Success logic
}

Tip

Pour une intégration plus détaillée en PHP pur (autoload, script complet, etc.), consultez le Guide d'intégration Pure PHP.

License

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

Contributing

Read here for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-05-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固