响应对象 - 使用 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字符串中所有不匹配的字符?

    我有一个文本 我想从中删除所有不属于以下字符的字符 所需字符 0123456789 abcdefghijklmnopqrstuvwxyz n 最后一个是我确实想保留的 n 换行符 要匹配除列出的字符之外的所有字符 请使用反转字符集 http
  • MySQL/PDO::quote() 尽管使用 PDO::PARAM_INT 参数,但仍在整数周围加上引号

    无论我传递给什么值 数据类型对 它都会出现 pdo gt quote value type 它总是将其引用为字符串 echo pdo gt quote foo PDO PARAM STR foo as expected echo pdo g
  • 检查 PHP 中“@”字符后面的单词

    我现在正在制作一个新闻和评论系统 但是我已经在一个部分上停留了一段时间了 我希望用户能够在 Twitter 上引用其他玩家的风格 例如 用户名 该脚本看起来像这样 不是真正的 PHP 只是想象脚本 3 string I loved the
  • 如何从父类函数访问子类中定义的常量?

    我从 php net 看到这个例子 但 c MY CONST 仅在 5 3
  • Apache 访问 Linux 中的 NTFS 链接文件夹

    在 Debian jessie 中使用 Apache2 PHP 当我想在 Apache 的文档文件夹 var www 中创建一个新的小节时 我只需创建一个指向我的 php 文件所在的外部文件夹的链接 然后只需更改该文件夹的所有者和权限文件夹
  • posts_search 中的自定义查询

    如何使用此查询作为我的自定义搜索查询 add filter posts search my search is perfect 20 2 function my search is perfect search wp query sWord
  • 如何使用 php 下载/打印页面的特定部分

    我有一个 HTML 页面如下 Lorem Ipsum is simply dummy text of the printing and typesetting industry Lorem Ipsum has been the indust
  • 扩展蓝图类?

    我想覆盖timestamps 函数中发现Blueprint班级 我怎样才能做到这一点 e g public function up Schema create users function Blueprint table table gt
  • 是否可以使用 PHP 重定向发送 POST 数据?

    更新 这不是重复的如何使用 PHP 发送 POST 请求 https stackoverflow com questions 5647461 how do i send a post request with php 那里的解决方案对我不起
  • Symfony2 Assetic 和 Less Sourcemaps

    我不确定如何破解 assetic less 过滤器以输出源映射文件 我这里指的是LessFilterhttps github com kriswallsmith assetic blob master src Assetic Filter
  • “使用未定义常量”注意,但该常量应该被定义

    共有三个文件 common php controller php 和 user php 文件 common php 如下所示 文件controller php看起来像 文件 user php 如下所示 执行脚本时 会给出通知 注意 使用未定
  • 交换关联数组中的两个项目

    Example arr array apple gt sweet grapefruit gt bitter pear gt tasty banana gt yellow 我想调换一下柚子和梨的位置 这样数组就变成了 arr array ap
  • 在 Wordpress 站点中进行 AJAX 调用时出现问题

    我在使用 Wordpress 站点功能的 AJAX 部分时遇到了一些问题 该功能接受在表单上输入的邮政编码 使用 PHP 函数来查找邮政编码是否引用特定位置并返回到该位置的永久链接 我的第一个问题是关于我构建的表单 现在我的表单操作是空白的
  • jQuery Mobile 表单验证

    我有一个移动网站 除了验证之外一切都工作正常 基本上我希望从用户那里获取值 然后在单独的页面 process php 上处理它们 但是 在这样做之前 我需要检查以确保字段已填充 我已经研究了几种方法来做到这一点 但似乎没有一种有效 我现在有
  • 在 apache docker 容器中运行虚拟主机

    我在同一个 apache 容器中有两个 php 应用程序 我试图在端口上运行其中一个应用程序 因为它需要通过根域而不是子文件夹进行访问 我想在端口 8060 上运行应用程序 我尝试使用 apache 虚拟主机执行此操作 但它不会加载页面 h
  • PHP HEREDoc (EOF) 语法在 Sublime Text 3 上突出显示与正斜杠的差异

    我不熟悉 Sublime Text 3 如何使用语法突出显示 例如 如果它纯粹依赖于主题 或者它内置于主题运行的标准中 但就我而言 使用 PHP 的 HERE 文档和转发存在一些语法突出显示差异斜线 一旦出现正斜杠 ST3 就会认为以下所有
  • php 错误 fopen(): 文件名不能为空

    发送带有附件代码的电子邮件工作正常 最近我们已将文件传输到另一个托管服务器 idk 发生了什么 它显示以下错误 警告 fopen 第 106 行 home hugerecruitmetnt public html validatecva p
  • 如何在 PHP 中从 IP 地址/国家/地区名称查找时区 ID?

    谁能告诉我 PHP 中是否有任何方法可以从 IP 地址或国家 地区名称获取时区区域 例如 亚洲 加尔各答 描述 我正在尝试根据他 她的国家 地区设置用户时区 我从他的 IP 地址获取用户所在国家 地区 但我需要该国家 地区的时区区域 例如
  • 如何在 Laravel 中使用 PUT http 动词提交表单

    我知道这个问题可能已经提出 但我就是无法让它发挥作用 如果有人可以帮助我 我将非常感激 我安装了 colletive form 但答案也可以是 html 表单标签 现在列出我的表格 我的路线和我的例外情况 Form model array
  • 无法显示 Laravel 欢迎页面

    我的服务器位于 DigitalOcean 云上 我正在使用 Ubuntu 和 Apache Web 服务器 我的家用计算机运行的是 Windows 7 我使用 putty 作为终端 遵循所有指示https laracasts com ser

随机推荐