Sample code for 30+ languages & platforms
Zig

PayPal PayFlowPro - Send Transaction to Server

See more HTTP Misc Examples

Sends a simple transaction to the Gateway server.

Chilkat Zig Downloads

Zig
const std = @import("std");
const chilkat = @import("chilkat");

pub fn main(init: std.process.Init) !void {
    const alloc = init.arena.allocator();

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    const http = try chilkat.Http.init();
    defer http.deinit();

    // Implements the following CURL command:

    // curl https://pilot-payflowpro.paypal.com -d PARTNER=PayPal -d VENDOR=zzz -d USER=zzz -d PWD=zzzzz -d TRXTYPE=S -d AMT=40 -d CREATESECURETOKEN=Y -d SECURETOKENID=XXXEFF0A-XXXX-4585-XXXX-B763B1F1XXXX

    // Use the following online tool to generate HTTP code from a CURL command
    // Convert a cURL Command to HTTP Source Code

    const req = try chilkat.HttpRequest.init();
    defer req.deinit();
    req.setHttpVerb("POST");
    req.setPath("/");
    req.setContentType("application/x-www-form-urlencoded");
    req.addParam("PARTNER", "PayPal");
    req.addParam("VENDOR", "zzz");
    req.addParam("USER", "zzz");
    req.addParam("PWD", "zzzzz");
    req.addParam("TRXTYPE", "S");
    req.addParam("AMT", "40");
    req.addParam("CREATESECURETOKEN", "Y");
    req.addParam("SECURETOKENID", "XXXEFF0A-XXXX-4585-XXXX-B763B1F1XXXX");

    const resp = try chilkat.HttpResponse.init();
    defer resp.deinit();
    http.httpReq("https://pilot-payflowpro.paypal.com", req, resp) catch {
        std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
        return;
    };

    std.debug.print("Status code: {d}\n", .{resp.getStatusCode()});
    std.debug.print("Response body:\n", .{});
    std.debug.print("{s}\n", .{try resp.getBodyStr(alloc)});
}