Skip to content

Commit a732427

Browse files
update obj-c examples
1 parent 00ea333 commit a732427

File tree

4 files changed

+32
-29
lines changed

4 files changed

+32
-29
lines changed

ExampleObjc/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PODS:
2-
- dojo-ios-sdk (0.2.0)
2+
- dojo-ios-sdk (0.7.8)
33

44
DEPENDENCIES:
55
- dojo-ios-sdk (from `../`)
@@ -9,7 +9,7 @@ EXTERNAL SOURCES:
99
:path: "../"
1010

1111
SPEC CHECKSUMS:
12-
dojo-ios-sdk: 42ce63330491333a73debc5d30324406a7cb3105
12+
dojo-ios-sdk: 9bfcaf7823b66fb7ec12b39ff31a29151e4ab200
1313

1414
PODFILE CHECKSUM: c2c88c22a0509eb52947865fab240d6e519f2e30
1515

ExampleObjc/dojo-ios-sdk-Example-Objc/ViewController.m

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ @implementation ViewController
1717
- (void)viewDidLoad {
1818
[super viewDidLoad];
1919
// Uncomment to test
20-
// [self executeCardPayment];
20+
[self executeCardPayment];
2121
// [self executeApplePayPayment];
2222
}
2323

@@ -26,27 +26,28 @@ - (void)executeCardPayment {
2626
initWithCardDetails: [[DojoCardDetails alloc]
2727
initWithCardNumber:@"4456530000001096"
2828
cardName:@"Card Holder Name"
29-
expiryDate:@"12/24"
29+
expiryDate:@"12 / 24"
3030
cv2:@"020"]
3131
userEmailAddress: NULL
3232
userPhoneNumber: NULL
3333
billingAddress: NULL
3434
shippingDetails: NULL
3535
metaData: NULL
36-
isSandbox: NO];
37-
NSString *token = @"Token from Payment Intent (connecteToken)";
36+
savePaymentMethod: FALSE];
37+
NSString *token = @"Token from Payment Intent";
3838
[DojoSDK executeCardPaymentWithToken: token payload: cardPaymentPayload fromViewController: self completion:^(NSInteger result) {
3939
NSLog(@"%ld", (long)result);
4040
}];
4141
}
4242

4343
- (void)executeApplePayPayment {
4444
DojoApplePayConfig *applePayConfig = [[DojoApplePayConfig alloc] initWithMerchantIdentifier: @"merchant.uk.co.paymentsense.sdk.demo.app"
45+
supportedCards: [NSArray arrayWithObjects: @"visa", @"mastercard", nil]
4546
collectBillingAddress: FALSE
4647
collectShippingAddress: FALSE
4748
collectEmail: FALSE];
48-
DojoApplePayPayload *applePayPayload = [[DojoApplePayPayload alloc] initWithApplePayConfig: applePayConfig email: NULL metaData: NULL isSandbox: NO];
49-
DojoPaymentIntent *paymentIntent = [[DojoPaymentIntent alloc] initWithConnecteToken: @"Token from Payment Intent (connecteToken)" totalAmount: [[DojoPaymentIntentAmount alloc] initWithValue: 120 currencyCode:@"GBP"]]; // TODO move to Swift as well
49+
DojoApplePayPayload *applePayPayload = [[DojoApplePayPayload alloc] initWithApplePayConfig: applePayConfig userEmailAddress: NULL metaData: NULL];
50+
DojoPaymentIntent *paymentIntent = [[DojoPaymentIntent alloc] initWithId: @"PaymentIntent ID" clientSessionSecret: @"Token from Payment Intent" totalAmount: [[DojoPaymentIntentAmount alloc] initWithValue: 120 currencyCode:@"GBP"]];
5051

5152
[DojoSDK executeApplePayPaymentWithPaymentIntent: paymentIntent payload: applePayPayload fromViewController:self completion: ^(NSInteger result) {
5253
NSLog(@"%ld", (long)result);

README.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dojo-ios-sdk is available through [CocoaPods](https://cocoapods.org). To install
1414
it, simply add the following line to your Podfile:
1515

1616
```ruby
17-
pod 'dojo-ios-sdk', :git => '[email protected]:Dojo-Engineering/dojo-ios-sdk.git', :tag => '0.7.0'
17+
pod 'dojo-ios-sdk', :git => '[email protected]:Dojo-Engineering/dojo-ios-sdk.git', :tag => '1.0.0'
1818
```
1919
## How to use
2020
SDK functionality can be accessed via DojoSdk object.
@@ -25,28 +25,28 @@ SDK functionality can be accessed via DojoSdk object.
2525
```swift
2626
import dojo_ios_sdk
2727

28-
let cardPaymentPayload = DojoCardPaymentPayload(cardDetails: DojoCardDetails(cardNumber: "4456530000001096", cardName: "Card Holder Name", expiryDate: "12 / 24", cv2: "020"), isSandbox: true)
28+
let cardPaymentPayload = DojoCardPaymentPayload(cardDetails: DojoCardDetails(cardNumber: "4456530000001096", cardName: "Card Holder Name", expiryDate: "12 / 24", cv2: "020"))
2929
let token = "Token from Payment Intent (connecteToken)"
3030
DojoSDK.executeCardPayment(token: token,
3131
payload: cardPaymentPayload,
3232
fromViewController: self) { [weak self] result in
3333
print(result)
3434
}
3535
```
36-
This example includes only required fields, you can find additional fields that can be passed in the API reference. // TODO URL
36+
This example includes only required fields, you can find additional fields that can be passed in the API reference.
3737

3838
### ApplePay Payment
3939
```swift
4040
import dojo_ios_sdk
4141

42-
let applePayConfig = DojoApplePayConfig(merchantIdentifier:"merchant.uk.co.paymentsense.sdk.demo.app")
43-
let applePayPayload = DojoApplePayPayload(applePayConfig: applePayConfig, isSandbox: true)
44-
let paymentIntent = DojoPaymentIntent(connecteToken: "Token from Payment Intent (connecteToken)", totalAmount: DojoPaymentIntentAmount(value: 120, currencyCode: "GBP")) // TODO - this values should be populated from payment intent
42+
let applePayConfig = DojoApplePayConfig(merchantIdentifier:"merchant.uk.co.paymentsense.sdk.demo.app", supportedCards: ["visa","mastercard", "amex", "maestro"])
43+
let applePayPayload = DojoApplePayPayload(applePayConfig: applePayConfig)
44+
let paymentIntent = DojoPaymentIntent(id: "Payment intent ID", totalAmount: DojoPaymentIntentAmount(value: 120, currencyCode: "GBP"))
4545
DojoSDK.executeApplePayPayment(paymentIntent: paymentIntent, payload: applePayPayload, fromViewController: self) { [weak self] result in
4646
print(result)
4747
}
4848
```
49-
This example includes only required fields, you can find additional fields that can be passed in the API reference. // TODO URL
49+
This example includes only required fields, you can find additional fields that can be passed in the API reference.
5050

5151
## Objective-C
5252

@@ -66,8 +66,8 @@ DojoCardPaymentPayload* cardPaymentPayload = [[DojoCardPaymentPayload alloc]
6666
billingAddress: NULL
6767
shippingDetails: NULL
6868
metaData: NULL
69-
isSandbox: YES];
70-
NSString *token = @"Token from Payment Intent (connecteToken)";
69+
savePaymentMethod: FALSE];
70+
NSString *token = @"Token from Payment Intent";
7171
[DojoSDK executeCardPaymentWithToken: token payload: cardPaymentPayload fromViewController: self completion:^(NSInteger result) {
7272
NSLog(@"%ld", (long)result);
7373
}];
@@ -79,17 +79,19 @@ NSString *token = @"Token from Payment Intent (connecteToken)";
7979
#import <dojo_ios_sdk/dojo_ios_sdk-Swift.h>
8080
8181
DojoApplePayConfig *applePayConfig = [[DojoApplePayConfig alloc] initWithMerchantIdentifier: @"merchant.uk.co.paymentsense.sdk.demo.app"
82+
supportedCards: [NSArray arrayWithObjects: @"visa", @"mastercard", nil]
8283
collectBillingAddress: FALSE
8384
collectShippingAddress: FALSE
84-
collectEmail: FALSE];
85-
DojoApplePayPayload *applePayPayload = [[DojoApplePayPayload alloc] initWithApplePayConfig: applePayConfig email: NULL metaData: NULL isSandbox: YES];
86-
DojoPaymentIntent *paymentIntent = [[DojoPaymentIntent alloc] initWithConnecteToken: @"Token from Payment Intent (connecteToken)" totalAmount: [[DojoPaymentIntentAmount alloc] initWithValue: 120 currencyCode:@"GBP"]]; / TODO - this values should be populated from payment intent
85+
collectEmail: FALSE];
86+
DojoApplePayPayload *applePayPayload = [[DojoApplePayPayload alloc] initWithApplePayConfig: applePayConfig userEmailAddress: NULL metaData: NULL];
87+
DojoPaymentIntent *paymentIntent = [[DojoPaymentIntent alloc] initWithId: @"PaymentIntent ID" clientSessionSecret: @"Token from Payment Intent" totalAmount: [[DojoPaymentIntentAmount alloc] initWithValue: 120 currencyCode:@"GBP"]];
88+
8789
[DojoSDK executeApplePayPaymentWithPaymentIntent: paymentIntent payload: applePayPayload fromViewController:self completion: ^(NSInteger result) {
8890
NSLog(@"%ld", (long)result);
8991
}];
9092
```
9193

92-
This example includes only required fields, you can find additional fields that can be passed in the API reference. // TODO URL
94+
This example includes only required fields, you can find additional fields that can be passed in the API reference.
9395

9496

9597
## Result codes

dojo-ios-sdk/Classes/DojoSDK.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protocol DojoSDKProtocol {
3939
/// - payload: Payment configuration and data.
4040
/// - fromViewController: Controller to present 3DS over.
4141
/// - completion: Result of the payment.
42-
public static func executeCardPayment(token: String,
42+
@objc public static func executeCardPayment(token: String,
4343
payload: DojoCardPaymentPayload,
4444
fromViewController: UIViewController,
4545
completion: ((Int) -> Void)?) {
@@ -55,7 +55,7 @@ protocol DojoSDKProtocol {
5555
/// - payload: Payment configuration and data.
5656
/// - fromViewController: Controller to present 3DS over.
5757
/// - completion: Result of the payment.
58-
public static func executeSavedCardPayment(token: String,
58+
@objc public static func executeSavedCardPayment(token: String,
5959
payload: DojoSavedCardPaymentPayload,
6060
fromViewController: UIViewController,
6161
completion: ((Int) -> Void)?) {
@@ -72,7 +72,7 @@ protocol DojoSDKProtocol {
7272
/// - payload: Apple Pay configuration
7373
/// - fromViewController: Controller to present ApplePay UI over
7474
/// - completion: Result of the payment.
75-
public static func executeApplePayPayment(paymentIntent: DojoPaymentIntent,
75+
@objc public static func executeApplePayPayment(paymentIntent: DojoPaymentIntent,
7676
payload: DojoApplePayPayload,
7777
fromViewController: UIViewController,
7878
completion: ((Int) -> Void)?) {
@@ -87,15 +87,15 @@ protocol DojoSDKProtocol {
8787
/// Check if apple pay is available for this device
8888
/// - Parameter config: Apple Pay configuration
8989
/// - Returns: Availability of ApplePay for a particular device
90-
public static func isApplePayAvailable(config: DojoApplePayConfig) -> Bool {
90+
@objc public static func isApplePayAvailable(config: DojoApplePayConfig) -> Bool {
9191
ApplePayHandler.shared.canMakeApplePayPayment(config: config)
9292
}
9393

9494
/// Fetch a payment intent
9595
/// - Parameters:
9696
/// - intentId: ID of payment Intent [reference](https://docs.dojo.tech/api#tag/Payment-intents)
9797
/// - completion: Payment Intent in String (JSON) format or error
98-
public static func fetchPaymentIntent(intentId: String,
98+
@objc public static func fetchPaymentIntent(intentId: String,
9999
completion: ((String?, Error?) -> Void)?) {
100100
handlePaymentIntentFetching(intentId: intentId, completion: completion)
101101
}
@@ -104,7 +104,7 @@ protocol DojoSDKProtocol {
104104
/// - Parameters:
105105
/// - intentId: Id of payment Intent [reference](https://docs.dojo.tech/api#tag/Payment-intents)
106106
/// - completion: Payment Intent in String (JSON) format or error
107-
public static func refreshPaymentIntent(intentId: String,
107+
@objc public static func refreshPaymentIntent(intentId: String,
108108
completion: ((String?, Error?) -> Void)?) {
109109
handlePaymentIntentRefresh(intentId: intentId, completion: completion)
110110
}
@@ -114,7 +114,7 @@ protocol DojoSDKProtocol {
114114
/// - customerId: Id of the customer
115115
/// - customerSecret: Access key for the customer
116116
/// - completion: Customer's saved payment methods in String (JSON) format or error
117-
public static func fetchCustomerPaymentMethods(customerId: String,
117+
@objc public static func fetchCustomerPaymentMethods(customerId: String,
118118
customerSecret: String,
119119
completion: ((String?, Error?) -> Void)?) {
120120
handleFetchCustomerPaymentMethods(customerId: customerId, customerSecret: customerSecret, completion: completion)
@@ -126,7 +126,7 @@ protocol DojoSDKProtocol {
126126
/// - paymentMethodId: Id of the payment method to delete
127127
/// - customerSecret: Access key for the customer
128128
/// - completion:
129-
public static func deleteCustomerPaymentMethod(customerId: String,
129+
@objc public static func deleteCustomerPaymentMethod(customerId: String,
130130
paymentMethodId: String,
131131
customerSecret: String,
132132
completion: ((Error?) -> Void)?) {

0 commit comments

Comments
 (0)