Örnekler

Payguru Mobil Ödeme API bileşenleri ile ilgili örnekler aşağıda verilmiştir.


1. Get Subscription Data

> Request

http://api.trend-tech.net/MicroPayment/subscription/detail/123/1234/12345678

> Response (HTTP STATUS 200)

{  
"response":{  
      "result":"SUCCESS",
      "resultCode":"0000",
      "resultDescription":"SUCCESS",
     "resultDetail":null,
     "timeElapsed":"8 ms",
      "responseTime":"2017-12-13T15:29:00"
      },
"subscription":{  
    "id":12345678,
    "service":1234,
    "status":"suspend",
    "msisdn":"5XXXXXXXXX",
    "operator":5,
    "subscriptionFee":12,
    "period":"weekly",
    "subscriptionDate":"2017-12-13T15:15:39",
    "renewalDate":1513167339174,
    "cancellationDate":null,
    "cancellationSource":null,
    "referenceCode":null,
    "hasTrialPeriod":false,
    "trialPeriodDay":0,
    "lastTransaction":{  
    "id":12345678912345,
    "service":1234,
    "status":4,
    "msisdn":"5XXXXXXXXX",
    "operator":5,
    "amount":12,
    "error":"Yetersiz limit",
    "errorDetail":"17|Limit error:onetime",
    "transactionDate":"2017-12-13T15:15:39",
    "referenceCode":"null",
    "subscriptionId":12345678
  },
  "lastSuccessfulTransaction":null
 }
}

2. Cancel Subscription

> Request

http://api.trend-tech.net/MicroPayment/subscription/cancel/123/1234/12345678

> Response (HTTP STATUS 200)

{  
   "response":{  
      "result":"SUCCESS",
      "resultCode":"0000",
      "resultDescription":"SUCCESS",
      "resultDetail":null,
      "timeElapsed":"298 ms",
      "responseTime":"2017-12-13T15:30:39"
   },
   "subscription":{  
      "id":12345678,
      "service":1234,
      "status":"cancelled",
      "msisdn":"5XXXXXXXXX",
      "operator":5,
      "subscriptionFee":12,
      "period":"weekly",
      "subscriptionDate":"2017-12-13T15:15:39",
      "renewalDate":"2017-12-13T15:15:39",
      "cancellationDate":"2017-12-13T15:30:39",
      "cancellationSource":"mi",
      "hasTrialPeriod":false,
      "trialPeriodDay":0
   }
}

> Response (HTTP STATUS 409)

    {  
       "response":{  
          "result":"FAILED",
          "resultCode":"API_ERR_2005",
          "resultDescription":"Subscription is already cancelled",
          "resultDetail":"Subscription current status: cancelled",
          "timeElapsed":"6 ms",
          "responseTime":"2017-11-30T16:46:44"
       },
       "subscription":{  
          "id":12345678,
          "service":1234,
          "status":"cancelled",
          "msisdn":"5XXXXXXXXX",
          "operator":5,
          "subscriptionFee":12,
          "period":"weekly",
          "subscriptionDate":"2017-12-13T15:15:39",
          "renewalDate":"2017-12-13T15:15:39",
          "cancellationDate":"2017-12-13T15:30:39",
          "cancellationSource":"mi"
       }
    }

3. Search Subscription

> Request

POST http://api.trend-tech.net/MicroPayment/subscriptions/search

    {  
   "merchantId":123,
   "serviceId":456,
   "search":[  
      {  
         "column":"modifiedDate","term":"2017-11-30","condition":">="
      }
   ],
   "sort":[  
      {  
         "column":"id","asc":true
      }
   ],
   "limit":100,
   "page":1
}

> Response (HTTP STATUS 200)

    {  
       "response":{  
          "result":"SUCCESS",
          "resultCode":"0000",
          "resultDescription":"SUCCESS",
          "resultDetail":null,
          "timeElapsed":"6 ms",
          "responseTime":"2017-11-30T17:00:41"
       },
       "meta":{  
          "totalCount":1,
          "limit":100,
          "page":1,
          "pageCount":1
       },
       "subscriptions":[  
          {  
          "id":123456,
          "status":"cancelled",
          "msisdn":"5XXXXXXXXX",
          "operator":5,
          "period":"monthly",
          "subscriptionFee":12.00,
          "subscriptionDate":"2017-11-27T20:34:11",
          "renewalDate":"2017-11-27T20:34:11",
          "cancellationDate":"2017-11-30T16:46:13",
          "cancellationSource":"mi",
          "hasTrialPeriod":false,
          "trialPeriodDay":0
          }
       ]
    }

4. Get Transaction Data

> Request

http://api.trend-tech.net/MicroPayment/transaction/detail/123/1234/12345678912345 

> Response (HTTP STATUS 200)

    {  
       "response":{  
          "result":"SUCCESS",
          "resultCode":"0000",
          "resultDescription":"SUCCESS",
          "resultDetail":null,
          "timeElapsed":"5 ms",
          "responseTime":"2017-12-13T15:27:33"
       },
       "transaction":{  
          "id":12345678912345,
          "status":4,
          "service":1234,
          "msisdn":"5XXXXXXXXX",
          "operator":5,
          "item":"Servis Üyelik",
          "amount":12,
          "transactionDate":"2017-12-13T15:15:39",
          "refundDate":null,
          "referenceCode":"null",
          "error":"Yetersiz limit",
          "errorDetail":"17|Limit error:onetime",
          "subscription":{  
             "id":12345678,
             "service":1234,
             "status":"suspend",
             "msisdn":"5XXXXXXXXX",
             "operator":5,
             "subscriptionFee":12,
             "period":"weekly",
             "subscriptionDate":"2017-12-13T15:15:39",
             "renewalDate":"2017-12-13T15:15:39",
             "cancellationDate":null,
             "cancellationSource":null,
             "hasTrialPeriod":false,
             "trialPeriodDay":0
          }
       }
    }

5. Search Transaction

> Request

POST http://api.trend-tech.net/MicroPayment/transactions/search

{  
   "merchantId":123,
   "serviceId":1234,
   "search":[  
      {  
         "column":"msisdn", "term":"5XXXXXXXXX"
      },
      {  
         "column":"modifiedDate", "term":"2017-12-13T15:15:30", "condition":">="
      }
   ],
   "sort":[  
      {  
         "column":"id", "asc":false
      }
   ]
}

> Response (HTTP STATUS 200)

    {  
       "response":{  
          "result":"SUCCESS",
          "resultCode":"0000",
          "resultDescription":"SUCCESS",
          "resultDetail":null
       },
       "meta":{  
          "totalCount":1,
          "limit":10,
          "page":1,
          "pageCount":1
       },
       "transactions":[  
          {  
             "id":12345678912345,
             "service":1234,
             "status":4,
             "msisdn":"5XXXXXXXXX",
             "operator":5,
             "amount":12,
             "error":"Yetersiz limit",
             "errorDetail":"17|Limit error:onetime",
             "transactionDate":"2017-12-13T15:15:39",
             "referenceCode":"null",
             "subscriptionId":12345678
          }
       ]
    }

6. Search Message

> Request

POST http://api.trend-tech.net/MicroPayment/messages/search

    {  
       "merchantId":123,
       "serviceId":1234,
       "search":[  
          {  
             "column":"msisdn", "term":"5XXXXXXXXX"
          }
       ],
       "sort":[  
          {  
             "column":"id", "asc":false
          }
       ]
    }

> Response (HTTP STATUS 200)

    {  
       "response":{  
          "result":"SUCCESS",
          "resultCode":"0000",
          "resultDescription":"SUCCESS",
          "resultDetail":null
       },
       "meta":{  
          "totalCount":2,
          "limit":10,
          "page":1,
          "pageCount":1
       },
       "messages":[  
          {  
             "id":87664782,
             "service":1234,
             "msisdn":"532XXXXXXX",
             "operator":5,
             "type":"MT",
             "message":"Servis Uyelik aboneliginiz iptal edilmistir.",
             "date":"2017-12-13T15:30:39"
          },
          {  
             "id":87661735,
             "service":1234,
             "msisdn":"5XXXXXXXXX",
             "operator":5,
             "type":"MT",
             "message":"Abonelik ucretiniz tahsil edilemedi, mobil odeme yetkinizi kontrol ediniz",
             "date":"2017-12-13T15:15:40"
          }
        ]
    }

7. Create Token for Common Payment Page Flow

> Request

    POST https://cp.payguru.com/token

    {  
    "merchantId":1234,
    "serviceId":5677,
    "referenceCode":"XYZREF",
    "item":"Sample Product",
    "price":12.00,
    "successUrl":"http://yourdomain.com/success.php",
    "failureUrl":"http://yourdomain.com/error.php",
    "key":"97f70d5eb46f53f0e33bb41beaa24113"
    }

> Response (HTTP STATUS 200)

    {  
       "response":{  
          "result":"SUCCESS",
          "resultCode":"0000",
          "resultDescription":"SUCCESS",
          "resultDetail":null,
          "timeElapsed":"8 ms",
          "respnseTime": "2018-05-28T11:23:00"
       },
       "tokenData":{  
          "token":"da202dc28c0acd6b38a279fbdf790ebb",
          "redirectUrl":"https://cp.payguru.com/?token=da2020dc28c0acd6b38a279fbdf790ebb",
          "expiryDate":"2018-05-28T11:26.00",
        }
    }

> Response (HTTP STATUS 400)

    {  
    "response":{  
    "result":"FAILED",
    "resultCode":"API_ERR_1023",
    "resultDescription":"Invalid parameter, key",
    "resultDetail":" key parameter is wrong, sent key: xEVGc24dsa23D34tadfq1asd235A", 
    "timeElapsed":"6 ms",
    "respnseTime": "2018-05-28T11:26:00"
        },
    }