Created
August 8, 2024 16:46
-
-
Save greenhornet79/671001e8603f2440ea6df38497b92d7e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('leaky_paywall_before_create_stripe_subscription', 'endo_handle_product_for_recurring_checkout', 20, 2); | |
function endo_handle_product_for_recurring_checkout($customer, $fields) { | |
$stripe = leaky_paywall_initialize_stripe_api(); | |
try { | |
$invoice_item = $stripe->invoiceItems->create([ | |
'customer' => $customer->id, | |
'amount' => 5000, // Amount in cents ($50.00 in this case) | |
'currency' => 'usd', | |
'description' => 'One-time fee for summer issue', | |
]); | |
} catch (\Throwable $th) { | |
leaky_paywall_log($user_id, 'leaky paywall - error creating invoice'); | |
wp_send_json(array( | |
'error' => $th->jsonBody | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment