Skip to content

Commit

Permalink
add new endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
WhinterGoncalves committed Aug 28, 2019
1 parent 106898d commit fb13a54
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 3 deletions.
4 changes: 4 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@
"settleCarnetParcel": {
"route": "/v1/carnet/:id/parcel/:parcel/settle",
"method": "put"
},
"payOneStep": {
"route": "/v1/charge/one-step",
"method": "post"
}
}
}
4 changes: 3 additions & 1 deletion demo/MainCode.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,9 @@ object MainFrm: TMainFrm
'Get Installments'
'Create Charge Balance Sheet '
'Settle Charge'
'Settle Carnet Parcel')
'Settle Carnet Parcel'
'Create One Step Billet'
'Create One Step Card')
end
object txtToken: TEdit
Left = 108
Expand Down
4 changes: 3 additions & 1 deletion demo/MainCode.pas
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ procedure TMainFrm.ActionBtnClick(Sender: TObject);
30 : DisplayServerResponse(CreateChargeBalanceSheet(Id));
31 : DisplayServerResponse(SettleCharge(Id));
32 : DisplayServerResponse(settleCarnetParcel(Id, CarnetParcel));
33 : DisplayServerResponse(PayOneStepWithBillet); //one-step-billet
34 : DisplayServerResponse(PayOneStepWithCard); //one-step-card
end;
end;

Expand All @@ -161,7 +163,7 @@ procedure TMainFrm.ActionsChange(Sender: TObject);
begin
Option := Integer(Actions.ItemIndex);
case Option of
0,9,19,22,29 : begin
0,9,19,22,29,33,34 : begin
txtId.Enabled:= False;
txtCarnetParcel.Enabled := False;
txtToken.Enabled := False
Expand Down
102 changes: 102 additions & 0 deletions demo/uChargeEndpoints.pas
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ function CreateCharge: String;
function DetailCharge(Id: String): String;
function PayChargeWithBillet(Id: String): String;
function PayChargeWithCard(Id, Token: String): String;
function PayOneStepWithBillet: String; //one step billet
function PayOneStepWithCard: String; //one step card
function CancelCharge(Id: String): String;
function CreateChargeHistory(Id: String): String;
function LinkCharge(Id: String): String;
Expand Down Expand Up @@ -152,6 +154,106 @@ function PayChargeWithCard(Id, Token: String): String;
end;


//one step billet
function PayOneStepWithBillet: String;
var
Body: String;

begin
Body :=
'{'+
'"metadata": {'+
'"custom_id": "sou_fera_0007",'+
'"notification_url": "https://url-do-cliente.com.br/"'+
'},'+
'"payment": {'+
'"banking_billet": {'+
'"configurations": {'+
'"fine": 200,'+
'"interest": 33'+
'},'+
'"conditional_discount": {'+
'"until_date": "2019-08-30",'+
'"type": "percentage",'+
'"value": 500'+
'},'+
'"discount": {'+
'"type": "currency",'+
'"value": 599'+
'},'+
'"expire_at": "2019-09-15",'+
'"customer": {'+
'"name": "Gorbadoc Oldbuck",'+
'"cpf": "94271564656",'+
'"phone_number": "5144916523"'+
'}'+
'}'+
'},'+
'"items": ['+
'{'+
'"amount": 1,'+
'"name": "Item 1",'+
'"value": 600'+
'},'+
'{'+
'"amount": 1,'+
'"name": "Item 2",'+
'"value": 1000'+
'}'+
']'+
'}';

Result := ExecuteGerenciaNetRequest( 'payOneStep','','',Body );
end;

//one step card
function PayOneStepWithCard: String;
var
Body: String;

begin
Body :=
'{'+
'"items": ['+
'{'+
'"name": "Product 1",'+
'"value": 590,'+
'"amount": 2'+
'}'+
'],'+
'"shippings": ['+
'{'+
'"name": "Default Shipping Cost",'+
'"value": 10'+
'}'+
'],'+
'"payment": {'+
'"credit_card": {'+
'"installments": 1,'+
'"payment_token": "fd6c81e1b812afcf9b57158207af3edfdb1e3ec0",'+
'"billing_address": {'+
'"street": "Av. JK",'+
'"number": 909,'+
'"neighborhood": "Bauxita",'+
'"zipcode": "35400000",'+
'"city": "Ouro Preto",'+
'"state": "MG"'+
'},'+
'"customer": {'+
'"name": "Gorbadoc Oldbuck",'+
'"email": "[email protected]",'+
'"cpf": "04267484171",'+
'"birth": "1977-01-15",'+
'"phone_number": "5144916523"'+
'}'+
'}'+
'}'+
'}';

Result := ExecuteGerenciaNetRequest( 'payOneStep','','',Body );
end;


function DetailCharge(Id: String): String;
var
DetailParams: String;
Expand Down
Binary file modified src/dll-compilada/GerenciaNet.dll
Binary file not shown.
4 changes: 4 additions & 0 deletions src/dll-compilada/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@
"settleCarnetParcel": {
"route": "/v1/carnet/:id/parcel/:parcel/settle",
"method": "put"
},
"payOneStep": {
"route": "/v1/charge/one-step",
"method": "post"
}
}
}
2 changes: 1 addition & 1 deletion src/dll-src/uGerenciaNetIndy.pas
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function TokenExpired: Boolean;
ProxyPort: Integer;
ExpireDateTime : TDateTime;

const API_SDK = 'delphi-3.0.1';
const API_SDK = 'delphi-3.0.2';

implementation

Expand Down

0 comments on commit fb13a54

Please sign in to comment.