1 - Intencion de Pago (POST):
Código: Seleccionar todo
POST /api/private/payment_intentions
{ "provider_id": “YPF351576293dhf9b50ugfyy4crrhb32qz73w”, // Identity unívoco de la intención de pago, lo envía el PDV para su seguimiento
"amount": 30, //Monto total de la operación. [opcional]
"products": [ //Siempre array tiene que contener por lo menos una posición
{
“id_price_book”: “432” // id price book (String, Opcional)
“description”: “pepsi 500cm”, //requerido
"quantity": 1, //requerido (1/99)
"type": "store", //valores opessa_store, opessa_fuel, opessa_boxes
"unit_price": 30,
"amount": 30, //opcional se calcula pxq
}
],
"fuel_station_id": 3344, //Apies "point_of_sale": 44637, //ID del punto de Venta
"sale_type": "store",
"meta_data":[ "provider_creation_date": "2019-01-17T17:09:45.664Z", //Momento del envío del mensaje desde el PDV
"provider_delivery_date": "2019-01-17T17:09:45.664Z", //Momento del envío del mensaje desde el YPF Central ]
}
2 - Consulta del pago realizado (GET)
GET /api/private/payment_intentions/{payment_id}
Como decia el problema lo tenemos en el POST, al realizar el OpenRequest nos devuelve el siguiente error:
Código: Seleccionar todo
----------------------- Información detallada del error -----------------------
Subsistema: BASE
Código de error: 1004
Estado: .F.
Descripción: Message not found
Operación: TINTERNET:OPENREQUEST
Argumentos:
Fichero:
Código error SO: 0
Pila de llamadas:
TFORM1:BTNBMP1CLICK (78)
TBTNBMP:ONCLICK (0)
TBTNBMP:CLICK (100)
(b)XCONTROL:XCONTROL (148)
TBTNBMP:COMMAND (0)
TSCROLLINGWINCONTROL:WMCOMMAND (282)
TFORM1:WMCOMMAND (943)
RUNFORM (0)
TAPPLICATION:RUN (276)
MAIN (15)
API URL: https://ypfamepcjqa.azure-api.net/mspayments/api/
SECURITY HEADERS
X-ACCESS-TOKEN : 65f76c1a-8475-407c-9f6c-ecd724fca025
Ocp-Apim-Subscription-Key : 8f12b920f95f4e5da21499b317c48b29
OTROS HEADERS
Content-Type : application/json
Aqui dejo el codigo completo y tambien para descargarlo:
Código: Seleccionar todo
#include "Xailer.ch"
#include "ExStruct.ch"
#include "hbxml.ch"
#include "WinINet.api"
CLASS TForm1 FROM TForm
COMPONENT oBtnBmp1
COMPONENT oMemo1
COMPONENT oBtnBmp2
DATA cAPIURL INIT 'https://ypfamepcjqa.azure-api.net/mspayments/api'
DATA cAccessToken INIT '65f76c1a-8475-407c-9f6c-ecd724fca025'
DATA cKey INIT '8f12b920f95f4e5da21499b317c48b29'
METHOD CreateForm()
METHOD BtnBmp1Click( oSender )
METHOD BtnBmp2Click( oSender )
ENDCLASS
#include "MenuPrincipal.xfm"
//------------------------------------------------------------------------------
// POST
METHOD BtnBmp1Click( oSender ) CLASS TForm1
LOCAL cJson, cDatos:='', cData, debug:=''
LOCAL cTexto, oInternet, xerror, Connection, File
cTexto:=''
BEGIN SEQUENCE
oInternet:= TInternet():New( Self )
oInternet:nPort := INTERNET_DEFAULT_HTTPS_PORT
oInternet:nTimeOut:= 60000
IF !oInternet:Open()
BREAK "Not Open"
ENDIF
Connection:= oInternet:Connect(::cAPIURL)
IF !Connection
BREAK "Not Connection"
ENDIF
cJson:='{'
//datos de ejemplo
cDatos+='"provider_id": "YPF351576293dhf9b50ugfyy4crrhb32qz73w",' //ID ingresa del PDV
cDatos+='"amount": 30,' //monto total opcional
cDatos+='"products": [{'
cDatos+='"id_price_book": "432",' // string opcional
cDatos+='"description": "50n litros de combustible",'
cDatos+='"quantity": 26.70,' //decimal
cDatos+='"type": "fuel",' //store,fuel,boxes
cDatos+='"code": "Infinia",' //Infinia, Disel, etc
cDatos+='"unit_price": 30,'
cDatos+='"title": "product title",'
cDatos+='"amount": 30}],' //opcional se calcula pxq
cDatos+='"fuel_station_id": 4321,' //id unico de cada QR
cDatos+='"point_of_sale": 1,' //si es null se enviaYVOSAPP
cDatos+='"fuel_pump": "1",'
cDatos+='"fuel_dispenser": "1",'
cDatos+='"provider_external_gateway_id": "432",'
cDatos+='"sale_type": "GAS_FLOW",'
cDatos+='"meta_data": [{'
cDatos+='"provider_creation_date":"2019-01-17T17:09:45.664Z",' //envio desde el PDV
cDatos+='"provider_delivery_date":"2019-01-17T17:09:45.664Z"}]' //envio desde el YPF central
cDatos+='}'
cJson+=cDatos
debug:=::cAPIURL+"/private/payment_intentions/Ocp-Apim-Subscription-Key:"+::cKey+"/X-ACCESS-TOKEN:"+::cAccessToken
File:= oInternet:OpenRequest("POST",::cAPIURL+"/private/payment_intentions/Ocp-Apim-Subscription-Key:"+::cKey+"/X-ACCESS-TOKEN:"+::cAccessToken,INTERNET_FLAG_SECURE,"HTTP/1.0")
IF !oInternet:SendRequest(File, "Content-type: application/json", cJson )
BREAK "Not SendRequest"
ENDIF
cTexto:=''
WHILE oInternet:ReadFile( File, @cData, 65536 )
cTexto += cData
ENDDO
cTexto += " *** "+oInternet:GetErrorDescription()+" "+HB_NToS(oInternet:nLastError)+" "+HB_NToS(GetLastError())
::oMemo1:Value:= cTexto
RECOVER USING xerror
xerror:= oInternet:GetErrorDescription()
MsgInfo( xerror )
END SEQUENCE
RETURN Nil
//------------------------------------------------------------------------------
// GET
METHOD BtnBmp2Click( oSender ) CLASS TForm1
LOCAL hRequest, cBuffer := Space( 1024 ), cData := ""
LOCAL cUrl1:='/payment_intentions/1'
LOCAL debug:=''
WITH OBJECT TInternet():Create()
IF :Open()
debug:=:GetErrorDescription(:nLastError())
IF !Empty( hRequest := :OpenURL(::cAPIURL+cUrl1) )
WHILE :ReadFile( hRequest, @cBuffer, 65536 )
cData += cBuffer
ENDDO
:CloseURL( hRequest )
ENDIF
ENDIF
debug:=:GetErrorDescription(:nLastError())
:Close()
::oMemo1:Value:= cData
END
RETURN Nil
Código: Seleccionar todo
curl -X POST \
https://ypfamepcjqa.azure-api.net/mspayments/api/private/payment_intentions \
-H 'Content-Type: application/json' \
-H 'Ocp-Apim-Subscription-Key: 8f12b920f95f4e5da21499b317c48b29' \
-H 'X-ACCESS-TOKEN: 65f76c1a-8475-407c-9f6c-ecd724fca025' \
-d '{
"provider_id": "1234",
"products": [
{
"id": "432",
"id_price_book": "432",
"description": "28 litros de combustible",
"quantity": 28,
"type": "fuel",
"code": "INFINIA",
"unit_price": 40
}
],
"fuel_station_id": XXX,
"fuel_pump": " XXX ",
"fuel_dispenser": "XXX",
"point_of_sale": XXX ,
"sale_type": "GAS_FLOW"
}'