Skip to content

Commit 24abdcc

Browse files
committed
Allow adding an NSMutableDictionary or an NSMutableArray directly to metadata
1 parent 24aef8b commit 24abdcc

File tree

11 files changed

+73
-10
lines changed

11 files changed

+73
-10
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
=== 3.0.5 2018-04-13
2+
3+
* Allow adding an NSMutableDictionary or an NSMutableArray directly to metadata
4+
15
=== 3.0.4 2017-05-25
26

37
* Hotfix Ensure we notify caller when showing or dismissing our dialogs

Example/Paystack iOS Example.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@
329329
SDKROOT = iphoneos;
330330
SWIFT_OBJC_BRIDGING_HEADER = "Paystack iOS Example (Simple)/Paystack iOS Example (Simple)-Bridging-Header.h";
331331
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
332+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
332333
};
333334
name = Debug;
334335
};
@@ -374,6 +375,7 @@
374375
SDKROOT = iphoneos;
375376
SWIFT_OBJC_BRIDGING_HEADER = "Paystack iOS Example (Simple)/Paystack iOS Example (Simple)-Bridging-Header.h";
376377
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
378+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
377379
VALIDATE_PRODUCT = YES;
378380
};
379381
name = Release;

Example/Paystack iOS Example/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>3.0.4</string>
18+
<string>3.0.5</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

Example/Paystack iOS Example/ViewController.swift

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class ViewController: UIViewController, PSTCKPaymentCardTextFieldDelegate {
7979
return
8080
}
8181
showOkayableMessage("Backend not configured", message:"To run this sample, please configure your backend.")
82-
82+
// chargeWithSDK(newCode:"");
8383

8484
}
8585

@@ -108,9 +108,20 @@ class ViewController: UIViewController, PSTCKPaymentCardTextFieldDelegate {
108108
let transactionParams = PSTCKTransactionParams.init();
109109
transactionParams.access_code = newCode as String;
110110
//transactionParams.additionalAPIParameters = ["enforce_otp": "true"];
111-
//transactionParams.email = "[email protected]";
112-
//transactionParams.amount = 2000;
113-
111+
// transactionParams.email = "[email protected]";
112+
// transactionParams.amount = 2000;
113+
// let dictParams: NSMutableDictionary = [
114+
// "recurring": true
115+
// ];
116+
// let arrParams: NSMutableArray = [
117+
// "0","go"
118+
// ];
119+
// do {
120+
// try transactionParams.setMetadataValueDict(dictParams, forKey: "custom_filters");
121+
// try transactionParams.setMetadataValueArray(arrParams, forKey: "custom_array");
122+
// } catch {
123+
// print(error)
124+
// }
114125
// use library to create charge and get its reference
115126
PSTCKAPIClient.shared().chargeCard(self.cardDetailsForm.cardParams, forTransaction: transactionParams, on: self, didEndWithError: { (error, reference) in
116127
self.outputOnLabel(str: "Charge errored")

GUIDE.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,18 @@ You will need to specify callbacks too. Each will be called depending on how the
261261

262262
// building new Paystack Transaction
263263
transactionParams.amount = 1390;
264+
let custom_filters: NSMutableDictionary = [
265+
"recurring": true
266+
];
267+
let items: NSMutableArray = [
268+
"Bag","Glasses"
269+
];
264270
do {
265271
try transactionParams.setCustomFieldValue("iOS SDK", displayedAs: "Paid Via");
266272
try transactionParams.setCustomFieldValue("Paystack hats", displayedAs: "To Buy");
267273
try transactionParams.setMetadataValue("iOS SDK", forKey: "paid_via");
274+
try transactionParams.setMetadataValueDict(custom_filters, forKey: "custom_filters");
275+
try transactionParams.setMetadataValueArray(items, forKey: "items");
268276
} catch {
269277
print(error);
270278
}

Paystack.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Paystack'
3-
s.version = '3.0.4'
3+
s.version = '3.0.5'
44
s.summary = 'Paystack is a web-based API helping African Businesses accept payments online.'
55
s.description = <<-DESC
66
Paystack makes it easy for African Businesses to accept Mastercard, Visa and Verve cards from anyone, anywhere in the world.

Paystack/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>3.0.4</string>
18+
<string>3.0.5</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

Paystack/PSTCKTransactionParams.m

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,36 @@ - (PSTCKTransactionParams *) setMetadataValue:(NSString*)value
4949
return [self _setMetadataValue:value forKey:key error:error];
5050
}
5151

52+
- (PSTCKTransactionParams *) setMetadataValueDict:(NSMutableDictionary*)dict
53+
forKey:(NSString*)key
54+
error:(NSError**) error {
55+
if([@"custom_fields" isEqualToString:key]){
56+
*error = [[NSError alloc] initWithDomain:PaystackDomain
57+
code:PSTCKTransactionError
58+
userInfo:@{
59+
NSLocalizedDescriptionKey: PSTCKUnexpectedError,
60+
PSTCKErrorMessageKey: PSTCKTransactionErrorDontSetCustomFieldDirectlyMessage
61+
}];
62+
return nil;
63+
}
64+
return [self _setMetadataValue:dict forKey:key error:error];
65+
}
66+
67+
- (PSTCKTransactionParams *) setMetadataValueArray:(NSMutableArray*)arr
68+
forKey:(NSString*)key
69+
error:(NSError**) error {
70+
if([@"custom_fields" isEqualToString:key]){
71+
*error = [[NSError alloc] initWithDomain:PaystackDomain
72+
code:PSTCKTransactionError
73+
userInfo:@{
74+
NSLocalizedDescriptionKey: PSTCKUnexpectedError,
75+
PSTCKErrorMessageKey: PSTCKTransactionErrorDontSetCustomFieldDirectlyMessage
76+
}];
77+
return nil;
78+
}
79+
return [self _setMetadataValue:arr forKey:key error:error];
80+
}
81+
5282
- (PSTCKTransactionParams *) _setMetadataValue:(NSObject*) value
5383
forKey:(NSString*)key
5484
error:(NSError**) error {

Paystack/PublicHeaders/PSTCKAPIClient.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#import <UIKit/UIViewController.h>
99
#endif
1010

11-
static NSString *const __nonnull PSTCKSDKVersion = @"3.0.4";
12-
static NSString *const __nonnull PSTCKSDKBuild = @"13";
11+
static NSString *const __nonnull PSTCKSDKVersion = @"3.0.5";
12+
static NSString *const __nonnull PSTCKSDKBuild = @"14";
1313

1414
@class PSTCKCard, PSTCKCardParams, PSTCKTransactionParams, PSTCKToken;
1515

Paystack/PublicHeaders/PSTCKTransactionParams.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
forKey:(nonnull NSString*)key
2727
error:(NSError * _Nullable __autoreleasing * _Nonnull) error;
2828

29+
- (nullable PSTCKTransactionParams *) setMetadataValueDict:(nonnull NSMutableDictionary*)dict
30+
forKey:(nonnull NSString*)key
31+
error:(NSError * _Nullable __autoreleasing * _Nonnull) error;
32+
33+
- (nullable PSTCKTransactionParams *) setMetadataValueArray:(nonnull NSMutableArray*)arr
34+
forKey:(nonnull NSString*)key
35+
error:(NSError * _Nullable __autoreleasing * _Nonnull) error;
36+
2937
- (nullable PSTCKTransactionParams *) setCustomFieldValue:(nonnull NSString*)value
3038
displayedAs:(nonnull NSString*)display_name
3139
error:(NSError * _Nullable __autoreleasing * _Nonnull) error;

0 commit comments

Comments
 (0)