维护者

详细信息

github.com/kadirov/payme

源代码

问题

安装: 353

依赖: 0

建议者: 0

安全: 0

星级: 5

关注者: 2

分支: 0

开放问题: 0

类型:symfony-bundle


README

安装

安装包

composer req kadirov/payme

添加到config/bundles.php

Kadirov\Payme\PaymeBundle::class => ['all' => true],

创建AfterFinishPaymentInterface和BeforeCancelFinishedPayment类。将其添加到config/services.yaml

services:
    Kadirov\Payme\Component\Billing\Payment\Payme\Interfaces\BeforeCancelFinishedPaymentInterface:
        class: App\Component\Payme\BeforeCancelFinishedPayment

    Kadirov\Payme\Component\Billing\Payment\Payme\Interfaces\AfterFinishPaymentInterface:
        class: App\Component\Payme\AfterFinishPayment

将以下行添加到您的.env文件中

### Payme
PAYME_CASHBOX_ID=""
PAYME_CASHBOX_KEY=""
PAYME_CASHBOX_TEST_ID=Paycom
PAYME_CASHBOX_TEST_KEY=""
PAYME_CHECK_IPS=true
PAYME_IPS="185.178.51.131,185.178.51.132,195.158.31.134,195.158.31.10,195.158.28.124,195.158.5.82"
### Payme

将payme路由添加到config/packages/security.yaml文件中

security:
    firewalls:
        payme:
            pattern: ^/api/payments/payme
            security: false
            methods:
                - post

如何使用

通过PaymeTransactionBuilder的createTransaction()方法创建PaymeTransaction。对于税务,您也可以调用addItem()方法。

简单使用示例

$paymeTransaction = $paymeTransactionBuilder
            ->createTransaction($price)
            ->getResult();

带有税务的示例

$paymeTransaction = $paymeTransactionBuilder
    ->createTransaction($finalPrice)
    ->addItem('10315002001000000', 3, '195815', $consultingPrice, 'Consulting services', 15)
    ->addItem('10305005001000000', 1, '195763', $softwarePrice, 'Software Development', 15)
    ->getResult();    

当用户支付此款项时,系统将调用AfterFinishPaymentInterface的afterFinishPayment()方法。因此,创建一个实现AfterFinishPaymentInterface的类。

您还必须实现BeforeCancelFinishedPaymentInterface。此类中的方法将在取消支付之前调用。如果取消支付不可行,您可以抛出BeforeCancelFinishedPaymentException

如何将您的项目与Payme连接

您应该在merchant.payme.uz上创建现金箱。然后复制ID并将其指定为PAYME_CASHBOX_ID的值

进入现金箱,点击设置,然后开发者工具,在那里您可以找到密钥测试密钥。将它们指定为PAYME_CASHBOX_KEYPAYME_CASHBOX_TEST_KEY的值

此外,您还必须输入类似于https://my-domain.com/api/payments/payme端点URL

点击支付详情选项卡并创建transactionId

添加以下表单,用户可以通过点击按钮进行支付

<!-- Start Payme Form -->
<form method="POST" action="https://checkout.paycom.uz">
    <!-- Use https://test.checkout.paycom.uz URL for testing -->

    <!-- Payme Cashbox ID  -->
    <input type="hidden" name="merchant" value="{{ PAYME_CASHBOX_ID }}"/>

    <!-- Cost with tiyin -->
    <input type="hidden" name="amount" value="{{ transaction.amount }}"/>

    <!-- Payment data -->
    <input type="hidden" name="account[transactionId]" value="{{ transaction.id }}"/>

    <!-- === OPTIONAL DATA === -->
    <!-- Language. By default 'ru'. Available options: ru|uz|en -->
    <input type="hidden" name="lang" value="{{ lang }}"/>

    <!-- 
        Currency. By default '860'. Available options: 643|840|860|978
        643 - RUB
        840 - USD
        860 - UZS
        978 - EUR 
    -->
    <input type="hidden" name="currency" value="860"/>

    <!-- 
        URL to redirecting after payment. By default, payme redirects to URL of Referer header value.
        URL may contain that will be replaced by Payme: 
        :transaction - id of transaction. Can be null if payme couldn't create transaction
        :account.{field} - field of account object
        For example: https://your-service.com/payme/:transaction 
    -->
    <!--            
        <input type="hidden" name="callback" value="{{ REDIRECT_URL }}"/>
    -->

    <!-- Redirect timeout after successful payment in milliseconds  -->
    <input type="hidden" name="callback_timeout" value="15"/>

    <!-- 
        Payment description. You can also specify descriptions in few 
        languages by using description object like name="description[{lang}]".
        As {lang} you can use ru, en or uz
    -->
    <input type="hidden" name="description" value="{{ PAYME_DESCRIPTION }}"/>

    <!-- 
        Details of payment. You can use JSON object encoded by BASE64. 
        For example:
        {
            "discount": {
                 "title": "discount 5%", 
                 "price": 10000
            },
            "shipping": {
                  "title": "Shipment to Termez 28/23", 
                  "price": 500000
            },
            "items": [
                {
                    "title": "Tomato", 
                    "price": 505000, 
                    "count": 2
                }
            ]
        }
     -->

    <button type="submit" >Pay with <b>Payme</b></button>
</form>