- Issue created by @a.griff
- π¨π¦Canada a.griff
Have created a fork with a potential fix for this issue. The approach checks if config.CountryCode === 'CAN' and sets the correct URL based off of that.
- πΊπΈUnited States rszrama
I've asked Affirm about this, but the person I was chatting with was unaware of any such requirement. Do you have a link to docs for this I can share with them, or is it something you just happened upon to make it work? (Struggling to onboard a Canadian merchant atm myself.)
- π¨π¦Canada a.griff
I no longer work for the company where we had to make these changes, so I don't have any of the communication related to this and can no longer test if it still works. But I can confirm that, unless they have made changes since, this is a requirement.
If the company is on Affirm Canada, you need the .ca domain. This makes it especially annoying when your company has a US and Canadian account since they treat these as completely different accounts with different companies.
I found Affirms documentation and support pretty bad in many areas. A lot of trial and error needed. But this single switch of using a .ca domain was the difference between things not working vs working for our Canadian account.
- π¨π¦Canada a.griff
I just did a quick diff check of
https://cdn1.affirm.com/js/v2/affirm.js and https://cdn1.affirm.ca/js/v2/affirm.js and while most of the code is the same, there are country specific differences in the two that I'm guessing lead to problems if you don't include the right one for the country you are trying to use.Example, this section of the code
{function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.cart={},this.buildTarget="prod-live",this.hash="master",this.pageType="",this.resource_urls={checkout_button_route:"apps/checkout-button/",new_order:"checkout/",product_flows_checkout_route:"products/checkout",new_future_checkout:"checkout/?as_future=1",orders_backend_route:"apps/orders/",prequal_backend_route:"apps/prequal/",prequal_frontend_learn_more_route:"#/prequalifications/learn-more",send_future_checkout:"send_future_checkout",third_party_cookie_check:"cookie_sent",breeze_route:"apps/breeze/",toast_route:"apps/toast/"},this.target="prod-live",this.tracking_blacklist={0:"E0QK6BONBI305A0Y"},this.apiTokens={tracking_blacklist:{0:"E0QK6BONBI305A0Y"},statsig_client_side_id:"client-gcVqW85xa36vHQOyW5ZNVdgIA4eDCVLkHmizTJxFRI9",statsig_client_environment_param:{environment:{tier:"production"}},rollbar:"dcce876e5122437d8373240f0b7c0778",branch:"key_live_eak0b1ysFeymTfKqPf8GfmjhyFpG45mQ"},this.api_url="https://api-cf.affirm.com/api/v2/",this.api_version="v2",this.cdn_root="https://cdn1.affirm.com",this.cdn_assets_root="https://cdn-assets.affirm.com",this.assets_root="https://cdn1.affirm.com/products/affirmjs/master/dist/",this.country_code="US",this.frontend_url="https://www.affirm.com",this.minified_url="https://cdn1.affirm.com/js/v2/affirm.js",this.payments_url_base="https://calculator.affirm.com",this.promos_url_prefix="https://cdn1.affirm.com/platform/public/promos/",this.tracking_endpoint="tracker.affirm.com",this.elastic_cloud_apm_endpoint="https://8f72b01b2e7a49d68c403ae5e6b1a428.apm.us-east-1.aws.cloud.es.io",this.extend=this.extend.bind(this)}return
becomes
{function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.cart={},this.buildTarget="prod-live",this.hash="master",this.pageType="",this.resource_urls={checkout_button_route:"apps/checkout-button/",new_order:"checkout/",product_flows_checkout_route:"products/checkout",new_future_checkout:"checkout/?as_future=1",orders_backend_route:"apps/orders/",prequal_backend_route:"apps/prequal/",prequal_frontend_learn_more_route:"#/prequalifications/learn-more",send_future_checkout:"send_future_checkout",third_party_cookie_check:"cookie_sent",breeze_route:"apps/breeze/",toast_route:"apps/toast/"},this.target="prod-live",this.tracking_blacklist={0:"E0QK6BONBI305A0Y"},this.apiTokens={tracking_blacklist:{0:"E0QK6BONBI305A0Y"},statsig_client_side_id:"client-gcVqW85xa36vHQOyW5ZNVdgIA4eDCVLkHmizTJxFRI9",statsig_client_environment_param:{environment:{tier:"production"}},rollbar:"dcce876e5122437d8373240f0b7c0778",branch:"key_live_eak0b1ysFeymTfKqPf8GfmjhyFpG45mQ"},this.api_url="https://api-cf.affirm.com/api/v2/",this.api_version="v2",this.cdn_root="https://cdn1.affirm.com",this.cdn_assets_root="https://cdn-assets.affirm.com",this.assets_root="https://cdn1.affirm.com/products/affirmjs/master/dist/",this.country_code="CA",this.frontend_url="https://www.affirm.com",this.minified_url="https://cdn1.affirm.com/js/v2/affirm.js",this.payments_url_base="https://calculator.affirm.com",this.promos_url_prefix="https://cdn1.affirm.com/platform/public/promos/",this.tracking_endpoint="tracker.affirm.com",this.elastic_cloud_apm_endpoint="https://8f72b01b2e7a49d68c403ae5e6b1a428.apm.us-east-1.aws.cloud.es.io",this.extend=this.extend.bind(this)}return
See this.country_code="US" changes to this.country_code="CA"
- πΊπΈUnited States rszrama
Thanks so much for following up on this! I finally got a Canadian sandbox account from them to test against and confirmed that the API keys page does show the .ca subdomain. I was just tripped up last time when I first saw this patch, because their own docs page shows Canadian locale information with the .com script:
https://docs.affirm.com/developers/v1.0-Global-Integration/docs/global-a...
Craziness. Then, even worse, I actually had applied your patch locally but forgot about it, and so in one of my test environments, transactions were working, but in a new one, they weren't, and it took me an hour to realize what I had done. π€¦πΌββοΈ
Committing this sucker now.
-
rszrama β
committed 6fa0eb02 on 2.0.x
Issue #3462826 by a.griff: Affirm Requires .ca URLs For Canada
-
rszrama β
committed 6fa0eb02 on 2.0.x
- Status changed to Fixed
22 days ago 2:14pm 17 April 2025 Automatically closed - issue fixed for 2 weeks with no activity.