Skip to content

Commit

Permalink
Remove the promo messaging restriction for requests above $17,500 (#157)
Browse files Browse the repository at this point in the history
Co-authored-by: Victor Zhu <[email protected]>
  • Loading branch information
ilabsvictor and hoyelo authored Nov 26, 2024
1 parent 7fb54c3 commit c660d4f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 30 deletions.
2 changes: 0 additions & 2 deletions AffirmSDK/AffirmConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ FOUNDATION_EXPORT NSString *const AFFIRM_CHECKOUT_PRODUCTION_URL;
FOUNDATION_EXPORT NSString *const AFFIRM_PROMOS_US_DOMAIN;
FOUNDATION_EXPORT NSString *const AFFIRM_PROMOS_CA_DOMAIN;

FOUNDATION_EXPORT NSString *const AFFIRM_MAX_PROMO_AMOUNT;

FOUNDATION_EXPORT NSString *const AFFIRM_CHECKOUT_CONFIRMATION_URL;
FOUNDATION_EXPORT NSString *const AFFIRM_CHECKOUT_CANCELLATION_URL;
FOUNDATION_EXPORT NSString *const AFFIRM_PREQUAL_REFERRING_URL;
Expand Down
2 changes: 0 additions & 2 deletions AffirmSDK/AffirmConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
NSString *const AFFIRM_PROMOS_US_DOMAIN = @"affirm.com";
NSString *const AFFIRM_PROMOS_CA_DOMAIN = @"affirm.ca";

NSString *const AFFIRM_MAX_PROMO_AMOUNT = @"17500";

NSString *const AFFIRM_PREQUAL_REFERRING_URL = @"https://iossdk/";
NSString *const AFFIRM_CHECKOUT_CONFIRMATION_URL = @"affirm://checkout/confirmed";
NSString *const AFFIRM_CHECKOUT_CANCELLATION_URL = @"affirm://checkout/cancelled";
Expand Down
5 changes: 0 additions & 5 deletions AffirmSDK/AffirmDataHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,6 @@ + (void)getPromoMessageWithPromoID:(nullable NSString *)promoID
{
[AffirmValidationUtils checkNotNil:amount name:@"amount"];

if (amount.doubleValue > [NSDecimalNumber decimalNumberWithString:AFFIRM_MAX_PROMO_AMOUNT].doubleValue) {
completionHandler(nil, nil, nil, nil, nil);
return;
}

AffirmColorType logoColor = colorType;
// Using default type when logoColor == AffirmColorTypeBlueBlack
if (logoColor == AffirmColorTypeBlueBlack) {
Expand Down
32 changes: 11 additions & 21 deletions AffirmSDK/AffirmPromotionalButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ + (NSAttributedString *)appendLogo:(UIImage *)logo
[attributedText addAttributes:@{NSFontAttributeName: font,
NSForegroundColorAttributeName: textColor}
range:NSMakeRange(0, attributedText.length)];

if (!logo) {
return attributedText;
}

while ([attributedText.mutableString containsString:@"Affirm"]) {
NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
attachment.image = logo;
Expand All @@ -125,7 +125,7 @@ - (instancetype)initWithPromoID:(nullable NSString *)promoID
frame:(CGRect)frame
{
[AffirmValidationUtils checkNotNil:presentingViewController name:@"presentingViewController"];

if (self = [super initWithFrame:frame]) {
_promoID = promoID;
_pageType = AffirmPageTypeNone;
Expand All @@ -142,7 +142,7 @@ - (instancetype)initWithShowCTA:(BOOL)showCTA
frame:(CGRect)frame
{
[AffirmValidationUtils checkNotNil:presentingViewController name:@"presentingViewController"];

if (self = [super initWithFrame:frame]) {
_promoID = nil;
_pageType = pageType;
Expand All @@ -160,7 +160,7 @@ - (instancetype)initWithPromoID:(nullable NSString *)promoID
frame:(CGRect)frame
{
[AffirmValidationUtils checkNotNil:presentingViewController name:@"presentingViewController"];

if (self = [super initWithFrame:frame]) {
_promoID = promoID;
_pageType = pageType;
Expand Down Expand Up @@ -280,17 +280,12 @@ - (void)configureByHtmlStylingWithAmount:(NSDecimalNumber *)amount
[AffirmValidationUtils checkNotNil:amount name:@"amount"];
self.amount = amount;

if (amount.doubleValue > [NSDecimalNumber decimalNumberWithString:AFFIRM_MAX_PROMO_AMOUNT].doubleValue) {
[self configureWithAttributedText:nil response:nil error:nil];
return;
}

AffirmColorType logoColor = affirmColor;
// Using default type when logoColor == AffirmColorTypeBlueBlack
if (logoColor == AffirmColorTypeBlueBlack) {
logoColor = AffirmColorTypeDefault;
}

AffirmPromoRequest *request = [[AffirmPromoRequest alloc] initWithPublicKey:[AffirmConfiguration sharedInstance].publicKey
promoId:self.promoID
amount:self.amount
Expand Down Expand Up @@ -351,17 +346,12 @@ - (void)configureWithAmount:(NSDecimalNumber *)amount
[AffirmValidationUtils checkNotNil:amount name:@"amount"];
self.amount = amount;

if (amount.doubleValue > [NSDecimalNumber decimalNumberWithString:AFFIRM_MAX_PROMO_AMOUNT].doubleValue) {
[self configureWithAttributedText:nil response:nil error:nil];
return;
}

AffirmColorType logoColor = affirmColor;
// Using default type when logoColor == AffirmColorTypeBlueBlack
if (logoColor == AffirmColorTypeBlueBlack) {
logoColor = AffirmColorTypeDefault;
}

AffirmPromoRequest *request = [[AffirmPromoRequest alloc] initWithPublicKey:[AffirmConfiguration sharedInstance].publicKey
promoId:self.promoID
amount:self.amount
Expand Down Expand Up @@ -427,12 +417,12 @@ - (void)configureWithHtmlString:(NSString *)htmlString
{
[AffirmValidationUtils checkNotNil:amount name:@"amount"];
self.amount = amount;

BOOL hasRemoteCss = remoteCssURL != nil;
NSString *jsURL = [AffirmConfiguration sharedInstance].jsURL;
NSURL *baseURL = [NSURL URLWithString:jsURL].baseURL;
NSMutableDictionary *matchedKeys = [@{@"{{HTML_FRAGMENT}}": htmlString} mutableCopy];

if (hasRemoteCss) {
baseURL = remoteCssURL.isFileURL ? [NSBundle mainBundle].bundleURL : remoteCssURL.baseURL;
}
Expand All @@ -442,7 +432,7 @@ - (void)configureWithHtmlString:(NSString *)htmlString
matchedKeys[@"{{JS_URL}}"] = jsURL;
matchedKeys[@"{{LOCALE}}"] = [AffirmConfiguration sharedInstance].locale;
matchedKeys[@"{COUNTRY_CODE}"] = [AffirmConfiguration sharedInstance].countryCode;

NSString *filePath = [[NSBundle resourceBundle] pathForResource:@"affirm_promo"
ofType:@"html"];
__block NSString *rawContent = [NSString stringWithContentsOfFile:filePath
Expand Down Expand Up @@ -508,7 +498,7 @@ - (void)showALAModal:(UIButton *)sender
params[@"page_type"] = FormatAffirmPageTypeString(self.pageType);
}
params[@"locale"] = [AffirmConfiguration sharedInstance].locale;

NSString *url = [NSString stringWithFormat:@"%@/apps/prequal/", [AffirmPromoClient host]];
NSURL *requestURL = [NSURL URLWithString:[NSString stringWithFormat:@"?%@", [params queryURLEncoding]]
relativeToURL:[NSURL URLWithString:url]];
Expand Down

0 comments on commit c660d4f

Please sign in to comment.