GithubHelp home page GithubHelp logo

creaturesurvive / in-tweak-purchase Goto Github PK

View Code? Open in Web Editor NEW

This project forked from imokhles/in-tweak-purchase

0.0 2.0 2.0 78.14 MB

in-tweak purchase system works with Paypal-SDK and using Parse framework to save informations

License: GNU General Public License v3.0

Objective-C 99.19% C 0.27% Roff 0.01% Makefile 0.10% Logos 0.43%

in-tweak-purchase's Introduction

In-Tweak Purchase

Platform Level License

  • in-tweak purchase system works with Paypal-iOS-SDK and ParseSDK.

  • this doesn't use any Private API all of the APIs used are Public. it uses Private API to get UDID and Serial, next step is to get an Unique identifier of each device, to secure your payments

  • You can use it within any iOS application

  • Works fine with tweaks

Tweak Demo

DemoVideo

Installation

Link against those frameworks:

Other Linker Flags:

  • -ObjC

How to integrate

#import <InTweakPurchase/InTweakPurchase.h>

// Configure your Parse Account

// inside your AppDelegate 
// you can use launchingWithOptions if u called it inside AppDelegate to track your device
// if you caleld it from another place you can put launchingWithOptions as nil

[[InTweakPurchasePaypal sharedInTweak] setParseApplicationID:@"PARSE_APP_ID" clientKey:@"PARSE_CLIENT_ID" className:@"CLASS_NAME" devicesLimit:2 launchingWithOptions:nil];

// Configure your Paypal Account

// Paypal Environments can be found inside InTweakPurchasePaypal.h
// USER_DEFAULT_ID is an NSUserDefaults key to save it after complete the purchase
[[InTweakPurchasePaypal sharedInTweak] initWithClienID:@"PAYPAL_CLIENT_ID" clientIDSandbox:@"PAYPAL_SANDBOX_CLIENT_ID" environment:PayPal_Environment andPurchaseID:@"USER_DEFAULT_ID"];

// Configure your purchase item

// ex: ITEM_NAME = @"Remove Ads"
// ex: ITEM DATA = an zip file contents dylib, zip-file, Image, music to be uploaded (if the purchase done) (just accept one file till now)
// ex: ITEM_ID = @"com.imokhles.testtweak-removeads"
// ex: ITEM_DESCRIPTION = @"purchase this item to remove ads"
// ex: PRICE = @"0.99"
// ex: ITEM_SKU = @"RMV-353553"

[[InTweakPurchasePaypal sharedInTweak] presentPaypalViewControllerFromViewController:self WithItemName:@"ITEM_NAME" andItemDataIfNedded:NSDATA_OF_ITEM inTweakID:@"ITEM_ID" Description:@"ITEM_DESCRIPTION" Quantity:1 Price:@"PRICE" Currency:@"USD" SKU:@"ITEM_SKU"];

// Checking purchase 

// u can use it as u want
[[InTweakPurchasePaypal sharedInTweak] checkTransactionInfo:@"com.imokhles.testInTweak-1" transInfo:^(NSDictionary *info, BOOL success) {
    
    /*
    Info - Output ******* {
        "device_secret_string" = BE51C5D3F7063C1057E0776459893;
        "file_object" = "<PFFile: 0x7fd3abf47740>"; // use it if u want, if not just use the getParseFileObjectWithBlock methode 
        "trans_create_time" = "2015-06-11T19:44:32Z";
        "trans_id" = "PAY-NONETWORKPDEXAMPLE123";
        "trans_state" = approved;
        }
    */
    [[NSUserDefaults standardUserDefaults] setBool:success forKey:@"USER_DEFAULT_ID"];
    [self performSelectorOnMainThread:@selector(testPurchaseNotification:) withObject:nil waitUntilDone:YES];
}];

// if there are an error u will find it easily
// ex: 2015-06-12 12:41:10.179 TestInTweak[26062:5042354] [InTweakPurchase] ERROR: The Internet connection appears to be offline.


// Restoring purchase 

// to restore purchases just ask the user about his Paypal Transacion ID
// then the framework will check everything for u
// it it will return NO, if the user reached the devices limit ( with a notification )
[[InTweakPurchasePaypal sharedInTweak] restorePurchasesForTransaction:@"PAYPAL_TRANS_ID" transInfo:^(BOOL success) {
        if (success) {
            NSLog(@"Purchased Already");
        } else {
            NSLog(@"Ops somthing goes wrong with your TRANSACTION ID");
        }
}];

// Getting file data

// if u have uploaded data when you configurated your purchase item
// you can retrive it easily from here
[[InTweakPurchasePaypal sharedInTweak] getParseFileObjectWithBlock:^(NSData *objectData) {
    // get data
    [self.imageView setImage:[UIImage imageWithData:objectData]];
} progressBlock:^(NSUInteger percentDone) {
    // get the progress value
    self.progressView.progress = percentDone;
}];

Get Payments Notifications

// Gettings payments Notifications
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(testPurchaseNotification:) name:IAProductPurchasedNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(testPurchaseNotification:) name:IAFailedProductPurchasedNotification object:nil];

// Gettings save payments information Notifications
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(testPurchaseNotification:) name:IAProductPurchasedInfoSavedNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(testPurchaseNotification:) name:IAProductPurchasedInfoFailedNotification object:nil];

// Gettings Devices limit reached notification
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(testPurchaseNotification:) name:IADevicesLimitFailedNotification object:nil];

- (void)testPurchaseNotification:(NSNotification *) notification {
    if ([notification.name isEqualToString:IAProductPurchasedNotification]) {
        //Purchased Done
    } else if ([notification.name isEqualToString:IAFailedProductPurchasedNotification]) {
        //Purchased Failed
    } else if ([notification.name isEqualToString:IAProductPurchasedInfoSavedNotification]) {
        //Purchased Info Saved Done
    } else if ([notification.name isEqualToString:IAProductPurchasedInfoFailedNotification]) {
        //Purchased Info Failed To Save
    } else if ([notification.name isEqualToString:IADevicesLimitFailedNotification]) {
        // Reached devices limit
    }
}

Notes

  • i think it will be available in Cydia as Hidden package, so
  • don't forget to depend it in your control file com.imokhles.InTweakPurchase

Contacts

If you have improvements or concerns, feel free to post an issue and write details.

Check out all iMokhles's GitHub projects. Email us with other ideas and projects.

in-tweak-purchase's People

Contributors

imokhles avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.