响应对象 - 使用 Mollie 和 Omnipay 付款

2024-01-02

我正在尝试在 Laravel 项目中使用 Omnipay 和 Mollie 创建付款方式。我正在使用以下 2 个库:

  • https://github.com/barryvdh/laravel-omnipay https://github.com/barryvdh/laravel-omnipay
  • https://github.com/thephpleague/omnipay-mollie https://github.com/thephpleague/omnipay-mollie

我在我的代码中执行以下操作:

$gateway = Omnipay\Omnipay::create('Mollie');

$gateway->setApiKey('test_gSDS4xNA96AfNmmdwB3fAA47zS84KN');

$params = [
    'amount' => $ticket_order['order_total'] + $ticket_order['organiser_booking_fee'],
    'description' => 'Bestelling voor klant: ' . $request->get('order_email'),
    'returnUrl' => URL::action('EventCheckoutController@fallback'),
];


$response = $gateway->purchase($params)->send();

if ($response->isSuccessful()) {
    session()->push('ticket_order_' . $event_id . '.transaction_id',
        $response->getTransactionReference());

    return $this->completeOrder($event_id);
}

付款有效。付款完成后,他返回到功能回退。但我不知道要在这个函数中放入什么以及如何返回该行if($response->isSuccesfull()...).

付款后我需要做的最重要的事情是:

session()->push('ticket_order_' . $event_id . '.transaction_id',
        $response->getTransactionReference());

return $this->completeOrder($event_id);

有人可以帮我弄清楚如何使用后备功能及以上功能吗?


使用 Mollie 的典型设置由三个单独的页面组成:

  • 创建付款的页面;
  • Mollie 在后台发布最终付款状态的页面;和
  • 消费者付款后返回的页面。

完整流程描述于莫莉文档 https://www.mollie.com/en/docs/overview#how-does-the-mollie-api-work。另请查看该页面上的流程图​​。

免责声明:我自己从未使用过 Omnipay,也没有测试以下代码,但它至少应该让您了解如何设置您的项目。

创建付款:

$gateway = Omnipay\Omnipay::create('Mollie');
$gateway->setApiKey('test_gSDS4xNA96AfNmmdwB3fAA47zS84KN');

$params = [
    'amount' => $ticket_order['order_total'] + $ticket_order['organiser_booking_fee'],
    'description' => 'Bestelling voor klant: ' . $request->get('order_email'),
    'notifyUrl' => '', // URL to the second script
    'returnUrl' => '', // URL to the third script
];

$response = $gateway->purchase($params)->send();

if ($response->isRedirect()) {
    // Store the Mollie transaction ID in your local database
    store_in_database($response->getTransactionReference());
    // Redirect to the Mollie payment screen
    $response->redirect();
} else {
    // Payment failed: display message to the customer
    echo $response->getMessage();
}

接收网络钩子:

$gateway = Omnipay\Omnipay::create('Mollie');
$gateway->setApiKey('test_gSDS4xNA96AfNmmdwB3fAA47zS84KN');

$params = [
    'transactionReference' => $_POST['id'],
];

$response = $gateway->fetchTransaction($params);

if ($response->isPaid()) {
    // Store in your local database that the transaction was paid successfully
} elseif ($response->isCancelled() || $response->isExpired()) {
    // Store in your local database that the transaction has failed
}

消费者返回的页面:

// Check the payment status of your order in your database. If the payment was paid
// successfully, you can display an 'OK' message. If the payment has failed, you
// can show a 'try again' screen.

// Most of the time the webhook will be called before the consumer is returned. For
// some payment methods however the payment state is not known immediately. In
// these cases you can just show a 'payment is pending' screen.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

响应对象 - 使用 Mollie 和 Omnipay 付款 的相关文章

  • PHP 读取 XML 播客 RSS 源

    好的 我正在为朋友的播客网站创建一个页面 列出他的播客的所有剧集 本质上 我所寻找的只是如何阅读 RSS 提要 解析出节点 并将信息显示在屏幕上 最终 我将创建一个可以播放剧集的播放器 但那是很久以后的事了 这就是我阅读 RSS 源的方式
  • Doctrine 模型的默认排序属性

    我想知道是否有办法声明我的学说模型的默认顺序 e g 我有一个work模型并且它有photos 当我加载作品时 与其关联的所有照片都会加载到 work gt photos 当我显示它们时 它们是按 ID 排序的 在另一个字段上声明默认顺序或
  • 开发中的 Laravel 和视图缓存——无法立即看到变化

    我和一些朋友决定开始一个项目 我们偶然发现了 Laravel 并认为它可能是一个很好的工具 我们开始在本地使用它来开发一些页面 并注意到一些奇怪的事情 当我们用不同的信息更新视图时 大约需要 5 到 10 分钟视图信息才会发生变化 这就像
  • 无法使用 javascript 建立与安全 Websocket 服务器的连接

    我的开发环境是这样的 操作系统 微软Windows 10 PHP 框架 Laravel 8 0 PHP 版本 7 4 Websocket 服务器 cboden ratchet 0 4 3 WAMP 服务器 3 2 0 Apache 2 4
  • 如何用破折号替换所有大写字母,用正则表达式替换所有小写字母?

    如何在 php 中用破折号和小写字母替换所有大写字母 Such as understandRegexBetter to understand regex better 我的 Google fu 和对以下代码的实验并没有让我走得太远 echo
  • 将变量从 PHP 发送到 Javascript

    我在两个单独的文件中有以下代码 其中一个是 javascript 另一个是 php JavaScript xmlhttp new XMLHttpRequest xmlhttp onreadystatechange function if t
  • 如何在 jQuery.knob 中添加值后缀

    我有问题jQuery knob http anthonyterrien com knob 我需要添加一个Sufixx至旋钮中的值 例如 我需要一个后缀 数值后 我只是输入数值字段 它会显示 但此时旋钮不会显示状态 它不会显示旋钮状态 但后缀
  • 如何使用正则表达式(php)匹配这个单词

    我有这个关键词3D DL1 现在我想从用户提交的数据中搜索 3D DL1 关键字 该规则是只要句子中出现 3D 和 DL1 它就有效 不区分大小写 例如 BLASDHSDHD 3D 8qw9e08e2323 DL1 有效的 BLASDHSD
  • cURL 错误 (35):错误:14077458:SSL 例程:SSL23_GET_SERVER_HELLO:tlsv1 无法识别的名称

    我一直在使用以下代码块使用 cURL 从 HTTPS 网站收集数据 q https www example org for example ch curl init curl setopt ch CURLOPT URL q curl set
  • str_replace 为数组

    我在使用 PHP 函数时遇到一些问题str replace使用数组时 我有这样的消息 message strtolower L rzzo rwldd ty esp mtdsza d szdepw ty esp opgtw d dple 我正
  • 在 PHP 中读取“分块”POST 数据

    我试图在发送时使用 Transfer Encoding chunked 从请求中读取 POST 数据 但在收到所有数据之前无法启动脚本 是否可以让 PHP能够在分块请求通过时对其做出反应吗 将 PHP 5 3 8 与 Apache 结合使用
  • php 的 SCORM 库 [关闭]

    Closed 这个问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 我们为一位客户开发了电子学习网站 最近他询问需要 SCORM feed 我不知道我的系统是否与 scr
  • 预期响应代码 250,但收到代码“530”,并显示消息“530 5.7.1 需要身份验证”

    我尝试配置 SMTP 邮件时遇到此错误laravel 这是我的配置 env MAIL DRIVER smtp MAIL HOST smtp mailtrap io MAIL PORT 2525 MAIL USERNAME fff3c01db
  • 从 https 切换到 http 时违反 RewriteRule

    我写了很多重写规则 in my htaccess文件 但是当我从https to http页面 它不遵守这些规则 NOTE 本地主机上一切正常 问题出在服务器上 UPDATE 这是我的website http www charityrumm
  • PHP fscanf 与 fgets

    我可以使用读取一行中的整个字符串fgets but fscanf 没有这样做 根据PHP手册 fscanf 根据格式解析文件的输入 功能fscanf 类似于sscanf 但它从与句柄关联的文件中获取输入 并根据指定的格式解释输入 这在文档中
  • Symfony2 将复选框值从 0/1 更改为“no”/“yes”

    我创建了一个带有一个复选框的表单 用户设置类型 php public function buildForm FormBuilderInterface builder array options builder gt add newslett
  • 更新 xampp 中的 ICU 扩展吗?

    我在跑xampp我需要升级ICU php intl 扩展 到最新版本 我下载了54从 ICU 页面 但不确定如何升级它 有一个bin include and lib文件夹 我应该把这些文件放在哪里 我还需要做其他事情吗 要升级 XAMP 安
  • PDO 从 Postgres 获取小数秒

    当我查询日期时间字段时postgresql 9 6 用一个简单的 pdo 语句 PHP7 sql SELECT date FROM table stmt adapter gt createStatement sql stmt gt prep
  • 如何防止显示菱形问号符号,即使使用 mb_substr 和 utf-8

    我读过其他一些问题 尝试了答案 但最终没有结果 我得到的是例如这个 我无法删除那个奇怪的问号 我所做的就是获取 RSS feed 的内容 该内容也被编码为内容使用希腊语 有没有什么办法解决这一问题 div div
  • 在 url 中传递百分号 (%) 并使用 php 获取其准确值

    我正在尝试在 url 中传递百分号 例如 B6011000995504101 SB 但当我回声时 它又回来了 011000995504101 SB 我想要与在 URL 中传递的值完全相同的值 我尝试使用 urlencode 函数 但它给了我

随机推荐