Help integrating Stripe payment processing
See original GitHub issueI’m working on trying to integrate a payment processor into Kivy. I’ve got Stripe working on Android which wasn’t too bad with Pyjnius but now I’m trying to do the same with kivy-ios. The amount of code it takes is pretty simple.
STPCardParams * cardParams = [[STPCardParams alloc] init];
cardParams.number = @"4242424242424242";
cardParams.expMonth = 10;
cardParams.expYear = 2018;
cardParams.cvc = @"123";
[[STPAPIClient sharedClient] createTokenWithCard:cardParams completion: ^ (STPToken * token, NSError * error){if (token == nil || error != nil){// Presenterrortouser...return;}
[self submitTokenToBackend:tokencompletion: ^ (NSError * error){if (error){// Presenterrortouser...}else {// Continuewith payment...}}];}];
I was going to go about it with pyobjus but then I ran into this issue with the completion:^ blocker https://github.com/kivy/pyobjus/issues/32. So I can’t use that so now I’m working on writing in obj-c and wrapping it with cython like the AVfoundation for the camera (https://github.com/kivy/kivy/tree/master/kivy/core/camera). So far I’ve got a rough wrapper made https://github.com/GoBig87/Stripe_iOS_Wrapper/tree/0.1 and a recipe to build a lib for it with this recipe
from toolchain import CythonRecipe, shprint
from os.path import join
from distutils.dir_util import copy_tree
import fnmatch
import sh
import os
class StripeRecipe(CythonRecipe):
version = "0.1"
url = "https://github.com/GoBig87/Stripe_iOS_Wrapper/archive/{version}.zip"
library = "stripe_ios.a"
pbx_frameworks = ['Stripe']
depends = ["python","hostpython"]
def install(self):
pass
arch = list(self.filtered_archs)[0]
build_dir = join(self.get_build_dir(arch.arch),'build','lib.macosx-10.13-x86_64-2.7')
dist_dir = join(self.ctx.dist_dir,'root','python','lib','python2.7','site-packages','stripe_ios')
copy_tree(build_dir, dist_dir)
def biglink(self):
dirs = []
for root, dirnames, filenames in os.walk(self.build_dir):
if fnmatch.filter(filenames, "*.so.*"):
dirs.append(root)
cmd = sh.Command(join(self.ctx.root_dir, "tools", "biglink"))
shprint(cmd, join(self.build_dir, "stripe_ios.a"), *dirs)
recipe = StripeRecipe()
which when building with ./toolchain.py gives the following
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (10 by maintainers)
Top GitHub Comments
So I got it working. My method was to use cython to wrap C which wrapped objc. The stripe objc framework was then able to be called and return a value to my app with a call back. I’ll leave a more detailed update with a pull request with the stripe recipe. The codes all online right now on my github page just got to submit it properly.
Closing as this is not really a Kivy issue? Thanks