is the correct way, this is an example for the old Stripe API, the new API is a little more difficult, but the Yoco API is similar to the old Stripe API, you can convert this code to NT curl and avoid using NetWebClient. By the way, I never used nt curl but I think it's similar to Mike Duglas' curl
SendRequest ROUTINE
DATA
curl TCurlHttpClass
res CURLcode
qIndex LONG, AUTO
respBuffer STRING(65000) !big enuff to hold received response
CODE
curl.Init()
curl.FreeHttpHeaders()
SSLInfo:bUseSSL = TRUE
p_web.ssv('PaymentFrom','Afiliacion')
IF SSLInfo:bUseSSL
res = curl.SetSSLVerifyHost(SSLInfo:bVerifyHost)
IF res <> CURLE_OK
END
res = curl.SetSSLVerifyPeer(SSLInfo:bVerifyPeer)
IF res <> CURLE_OK
END
res = curl.SetSSLVersion(SSLInfo:Version)
IF res <> CURLE_OK
END
IF SSLInfo:Certificate
res = curl.SetCAInfo(SSLInfo:Certificate)
IF res <> CURLE_OK
END
END
END
curl.SetCustomRequest('POST')
!-H "Content-Type: application/json"
!-H "Authorization: Bearer Access-Token"
CASE p_Web.gsv('Com:PaymentEnviroment')
OF 'sandbox'
curl.AddHttpHeader('Authorization: Bearer '&p_web.gsv('Com:StripteSandBoxToken'))
OF 'production'
curl.AddHttpHeader('Authorization: Bearer '&p_web.gsv('Com:StripteProductionToken'))
END
!-- applies http headers added by AddHttpHeader calls
curl.SetHttpHeaders()
!----Create a Token --------!
Send:Url = '
https://api.stripe.com/v1/tokens' Send:PostParams ='card[number]='&p_web.gsv('CardNumber')&'&card[exp_month]='&p_web.GSV('ExpMonth')&'&card[exp_year]='&p_web.GSV('ExpYear')&'&card[cvc]='&p_web.GSV('Cvv')
!----Create a Token -------!
CLEAR(TokenError)
CLEAR(Token)
res = curl.SendRequestStr(Send:Url, Send:PostParams, respBuffer)
Loc:CantidadaPagarSend = p_web.gsv('Loc:CantidadaPagar')*100
IF res = CURLE_OK
jsonStr = CLIP(respBuffer)
DO ParseJSON
IF Token<>'' AND TokenError=''
CLEAR(pJsonString)
curl.FreeHttpHeaders()
curl.SetCustomRequest('POST')
CASE p_web.gsv('Com:PaymentEnviroment')
OF 'sandbox'
curl.AddHttpHeader('Authorization: Bearer '&p_web.gsv('Com:StripteSandBoxToken'))
OF 'production'
curl.AddHttpHeader('Authorization: Bearer '&p_web.gsv('Com:StripteProductionToken'))
END
curl.SetHttpHeaders()
Send:Url = '
https://api.stripe.com/v1/charges' Send:PostParams ='currency=usd&amount='&p_web.gsv('Loc:CantidadaPagar')*100&'&description=charge&source='&clip(Token)&'&receipt_email='&p_web.gsv('Use:EMAIL')&'&metadata[afiliacionid]='&p_web.gsv('AfiliacionId')
res = curl.SendRequestStr(Send:Url, Send:PostParams, respBuffer)
IF res = CURLE_OK
pJsonString = CLIP(respBuffer)
DO ParseJSON2
IF TokenError<>''
loc:alert = TokenError
p_web.SetValue('SelectField','CardNumber')
EXIT
END
Loc:Status=1
DO AddPayment
do Refresh::b1
DO SendEmail
p_web.Script( p_web.WindowOpen( 'PaymentSucessfull' ))
END
ELSE
loc:alert = CLIP(TokenError)
p_web.SetValue('SelectField','NameonCard')
EXIT
END
ELSIF res = -1
loc:alert = 'Cannot open local file Contact System Administrator'
p_web.SetValue('SelectField','NameonCard')
ELSE
loc:alert = 'SendRequest failed2: '& curl.StrError(res)&' Contact System Administrator'
p_web.SetValue('SelectField','NameonCard')
END