@@ -77,14 +77,6 @@ plan_services AS (
77
77
GROUP BY
78
78
plan_id
79
79
),
80
- paypal_subscriptions AS (
81
- SELECT DISTINCT
82
- subscription_id
83
- FROM
84
- ` moz-fx-data-shared-prod.stripe_external.invoice_v1`
85
- WHERE
86
- JSON_VALUE(metadata, ' $.paypalTransactionId' ) IS NOT NULL
87
- ),
88
80
subscriptions_history_charge_summaries AS (
89
81
SELECT
90
82
history .id AS subscriptions_history_id,
@@ -226,7 +218,11 @@ SELECT
226
218
FORMAT_TIMESTAMP(' %FT%H:%M:%E6S' , history .subscription_first_active_at )
227
219
) AS id,
228
220
' Stripe' AS provider,
229
- IF(paypal_subscriptions .subscription_id IS NOT NULL , ' PayPal' , ' Stripe' ) AS payment_provider,
221
+ IF(
222
+ history .subscription .collection_method = ' send_invoice' ,
223
+ ' PayPal' ,
224
+ ' Stripe'
225
+ ) AS payment_provider,
230
226
history .subscription .id AS provider_subscription_id,
231
227
subscription_item .id AS provider_subscription_item_id,
232
228
history .subscription .created AS provider_subscription_created_at,
@@ -247,7 +243,7 @@ SELECT
247
243
charge_summaries .latest_card_country
248
244
)
249
245
-- SubPlat copies the PayPal billing agreement country to the customer's address.
250
- WHEN paypal_subscriptions . subscription_id IS NOT NULL
246
+ WHEN history . subscription .collection_method = ' send_invoice '
251
247
THEN NULLIF(history .subscription .customer .address .country, ' ' )
252
248
ELSE charge_summaries .latest_card_country
253
249
END AS country_code,
@@ -366,9 +362,6 @@ CROSS JOIN
366
362
LEFT JOIN
367
363
plan_services
368
364
ON subscription_item .plan .id = plan_services .plan_id
369
- LEFT JOIN
370
- paypal_subscriptions
371
- ON history .subscription .id = paypal_subscriptions .subscription_id
372
365
LEFT JOIN
373
366
subscriptions_history_charge_summaries AS charge_summaries
374
367
ON history .id = charge_summaries .subscriptions_history_id
0 commit comments