venmo / venmo-ios-sdk

Make and accept payments in your iOS app via Venmo
MIT License
178 stars 57 forks source link

iOS SDK malfunction/ request feature unavailable? #71

Closed sudov closed 9 years ago

sudov commented 9 years ago

Here is code for a payment through my app, the console says "Transaction successful" but I don't see that reflected ANYWHERE on my venmo account. What is going on?

Venmo.sharedInstance().sendPaymentTo("15555555555", amount: 1, note: "Test", audience: VENTransactionAudience.Private) {
                    (transaction: VENTransaction!, success: Bool!, error:NSError!) -> Void in
                    if (success != nil) {
                        println("Transaction went through!")
                    } else {
                        println("Transaction failed")
                    }
                }

Secondly, I want to REQUEST money in my function not PAY. Is this not supported?

sudov commented 9 years ago

In the event that requesting through the API is not supported, I tried doing an NSURL based request and get the following error.

Optional({
    error =     {
        code = 261;
        message = "You did not pass a valid OAuth access token.";
    };
})

My URL reads:

https://api.venmo.com/v1/payments?token=<super_long_token>&phone=<some_phone>&amount=0.01&note=SplitPEAAAAAS&audience=private

Not sure how to proceed. Help?

sudov commented 9 years ago

EDIT: the NSURL approach works (swapped token= for access_token=). I would still like to know whether the SDK has a function to request money instead of paying.

diogeneshamilton commented 9 years ago

@sudov I'm pretty sure setting the amount to something negative will send a request.

sudov commented 9 years ago

@diogeneshamilton no the datatype is NSUInteger (cant remember of the top of my head exaclty) and only takes positive values

sudov commented 9 years ago

Yup, just checked, the error that shows up when using a negative number is "Integer literal overflows when stored into UInt"

sudov commented 9 years ago

@eliperkins is this a bug in the way Swift interprets the Objective C function?

eliperkins commented 9 years ago

@sudov there are native ways to do this via the SDK. Please see [Venmo -sendRequestTo:amount:note:completionHandler:]: https://github.com/venmo/venmo-ios-sdk/blob/master/venmo-sdk/Venmo.h#L143-L168

sudov commented 9 years ago

@eliperkins yup thats exactly what I did (My app is in Swift and I'm using a bridging header, could that be a problem?)

sudov commented 9 years ago

@eliperkins Notice the datatype is NSUInteger not NSInteger!!! (so unsigned!!! how could an unsigned number be negative (in the case of a charge)

eliperkins commented 9 years ago

Are you referring to the Integer literal overflows when stored into UInt issue you discussed? This value should always be a positive number. We handle the value inside of the Venmo app upon app switch, internally. You should provide a positive integer here.

sudov commented 9 years ago

But then how do you differentiate between a charge and a payment?

eliperkins commented 9 years ago

Payments are created via sendPaymentTo:, where as charges are created via sendRequestTo:.

sudov commented 9 years ago

Oh boy, my bad. Thanks man.