iOS InApp Purchases

Previous topic - Next topic

matchy

I'm not sure, but I think Apple returns the incorrect spelling of "SUCCESSFULL or is it my typo?  ;/

:good:
Anyhow, I am keen to see the first glb app with it running on the app store.

Omadan

Same here. Let us know Ampos when its live
Top Arcade Apps - Best game for mobiles and computers

http://www.toparcadeapps.com

msx


Millerszone

#18
Excellent work Ampos!
:good: :good: :good: :good: :good: :good:
Hardware: iMac 27", MacBook Air, PC 3.5Ghz Quad
Developing Tools: GLBasic SDK, Gideros Studio, PureBasic
Developing for: iOS, Android, Windows, OS X, webOS, HTML5

blackway

Ampos, you said that this wrapper doesn't work under IOS 4.2.1 .  Is this a problem related with JB or it doesn't work in any device under IOS 4.2.1  ??
Thanks!!!


ampos

I have just tested it with 1 device with iOS 4.2, I am updating one of my 3G-NoJB to 4.2.1 for testings. I dont think it is related to JB as one of the devices is JB and working.

Matchy, the part that fails is the list request. On this machine, it answer "no listed product", you knwo, the very first step.

Note that previous iAD wrapper by Matchy didnt work in iOS 4.2+, as the iOS call was changed from "display_320x50" to "display_horizontal", so we changed the routine to check first iOS version, and call one or the other. Could be this similar?

I just need to add iAD to the same app and it will be ready to be sent to Apple.
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

blackway

Quote from: ampos on 2011-Aug-10
I have just tested it with 1 device with iOS 4.2, I am updating one of my 3G-NoJB to 4.2.1 for testings. I dont think it is related to JB as one of the devices is JB and working.

Matchy, the part that fails is the list request. On this machine, it answer "no listed product", you knwo, the very first step.

Note that previous iAD wrapper by Matchy didnt work in iOS 4.2+, as the iOS call was changed from "display_320x50" to "display_horizontal", so we changed the routine to check first iOS version, and call one or the other. Could be this similar?

I just need to add iAD to the same app and it will be ready to be sent to Apple.
Thanks Ampos for your reply!

I guess that isn't a good idea to submit any app with this InApp purchases wrapper until Matchy fix this problem with IOS 4.2+

Bye!



ampos

It is not (yet) a problem with 4.2+, it is just 1 4.2 unit tested and failing. More test are needed before saying it does not work on 4.2+  :)
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

okee

Are you still liable to get pursued by Lodsys for using InApp purchasing ?
Android: Samsung Galaxy S2 -  ZTE Blade (Orange San Francisco) - Ainol Novo 7 Aurora 2
IOS: 2 x Ipod Touch (1G)

matchy

Quote from: blackway on 2011-Aug-10
Quote from: ampos on 2011-Aug-10
I have just tested it with 1 device with iOS 4.2, I am updating one of my 3G-NoJB to 4.2.1 for testings. I dont think it is related to JB as one of the devices is JB and working.

Matchy, the part that fails is the list request. On this machine, it answer "no listed product", you knwo, the very first step.

Note that previous iAD wrapper by Matchy didnt work in iOS 4.2+, as the iOS call was changed from "display_320x50" to "display_horizontal", so we changed the routine to check first iOS version, and call one or the other. Could be this similar?

I just need to add iAD to the same app and it will be ready to be sent to Apple.
Thanks Ampos for your reply!

I guess that isn't a good idea to submit any app with this InApp purchases wrapper until Matchy fix this problem with IOS 4.2+

Bye!

Please note, I am unable to use or support InApp wrapper for quite some time.  :noggin: Besides, I only run the latest official iOS version updates only.

ampos

Matchy, in fact, it is the inverse.

Your previous iAD wrapper didnt work on 4.2+ iOS, only in earlier ones.

And InApp work on all my machines (-4.2) but not on my only 4.2 machine. I have sooo many apps on my machine that I dont want to upgrade to 4.3.5, the latest.

Also, my wife iPhone is 4.1, and I dont want to upgrade her yet.

I hope to have tomorrow a different 4.2 working machine, even a 4.3.4 one.
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

matchy

How about iOS 5 beta?

ampos

Tested on 3G 4.2.1...

It runs and fail.

It request the list of current in-app purchases and it is received correctly (here it was were my 4G-4.2.0 fails), but when requesting the payment, there is no answer. Perhaps is a tremporary fail on Apple side.

Im going to test on a unJB 4G-4.3.5, the latest one.
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

ampos

To help you to implement InApp purchases, here is the full source code of my app InApp Purchase routines:

Code (glbasic) Select
FUNCTION check_free: // this one is called at the first run of the app to check if it was fully registered previously
LOCAL a$

dpat$=PLATFORMINFO$("Documents")

INIOPEN dpat$+"/prefs.txt"

a$=INIGET$("Main","Full")
a$=DECRYPT$("---",a$)
IF a$=PLATFORMINFO$("ID") THEN free=0

ENDFUNCTION

FUNCTION compra_ok:  /this one is called after a sucesfull purchase, to set the app as registered.
LOCAL a$

INIOPEN dpat$+"/prefs.txt"

INIPUT "Main","Full",ENCRYPT$("Dimas",PLATFORMINFO$("ID"))
INIOPEN dpat$+"/cccc"

ENDFUNCTION


FUNCTION compra:   // this is called to start the inapp purchases
?IFDEF IPHONE
compra_ios()
?ENDIF

?IFDEF WEBOS
compra_webos()
?ENDIF

?IFDEF WIN32
compra_win()
?ENDIF

?IFDEF ANDROID
compra_win()
?ENDIF


ENDFUNCTION

FUNCTION compra_win:  //just a call to a external paypal pay-me button or the full app
IF free=0
NETWEBEND "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KYU26B8XLMVAN&custom="+"W("+PLATFORMINFO$("ID")+")"
ELSE
NETWEBEND "http://developer.palm.com/appredirect/?packageid=com.diniplay.glowingsky"
ENDIF

REPEAT;UNTIL MOUSEAXIS(3)=0

ENDFUNCTION

FUNCTION compra_webos:
IF free=0
NETWEBEND "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KYU26B8XLMVAN&custom="+"W("+PLATFORMINFO$("ID")+")"
ELSE
NETWEBEND "http://developer.palm.com/appredirect/?packageid=com.diniplay.glowingsky"
ENDIF

REPEAT;UNTIL MOUSEAXIS(3)=0
ENDFUNCTION

FUNCTION compra_ios:   //the real iOS purchase procedure
LOCAL ys=120*appzoom,z=1,n=1,p

debu("Comprando...")

LOCAL id_list$ = "glowingsky.full,glowingsky.don1,glowingsky.don2,glowingsky.don5,glowingsky.dona1,glowingsky.dona2,glowingsky.dona5"  // product id
//notice I am asking for the purchases of the free version (...donX) and full version (...donaX). So I have not to change anything from compiling one or other version.
//iTunes will answer with the rights inApp purchases

LOCAL request_data$ = "NO_DATA"

glb_inapp_init(id_list$)
WHILE request_data$ = "NO_DATA"
main(3);ALPHAMODE -1  //main() is the background/main drawer routine
DRAWSPRITE 7,xoff,0 //it is just a banner on the top
cprint("Contacting AppStore...",xres/2,yres/2)
sc()
request_data$ = glb_inapp_product_request()
WEND  //waiting for iTunes answering if my InApp purchases list request is ok
debu("[LISTING]:" + request_data$+" [END]")

?IFDEF WIN32
request_data$="glowingsky.don1##Donation 1##0.79##Donate some money to the programmer for encouraging him for more proyects.##glowingsky.don2##Donation 2##1.59##Donate some money##glowingsky.don5##Donation 5##3.99##Donate some money##glowingsky.full##Version completa##0.79##Actualiza la app a la version completa.##"
//this is the exact string itunes will answer, used for testing on windows the rest of the code
?ENDIF

LOCAL item$[]
LOCAL item_count = SPLITSTR(request_data$, item$[], "##")   //split the previous string
LOCAL i   

FreeZones()

IF item_count > 3  //if the answer is less than 3 strings, there was an error
REPEAT
ys=120*appzoom;n=1
main(3);ALPHAMODE -1
ADRAWSPRITE 7,xoff,0
DRAWSPRITE 3,(xres-(640*appzoom))/2,ys  //draw a button
cprint("CHOOSE YOUR OPTION",xres/2,ys+(20*appzoom));INC ys,100*appzoom
FOR i = 0 TO item_count - 1 STEP 4
IF item$[i]="glowingsky.full" AND free=0  //if free=1 then is is the full app, instead it is the lite. Not sure now about this IF
// Oh, I remember, was to remove the FULL button, in case it was registered and the user just want to donate me extra money
ELSE
DRAWSPRITE 8,(xres-boton)/2,ys  //draw a button
PRINT UCASE$(item$[i+1]),(xres-boton)/2+(20*appzoom),ys+(40*appzoom),1
PRINT item$[i+2],((xres-boton)/2)+boton-(24*appzoom)-LEN(item$[i+2],1),ys+(44*appzoom),1
CreateZone(n,0,ys,xres,124*appzoom);INC n
INC ys,120*appzoom
ENDIF
NEXT

INC ys,20*appzoom
DRAWSPRITE 3,(xres-(640*appzoom))/2,ys
cprint ("CANCEL",xres/2,ys+(24*appzoom))
CreateZone(100,0,ys,xres,124*appzoom)  //the cancel button

IF free=1
INC ys,90*appzoom
cprint("Any purchase will",xres/2,ys)
cprint("unlock full program",xres/2,ys+(40*appzoom))
ENDIF

MOUSESTATE mx,my,b1,b2
z=Zone(mx,my)

sc()  //bassically, a showscreen()
UNTIL b1=1 AND z<>0
ELSE  //I said if it has no answer...
REPEAT;UNTIL MOUSEAXIS(3)=0
REPEAT
main(3);ALPHAMODE -1
cprint ("NO ACCESS or ERROR.",xres/2,yres/2)
sc()
UNTIL MOUSEAXIS(3)<>0
RETURN
ENDIF

IF z=100 THEN RETURN  //Zone 100 was a cancel button

debu("COSA:"+item$[(z-1)*4])  //debu is my debug routine

glb_inapp_buy(item$[(z-1)*4])
request_data$ = "NO_DATA"

REPEAT  //user choose a purchase. Wait for itunes to validate (or not) it
main(3);ALPHAMODE -1
ys=120*appzoom;n=1
DRAWSPRITE 3,(xres-(640*appzoom))/2,ys
cprint("REQUESTING PURCHASE",xres/2,ys+(20*appzoom));INC ys,100*appzoom

FOR i = 0 TO item_count - 1 STEP 4  //draw the butttons while waiting
IF item$[i]="glowingsky.full" AND free=0
//
ELSE
IF n=z   //the choosen one is brighter
ALPHAMODE -1
ELSE
ALPHAMODE -.5
ENDIF
INC n
DRAWSPRITE 8,(xres-boton)/2,ys
PRINT UCASE$(item$[i+1]),(xres-boton)/2+(20*appzoom),ys+(40*appzoom),1
PRINT item$[i+2],((xres-boton)/2)+boton-(24*appzoom)-LEN(item$[i+2],1),ys+(44*appzoom),1
INC ys,120*appzoom
ENDIF
NEXT
ALPHAMODE -1
sc()
request_data$ = UCASE$(glb_inapp_product_request())
UNTIL request_data$="TRANSACTION_SUCCESSFUL" OR request_data$="TRANSACTION_FAILED"  //what is the "TRANSACTION_CANCELED" text?

IF request_data$ = "TRANSACTION_SUCCESSFUL" THEN compra_ok()  //yeah, it works!!! muahahaha!!!!

FOR p=0 TO 10*60   //just a delay
cuadrao();main(3);ALPHAMODE -1
ys=120*appzoom;n=1
DRAWSPRITE 3,(xres-(640*appzoom))/2,ys
IF request_data$ = "TRANSACTION_SUCCESSFUL"
cprint("PURCHASE SUCESSFUL",xres/2,ys+(20*appzoom));INC ys,100*appzoom
free=0
ELSEIF request_data$ = "TRANSACTION_FAILED"
cprint("PURCHASE FAILED",xres/2,ys+(20*appzoom));INC ys,100*appzoom
ENDIF

FOR i = 0 TO item_count - 1 STEP 4
IF item$[i]="glowingsky.full" AND free=0
//
ELSE
IF n=z
ALPHAMODE -1
ELSE
ALPHAMODE -.5
ENDIF
INC n
DRAWSPRITE 8,(xres-boton)/2,ys
PRINT UCASE$(item$[i+1]),(xres-boton)/2+(20*appzoom),ys+(40*appzoom),1
PRINT item$[i+2],((xres-boton)/2)+boton-(24*appzoom)-LEN(item$[i+2],1),ys+(44*appzoom),1
INC ys,120*appzoom
ENDIF
NEXT
ALPHAMODE -1
IF MOUSEAXIS(3)<>0 THEN BREAK
sc()
NEXT
cargas()

ENDFUNCTION
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

matchy