Open devzeemalik opened 1 year ago
Hi, I had same issue. In my app I added support for "test mode functionality".
Here is issue: https://github.com/Shopify/shopify-app-template-php/blob/main/web/app/Lib/EnsureBilling.php#L68
Shops during review has "staff" plan (plan_name) . All payments are with test flag . So hasSubscription method for staff plans return allways false.
We have solution on Symfony and all shop plans exclude staff and partner_test has payment registered with test flag (here) based on envoirument (if !prod => is test) and based on shop_plan.
I hope that this answer is helpful. For review you can disable required payments on change your code to support for staff plans:
Some code:
<?php
namespace App\Billing;
/**
* List of Shopify shop plans which should be treated as test payment.
*/
enum TestPlans: string
{
case STAFF = 'staff';
case PARTNER_TEST = 'partner_test';
}
<?php
namespace App\Billing\Service;
use App\Billing\TestPlans;
class TestPlanChecker
{
public function isTest(string $environment, string $planName): bool
{
if ($environment !== 'prod') {
return true;
}
return in_array($planName, array_column(TestPlans::cases(), 'value'), true);
}
}
<?php
namespace App\Billing;
use App\Billing\Provider\ActiveSubscriptionsProvider;
use App\Billing\Service\TestPlanChecker;
use App\Entity\Shop;
use Shopify\Auth\Session;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
class BillingChecker
{
public function __construct(
private readonly TestPlanChecker $trialPlans,
private readonly ActiveSubscriptionsProvider $activeSubscriptionsProvider,
#[Autowire('%kernel.environment%')] private readonly string $environment,
) {
}
public function hasPayment(Session $session, Shop $shop): bool
{
return $this->activeSubscriptionsProvider
->getActiveSubscriptions($session)
->filter(
fn(Subscription $subscription) => !$subscription->test || $this->trialPlans->isTest(
$this->environment,
$shop->getPlanName()
)
)
->count() > 0;
}
}
@sebastianpisula Thank you for your time. I reviewed the solution you provided, but I only found the billing namespace in the package. The other files were not included. Can you please explain the code you shared earlier?
@sebastianpisula How can I test the payment system? Do I need to use the original payment card or is there another method available for testing purposes?
Anyone have luck implementing something similar to sebastianpisula in this package? The issue is definitely here: https://github.com/Shopify/shopify-app-template-php/blob/main/web/app/Lib/EnsureBilling.php#L68 Only issue is I am not show how to get the plan name their to check if it is a staff plan
To enable billing, I have made modifications to the shopify.php file located in the config directory. Specifically, I have set the amount and billing requirement to true. These changes successfully activate the billing functionality. However, my app has been rejected by Shopify due to an issue where, they said after payment it repeatedly redirects to the billing page, indicating that the billing process is not functioning correctly. Is there anyone here who might have insights or suggestions on how to resolve this problem?