Alpha Video Training
Results 1 to 3 of 3

Thread: Stripe and cURL

  1. #1
    Member
    Real Name
    Jmo
    Join Date
    May 2013
    Posts
    359

    Default Stripe and cURL

    I wanted to put this here as I see a lot of users who I know will probably show me exactly what I am missing (though it doesn't pertain to the DocuSign API but rather Stripe)..

    I have been very successful in implementing using stripe for subscriptions using Alphas cURL genie but today I saw 5 different people try to subscribe (I send myself an email when they click the button that on my site opens the a5w page that has the stripe checkout html on it so I know someone attempted to subscribe) but I never got an email saying their subscription was set up (which occurs when they submit the stripe checkout and the token is sent to another a5w page that contains all the cURL code and xBasic that updates my database). The issue I am running into is with the below xBasic generated by the genie:

    Code:
    flag_1 = ce.Exec()
    if flag_1 then
         
            dim headers as c
    	dim contents as c
    	dim response as p
    	headers = cf_1.GetHeaders()
    	contents = cf_1.GetContent()
            response = json_parse(contents)
    	
    else 
    
    	errors = ce.error()
    
    
    end if
    ce.close()
    I expected that flag would be true if the call succeeded and the card was charged and false if it failed and there was an error from stripe (which would end up in ce.error()), however instead the flag_1 returns true no matter what if there was an error (i.e. card declined). I'm fine with this but the problem is the returned JSON (and resulting dot variable in response) from stripe doesn't always have an error property so I am trying to figure out how I can check if the error property exists so that if it does I can show an error to the user and if it doesn't I can tell the user their card was charged. If the error property returned as null when a successful charge occurred I would be fine but the issue I run into is when there is an error my error checking works but when there isn't an error my xBasic fails because it can't find the "response.error" property. I thought I might be able to use variable_exists() but this didn't work so any ideas on what I can do here?

  2. #2
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,683

    Default Re: cURL Xbasic Object

    Josh... I would start a new thread on this. It's very different stuff.

    flag_1 returns true because the cURL call itself didn't fail. It was a good call. Put some garbage into some cURL property so that it fails and you'll catch the else section. Whether or not what was suppose to happen actually happened is another matter. You heed to examine contents for what happened on the Stripe end.

    Further... who is sending the email? You... or Stripe?

    Lastly, why use cURL? Stripe was already implemented on the Javascript and NodeJS side. It works and is lovely to use.

  3. #3
    Member
    Real Name
    Jmo
    Join Date
    May 2013
    Posts
    359

    Default Re: cURL Xbasic Object

    I finally found some xBasic information on how to look at a dot variable and see if a property exists (specifically the prop_valid() function). With this I can check if the "error" property is inside my response dot variable so all is well now (wasn't easy finding that function though but sure glad it exists)!

    I'm using cURL because all my attempts at using node.js failed miserably and I wasn't sure the best way to debug the node.js (also I would have had to write the node.js files myself where the cURL genie created the code for me and I could just tweak it to work for my use case). Is there a reason to use node.js over cURL that I am missing?

    Also, the emails were coming from alpha (i.e. I was using them to alert me of what was going on) though this is moot now that I figured out how to check the dot variable. I do appreciate your quick response though!

Similar Threads

  1. curl Genie Issues
    By JoePK in forum Mobile & Browser Applications
    Replies: 7
    Last Post: 11-25-2015, 12:41 PM
  2. cURL Xbasic Object
    By Steve Workings in forum Mobile & Browser Applications
    Replies: 33
    Last Post: 06-04-2015, 08:28 PM
  3. cURL and Rest API Question for Newsfeed
    By ssmoore1 in forum Mobile & Browser Applications
    Replies: 1
    Last Post: 10-26-2014, 08:08 AM
  4. Convert CURL command to HTTP_POST
    By Scott Kurimski in forum Alpha Five Version 11 - Desktop Applications
    Replies: 6
    Last Post: 02-03-2014, 09:27 AM
  5. Cron & Curl
    By EricN in forum Application Server Version 9 - Web/Browser Applications
    Replies: 5
    Last Post: 08-27-2009, 02:32 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •