Commit 1ee49d4d authored by mattwire's avatar mattwire
Browse files

Switch final instances of static Stripe library access to object

parent 82391755
......@@ -180,7 +180,7 @@ class CRM_Stripe_Customer {
$stripeCustomerParams = self::getStripeCustomerMetadata($params);
try {
$stripeCustomer = \Stripe\Customer::update($stripeCustomerID, $stripeCustomerParams);
$stripeCustomer = $stripe->stripeClient->customers->update($stripeCustomerID, $stripeCustomerParams);
}
catch (Exception $e) {
$err = CRM_Core_Payment_Stripe::parseStripeException('create_customer', $e, FALSE);
......
......@@ -158,21 +158,22 @@ class CRM_Stripe_Upgrader extends CRM_Stripe_Upgrader_Base {
$dbName = DB::connect($config->dsn)->_db;
$null_count = CRM_Core_DAO::executeQuery('SELECT COUNT(*) FROM civicrm_stripe_subscriptions where subscription_id IS NULL');
if ( $null_count == 0 ) {
if ($null_count == 0) {
$this->ctx->log->info('Skipped civicrm_stripe update 5004. No nulls found in column subscription_id in our civicrm_stripe_subscriptions table.');
}
else {
$customer_infos = CRM_Core_DAO::executeQuery("SELECT customer_id,processor_id
FROM `civicrm_stripe_subscriptions`;");
while ( $customer_infos->fetch() ) {
while ($customer_infos->fetch()) {
$processor_id = $customer_infos->processor_id;
$customer_id = $customer_infos->customer_id;
try {
$processor = new CRM_Core_Payment_Stripe('', civicrm_api3('PaymentProcessor', 'getsingle', ['id' => $processor_id]));
/** @var \CRM_Core_Payment_Stripe $paymentProcessor */
$paymentProcessor = \Civi\Payment\System::singleton()->getById($processor_id);
$subscription = \Stripe\Subscription::all([
'customer'=> $customer_id,
'limit'=>1,
$subscription = $paymentProcessor->stripeClient->subscriptions->all([
'customer' => $customer_id,
'limit' => 1,
]);
}
catch (Exception $e) {
......
......@@ -150,7 +150,6 @@ function stripe_civicrm_buildForm($formName, &$form) {
/** @var \CRM_Core_Payment_Stripe $paymentProcessor */
$paymentProcessor = \Civi\Payment\System::singleton()->getById($form->_paymentProcessor['id']);
$paymentProcessor->setAPIParams();
try {
$jsVars = [
'id' => $form->_paymentProcessor['id'],
......@@ -164,7 +163,7 @@ function stripe_civicrm_buildForm($formName, &$form) {
switch (substr($paymentIntent['stripe_intent_id'], 0, 2)) {
case 'pi':
// pi_ Stripe PaymentIntent
$stripePaymentIntent = \Stripe\PaymentIntent::retrieve($paymentIntent['stripe_intent_id']);
$stripePaymentIntent = $paymentProcessor->stripeClient->paymentIntents->retrieve($paymentIntent['stripe_intent_id']);
// We need the confirmation_method to decide whether to use handleCardAction (manual) or handleCardPayment (automatic) on the js side
$jsVars['paymentIntentID'] = $stripePaymentIntent->id;
$jsVars['intentStatus'] = $stripePaymentIntent->status;
......@@ -173,7 +172,7 @@ function stripe_civicrm_buildForm($formName, &$form) {
case 'se':
// seti_ Stripe SetupIntent
$stripeSetupIntent = \Stripe\SetupIntent::retrieve($paymentIntent['stripe_intent_id']);
$stripeSetupIntent = $paymentProcessor->stripeClient->setupIntents->retrieve($paymentIntent['stripe_intent_id']);
$jsVars['setupIntentID'] = $stripeSetupIntent->id;
$jsVars['setupIntentNextAction'] = $stripeSetupIntent->next_action;
$jsVars['setupIntentClientSecret'] = $stripeSetupIntent->client_secret;
......
......@@ -51,10 +51,12 @@ while ($dao->fetch()) {
if (!$paymentProcessor) {
echo "Failed to find a stripe payment processor for recurring contrib $dao->contribution_recur_id\n";
}
$processor = new CRM_Core_Payment_Stripe('', civicrm_api3('PaymentProcessor', 'getsingle', ['id' => $paymentProcessor['id']]));
/** @var \CRM_Core_Payment_Stripe $processor */
$processor = \Civi\Payment\System::singleton()->getById($paymentProcessor['id']);
try {
$results = Charge::retrieve(['id' => $dao->trxn_id]);
$results = $processor->stripeClient->charges->retrieve($dao->trxn_id);
//print json_encode($results, JSON_PRETTY_PRINT);
if (empty($results->created)) {
echo " Failed to retrieve a charge created date\n";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment