strangerstudios / pmpro-ccbill

CCBill Gateway for Paid Memberships Pro
https://www.paidmembershipspro.com/add-ons/ccbill/
7 stars 11 forks source link

Successful renewals webhook events are not processed #45

Open misfist opened 1 month ago

misfist commented 1 month ago

Describe the bug Successful renewals webhook events are not saved as a member order.

To Reproduce Steps to reproduce the behavior:

  1. Webhook is received for RenewalSuccess event
Subscription ID: 0220000000000000002
Event: RenewalSuccess
Response Code: 200
URL: https://example.com/wp-admin/admin-ajax.php?action=ccbill-webhook
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ENSEventMessage 
   clientAccnum="940000" 
   clientSubacc="01" 
   eventType="RenewalSuccess" 
   eventGroup="Subscription" 
   creationDate="20240517201114" 
   validate="true">
    <subscriptionId>0224108301000365797</subscriptionId>
    <transactionId>0124138501000194835</transactionId>
    <timestamp>2024-05-17 20:11:14</timestamp>
    <accountingAmount>3.00</accountingAmount>
    <accountingCurrency>USD</accountingCurrency>
    <accountingCurrencyCode>840</accountingCurrencyCode>
    <billedAmount>3.00</billedAmount>
    <billedCurrency>USD</billedCurrency>
    <billedCurrencyCode>840</billedCurrencyCode>
    <cardType>VISA</cardType>
    <clientAccnum>942299</clientAccnum>
    <clientSubacc>0010</clientSubacc>
    <expDate>1024</expDate>
    <last4>3992</last4>
    <nextRenewalDate>2024-06-16</nextRenewalDate>
    <paymentAccount>720b797f2ee582eb1000000319514b5</paymentAccount>
    <paymentType>CREDIT</paymentType>
    <renewalDate>2024-05-17</renewalDate>
</ENSEventMessage>
  1. In ./pmpro-ccbill/webhook.php, RenewalSuccess event case is run

  2. Code looks for X-pmpro_orderid in response, which doesn't exist

  3. new MemberOrder( $order_id ) fails because $order_id is undefined

Expected behavior RenewalSuccess event should create a new order for the user's membership.

Isolating the problem (mark completed items with an [x]):

WordPress Environment

``` ### wp-core ### version: 6.5.3 site_language: en_US user_language: en_US timezone: America/Los_Angeles permalink: /%postname%/ https_status: true multisite: false user_registration: 0 blog_public: 1 default_comment_status: undefined environment_type: production user_count: 14 dotorg_communication: true ### wp-server ### server_architecture: Linux 5.15.0-97-generic x86_64 httpd_software: Apache php_version: 8.1.27 64bit php_sapi: cgi-fcgi max_input_variables: 1000 time_limit: 120 memory_limit: 256M max_input_time: -1 upload_max_filesize: 512M php_post_max_size: 512M curl_version: 7.68.0 OpenSSL/1.1.1f suhosin: false imagick_availability: true pretty_permalinks: true htaccess_extra_rules: true current: 2024-05-18T03:44:13+00:00 utc-time: Saturday, 18-May-24 03:44:13 UTC server-time: 2024-05-17T20:44:11-07:00 ### wp-database ### extension: mysqli server_version: 8.0.34-0ubuntu0.22.04.1 client_version: mysqlnd 8.1.27 max_allowed_packet: 33554432 max_connections: 200 ```
misfist commented 1 month ago

@andrewlimaza I started working on updates to renewal events in this branch https://github.com/misfist/pmpro-ccbill/tree/45-successful-renewals-webhook-events-are-not-processed .

I'm not particularly familiar with the PMPro codebase, so took some direction from the Stripe and Braintree. Still WIP, but wanted to share. :)