starkpay / omnipay
针对 Omnipay 支付处理库的 Stark 驱动
v0.0.4
2021-05-16 17:52 UTC
Requires
- league/omnipay: ^3
This package is auto-updated.
Last update: 2024-09-26 22:23:43 UTC
README
针对 Omnipay PHP 支付库的 Stark 驱动
Omnipay 是一个针对 PHP 的框架无关的多网关支付处理库。本包实现了 Omnipay 对 Stark 的支持,以便您能够接受加密货币支付。
安装
Omnipay 通过 Composer 安装。要安装,只需使用 Composer 需求 league/omnipay 和 starkpay/omnipay
composer require league/omnipay starkpay/omnipay
基本用法
本包提供 Stark 支付解决方案。
有关通用使用说明,请参阅主要的 Omnipay 存储库。
基本购买示例
API 密钥将在您的 Stark 商户控制台中可用。请访问:(https://dashboard.starkpayments.net/)
$gateway = \Omnipay\Omnipay::create('Stark'); $gateway->setApiKey('key_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM'); $response = $gateway->purchase( [ "amount" => "10.00", "currency" => "EUR", "description" => "My first Payment", "returnUrl" => "https://webshop.example.org/return-page.php" ] )->send(); // Process response if ($response->isSuccessful()) { // Payment was successful print_r($response); } elseif ($response->isRedirect()) { // You can get Transaction id by $response->getTransactionId(); // Redirect to offsite payment gateway $response->redirect(); } else { // Payment failed echo $response->getMessage(); }
与客户一起的购买示例
$gateway = \Omnipay\Omnipay::create('Stark'); $gateway->setApiKey('key_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM'); $response = $gateway->purchase( [ "amount" => "10.00", "currency" => "EUR", "description" => "My first Payment", "returnUrl" => "https://webshop.example.org/return-page.php", 'metadata' => array( 'customer' => array( 'name' => 'Customer Full name', 'email' => 'customeremail@email.com', 'verified' => true, ) ) ] )->send(); // Process response if ($response->isSuccessful()) { // Payment was successful print_r($response); } elseif ($response->isRedirect()) { // You can get Transaction id by $response->getTransactionId(); // Redirect to offsite payment gateway $response->redirect(); } else { // Payment failed echo $response->getMessage(); }
响应页面
在购买过程中,我们将交易 id 和 status 发布到您的 returnUrl。一旦交易完成,您将收到配置在 dashboard.starkpayments.net 的 webhook 通知。
示例返回页面:return-page.php
echo "Your transaction id is : " . $_POST['id'] ." and status is : ".$_POST['status'];
获取交易详情
使用交易 ID 获取交易详情
$gateway = Omnipay::create('Stark'); $gateway->setApiKey('key_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM'); // Send purchase request $response = $gateway->fetchTransaction([ 'transactionReference' => '5eb165796a7b7' ])->send(); // Process response if ($response->isSuccessful()) { // Transaction Details print_r($response->getMetaData()); /* Sample Response Array ( [id] => 5eb165796a7b7 [amount] => 15.00 [currency] => USD [crypto_amount] => 0.001694 [crypto] => BTC [status] => success [customer_name] => John Doe [customer_email] => john.doe@mail.com [transaction_hash] => 76a3e766bf49b0e36ffcd8636cf546f8a4bf1908e176139fdc42e508ba38a7d7 ) */ } else { // Get Error Message echo $response->getMessage(); }
支付状态详情
支持
如果您对 Omnipay 有任何一般性问题,我们建议在 Stack Overflow 上发布。请确保添加 omnipay 标签,以便更容易找到。
如果您想了解发布公告,讨论项目想法或提出更详细的问题,还有一个您可以订阅的 邮件列表。
如果您认为您已经找到了一个错误,请使用 GitHub 问题跟踪器 报告,或者更好的是,分支库并提交一个 pull request。