Esc
Start typing to search...

Masterpass Integration

What is Masterpass? #

Masterpass is Mastercard's digital payment solution. After users register their cards in the Masterpass system, they can make fast and secure payments with their mobile phone numbers.

The marketplace system supports accepting payments with Masterpass as well as standard card payments.

Advantages #

  • Fast Payment - User does not enter card info, only SMS confirmation
  • Secure - Card info is stored by Masterpass
  • Mobile Friendly - Easy use on mobile devices
  • Stored Cards - Users' cards registered in Masterpass are used

CreatePayment (Masterpass) #

A special endpoint is used to accept payments with Masterpass.

Endpoint #

TEST:

POST https://apitest.paynkolay.com.tr/marketplace/v1/payment/create/MASTERPASS

PROD:

POST https://api.paynkolay.com.tr/marketplace/v1/payment/create/MASTERPASS

Request Parameters #

In Masterpass payment, bankCard information is not sent. Instead, the gsm parameter is mandatory.

{
  "apiKey": "calculated_api_key",
  "apiSecretKey": "sx_value",
  "gsm": "5321234567",
  "trxCurrency": "TRY",
  "trxAmount": 150.00,
  "trxCode": "ORDER_12345",
  "trxType": "SALES",
  "callbackUrl": "https://yoursite.com/payment-callback",
  "sellerList": [
    {
      "sellerExternalId": "SELLER_001",
      "trxAmount": 100.00,
      "withholdingTax": 0.80
    },
    {
      "sellerExternalId": "SELLER_002",
      "trxAmount": 50.00,
      "withholdingTax": 0.40
    }
  ],
  "shippingCost": 0.00,
  "otherAmount": 0.00,
  "marketplaceCode": "MP12345"
}

Masterpass Specific Parameters #

ParameterTypeRequiredDescription
gsmStringUser's mobile phone (without +90 prefix)

GSM Format:

✅ Correct: "5321234567"
❌ Wrong: "+905321234567"
❌ Wrong: "05321234567"

Common Mandatory Parameters #

Common mandatory parameters with standard CreatePayment:

  • apiKey
  • apiSecretKey
  • trxCurrency
  • trxAmount
  • trxCode
  • trxType
  • callbackUrl
  • sellerList (sellerExternalId, trxAmount, withholdingTax)
  • shippingCost
  • otherAmount
  • marketplaceCode

OMITTED Parameters #

The following parameters are not sent in Masterpass payment:

  • ❌ bankCard (card info)
  • ❌ installment
  • ❌ isFetchInstallments
  • ❌ encodedValue
  • ❌ customerCardInfo

Response #

{
  "data": {
    "refCode": "REF123456789",
    "trxCode": "ORDER_12345",
    "form": "PGh0bWw+...Masterpass HTML Form Base64..."
  },
  "success": true,
  "responseCode": "200",
  "responseMessage": "SUCCESS"
}

Response format is the same as standard CreatePayment. form field contains Base64 encoded HTML.


Masterpass Transaction Flow #

sequenceDiagram
    participant User as Kullanıcı
    participant Your as Sizin Sistem
    participant PNK as Paynkolay
    participant MP as Masterpass

    User->>Your: GSM numarası ile ödeme başlat
    Your->>PNK: CreatePayment/MASTERPASS (gsm)
    PNK->>Your: HTML Form (Base64)
    Your->>Your: Base64 Decode
    Your->>User: Masterpass Form Göster
    User->>MP: Masterpass'e Giriş
    MP->>User: Kayıtlı Kartları Göster
    User->>MP: Kart Seç + SMS Onay
    MP->>PNK: Ödeme Sonucu
    PNK->>Your: callbackUrl'e POST
    Your->>User: Sonuç Sayfası

Example Code #


Callback Processing #

Masterpass payment callback process is the same as standard payment:

app.post('/payment-callback', (req, res) => {
  const {
    trxCode,
    responseCode,
    referenceCode,
    authAmount,
    timestamp,
    hash,
    paymentSystem  // Masterpass için "MASTERPASS" değeri gelir
  } = req.body;

  // Hash doğrula
  const calculatedHash = calculateCallbackHash({
    timestamp,
    referenceCode,
    trxCode,
    authAmount,
    responseCode
  }, apiSecretKey);

  if (calculatedHash !== hash) {
    return res.status(400).send('Invalid hash');
  }

  // Ödeme başarılı mı?
  if (responseCode === '00' || responseCode === '0000') {
    // Masterpass ile ödeme başarılı
    console.log('Masterpass ödeme başarılı:', trxCode);
    updateOrderStatus(trxCode, 'PAID', 'MASTERPASS');
  } else {
    console.log('Masterpass ödeme başarısız:', responseCode);
    updateOrderStatus(trxCode, 'FAILED');
  }

  res.status(200).send('OK');
});

User Interface Example #

Payment Method Selection #

<div class="payment-methods">
  <label>
    <input type="radio" name="paymentMethod" value="card">
    Kredi/Banka Kartı
  </label>

  <label>
    <input type="radio" name="paymentMethod" value="masterpass">
    <img src="/images/masterpass-logo.png" alt="Masterpass">
    Masterpass ile Öde
  </label>
</div>

<div id="card-form" style="display:none;">
  <!-- Standart kart formu -->
  <input type="text" name="cardNumber" placeholder="Kart Numarası">
  <input type="text" name="cardHolder" placeholder="Kart Üzerindeki İsim">
  <!-- ... -->
</div>

<div id="masterpass-form" style="display:none;">
  <label>Cep Telefonu Numaranız:</label>
  <input type="tel" name="gsm" placeholder="5XX XXX XX XX" pattern="5[0-9]{9}">
  <small>Masterpass'e kayıtlı cep telefonu numaranız</small>
</div>

<script>
document.querySelectorAll('input[name="paymentMethod"]').forEach(radio => {
  radio.addEventListener('change', (e) => {
    document.getElementById('card-form').style.display =
      e.target.value === 'card' ? 'block' : 'none';

    document.getElementById('masterpass-form').style.display =
      e.target.value === 'masterpass' ? 'block' : 'none';
  });
});
</script>

Form Submission #

async function processPayment(formData) {
  const paymentMethod = formData.get('paymentMethod');

  if (paymentMethod === 'masterpass') {
    // Masterpass ile ödeme
    const gsm = formData.get('gsm').replace(/\s/g, ''); // Boşlukları temizle

    // GSM validasyonu
    if (!/^5[0-9]{9}$/.test(gsm)) {
      alert('Geçerli bir cep telefonu numarası girin');
      return;
    }

    const response = await fetch('/api/payment/masterpass', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        gsm: gsm,
        amount: orderTotal,
        orderId: orderId
      })
    });

    const result = await response.json();

    if (result.success) {
      // Base64 decode ve göster
      const htmlForm = atob(result.data.form);
      document.body.innerHTML = htmlForm;
    }

  } else {
    // Standart kart ile ödeme
    // ...
  }
}

Masterpass Features #

Card Info Not Required #

// ❌ YANLIŞ - Masterpass için kart bilgisi göndermeyin
// ❌ WRONG - Do not send card info for Masterpass
{
  "bankCard": {
    "cardNumber": "...",
    "cvv": "..."
  },
  "gsm": "5321234567"
}

// ✅ DOĞRU - Sadece GSM yeterli
// ✅ CORRECT - Only GSM is sufficient
{
  "gsm": "5321234567"
  // bankCard GÖNDERİLMEZ / OMITTED
}

Installment Support #

In Masterpass payments, installment options are shown on the Masterpass screen. Installment parameter is not sent in the API request.

Stored Cards #

Using the GSM number, user's cards registered in Masterpass are automatically retrieved. No additional action is required.


Error Situations #

Not Registered to Masterpass #

If user's GSM number is not registered to Masterpass, a registration option is offered on the Masterpass screen.

// Kullanıcıyı bilgilendir
if (paymentMethod === 'masterpass') {
  alert(
    'Masterpass ile ödeme yapmak için Masterpass hesabınızın olması gerekmektedir. ' +
    'Eğer hesabınız yoksa, ödeme ekranında Masterpass\'e kayıt olabilirsiniz.'
  );
}

Invalid GSM #

function validateGSM(gsm) {
  // Başında 5, toplam 10 hane
  if (!/^5[0-9]{9}$/.test(gsm)) {
    throw new Error('Geçersiz GSM formatı. Başında 0 olmadan 10 hane olmalı.');
  }
  return true;
}

Masterpass vs Standard Card #

FeatureMasterpassStandard Card
Card Info❌ Not Required✅ Required
GSM✅ Mandatory❌ Optional
Speed⚡ Very Fast🐢 Slower
Security🔒 Masterpass🔒 3D Secure
Stored Card✅ Automatic❌ Manual
Mobile📱 Optimize💻 Standard

Testing #

For Masterpass test operations:

  • Test GSM Number: Use test numbers provided by Mastercard
  • Test Cards: Add test cards to Masterpass test account
  • Test Environment: apitest.paynkolay.com.tr use

Next Steps #

After completing Masterpass integration: