WordPress插件中的WebhookUrl更新导致致命错误:未捕获的错误:调用未定义的方法Mollie\Api\Endpoints\SubscriptionEndpoint::update()
P粉993712159
P粉993712159 2023-09-04 00:15:50
[PHP讨论组]
<p>我正在尝试更新 mollie 中的 webhookUrl 以进行订阅。旧的 webhookUrl 已经过时了,制作它的程序员已经不在我们身边了。</p> <p>这是我正在尝试使用的 mollie 的链接。在github上检查了新版本后,我发现更新订阅的方法有点不同。尽管存在差异,我仍然收到错误:</p> <p>致命错误:未捕获错误:调用未定义的方法 Mollie\Api\Endpoints\SubscriptionEndpoint::update()</p> <p>这是我用来制作表单的代码。我正在尝试更改 webhookUrl 以连接到 Easy digital Downloads,以便订阅和许可证不会因为无法检查付款而过期。</p> <p>表单(admin__update_subscription.php):</p> <pre class="brush:php;toolbar:false;">&lt;form id=&quot;wmcs-form&quot; method=&quot;post&quot;&gt; &lt;div class=&quot;wmcs_admin_card&quot;&gt; &lt;div class=&quot;wmcs_admin_body&quot;&gt; &lt;fieldset class=&quot;choose-theme-wrap radio-boxes dp-tabular&quot;&gt; &lt;ul&gt; &lt;li&gt; &lt;label&gt;Customer id&lt;/label&gt; &lt;input type=&quot;text&quot; id=&quot;customer_id&quot; name=&quot;customer_id&quot; value=&quot;&quot; required&gt; &lt;/li&gt; &lt;li&gt; &lt;label&gt;Subscription id&lt;/label&gt; &lt;input type=&quot;text&quot; id=&quot;subscription_id&quot; name=&quot;subscription_id&quot; value=&quot;&quot; required&gt; &lt;/li&gt; &lt;li&gt; &lt;label&gt;Webhook URL&lt;/label&gt; &lt;input type=&quot;text&quot; id=&quot;webhook_url&quot; name=&quot;webhook_url&quot; value=&quot;&quot; required&gt; &lt;/li&gt; &lt;li&gt; &lt;button type=&quot;submit&quot; class=&quot;button-primary&quot; name=&quot;mollie_update_subscription&quot;&gt;Change&lt;/button&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/fieldset&gt;&lt;!-- End of choose-theme-wrap --&gt; &lt;/div&gt;&lt;!-- End of wmcs_admin_body --&gt; &lt;/div&gt;&lt;!-- End of wmcs_admin_card --&gt; &lt;/form&gt;</pre> <p>表单处理程序:</p> <pre class="brush:php;toolbar:false;">public function change_subscription(){ ?&gt; &lt;div class=&quot;wrap&quot;&gt; &lt;?php if(isset($_POST['mollie_update_subscription'])){ if(!empty($_POST['customer_id']) &amp;&amp; !empty($_POST['subscription_id'])){ $customer_id = sanitize_text_field($_POST['customer_id']); $subscription_id = sanitize_text_field($_POST['subscription_id']); $webhook_url = sanitize_text_field($_POST['webhook_url']); // $orderID = sanitize_text_field($_POST['order_id']); // $orderKey = sanitize_text_field($_POST['order_key']); echo $this-&gt;mollie_update_subscription($customer_id, $subscription_id, $webhook_url); } } ?&gt; &lt;h2&gt;&lt;?php _e('Change Subscription URL'); ?&gt;&lt;/h2&gt; &lt;div id=&quot;Features&quot; class=&quot;wmcs-tabs&quot;&gt; &lt;?php require_once('admin__update_subscription.php'); ?&gt; &lt;/div&gt; &lt;!-- End of Settings --&gt; &lt;?php }</pre> <p>莫莉更新请求:</p> <pre class="brush:php;toolbar:false;">public function mollie_update_subscription($customer_id, $subscription_id, $webhook_url){ $mollie = new \Mollie\Api\MollieApiClient(); $mollie-&gt;setApiKey(MOLLIE_KEY);(defined elsewhere) $message = &quot;&quot;; try { $customer = $mollie-&gt;customers-&gt;get($customer_id); $subscription = $customer-&gt;getSubscription($subscription_id); $subscription-&gt;webhookUrl = $webhook_url; $subscription-&gt;description = 'subscription update success'; $mollie-&gt;subscriptions-&gt;update(); $message = &quot;&lt;p&gt;Subscription updated: &quot; . $subscription-&gt;id . &quot;&lt;/p&gt;&quot;; } catch (\Mollie\Api\Exceptions\ApiException $e) { $message = &quot;&lt;div class='alert alert-danger' role='alert'&gt;API call failed: &quot; . htmlspecialchars($e-&gt;getMessage()).'&lt;/div&gt;'; } return $message; }</pre> <p>知道我缺少什么吗?我希望这会更新 webhookUrl,以便付款将自动连接到网站上的订阅。</p>
P粉993712159
P粉993712159

全部回复(1)
P粉685757239

找到了解决方案。我需要更改这部分:

$mollie->subscriptions->update();

$subscription->update();

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号