Attach a saved card to a seller

Credentials

Attaches a saved card, identified by its buyer_key, to a seller. A contract paid by credit card uses a card attached this way; see the contracts overview.

If the card was saved by PayMe for a contract, it is assigned to this seller. Calling again for the same card isn't needed.

This endpoint sends no callback. The result, including the buyer token fields, is in the HTTP response: status_code 0 means success and 1 means failure.

The response holds the buyer's details, so handle it securely.

Errors

HTTP status Error code Message When
500 900 Please provide all required information in JSON format. Make sure to include 'Content-Type: application/json' header The request is not JSON.
500 901 Please verify that the JSON provided is valid The JSON body is empty or invalid.
500 1 Required parameter is missing One of these is missing: seller_payme_id, buyer_key. status_additional_info names it.
500 251 Seller was not found The seller key is unknown.
500 163 Account settings problem - please contact Customer Support The seller is not active.
500 600 Buyer not found No buyer has this buyer_key.
500 604 Buyer inactive The buyer is inactive.
500 605 The buyer was not captured using the provided seller This seller may not use this buyer.

Parameters

This endpoint takes no path, query or header parameters.

Request body

Content type: application/json

Field Type Required Description
seller_payme_id string yes The seller's MPL: the seller the card is attached to.
buyer_key string yes The saved card to attach, from Capture a buyer token or a sale callback.

Request example

{
  "seller_payme_id": "MPLDEMO-MPLDEMO-MPLDEMO-1234567",
  "buyer_key": "BUYERDEMO-BUYERDEMO-BUYERDEMO-1234567"
}

Code samples

curl

curl -X POST 'https://sandbox.payme.io/api/add-card-to-seller' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "seller_payme_id": "MPLDEMO-MPLDEMO-MPLDEMO-1234567",
  "buyer_key": "BUYERDEMO-BUYERDEMO-BUYERDEMO-1234567"
}'

Node.js

const response = await fetch("https://sandbox.payme.io/api/add-card-to-seller", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "seller_payme_id": "MPLDEMO-MPLDEMO-MPLDEMO-1234567",
    "buyer_key": "BUYERDEMO-BUYERDEMO-BUYERDEMO-1234567"
  }),
});

console.log(await response.text());

Python

import requests

response = requests.post(
    "https://sandbox.payme.io/api/add-card-to-seller",
    json={
        "seller_payme_id": "MPLDEMO-MPLDEMO-MPLDEMO-1234567",
        "buyer_key": "BUYERDEMO-BUYERDEMO-BUYERDEMO-1234567",
    },
)

print(response.text)

PHP

<?php

$body = <<<'BODY'
{
  "seller_payme_id": "MPLDEMO-MPLDEMO-MPLDEMO-1234567",
  "buyer_key": "BUYERDEMO-BUYERDEMO-BUYERDEMO-1234567"
}
BODY;

$ch = curl_init('https://sandbox.payme.io/api/add-card-to-seller');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;

Responses

200 — OK (success)

Field Type Description
status_code integer 0 on success.
session string PayMe session ID.
buyer_key string The buyer token (buyer_key) you sent.
buyer_name string The buyer's name.
buyer_email string The buyer's email address.
buyer_phone string The buyer's phone number.
buyer_card_mask string The masked card number.
buyer_card_exp string The card expiry date, MMYY.
buyer_social_id string The buyer's national ID number.
buyer_is_permanent boolean Whether the buyer token is permanent.
buyer_status string Always null; ignore it.
{
  "status_code": 0,
  "session": "a1B2c3D4",
  "buyer_key": "BUYERDEMO-BUYERDEMO-BUYERDEMO-1234567",
  "buyer_name": "Example Buyer",
  "buyer_email": "buyer@example.com",
  "buyer_phone": "0500000001",
  "buyer_card_mask": "458045******4580",
  "buyer_card_exp": "1228",
  "buyer_social_id": "123456782",
  "buyer_is_permanent": false,
  "buyer_status": null
}

500 — Error, for example error 600: no buyer has this buyer_key (error)

Field Type Description
status_code integer 1 on failure.
status_error_code integer PayMe error code. See Errors.
status_error_details string Error message, in the request's language.
status_additional_info string Extra detail, such as the name of the missing or invalid field. Can be null.
session string PayMe session ID. Quote it when you contact support.
{
  "status_code": 1,
  "status_error_details": "Buyer not found",
  "status_additional_info": null,
  "status_error_code": 600,
  "session": "XXXXXXXX"
}