Skip to content

Instantly share code, notes, and snippets.

@jasminsuljic
Last active January 30, 2017 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasminsuljic/9bb41d0e4ecd037d3d50c072cf5e8455 to your computer and use it in GitHub Desktop.
Save jasminsuljic/9bb41d0e4ecd037d3d50c072cf5e8455 to your computer and use it in GitHub Desktop.
//
// PgwApiExampleViewController.m
// pay
//
// Created by Jasmin Suljic on 22/12/16.
// Copyright © 2016 Webteh.hr. All rights reserved.
//
#import "PgwApiExampleViewController.h"
#import "PgwApi.h"
#import "TransactionErrorDetailed.h"
#import <AFNetworking/AFNetworking.h>
#import "PayModel.h"
@interface PgwApiExampleViewController ()
@end
@implementation PgwApiExampleViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
PgwApi *api = [[PgwApi alloc] init:@"00001111222233330000111122223333" isDebug:true];
if (_isGetError) {
[api getError:1 success:^(TransactionErrorDetailed *error){
NSLog(@"getErrorSuccess: %@", error);
}failure:^(ApiError * error){
NSLog(@"getErrorFailure: %@", error);
}];
} else if(_isCheckTransaction){
[api checkTransaction:80803 success: ^(Transaction *transaction ){
NSLog(@"checkTransactionSuccess: %@", transaction);
}failure: ^(ApiError *error){
NSLog(@"checkTransactionFailure: %@", error);
}];
} else if(_isCheckOrder) {
// will only work with new transactions
ShowOrderModel *model = [[ShowOrderModel alloc] init];
model.orderNumber = @"1484635152";
// merchantKey + orderNumber
model.digest = [PayModel sha1:[NSString stringWithFormat:@"%@%@", @"TestKeyXULLyvgWyPJSwOHe", model.orderNumber]];
[api checkOrder:model success:^(TransactionSuccess *model){
NSLog(@"checkOrder: %@", model);
} failure:^(ApiError *error){
NSLog(@"checkOrderFailure: %@", error);
}];
} else{
ShowOrderModel *model = [[ShowOrderModel alloc] init];
model.digest = @"16ef726f3111de11ee8e4e47431bebad58e0ce14"; //sha1(merchantKey + orderNumber)
model.orderNumber = @"1482240015006";
[api checkOrderId:model success:^(ShowOrderResponse *model){
NSLog(@"checkOrderIdSuccess: %@", model);
} failure:^(ApiError *error){
NSLog(@"checkOrderIdFailure: %@", error);
}];
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment