zoodpay / laravel-package
Laravel 通过 ZoodPay BNPL 处理支付的开源包
1.0.1
2022-06-17 11:52 UTC
Requires
- ext-json: *
- guzzlehttp/guzzle: ~6.0 || ~7.0
- illuminate/support: ^7.0|^8.0
- zoodpay/api-php-sdk: >=1.0.1
Requires (Dev)
- orchestra/database: ^6.0
- orchestra/testbench: ^6.0
This package is auto-updated.
Last update: 2024-09-20 10:42:24 UTC
README
安装
composer require zoodpay/laravel-package
使用方法
请确保在 config/app.php 中已添加 ZoodpayServiceProvider,或手动添加。
'providers' => [ /* * Laravel Framework Service Providers... */ ... ZoodPay\ZoodpayServiceProvider::class, ]
如下将 zoodpay 凭证添加到 config/services.php 配置文件中。
return [ ... 'zoodpay' => [ 'merchant_key' => "", 'merchant_secret' => "", 'merchant_salt' => "", 'merchant_api_url' => "", 'merchant_api_ver' => "", 'market_code' => "", 'currency' =>"", 'success_url' => "", 'error_url' => "" , 'pending_url' => "" ]
可用函数
//Return the ZoodPay Config settings $this->app->zoodpay->getAPISettings() //Fetch the merchant configuration. $this->app->zoodpay->getZoodPayLimit() //To verify if ZoodPay need to be shown in Checkout Page $this->app->zoodpay->availableZoodPayService($amount) //Fetch the credit balance of a customer. $this->app->zoodpay->getCreditBalance($phone_number) //Return ZoodPay Signature for Transaction Signature Verification $this->app->zoodpay->getResponseSignature($amount, $merchant_reference_no, $transaction_id) //Return ZoodPay Refund Signature for Refund Signature Verification $this->app->zoodpay->getRefundResponseSignature($merchant_refund_reference, $refund_amount, $status, $refund_id) /* * Create Transaction Using ZoodPay, it will return ZoodPay API response. * Initiate the Models and set Values * $billing = new Model\BillingShippingInfo(); * $customer = new Model\CustomerInfo(); * $items[] = new Model\ItemsInfo(); * $order = new Model\OrderInfo(); * $shippingService = new Model\ShippingServiceInfo(); * $shipping = $billing; * */ $this->app->zoodpay->createTransaction($billing, $customer, $items, $order, $shipping, $shippingService) /* * Set Delivery Date for the Paid Transaction, it will return ZoodPay API response. * Init the Model and set Values * Model\DeliveryDate(); * * */ $this->app->zoodpay->setDeliveryDate($deliveryModel); /* * Create Refund for the Paid Transaction, it will return ZoodPay API response. * Init the Model and set Values * Model\CreateRefund() * * */ $this->app->zoodpay->createRefund($refundModel); /* * Get Refund Status by Refund id, it will return ZoodPay API response. * Init the Model and set Values * Model\CreateRefund() * * */ $this->app->zoodpay->getRefundStatusById($refund_id);
/* 1) * To check if ZoodPay need to be Shown in Checkout Page, call this function * and based on the available response show the corresponding service */ $this->app->zoodpay->availableZoodPayService($amount) /* 2) * User Select ZoodPay Service and Click Pay, Prepare the request and Create Transaction * and function will return ZoodPay API response. * Initiate the Models and set Values * $billing = new Model\BillingShippingInfo(); * $customer = new Model\CustomerInfo(); * $items[] = new Model\ItemsInfo(); * $order = new Model\OrderInfo(); * $shippingService = new Model\ShippingServiceInfo(); * $shipping = $billing; * * API Response : * * Transaction created: {"session_token":"YYYYYYYYYYYYYYYYYYYY","transaction_id":"407879856581528","expiry_time":"2021-12-22T16:58:49Z","payment_url":"https://b2c.zoodpay.com/index.php?XXXXXXXXXXXXXXXXXXXXXXXXXXXX","signature":"96496a0ae20cf58d936d195fd1d0b19526201313f7af97aae3e99610e314294dc3d66c9d3881d06994af273b25bb115bf5eef5b21806f24b5bd61b37f2387be7"} * * */ $this->app->zoodpay->createTransaction($billing, $customer, $items, $order, $shipping, $shippingService); /* * 3) * Verify the Signature by Calling below function and if the signature match, * do necessary changes and save transaction_id as reference and redirect user to ZoodPay UI . * * */ $this->app->zoodpay->getResponseSignature($amount, $merchant_reference_no, $transaction_id) /* * 4) * User will be redirected to the Callback Http/Controller/Callback.php, * change your Order Status Accordingly in each Action. */ /* * 5) * Set Delivery Date for the Paid Transaction, it will return ZoodPay API response. * Init the Model and set Values * Model\DeliveryDate(); * * */ $this->app->zoodpay->setDeliveryDate($deliveryModel); /* * 6) * Create Refund for the Paid Transaction, it will return ZoodPay API response. * Init the Model and set Values * Model\CreateRefund() * * */ $this->app->zoodpay->createRefund($refundModel);
测试
使用以下命令运行测试:加载 phpunit.xml 并更改
$ /usr/bin/php /path to laravel/vendor/phpunit/phpunit/phpunit --configuration /path to laravel/packages/zoodpay-laravel/phpunit.xml
变更日志
请参阅CHANGELOG 了解最近更改的信息。
贡献
请参阅CONTRIBUTING 了解详细信息。
致谢
安全
如果您发现任何与安全相关的问题,请通过电子邮件mohammadali.namazi@zoodpay.com联系,而不是使用问题跟踪器。
许可
MIT 许可证 (MIT)。有关更多信息,请参阅许可文件。