Skip to content
Snippets Groups Projects
Commit 4286bc81 authored by mattwire's avatar mattwire
Browse files

Fix #422 The resource ID cannot be null or whitespace

parent 35213988
Branches
Tags
No related merge requests found
......@@ -737,7 +737,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
* @throws \CiviCRM_API3_Exception
* @throws \CRM_Core_Exception
*/
public function doRecurPayment($propertyBag, $amountFormattedForStripe, $stripeCustomer) {
public function doRecurPayment(\Civi\Payment\PropertyBag $propertyBag, int $amountFormattedForStripe, $stripeCustomer): array {
$params = $this->getPropertyBagAsArray($propertyBag);
// @fixme FROM HERE we are using $params array (but some things are READING from $propertyBag)
......@@ -902,7 +902,7 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
}
elseif (!empty($intent->latest_charge)) {
// Stripe API version 2022-11-15
$stripeCharge = $this->stripeClient->charges->retrieve($intent->latest_charge->id);
$stripeCharge = $this->stripeClient->charges->retrieve($intent->latest_charge);
}
try {
$stripeBalanceTransaction = $this->stripeClient->balanceTransactions->retrieve($stripeCharge->balance_transaction);
......
......@@ -95,11 +95,11 @@ class CRM_Stripe_Customer {
* @param array $params
* @param \CRM_Core_Payment_Stripe $stripe
*
* @return \Stripe\ApiResource
* @return \Stripe\Customer|\PropertySpy
* @throws \CiviCRM_API3_Exception
* @throws \Civi\Payment\Exception\PaymentProcessorException
*/
public static function create($params, $stripe) {
public static function create(array $params, \CRM_Core_Payment_Stripe $stripe) {
$requiredParams = ['contact_id', 'processor_id'];
foreach ($requiredParams as $required) {
if (empty($params[$required])) {
......
......@@ -955,7 +955,7 @@ class CRM_Stripe_IpnTest extends CRM_Stripe_BaseTest {
$mockPaymentIntent = new PropertySpy('PaymentIntent', [
'id' => 'pi_mock',
'status' => 'succeeded',
'latest_charge' => $mockCharge
'latest_charge' => 'ch_mock'
]);
$stripeClient->paymentIntents = $this->createMock('Stripe\\Service\\PaymentIntentService');
......@@ -967,7 +967,7 @@ class CRM_Stripe_IpnTest extends CRM_Stripe_BaseTest {
$mockPaymentIntentWithAmount = new PropertySpy('PaymentIntent', [
'id' => 'pi_mock',
'status' => 'succeeded',
'latest_charge' => $mockCharge,
'latest_charge' => 'ch_mock',
'amount' => '40000',
]);
$stripeClient->paymentIntents
......@@ -1123,7 +1123,7 @@ class CRM_Stripe_IpnTest extends CRM_Stripe_BaseTest {
$mockPaymentIntent = new PropertySpy('PaymentIntent', [
'id' => 'pi_mock',
'status' => 'succeeded',
'latest_charge' => $mockCharge
'latest_charge' => 'ch_mock'
]);
$stripeClient->paymentIntents = $this->createMock('Stripe\\Service\\PaymentIntentService');
......@@ -1135,7 +1135,7 @@ class CRM_Stripe_IpnTest extends CRM_Stripe_BaseTest {
$mockPaymentIntentWithAmount = new PropertySpy('PaymentIntent', [
'id' => 'pi_mock',
'status' => 'succeeded',
'latest_charge' => $mockCharge,
'latest_charge' => 'ch_mock',
'amount' => '40000',
]);
$stripeClient->paymentIntents
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment