digitaluapi

<back to all web services

PayFastWebHook

The following routes are available for this service:
POST/payfast/webhook/{PublicAccessGuid}
<?php namespace dtos;

use DateTime;
use Exception;
use DateInterval;
use JsonSerializable;
use ServiceStack\{IReturn,IReturnVoid,IGet,IPost,IPut,IDelete,IPatch,IMeta,IHasSessionId,IHasBearerToken,IHasVersion};
use ServiceStack\{ICrud,ICreateDb,IUpdateDb,IPatchDb,IDeleteDb,ISaveDb,AuditBase,QueryDb,QueryDb2,QueryData,QueryData2,QueryResponse};
use ServiceStack\{ResponseStatus,ResponseError,EmptyResponse,IdResponse,ArrayList,KeyValuePair2,StringResponse,StringsResponse,Tuple2,Tuple3,ByteArray};
use ServiceStack\{JsonConverters,Returns,TypeContext};


class PayFastWebHook implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="m_payment_id")
        /** @var string|null */
        public ?string $m_payment_id=null,

        // @DataMember(Name="pf_payment_id")
        /** @var string|null */
        public ?string $pf_payment_id=null,

        // @DataMember(Name="payment_status")
        /** @var string|null */
        public ?string $payment_status=null,

        // @DataMember(Name="item_name")
        /** @var string|null */
        public ?string $item_name=null,

        // @DataMember(Name="item_description")
        /** @var string|null */
        public ?string $item_description=null,

        // @DataMember(Name="amount_gross")
        /** @var float */
        public float $amount_gross=0.0,

        // @DataMember(Name="amount_fee")
        /** @var float */
        public float $amount_fee=0.0,

        // @DataMember(Name="amount_net")
        /** @var float */
        public float $amount_net=0.0,

        // @DataMember(Name="custom_str1")
        /** @var string|null */
        public ?string $custom_str1=null,

        // @DataMember(Name="custom_str2")
        /** @var string|null */
        public ?string $custom_str2=null,

        // @DataMember(Name="custom_str3")
        /** @var string|null */
        public ?string $custom_str3=null,

        // @DataMember(Name="custom_str4")
        /** @var string|null */
        public ?string $custom_str4=null,

        // @DataMember(Name="custom_str5")
        /** @var string|null */
        public ?string $custom_str5=null,

        // @DataMember(Name="custom_int1")
        /** @var int */
        public int $custom_int1=0,

        // @DataMember(Name="custom_int2")
        /** @var int */
        public int $custom_int2=0,

        // @DataMember(Name="custom_int3")
        /** @var int */
        public int $custom_int3=0,

        // @DataMember(Name="custom_int4")
        /** @var int */
        public int $custom_int4=0,

        // @DataMember(Name="custom_int5")
        /** @var int */
        public int $custom_int5=0,

        // @DataMember(Name="name_first")
        /** @var string|null */
        public ?string $name_first=null,

        // @DataMember(Name="name_last")
        /** @var string|null */
        public ?string $name_last=null,

        // @DataMember(Name="email_address")
        /** @var string|null */
        public ?string $email_address=null,

        // @DataMember(Name="merchant_id")
        /** @var string|null */
        public ?string $merchant_id=null,

        // @DataMember(Name="signature")
        /** @var string|null */
        public ?string $signature=null,

        // @DataMember(Name="token")
        /** @var string|null */
        public ?string $token=null,

        // @DataMember(Name="billing_date")
        /** @var DateTime */
        public DateTime $billing_date=new DateTime(),

        /** @var string */
        public string $PublicAccessGuid='',
        /** @var bool|null */
        public ?bool $Sandbox=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['m_payment_id'])) $this->m_payment_id = $o['m_payment_id'];
        if (isset($o['pf_payment_id'])) $this->pf_payment_id = $o['pf_payment_id'];
        if (isset($o['payment_status'])) $this->payment_status = $o['payment_status'];
        if (isset($o['item_name'])) $this->item_name = $o['item_name'];
        if (isset($o['item_description'])) $this->item_description = $o['item_description'];
        if (isset($o['amount_gross'])) $this->amount_gross = $o['amount_gross'];
        if (isset($o['amount_fee'])) $this->amount_fee = $o['amount_fee'];
        if (isset($o['amount_net'])) $this->amount_net = $o['amount_net'];
        if (isset($o['custom_str1'])) $this->custom_str1 = $o['custom_str1'];
        if (isset($o['custom_str2'])) $this->custom_str2 = $o['custom_str2'];
        if (isset($o['custom_str3'])) $this->custom_str3 = $o['custom_str3'];
        if (isset($o['custom_str4'])) $this->custom_str4 = $o['custom_str4'];
        if (isset($o['custom_str5'])) $this->custom_str5 = $o['custom_str5'];
        if (isset($o['custom_int1'])) $this->custom_int1 = $o['custom_int1'];
        if (isset($o['custom_int2'])) $this->custom_int2 = $o['custom_int2'];
        if (isset($o['custom_int3'])) $this->custom_int3 = $o['custom_int3'];
        if (isset($o['custom_int4'])) $this->custom_int4 = $o['custom_int4'];
        if (isset($o['custom_int5'])) $this->custom_int5 = $o['custom_int5'];
        if (isset($o['name_first'])) $this->name_first = $o['name_first'];
        if (isset($o['name_last'])) $this->name_last = $o['name_last'];
        if (isset($o['email_address'])) $this->email_address = $o['email_address'];
        if (isset($o['merchant_id'])) $this->merchant_id = $o['merchant_id'];
        if (isset($o['signature'])) $this->signature = $o['signature'];
        if (isset($o['token'])) $this->token = $o['token'];
        if (isset($o['billing_date'])) $this->billing_date = JsonConverters::from('DateTime', $o['billing_date']);
        if (isset($o['PublicAccessGuid'])) $this->PublicAccessGuid = $o['PublicAccessGuid'];
        if (isset($o['Sandbox'])) $this->Sandbox = $o['Sandbox'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->m_payment_id)) $o['m_payment_id'] = $this->m_payment_id;
        if (isset($this->pf_payment_id)) $o['pf_payment_id'] = $this->pf_payment_id;
        if (isset($this->payment_status)) $o['payment_status'] = $this->payment_status;
        if (isset($this->item_name)) $o['item_name'] = $this->item_name;
        if (isset($this->item_description)) $o['item_description'] = $this->item_description;
        if (isset($this->amount_gross)) $o['amount_gross'] = $this->amount_gross;
        if (isset($this->amount_fee)) $o['amount_fee'] = $this->amount_fee;
        if (isset($this->amount_net)) $o['amount_net'] = $this->amount_net;
        if (isset($this->custom_str1)) $o['custom_str1'] = $this->custom_str1;
        if (isset($this->custom_str2)) $o['custom_str2'] = $this->custom_str2;
        if (isset($this->custom_str3)) $o['custom_str3'] = $this->custom_str3;
        if (isset($this->custom_str4)) $o['custom_str4'] = $this->custom_str4;
        if (isset($this->custom_str5)) $o['custom_str5'] = $this->custom_str5;
        if (isset($this->custom_int1)) $o['custom_int1'] = $this->custom_int1;
        if (isset($this->custom_int2)) $o['custom_int2'] = $this->custom_int2;
        if (isset($this->custom_int3)) $o['custom_int3'] = $this->custom_int3;
        if (isset($this->custom_int4)) $o['custom_int4'] = $this->custom_int4;
        if (isset($this->custom_int5)) $o['custom_int5'] = $this->custom_int5;
        if (isset($this->name_first)) $o['name_first'] = $this->name_first;
        if (isset($this->name_last)) $o['name_last'] = $this->name_last;
        if (isset($this->email_address)) $o['email_address'] = $this->email_address;
        if (isset($this->merchant_id)) $o['merchant_id'] = $this->merchant_id;
        if (isset($this->signature)) $o['signature'] = $this->signature;
        if (isset($this->token)) $o['token'] = $this->token;
        if (isset($this->billing_date)) $o['billing_date'] = JsonConverters::to('DateTime', $this->billing_date);
        if (isset($this->PublicAccessGuid)) $o['PublicAccessGuid'] = $this->PublicAccessGuid;
        if (isset($this->Sandbox)) $o['Sandbox'] = $this->Sandbox;
        return empty($o) ? new class(){} : $o;
    }
}

PHP PayFastWebHook DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv

HTTP + JSV

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /payfast/webhook/{PublicAccessGuid} HTTP/1.1 
Host: duengageapi.uat.scadsoftware.com 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	m_payment_id: String,
	pf_payment_id: String,
	payment_status: String,
	item_name: String,
	item_description: String,
	amount_gross: 0,
	amount_fee: 0,
	amount_net: 0,
	custom_str1: String,
	custom_str2: String,
	custom_str3: String,
	custom_str4: String,
	custom_str5: String,
	custom_int1: 0,
	custom_int2: 0,
	custom_int3: 0,
	custom_int4: 0,
	custom_int5: 0,
	name_first: String,
	name_last: String,
	email_address: String,
	merchant_id: String,
	signature: String,
	token: String,
	billing_date: 0001-01-01,
	PublicAccessGuid: 00000000000000000000000000000000,
	Sandbox: False
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	
}