Create Token

Create a transaction in the Direct Pay Online system and receive a transaction token for the payment page.

createToken (v6)

Create a transaction in the Direct Pay Online system and receive a transaction token that can be used to send the customer to the payment page.

The createToken request is built from the request wrapper and five data levels:

  • Transaction level — Mandatory. Contains the basic transaction information.
  • Services level — Mandatory. Contains information about the services sold in the transaction. You must send at least one service.
  • Allocations level — Optional. Contains information about allocating money from the transaction to other providers in the Direct Pay Online system. If you do not send this level, the full transaction amount is allocated to the provider.
  • Additional level — Optional. Blocks specific payment options for the transaction. For example, an application that needs fast payment can block Direct Pay Online bank payment.
  • Travelers level — Optional. Contains traveler, passenger, or guest information used by Direct Pay Online to verify that one payer name matches one traveler name.

Legacy note:
Some fields and endpoints may still reference 3G Direct Pay (3G).
This is the same platform, now branded as DPO Pay by Network.


Endpoint

Method: POST

URL:

https://secure.3gdirectpay.com/API/v6/

Headers:

Content-Type: application/xml; charset=utf-8
Accept: application/xml

Request fields

Send these fields at the root level of the XML request.

ParameterData typeDescriptionRequired
CompanyTokenTokenToken you received from 3G to operate this API.Mandatory
RequestTextMust be createToken.Mandatory

Transaction level

Wrap transaction fields in a Transaction tag. The transaction level is mandatory.

<Transaction>
  <PaymentAmount>300</PaymentAmount>
  <PaymentCurrency>tzs</PaymentCurrency>
  <CompanyRefUnique>1</CompanyRefUnique>
  <CompanyRef>YourRef12345</CompanyRef>
  <OriginatorSourceID>8777250772</OriginatorSourceID>
  <OrderNumber>735487493</OrderNumber>
  <PTL>56</PTL>
  <customerFirstName>John</customerFirstName>
  <customerLastName>Doe</customerLastName>
  <customerEmail>[email protected]</customerEmail>
  <DefaultPayment>MO</DefaultPayment>
  <DefaultPaymentCountry>Tanzania</DefaultPaymentCountry>
  <DefaultPaymentMNO>Tigo</DefaultPaymentMNO>
  <TransactionSource>Mobile</TransactionSource>
  <MetaData>
    <![CDATA[
    {
      "key": "Value"
    }
    ]]>
  </MetaData>
</Transaction>

Transaction fields

ParameterData typeDescriptionRequired
PaymentAmountMoneyTotal amount in the selected currency. Use no more than 2 digits after the comma.Mandatory
PaymentCurrencyTextCurrency from the table of options accepted by DPO.Mandatory
CompanyRefTextCompany reference number, also referred to as the booking reference.Optional
OriginatorSourceIDText (15 bytes)Third-party unique transaction identifier.Optional
OrderNumberText (15 bytes)Merchant order reference number.Optional
RedirectURLTextURL to redirect the customer after payment. The customer is redirected to this URL using the GET method with TransID, CCDapproval, PnrID, TransactionToken, and CompanyRef. If you include additional variables in your URL, the system appends the DPO variables with & instead of starting with ?.Optional
BackURLTextURL that lets the customer go back from the payment page. The customer is redirected to this URL using the GET method with TransactionToken and CompanyRef. If you include additional variables in your URL, the system appends the DPO variables with & instead of starting with ?.Optional
CompanyRefUniqueBooleanTells the system to check whether the company reference number, also referred to as the transaction ID given by the provider, already exists and is paid. If it does, the API returns an error. This prevents double payments. Default: False.Optional
PTLNumberNumber of hours for the payment time limit. Default: 96 hours.Optional
PTLtypeTextDefines whether the PTL tag is measured in hours or minutes. Default: hours.Optional
TransactionChargeTypeNumberType of transaction. Use 1 for Charge, which is an immediate charge; 2 for Authorize-Manual, which authorizes the transaction and requires a manual charge using chargeToken; or 3 for Authorize-Auto, which authorizes the transaction and automatically charges it on the selected date. Default: 1 (Charge).Optional
TransactionAutoChargeDateDateTimeDate and time for automatic charging of the transaction, if authorized by that date. Supported formats: YYYY/MM/DD HH:MM(:SS), YYYY/MM/DD, YYYY-MM-DD HH:MM(:SS), and YYYY-MM-DD.Optional. Mandatory if TransactionChargeType is Authorize-Auto.
customerEmailTextCustomer email address used to send the payment link.Optional
customerFirstNameTextCustomer first name.Optional
customerLastNameTextCustomer last name.Optional
customerAddressTextCustomer address.Optional
customerCityTextCustomer city.Optional
customerCountryISO codeCustomer country ISO 2-letter code. See http://en.wikipedia.org/wiki/ISO_3166-1.Optional
customerDialCodeISO codeCustomer country ISO 2-letter code.Optional
customerPhoneNumberCustomer phone number.Optional
customerZipTextCustomer ZIP code.Optional
DemandPaymentbyTravelerBoolean (1/0)If set to 1, the system requires one of the travelers included in the Travelers tag to be the payer.Optional
EmailTransactionBoolean (1/0)If set to 1, the system sends the customer an email about the transaction with a link to pay.Optional
CompanyAccRefTextInternal accounting reference number.Optional
userTokenTokenDefines who created the transaction.Optional
DefaultPaymentTextCode of the default payment option to display first on the payment page. Options: CC for credit card, MO for mobile, PP for PayPal, BT for bank transfer, and XP for xPay.Optional
DefaultPaymentCountryTextUse only for mobile default payment. Sets the default country for the payment option. DefaultPayment also works without this field. Example: <DefaultPaymentCountry>kenya</DefaultPaymentCountry>.Optional
DefaultPaymentMNOTextUse only for mobile default payment. Sets the default MNO (mobile network operator) for the payment option. DefaultPayment also works without this field. Example: <DefaultPaymentMNO>mpesa</DefaultPaymentMNO>.Optional
TransactionToPrepBoolean (1/0)Marks the transaction as Marketplace Prep.Optional
AllowRecurrentBoolean (1/0)Allows payment by recurrent payment.Optional
FraudTimeLimitNumberSets the fraud time limit in minutes from the current date.Optional
VoidableBoolean (1/0)If this tag is sent, the transaction is checked in the scoring process. If set to 0 and scoring is high risk or very high risk, the transaction is blocked. If set to 1, the transaction goes to the DPO support team for review.Optional
ChargeTypeTextCharge type.Optional
TRANSmarketplaceNumberIf sent, the allocation amount is updated based on the API_GetCCTclientprecentage stored procedure.Optional
TRANSblockCountriesBoolean (1/0)Transaction block countries.Optional
MetaDataText (2000)Custom data to store for the transaction. Maximum length: 2000 symbols.Optional
SMSTransactionBoolean (1/0)SMS transaction.Optional
TransactionTypeTextIf set, updates the transaction status ID based on this value.Optional
DeviceIdTextUsed if the transaction type is Duma Directpay.Optional
DeviceCountryTextUsed if the transaction type is Duma Directpay.Optional
TransactionSourceTextIndicates the source of the transaction. If omitted, the default source is applied. Default: API. Available sources include Computer, Mobile, API, Website, Catalogue, Realtime Settlement, DPO Card, DPO Store, Lite Portal, Marketplace, Pay My Bills, Shopify, Wordpress, Magento, Whcms, Wix, Ecwid, Android SDK, IOS SDK, DPO Pay mobile Android, DPO Pay mobile IOS, POS, and sPOS.Optional

Services level

Wrap services in a Services tag and each individual service in a Service tag. The services level is mandatory, and there is no limit on the number of individual services you can send in the Services tag.

<Services>
  <Service>
    <ServiceType>33</ServiceType>
    <ServiceDescription>Service number 1</ServiceDescription>
    <ServiceDate>2018/01/20 19:00</ServiceDate>
  </Service>
  <Service>
    <ServiceType>39</ServiceType>
    <ServiceDescription>Service number 2</ServiceDescription>
    <ServiceDate>2018/01/20 19:00</ServiceDate>
    <ServiceFrom>JFK</ServiceFrom>
    <ServiceTo>CDG</ServiceTo>
  </Service>
  <Service>
    <ServiceTypeName>Commission</ServiceTypeName>
    <ServiceDescription>Service number 2</ServiceDescription>
    <ServiceDate>2018/01/20 19:00</ServiceDate>
    <ServiceFrom>JFK</ServiceFrom>
    <ServiceTo>CDG</ServiceTo>
  </Service>
</Services>

Service fields

ParameterData typeDescriptionRequired
ServiceDescriptionTextDescription of the payment made.Mandatory
ServiceTypeNumberService type number according to the options accepted by DPO.Mandatory-Optional. Send either ServiceType or ServiceTypeName.
ServiceTypeNameTextService type name according to the options accepted by DPO.Mandatory-Optional. Send either ServiceType or ServiceTypeName.
ServiceDateDateTimeService date of the booked service. Format: YYYY/MM/DD HH:MM.Mandatory
ServiceFromIATA3-letter departure airport code.Optional
ServiceToIATA3-letter destination airport code.Optional
ServiceRefTextService reference.Optional

Allocations level

Wrap allocations in an Allocations tag and each allocation in an Allocation tag. The limit for an allocation is 89% of the total transaction amount. Some fields are mandatory for each allocation sent.

<Allocations>
  <Allocation>
    <AllocationCode>demo1</AllocationCode>
    <AllocationAmount>130.00</AllocationAmount>
    <AllocationServiceType>39</AllocationServiceType>
  </Allocation>
  <Allocation>
    <AllocationCode>demo2</AllocationCode>
    <AllocationAmount>40.00</AllocationAmount>
    <AllocationServiceType>33</AllocationServiceType>
    <AllocationServiceDescription>Description of the allocation</AllocationServiceDescription>
  </Allocation>
</Allocations>

Allocation fields

ParameterData typeDescriptionRequired
AllocationCodeTextCode of the other provider to allocate money to.Mandatory
AllocationAmountMoneyAllocated amount.Mandatory
AllocationServiceTypeNumberAllocation service type from the list of services.Mandatory
AllocationServiceDescriptionTextFree text.Optional
AllocationInvoiceTextInvoice of the allocation.Optional
AllocationPnrTextPNR of the allocation.Optional
AllocationBlockBoolean (1/0)Insert into API_CreateToken_additional_insert.Optional

Additional level

Wrap additional information in an Additional tag and each blocked payment option in a BlockPayment tag.

Additional fields

ParameterData typeDescriptionRequired
BlockPaymentTextCode of the payment option to block. Options: CC for credit card, MO for mobile, PP for PayPal, BT for bank transfer, XP for xPay, SE for SID-EFT, and CP for USSD (Coral Pay).Optional

Travelers level

Wrap travelers in a Travelers tag and each traveler in a Traveler tag. Some fields are mandatory for each traveler sent.

<Travelers>
  <Traveler>
    <TravelerFirstName>John</TravelerFirstName>
    <TravelerLastName>Doe</TravelerLastName>
    <TravelerPhone>12312312</TravelerPhone>
    <TravelerPhonePrefix>254</TravelerPhonePrefix>
  </Traveler>
  <Traveler>
    <TravelerFirstName>Rose</TravelerFirstName>
    <TravelerLastName>Doe</TravelerLastName>
  </Traveler>
</Travelers>

Traveler fields

ParameterData typeDescriptionRequired
TravelerFirstNameTextFirst name.Mandatory
TravelerLastNameTextLast name.Mandatory
TravelerPhoneTextPhone number.Optional
TravelerPhonePrefixNumericPhone number prefix without +.Optional

Request examples

Simple one-service transaction

In this type of transaction, the customer is redirected to the RedirectURL after payment.

<?xml version="1.0" encoding="utf-8"?>
<API3G>
  <CompanyToken>57466282-EBD7-4ED5-B699-8659330A6996</CompanyToken>
  <Request>createToken</Request>
  <Transaction>
    <PaymentAmount>450.00</PaymentAmount>
    <PaymentCurrency>USD</PaymentCurrency>
    <CompanyRef>49FKEOA</CompanyRef>
    <RedirectURL>http://www.domain.com/payurl.php</RedirectURL>
    <BackURL>http://www.domain.com/backurl.php</BackURL>
    <CompanyRefUnique>0</CompanyRefUnique>
    <PTL>5</PTL>
  </Transaction>
  <Services>
    <Service>
      <ServiceType>45</ServiceType>
      <ServiceDescription>Flight from Nairobi to Diani</ServiceDescription>
      <ServiceDate>2013/12/20 19:00</ServiceDate>
    </Service>
  </Services>
</API3G>

Two services with allocation, travelers, and email alert

This example does not define a redirect URL or back URL because the transaction is completed on the DPO website.

<?xml version="1.0" encoding="utf-8"?>
<API3G>
  <CompanyToken>57466282-EBD7-4ED5-B699-8659330A6996</CompanyToken>
  <Request>createToken</Request>
  <Transaction>
    <PaymentAmount>950.00</PaymentAmount>
    <PaymentCurrency>USD</PaymentCurrency>
    <CompanyRef>49FKEOA</CompanyRef>
    <RedirectURL></RedirectURL>
    <BackURL></BackURL>
    <CompanyRefUnique>0</CompanyRefUnique>
    <PTL>5</PTL>
    <customerEmail>[email protected]</customerEmail>
    <FraudTimeLimit>60</FraudTimeLimit>
  </Transaction>
  <Services>
    <Service>
      <ServiceType>45</ServiceType>
      <ServiceDescription>Flight from Nairobi to Diani</ServiceDescription>
      <ServiceDate>2013/12/20 19:00</ServiceDate>
    </Service>
    <Service>
      <ServiceType>45</ServiceType>
      <ServiceDescription>Flight from Diani to Wilson</ServiceDescription>
      <ServiceDate>2013/12/25 09:00</ServiceDate>
    </Service>
  </Services>
  <Allocations>
    <Allocation>
      <AllocationCode>demo1</AllocationCode>
      <AllocationAmount>850</AllocationAmount>
      <AllocationServiceType>45</AllocationServiceType>
    </Allocation>
  </Allocations>
  <Travelers>
    <Traveler>
      <TravelerFirstName>John</TravelerFirstName>
      <TravelerLastName>Doe</TravelerLastName>
      <TravelerPhone>456887014</TravelerPhone>
      <TravelerPhonePrefix>254</TravelerPhonePrefix>
    </Traveler>
    <Traveler>
      <TravelerFirstName>Rose</TravelerFirstName>
      <TravelerLastName>Doe</TravelerLastName>
    </Traveler>
  </Travelers>
</API3G>

Simple one-service transaction with blocked payment options

<?xml version="1.0" encoding="utf-8"?>
<API3G>
  <CompanyToken>57466282-EBD7-4ED5-B699-8659330A6996</CompanyToken>
  <Request>createToken</Request>
  <Transaction>
    <PaymentAmount>950.00</PaymentAmount>
    <PaymentCurrency>USD</PaymentCurrency>
    <CompanyRef>49FKEOA</CompanyRef>
    <RedirectURL>http://www.domain.com/payurl.php</RedirectURL>
    <BackURL>http://www.domain.com/backurl.php</BackURL>
    <CompanyRefUnique>0</CompanyRefUnique>
    <PTL>5</PTL>
  </Transaction>
  <Services>
    <Service>
      <ServiceType>45</ServiceType>
      <ServiceDescription>Flight from Nairobi to Diani</ServiceDescription>
      <ServiceDate>2013/12/20 19:00</ServiceDate>
    </Service>
  </Services>
  <Additional>
    <BlockPayment>BT</BlockPayment>
    <BlockPayment>PP</BlockPayment>
  </Additional>
</API3G>

AdditionalAirlineFields

Use AdditionalAirlineFields to send additional transaction properties for airline transactions.

ParameterData typeDescriptionRequired
AdditionalAirlineFieldsXML (String)Additional transaction properties.Optional

AdditionalAirlineFields parameters

ParameterData typeDescriptionRequired
TicketTypeTextTicket type.Optional
DocumentTypeTextDocument type.Optional
DateIssuedDateTimeDate issued.Mandatory
IATACarrierCodeTextIATA carrier code.Mandatory
IATATravelAgencyNbrTextIATA travel agency number.Optional
TicketCarrierNameTextTicket carrier name.Optional
TicketIssuerCityNameTextTicket issuer city name.Optional
PassengerCountNumericNumber of passengers.Optional
ConjTicketIndicatorTextConjunction ticket indicator.Optional
ElecTicketIndicatorTextElectronic ticket indicator.Optional
TicketNumberTextExchanged/original ticket number or PNR.Mandatory
FlightLegDetailsXML (String)Flight leg details.Optional
TravelersXML (String)Traveler details.Optional

AdditionalAirlineFields traveler parameters

ParameterData typeDescriptionRequired
TravelerFirstNameTextFirst name.Mandatory
TravelerLastNameTextLast name.Mandatory
TravelerPhoneTextPhone number.Optional
TravelerPhonePrefixNumericPhone number prefix without +.Optional
TravelerDateOfBirthDateTimeTraveler date of birth.Optional
TravelerCountryCodeTextTraveler country code.Optional

Flight leg parameters

ParameterData typeDescriptionRequired
FlightDescriptionTextDescription of the payment made.Mandatory
FlightTypeNumberService type number according to the options accepted by DPO.Mandatory
FlightDateDateTimeService date of the booked service. Format: YYYY/MM/DD HH:MM.Mandatory
FlightFromText3-letter departure airport code.Mandatory
FlightToText3-letter destination airport code.Mandatory
FlightRefTextService reference.Optional
CarrierCodeTextIATA carrier code.Mandatory
ServiceClassTextService class.Mandatory
FlightNumberTextFlight number.Mandatory
FareBasisCodeTextFare basis code.Mandatory
StopOverCodeTextStopover code.Mandatory

AdditionalAirlineFields request example

<API3G>
  <CompanyToken>90EC1DA4-A7C5-432C-930C-098715D3130E</CompanyToken>
  <Request>createToken</Request>
  <Transaction>
    <PaymentAmount>3.00</PaymentAmount>
    <PaymentCurrency>USD</PaymentCurrency>
    <CompanyRef>tr11212bnbv</CompanyRef>
    <CompanyRefUnique>0</CompanyRefUnique>
    <PTL>100000</PTL>
    <CompanyAccRef>www</CompanyAccRef>
    <PTLtype>minutes</PTLtype>
    <DefaultPayment>XP</DefaultPayment>
    <AllowRecurrent></AllowRecurrent>
    <customerFirstName>Dima</customerFirstName>
    <customerLastName>Kyselov</customerLastName>
    <customerCity>Nairobddi</customerCity>
    <customerCountry>KE</customerCountry>
    <CardHolderName>Dimdad Kyselovfd</CardHolderName>
    <customerEmail>[email protected]</customerEmail>
    <customerPhone>789564545</customerPhone>
    <DefaultPaymentCountry>Israel</DefaultPaymentCountry>
  </Transaction>
  <Services>
    <Service>
      <ServiceType>6456</ServiceType>
      <ServiceDescription>Airlines Service</ServiceDescription>
      <ServiceDate>2020/05/12</ServiceDate>
    </Service>
  </Services>
  <AdditionalAirlineFields>
    <TicketType>TICKET_PURCHASE</TicketType>
    <DocumentType>ADDITIONAL_COLLECTION</DocumentType>
    <DateIssued>2013/12/20 19:00</DateIssued>
    <IATACarrierCode>CP</IATACarrierCode>
    <IATATravelAgencyNbr>CPT</IATATravelAgencyNbr>
    <TicketCarrierName>KenyaAirways</TicketCarrierName>
    <TicketIssuerCityName>Nairobi</TicketIssuerCityName>
    <PassengerCount>3</PassengerCount>
    <ConjTicketIndicator>12233</ConjTicketIndicator>
    <ElecTicketIndicator>1A848F</ElecTicketIndicator>
    <ExchTicketIndicator>1A848E5</ExchTicketIndicator>
    <FlightLegDetails>
      <FlightLeg>
        <FlightDescription>Flight from TelAviv to CapeTown</FlightDescription>
        <FlightType>45</FlightType>
        <FlightDate>2013/12/20</FlightDate>
        <FlightFrom>TLV</FlightFrom>
        <FlightTo>CPT</FlightTo>
        <FlightRef>1234ABC</FlightRef>
        <CarrierCode>AI</CarrierCode>
        <ServiceClass>A</ServiceClass>
        <FlightNumber>101</FlightNumber>
        <FareBasisCode>SPRSVR</FareBasisCode>
        <StopOverCode>X</StopOverCode>
      </FlightLeg>
      <FlightLeg>
        <FlightDescription>Flight from CapeTown to TelAviv</FlightDescription>
        <FlightType>45</FlightType>
        <FlightDate>2013/12/21 16:00</FlightDate>
        <FlightFrom>CPT</FlightFrom>
        <FlightTo>TLV</FlightTo>
        <FlightRef>1234ABC</FlightRef>
        <CarrierCode>AI</CarrierCode>
        <ServiceClass>A</ServiceClass>
        <FlightNumber>101</FlightNumber>
        <FareBasisCode>SPRSVR</FareBasisCode>
        <StopOverCode>X</StopOverCode>
      </FlightLeg>
    </FlightLegDetails>
    <Travelers>
      <Traveler>
        <TravelerFirstName>John</TravelerFirstName>
        <TravelerLastName>Doe</TravelerLastName>
        <TravelerPhone>45640404</TravelerPhone>
        <TravelerPhonePrefix>123</TravelerPhonePrefix>
        <TravelerDateOfBirth>2001/12/21</TravelerDateOfBirth>
        <TravelerCountryCode>US</TravelerCountryCode>
      </Traveler>
      <Traveler>
        <TravelerFirstName>Rose</TravelerFirstName>
        <TravelerLastName>Doe</TravelerLastName>
      </Traveler>
    </Travelers>
  </AdditionalAirlineFields>
</API3G>

Response

The method responds with the result of your request.

Response fields

ParameterData typeDescription
Result3-digit codeCode sent with the result of the request.
ResultExplanationTextFree text result explanation.
TransTokenTextTransaction token, if the transaction was created.
TransRefTextTransaction reference, if the transaction was created.
notesTextRequest notes, if any.
AllocationIDNumberxPay ID when there is an allocation in the transaction.
AllocationCodeTextReceiver merchant code.
📘

Payment page URL: https://secure.3gdirectpay.com//payv2.php?ID={{TransToken}}

Example: https://secure.3gdirectpay.com//payv2.php?ID=72983CAC-5DB1-4C7F-BD88-352066B71592

Response codes

CodeExplanation
000Transaction created.
801Request missing company token.
802Company token does not exist.
803No request or error in request type name.
804Error in XML.
901Error: maximum string size allowed.
902Request missing transaction-level mandatory fields: name of field.
904Currency not supported.
905The transaction amount has exceeded your allowed transaction limit. Contact [email protected].
906You exceeded your monthly transaction limit. Contact [email protected].
922Provider does not exist.
923Allocated money exceeds payment amount.
930Block payment code incorrect.
940CompanyRef already exists and is paid.
950Request missing mandatory fields: name of field, or request fields are empty.
960Tag has been sent multiple times.

Success response example

<?xml version="1.0" encoding="utf-8"?>
<API3G>
  <Result>000</Result>
  <ResultExplanation>Transaction created</ResultExplanation>
  <TransToken>72983CAC-5DB1-4C7F-BD88-352066B71592</TransToken>
  <TransRef>1285DB12G</TransRef>
  <Allocations>
    <Allocation>
      <AllocationID>95746</AllocationID>
      <AllocationCode>f8g</AllocationCode>
    </Allocation>
  </Allocations>
</API3G>

Error response example

<?xml version="1.0" encoding="utf-8"?>
<API3G>
  <Result>920</Result>
  <ResultExplanation>Request missing mandatory allocation field AllocationCode</ResultExplanation>
</API3G>