{
"Tag": "Created using the Mangopay API Postman collection",
"AuthorId": "213407540",
"DebitedFunds": {
"Currency": "EUR",
"Amount": 1300
},
"Fees": {
"Currency": "EUR",
"Amount": 300
},
"CreditedWalletId": "213407543",
"ReturnURL": "http://www.mangopay.com/docs/please-ignore",
"StatementDescriptor": "Mangopay",
"Billing": {
"FirstName": "Alex",
"LastName": "Smith",
"Address": {
"AddressLine1": "6 rue de la Cité",
"AddressLine2": "Appartement 3",
"City": "Paris",
"Region": "île-de-france",
"PostalCode": "75003",
"Country": "FR"
}
},
"Shipping": {
"FirstName": "Alex",
"LastName": "Smith",
"Address": {
"AddressLine1": "Rue de la Fourche 26",
"AddressLine2": "Appartement 3",
"City": "Bruxelles",
"Region": "Bruxelles-Capitale",
"PostalCode": "75003",
"Country": "BE"
}
},
"LineItems": [
{
"Name": "Running shoes",
"Quantity": 2,
"UnitAmount": 400,
"TaxAmount": 100,
"Description": "ID of Seller 1",
"Category": "PHYSICAL_GOODS",
"Sku": "example-item-123",
"Discount": 100,
},
{
"Name": "Walking shoes",
"Quantity": 1,
"UnitAmount": 400,
"TaxAmount": 100,
"Description": "ID of Seller 2",
"Category": "PHYSICAL_GOODS",
"Sku": "example-item-456",
"Discount": 100,
}
],
"Country": "FR",
"Culture": "FR",
"Email": "alex.smith@example.com",
"Phone": "[+33][689854321]",
"AdditionalData": "{\"customer_account_info\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"app_id\": \"81363501-3540-494a-8627-33bc6112035d\",\"loyalty_level\": \"high\",\"customer_email\": \"customer@email.com\",\"customer_phone\": \"0611223344\",\"customer_ranking\": 2,\"customer_reviews\": 5,\"last_login_time\": \"2023-10-21T19:11:34Z\",\"account_security\": {\"last_verification_method\": \"2FA TOTP\",\"last_verification_time\": \"2023-10-21T19:11:34Z\",\"device_id\": \"772af5a5-2d55-4a5e-bb79-85969f683810\",\"fraud_behavior\": false,\"devices_linked\": 2,\"phone_verified\": true,\"email_verified\": true,\"failed_transactions_attempts\": 0},\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": \"2022-12-22T18:45:44Z\"}],\"marketplace_seller_info\": [{\"sub_merchant_id\": \"615a0e87-4941-45dc-978d-e6efcbd90ba0\",\"sub_merchant_name\": \"Marketbrick Ltd.\",\"sub_merchant_postal_code\": \"75010\",\"product_category\": \"Computers\",\"product_name\": \"Asus Zenbook 14\",\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2020-06-10T12:02:21Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2020-06-10T12:02:21Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"digital_download\": false,\"seller_rating\": 4.5,\"number_of_trades\": 34,\"volume_of_trades\": 4500}],\"payment_history_full\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 10,\"payment_option\": \"card\",\"total_amount_paid_purchases\": 1000.10,\"date_of_first_paid_purchase\": \"2020-06-10T12:12:34Z\",\"date_of_last_paid_purchase\": \"2023-10-26T18:52:38Z\"},{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 14,\"payment_option\": \"non klarna credit\",\"total_amount_paid_purchases\": 2322.10,\"date_of_first_paid_purchase\": \"2021-10-11T20:31:15Z\",\"date_of_last_paid_purchase\": \"2023-09-22T14:59:22Z\"}],\"marketplace_winner_info\": [{\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2022-12-22T18:45:44Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2023-08-14T08:23:34Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"number_of_trades\": 24,\"volume_of_trades\": 3322}],\"other_delivery_address\": [{\"shipping_method\": \"pick-up point\",\"shipping_type\": \"express\",\"first_name\": \"Test\",\"last_name\": \"Person\",\"street_address\": \"Rue La Fayette\",\"street_number\": \"33\",\"postal_code\": \"75009\",\"city\": \"Paris\",\"country\": \"FR\"}]}",
"Reference": "1234"
}
<?php
require_once 'vendor/autoload.php';
use MangoPay\MangoPayApi;
use MangoPay\Libraries\ResponseException as MGPResponseException;
use MangoPay\Libraries\Exception as MGPException;
$api = new MangoPayApi();
$api->Config->ClientId = 'your-client-id';
$api->Config->ClientPassword = 'your-api-key';
$api->Config->TemporaryFolder = 'tmp/';
try {
$user = $api->Users->Get('210513027');
$payIn = new \MangoPay\PayIn();
$payIn->Tag = "Created using Mangopay PHP SDK";
$payIn->CreditedWalletId = "210514820";
$payIn->PaymentType = "KLARNA";
$payIn->AuthorId = $user->Id;
$payIn->DebitedFunds = new \MangoPay\Money();
$payIn->DebitedFunds->Currency = 'EUR';
$payIn->DebitedFunds->Amount = 1500;
$payIn->Fees = new \MangoPay\Money();
$payIn->Fees->Currency = 'EUR';
$payIn->Fees->Amount = 300;
$payIn->ExecutionDetails = new \MangoPay\PayInExecutionDetailsWeb();
$payIn->ExecutionDetails->ReturnURL = "http://example.com";
$payIn->ExecutionDetails->Culture = 'FR';
$payIn->PaymentDetails = new \MangoPay\PayInPaymentDetailsKlarna();
$payIn->PaymentDetails->Email = $user->Email;
$payIn->PaymentDetails->Phone = '[+33][689854321]';
$payIn->PaymentDetails->Country = $user->Address->Country;
$payIn->PaymentDetails->AdditionalData = "your-additional-data"
$payIn->PaymentDetails->Reference = '8569';
$payIn->ExecutionDetails->Billing = new \MangoPay\Billing();
$payIn->ExecutionDetails->Billing->FirstName = $user->FirstName;
$payIn->ExecutionDetails->Billing->LastName = $user->LastName;
$payIn->ExecutionDetails->Billing->Address = new \MangoPay\Address();
$payIn->ExecutionDetails->Billing->Address->AddressLine1 =$user->Address->AddressLine1;
$payIn->ExecutionDetails->Billing->Address->AddressLine2 =$user->Address->AddressLine2;
$payIn->ExecutionDetails->Billing->Address->Region = $user->Address->Region;
$payIn->ExecutionDetails->Billing->Address->City = $user->Address->City;
$payIn->ExecutionDetails->Billing->Address->PostalCode = $user->Address->PostalCode;
$payIn->ExecutionDetails->Billing->Address->Country = $user->Address->Country;
$payIn->PaymentDetails->Shipping = new \MangoPay\Shipping();
$payIn->PaymentDetails->Shipping->FirstName = $user->FirstName;
$payIn->PaymentDetails->Shipping->LastName = $user->LastName;
$payIn->PaymentDetails->Shipping->Address = new \MangoPay\Address();
$payIn->PaymentDetails->Shipping->Address->AddressLine1 =$user->Address->AddressLine1;
$payIn->PaymentDetails->Shipping->Address->AddressLine2 =$user->Address->AddressLine2;
$payIn->PaymentDetails->Shipping->Address->Region = $user->Address->Region;
$payIn->PaymentDetails->Shipping->Address->City = $user->Address->City;
$payIn->PaymentDetails->Shipping->Address->PostalCode = $user->Address->PostalCode;
$payIn->PaymentDetails->Shipping->Address->Country = $user->Address->Country;
$lineItem1 = new \MangoPay\LineItem();
$lineItem1->Name = 'Running shoes';
$lineItem1->Quantity = 1;
$lineItem1->UnitAmount = 400;
$lineItem1->TaxAmount = 100;
$lineItem1->Description = 'ID of Seller 1';
$lineItem2 = new \MangoPay\LineItem();
$lineItem2->Name = 'Walking shoes';
$lineItem2->Quantity = 2;
$lineItem2->UnitAmount = 400;
$lineItem2->TaxAmount = 100;
$lineItem2->Description = 'ID of Seller 2';
$payIn->PaymentDetails->LineItems = array($lineItem1, $lineItem2);
$response = $api->PayIns->Create($payIn);
print_r($response);
} catch(MGPResponseException $e) {
print_r($e);
} catch(MGPException $e) {
print_r($e);
}
const mangopayInstance = require('mangopay4-nodejs-sdk');
const mangopay = new mangopayInstance({
clientId: "your-client-id",
clientApiKey: "your-api-key",
})
let myPayIn = {
PaymentType: 'KLARNA',
ExecutionType: 'WEB',
AuthorId: '210513027',
Tag: 'Created with Mangopay Node.js SDK',
CreditedUserId: '210513027',
DebitedFunds: {
Currency: 'EUR',
Amount: 400
},
Fees: {
Currency: 'EUR',
Amount: 10
},
LineItems: [
{
Name: "Running shoes",
Quantity: 1,
UnitAmount: 200,
TaxAmount: 0,
Description: "seller1 ID"
},
{
Name: "Running shoes",
Quantity: 1,
UnitAmount: 200,
TaxAmount: 0,
Description: "seller2 ID"
}
],
Country: 'FR',
Phone: '33#607080900',
Email: 'mango@mangopay.com',
CreditedWalletId: '210514820',
ReturnURL: 'http://example.com',
Culture: 'FR',
Billing: {
FirstName: 'Alex',
LastName: 'Smith',
Address: {
AddressLine1: 'Rue des plantes',
AddressLine2: 'The Oasis',
City: 'Paris',
Region: 'IDF',
PostalCode: '75000',
Country: 'FR',
},
},
Shipping: {
FirstName: 'Alex',
LastName: 'Smith',
Address: {
AddressLine1: 'Rue des plantes',
AddressLine2: 'The Oasis',
City: 'Paris',
Region: 'IDF',
PostalCode: '75000',
Country: 'FR',
},
},
AdditionalData: 'your-additional-data',
StatementDescriptor: 'Feb2024',
Reference: 'afd48-879d-48fg'
}
const createKlarnaPayIn = async (payin) => {
return await mangopay.PayIns.create(payin)
.then((response) => {
console.info(response)
return response
})
.catch((err) => {
console.log(err)
return false
})
}
createKlarnaPayIn(myPayIn)
require 'mangopay'
require 'PP'
MangoPay.configure do |client|
client.preproduction = true
client.client_id = 'your-client-id'
client.client_apiKey = 'your-api-key'
client.log_file = File.join(Dir.pwd, 'mangopay.log')
end
let myPayIn = {
PaymentType: 'KLARNA',
ExecutionType: 'WEB',
AuthorId: '210513027',
Tag: 'Created with Mangopay Node.js SDK',
CreditedUserId: '210513027',
DebitedFunds: {
Currency: 'EUR',
Amount: 400
},
Fees: {
Currency: 'EUR',
Amount: 10
},
LineItems: [
{
Name: "running shoes",
Quantity: 1,
UnitAmount: 200,
TaxAmount: 0,
Description: "seller1 ID"
},
{
Name: "running shoes",
Quantity: 1,
UnitAmount: 200,
TaxAmount: 0,
Description: "seller2 ID"
}
],
Country: 'FR',
Phone: '33#607080900',
Email: 'mango@mangopay.com',
CreditedWalletId: '210514820',
ReturnURL: 'http://example.com',
Culture: 'FR',
Billing: {
FirstName: 'Alex',
LastName: 'Smith',
Address: {
AddressLine1: 'Rue des plantes',
AddressLine2: 'The Oasis',
City: 'Paris',
Region: 'IDF',
PostalCode: '75000',
Country: 'FR',
},
},
Shipping: {
FirstName: 'Alex',
LastName: 'Smith',
Address: {
AddressLine1: 'Rue des plantes',
AddressLine2: 'The Oasis',
City: 'Paris',
Region: 'IDF',
PostalCode: '75000',
Country: 'FR',
},
},
StatementDescriptor: 'Feb2024',
Reference: 'afd48-879d-48fg',
AdditionalData: "your-additional-data"
}
const createKlarnaPayIn = async (payin) => {
return await mangopay.PayIns.create(payin)
.then((response) => {
console.info(response)
return response
})
.catch((err) => {
console.log(err)
return false
})
}
pp(createKlarnaPayIn(myPayIn))
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mangopay.MangoPayApi;
import com.mangopay.core.Address;
import com.mangopay.core.Billing;
import com.mangopay.core.LineItem;
import com.mangopay.core.Money;
import com.mangopay.entities.PayIn;
import com.mangopay.entities.User;
import com.mangopay.entities.subentities.PayInExecutionDetailsWeb;
import com.mangopay.entities.subentities.PayInPaymentDetailsKlarna;
import com.mangopay.core.enumerations.PayInExecutionType;
import com.mangopay.core.enumerations.PayInPaymentType;
import com.mangopay.core.enumerations.CountryIso;
import com.mangopay.core.enumerations.CultureCode;
import com.mangopay.core.enumerations.CurrencyIso;
import java.util.Arrays;
import java.util.List;
public class CreateKlarnaPayIn {
public static void main(String[] args) throws Exception {
MangoPayApi mangopay = new MangoPayApi();
mangopay.getConfig().setClientId("your-client-id");
mangopay.getConfig().setClientPassword("your-api-key");
PayIn payin = new PayIn();
User myUser = mangopay.getUserApi().get("user_m_01HT2NFK7Z2BRQNGNHMY30VVTT");
var walletId = "wlt_m_01HTHTXEF4BJCTKMXNWMSZ6KP5";
var additionalData = "{\"customer_account_info\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"app_id\": \"81363501-3540-494a-8627-33bc6112035d\",\"loyalty_level\": \"high\",\"customer_email\": \"customer@email.com\",\"customer_phone\": \"0611223344\",\"customer_ranking\": 2,\"customer_reviews\": 5,\"last_login_time\": \"2023-10-21T19:11:34Z\",\"account_security\": {\"last_verification_method\": \"2FA TOTP\",\"last_verification_time\": \"2023-10-21T19:11:34Z\",\"device_id\": \"772af5a5-2d55-4a5e-bb79-85969f683810\",\"fraud_behavior\": false,\"devices_linked\": 2,\"phone_verified\": true,\"email_verified\": true,\"failed_transactions_attempts\": 0},\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": \"2022-12-22T18:45:44Z\"}],\"marketplace_seller_info\": [{\"sub_merchant_id\": \"615a0e87-4941-45dc-978d-e6efcbd90ba0\",\"sub_merchant_name\": \"Marketbrick Ltd.\",\"sub_merchant_postal_code\": \"75010\",\"product_category\": \"Computers\",\"product_name\": \"Asus Zenbook 14\",\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2020-06-10T12:02:21Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2020-06-10T12:02:21Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"digital_download\": false,\"seller_rating\": 4.5,\"number_of_trades\": 34,\"volume_of_trades\": 4500}],\"payment_history_full\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 10,\"payment_option\": \"card\",\"total_amount_paid_purchases\": 1000.10,\"date_of_first_paid_purchase\": \"2020-06-10T12:12:34Z\",\"date_of_last_paid_purchase\": \"2023-10-26T18:52:38Z\"},{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 14,\"payment_option\": \"non klarna credit\",\"total_amount_paid_purchases\": 2322.10,\"date_of_first_paid_purchase\": \"2021-10-11T20:31:15Z\",\"date_of_last_paid_purchase\": \"2023-09-22T14:59:22Z\"}],\"marketplace_winner_info\": [{\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2022-12-22T18:45:44Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2023-08-14T08:23:34Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"number_of_trades\": 24,\"volume_of_trades\": 3322}],\"other_delivery_address\": [{\"shipping_method\": \"pick-up point\",\"shipping_type\": \"express\",\"first_name\": \"Test\",\"last_name\": \"Person\",\"street_address\": \"Rue La Fayette\",\"street_number\": \"33\",\"postal_code\": \"75009\",\"city\": \"Paris\",\"country\": \"FR\"}]}";
Address address = new Address();
address.setAddressLine1("2795 Edgewood Road");
address.setCity("Little Rock");
address.setRegion("Arkansas");
address.setPostalCode("72212");
address.setCountry(CountryIso.FR);
LineItem lineItem1 = new LineItem(null, null, null, null, null);
lineItem1.setName("Running shoes");
lineItem1.setQuantity(1);
lineItem1.setUnitAmount(200);
lineItem1.setTaxAmount(0);
lineItem1.setDescription("Seller 1 ID");
LineItem lineItem2 = new LineItem(null, null, null, null, null);
lineItem2.setName("Running shoes");
lineItem2.setQuantity(1);
lineItem2.setUnitAmount(200);
lineItem2.setTaxAmount(0);
lineItem2.setDescription("Seller 2 ID");
List<LineItem> lineItems = Arrays.asList(lineItem1, lineItem2);
PayInExecutionDetailsWeb payinExecutionDetails = new PayInExecutionDetailsWeb();
payinExecutionDetails.setReturnUrl("http://www.mangopay.com/docs/please-ignore");
PayInPaymentDetailsKlarna paymentDetails = new PayInPaymentDetailsKlarna();
paymentDetails.setAdditionalData(additionalData);
paymentDetails.setBilling(new Billing());
paymentDetails.getBilling().setFirstName("Alex");
paymentDetails.getBilling().setLastName("Smith");
paymentDetails.getBilling().setAddress(address);
paymentDetails.setCountry(CountryIso.FR);
paymentDetails.setCulture(CultureCode.FR);
paymentDetails.setReference("1234");
paymentDetails.setPhone("[+33][689854321]");
paymentDetails.setEmail(myUser.getEmail());
paymentDetails.setLineItems(lineItems);
payin.setPaymentType(PayInPaymentType.KLARNA);
payin.setExecutionType(PayInExecutionType.WEB);
payin.setCreditedWalletId(walletId);
payin.setExecutionDetails(payinExecutionDetails);
payin.setPaymentDetails(paymentDetails);
payin.setTag("Created with Mangopay Java SDK");
payin.setAuthorId(myUser.getId());
payin.setDebitedFunds(new Money(CurrencyIso.EUR, 400));
payin.setFees(new Money(CurrencyIso.EUR, 100));
PayIn createKlarnaPayin = mangopay.getPayInApi().create(payin);
Gson prettyPrint = new GsonBuilder().setPrettyPrinting().create();
String prettyJson = prettyPrint.toJson(createKlarnaPayin);
System.out.println(prettyJson);
}
}
from pprint import pprint
import mangopay
mangopay.client_id='your-client-id'
mangopay.apikey='your-api-key'
from mangopay.api import APIRequest
handler = APIRequest(sandbox=True)
from mangopay.resources import NaturalUser, KlarnaPayIn
from mangopay.utils import Money, Billing, Shipping, Address, LineItem
natural_user = NaturalUser.get('210513027')
klarna_payin = KlarnaPayIn(
author = natural_user,
credited_wallet_id = '210514820',
debited_funds = Money(amount=1500, currency='EUR'),
fees = Money(amount=300, currency='EUR'),
return_url = 'http://www.mangopay.com/docs/please-ignore',
statement_descriptor = 'Feb2024',
billing = Billing(
first_name = natural_user.first_name,
last_name = natural_user.last_name,
address = Address(
address_line_1 = natural_user.address.address_line_1,
address_line_2 = natural_user.address.address_line_2,
city = natural_user.address.city,
region = natural_user.address.region,
postal_code = natural_user.address.postal_code,
country = natural_user.address.country
)
),
line_items = [
LineItem(
name = 'Running shoes',
quantity=1,
unit_amount=400,
tax_amount=100,
description='ID of Seller 1'),
LineItem(
name = 'Walking shoes',
quantity=2,
unit_amount=400,
tax_amount=100,
description='ID of Seller 2')
],
shipping = Shipping(
first_name = natural_user.first_name,
last_name = natural_user.last_name,
address = Address(
address_line_1 = natural_user.address.address_line_1,
address_line_2 = natural_user.address.address_line_2,
city = natural_user.address.city,
region = natural_user.address.region,
postal_code = natural_user.address.postal_code,
country = natural_user.address.country,
)
),
country = natural_user.address.country,
email = natural_user.email,
phone = '[+33][689854321]',
reference = '2345',
culture = 'FR',
additional_data = 'your-additional-data',
tag = 'Created using the Mangopay Python SDK'
)
create_klarna_payin = klarna_payin.save()
pprint(create_klarna_payin)
using MangoPay.SDK;
using MangoPay.SDK.Core.Enumerations;
using MangoPay.SDK.Entities;
using MangoPay.SDK.Entities.POST;
using Newtonsoft.Json;
class Program
{
static async Task Main(string[] args)
{
MangoPayApi api = new MangoPayApi();
api.Config.ClientId = "your-client-id";
api.Config.ClientPassword = "your-api-key";
var myUser = await api.Users.GetNaturalAsync("210513027");
List<LineItem> LineItems = new List<LineItem>();
var myPayIn = new PayInKlarnaWebPostDTO(
authorId: myUser.Id,
debitedFunds: new Money {
Amount = 1500,
Currency = CurrencyIso.EUR
},
fees: new Money {
Amount = 300,
Currency = CurrencyIso.EUR
},
creditedWalletId: "210514820",
returnUrl: "http://www.mangopay.com/docs/please-ignore",
lineItems: new List<LineItem>{
new LineItem
{
Name = "Running shoes",
Quantity = 1,
UnitAmount = 400,
TaxAmount = 100,
Description = "ID of Seller 1"
},
new LineItem
{
Name = "Walking shoes",
Quantity = 2,
UnitAmount = 400,
TaxAmount = 100,
Description = "ID of Seller 2"
}
},
country: "FR",
phone: "[+33][689854321]",
email: myUser.Email,
additionalData: "{\"customer_account_info\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"app_id\": \"81363501-3540-494a-8627-33bc6112035d\",\"loyalty_level\": \"high\",\"customer_email\": \"customer@email.com\",\"customer_phone\": \"0611223344\",\"customer_ranking\": 2,\"customer_reviews\": 5,\"last_login_time\": \"2023-10-21T19:11:34Z\",\"account_security\": {\"last_verification_method\": \"2FA TOTP\",\"last_verification_time\": \"2023-10-21T19:11:34Z\",\"device_id\": \"772af5a5-2d55-4a5e-bb79-85969f683810\",\"fraud_behavior\": false,\"devices_linked\": 2,\"phone_verified\": true,\"email_verified\": true,\"failed_transactions_attempts\": 0},\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": \"2022-12-22T18:45:44Z\"}],\"marketplace_seller_info\": [{\"sub_merchant_id\": \"615a0e87-4941-45dc-978d-e6efcbd90ba0\",\"sub_merchant_name\": \"Marketbrick Ltd.\",\"sub_merchant_postal_code\": \"75010\",\"product_category\": \"Computers\",\"product_name\": \"Asus Zenbook 14\",\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2020-06-10T12:02:21Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2020-06-10T12:02:21Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"digital_download\": false,\"seller_rating\": 4.5,\"number_of_trades\": 34,\"volume_of_trades\": 4500}],\"payment_history_full\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 10,\"payment_option\": \"card\",\"total_amount_paid_purchases\": 1000.10,\"date_of_first_paid_purchase\": \"2020-06-10T12:12:34Z\",\"date_of_last_paid_purchase\": \"2023-10-26T18:52:38Z\"},{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 14,\"payment_option\": \"non klarna credit\",\"total_amount_paid_purchases\": 2322.10,\"date_of_first_paid_purchase\": \"2021-10-11T20:31:15Z\",\"date_of_last_paid_purchase\": \"2023-09-22T14:59:22Z\"}],\"marketplace_winner_info\": [{\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2022-12-22T18:45:44Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2023-08-14T08:23:34Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"number_of_trades\": 24,\"volume_of_trades\": 3322}],\"other_delivery_address\": [{\"shipping_method\": \"pick-up point\",\"shipping_type\": \"express\",\"first_name\": \"Test\",\"last_name\": \"Person\",\"street_address\": \"Rue La Fayette\",\"street_number\": \"33\",\"postal_code\": \"75009\",\"city\": \"Paris\",\"country\": \"FR\"}]}",
billing: new Billing{
FirstName = myUser.FirstName,
LastName = myUser.LastName,
Address = new Address {
AddressLine1 = myUser.Address.AddressLine1,
AddressLine2 = myUser.Address.AddressLine2,
City = myUser.Address.City,
Region = myUser.Address.Region,
PostalCode = myUser.Address.PostalCode,
Country = myUser.Address.Country
},
},
reference: "2345",
culture: "FR",
tag: "Created using the Mangopay .NET SDK"
);
var createKlarnaPayIn = await api.PayIns.CreateKlarnaWebAsync(myPayIn);
string prettyPrint = JsonConvert.SerializeObject(createKlarnaPayIn, Formatting.Indented);
Console.WriteLine(prettyPrint);
}
}
{
"Id": "wt_5a175522-04c3-4115-88ef-3b1b3446c4c6",
"Tag": "Created using the Mangopay API Postman collection",
"CreationDate": 1706797249,
"AuthorId": "213407540",
"DebitedFunds": {
"Currency": "EUR",
"Amount": 1300
},
"CreditedFunds": {
"Currency": "EUR",
"Amount": 1000
},
"Fees": {
"Currency": "EUR",
"Amount": 300
},
"Status": "CREATED",
"ResultCode": null,
"ResultMessage": null,
"ExecutionDate": null,
"Type": "PAYIN",
"Nature": "REGULAR",
"CreditedWalletId": "213407543",
"CreditedUserId": "213407540",
"PaymentType": "KLARNA",
"ExecutionType": "WEB",
"ReturnURL": "http://www.mangopay.com/docs/please-ignore?transactionId=wt_5a175522-04c3-4115-88ef-3b1b3446c4c6",
"RedirectURL": "https://pay.playground.klarna.com/eu/hpp/payments/2fuacUE",
"StatementDescriptor": "Mangopay",
"Billing": {
"FirstName": "Alex",
"LastName": "Smith",
"Address": {
"AddressLine1": "6 rue de la Cité",
"AddressLine2": "Appartement 3",
"City": "Paris",
"Region": "île-de-france",
"PostalCode": "75003",
"Country": "FR"
}
},
"Shipping": {
"FirstName": "Alex",
"LastName": "Smith",
"Address": {
"AddressLine1": "Rue de la Fourche 26",
"AddressLine2": "Appartement 3",
"City": "Bruxelles",
"Region": "Bruxelles-Capitale",
"PostalCode": "75003",
"Country": "BE"
}
},
"LineItems": [
{
"Name": "Running shoes",
"Quantity": 2,
"UnitAmount": 400,
"TaxAmount": 100,
"Description": "ID of Seller 1",
"Category": "PHYSICAL_GOODS",
"Sku": "example-item-123",
"Discount": 100
},
{
"Name": "Walking shoes",
"Quantity": 1,
"UnitAmount": 400,
"TaxAmount": 100,
"Description": "ID of Seller 2",
"Category": "PHYSICAL_GOODS",
"Sku": "example-item-456",
"Discount": 100
}
],
"Country": "FR",
"Culture": "FR",
"Email": "alex.smith@example.com",
"Phone": "[+33][689854321]",
"AdditionalData": "{\"customer_account_info\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"app_id\": \"81363501-3540-494a-8627-33bc6112035d\",\"loyalty_level\": \"high\",\"customer_email\": \"customer@email.com\",\"customer_phone\": \"0611223344\",\"customer_ranking\": 2,\"customer_reviews\": 5,\"last_login_time\": \"2023-10-21T19:11:34Z\",\"account_security\": {\"last_verification_method\": \"2FA TOTP\",\"last_verification_time\": \"2023-10-21T19:11:34Z\",\"device_id\": \"772af5a5-2d55-4a5e-bb79-85969f683810\",\"fraud_behavior\": false,\"devices_linked\": 2,\"phone_verified\": true,\"email_verified\": true,\"failed_transactions_attempts\": 0},\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": \"2022-12-22T18:45:44Z\"}],\"marketplace_seller_info\": [{\"sub_merchant_id\": \"615a0e87-4941-45dc-978d-e6efcbd90ba0\",\"sub_merchant_name\": \"Marketbrick Ltd.\",\"sub_merchant_postal_code\": \"75010\",\"product_category\": \"Computers\",\"product_name\": \"Asus Zenbook 14\",\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2020-06-10T12:02:21Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2020-06-10T12:02:21Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"digital_download\": false,\"seller_rating\": 4.5,\"number_of_trades\": 34,\"volume_of_trades\": 4500}],\"payment_history_full\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 10,\"payment_option\": \"card\",\"total_amount_paid_purchases\": 1000.10,\"date_of_first_paid_purchase\": \"2020-06-10T12:12:34Z\",\"date_of_last_paid_purchase\": \"2023-10-26T18:52:38Z\"},{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 14,\"payment_option\": \"non klarna credit\",\"total_amount_paid_purchases\": 2322.10,\"date_of_first_paid_purchase\": \"2021-10-11T20:31:15Z\",\"date_of_last_paid_purchase\": \"2023-09-22T14:59:22Z\"}],\"marketplace_winner_info\": [{\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2022-12-22T18:45:44Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2023-08-14T08:23:34Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"number_of_trades\": 24,\"volume_of_trades\": 3322}],\"other_delivery_address\": [{\"shipping_method\": \"pick-up point\",\"shipping_type\": \"express\",\"first_name\": \"Test\",\"last_name\": \"Person\",\"street_address\": \"Rue La Fayette\",\"street_number\": \"33\",\"postal_code\": \"75009\",\"city\": \"Paris\",\"country\": \"FR\"}]}",
"Reference": "1234"
}
Klarna
Create a Klarna PayIn
POST
/
v2.01
/
{ClientId}
/
payins
/
payment-methods
/
klarna
{
"Tag": "Created using the Mangopay API Postman collection",
"AuthorId": "213407540",
"DebitedFunds": {
"Currency": "EUR",
"Amount": 1300
},
"Fees": {
"Currency": "EUR",
"Amount": 300
},
"CreditedWalletId": "213407543",
"ReturnURL": "http://www.mangopay.com/docs/please-ignore",
"StatementDescriptor": "Mangopay",
"Billing": {
"FirstName": "Alex",
"LastName": "Smith",
"Address": {
"AddressLine1": "6 rue de la Cité",
"AddressLine2": "Appartement 3",
"City": "Paris",
"Region": "île-de-france",
"PostalCode": "75003",
"Country": "FR"
}
},
"Shipping": {
"FirstName": "Alex",
"LastName": "Smith",
"Address": {
"AddressLine1": "Rue de la Fourche 26",
"AddressLine2": "Appartement 3",
"City": "Bruxelles",
"Region": "Bruxelles-Capitale",
"PostalCode": "75003",
"Country": "BE"
}
},
"LineItems": [
{
"Name": "Running shoes",
"Quantity": 2,
"UnitAmount": 400,
"TaxAmount": 100,
"Description": "ID of Seller 1",
"Category": "PHYSICAL_GOODS",
"Sku": "example-item-123",
"Discount": 100,
},
{
"Name": "Walking shoes",
"Quantity": 1,
"UnitAmount": 400,
"TaxAmount": 100,
"Description": "ID of Seller 2",
"Category": "PHYSICAL_GOODS",
"Sku": "example-item-456",
"Discount": 100,
}
],
"Country": "FR",
"Culture": "FR",
"Email": "alex.smith@example.com",
"Phone": "[+33][689854321]",
"AdditionalData": "{\"customer_account_info\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"app_id\": \"81363501-3540-494a-8627-33bc6112035d\",\"loyalty_level\": \"high\",\"customer_email\": \"customer@email.com\",\"customer_phone\": \"0611223344\",\"customer_ranking\": 2,\"customer_reviews\": 5,\"last_login_time\": \"2023-10-21T19:11:34Z\",\"account_security\": {\"last_verification_method\": \"2FA TOTP\",\"last_verification_time\": \"2023-10-21T19:11:34Z\",\"device_id\": \"772af5a5-2d55-4a5e-bb79-85969f683810\",\"fraud_behavior\": false,\"devices_linked\": 2,\"phone_verified\": true,\"email_verified\": true,\"failed_transactions_attempts\": 0},\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": \"2022-12-22T18:45:44Z\"}],\"marketplace_seller_info\": [{\"sub_merchant_id\": \"615a0e87-4941-45dc-978d-e6efcbd90ba0\",\"sub_merchant_name\": \"Marketbrick Ltd.\",\"sub_merchant_postal_code\": \"75010\",\"product_category\": \"Computers\",\"product_name\": \"Asus Zenbook 14\",\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2020-06-10T12:02:21Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2020-06-10T12:02:21Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"digital_download\": false,\"seller_rating\": 4.5,\"number_of_trades\": 34,\"volume_of_trades\": 4500}],\"payment_history_full\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 10,\"payment_option\": \"card\",\"total_amount_paid_purchases\": 1000.10,\"date_of_first_paid_purchase\": \"2020-06-10T12:12:34Z\",\"date_of_last_paid_purchase\": \"2023-10-26T18:52:38Z\"},{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 14,\"payment_option\": \"non klarna credit\",\"total_amount_paid_purchases\": 2322.10,\"date_of_first_paid_purchase\": \"2021-10-11T20:31:15Z\",\"date_of_last_paid_purchase\": \"2023-09-22T14:59:22Z\"}],\"marketplace_winner_info\": [{\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2022-12-22T18:45:44Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2023-08-14T08:23:34Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"number_of_trades\": 24,\"volume_of_trades\": 3322}],\"other_delivery_address\": [{\"shipping_method\": \"pick-up point\",\"shipping_type\": \"express\",\"first_name\": \"Test\",\"last_name\": \"Person\",\"street_address\": \"Rue La Fayette\",\"street_number\": \"33\",\"postal_code\": \"75009\",\"city\": \"Paris\",\"country\": \"FR\"}]}",
"Reference": "1234"
}
<?php
require_once 'vendor/autoload.php';
use MangoPay\MangoPayApi;
use MangoPay\Libraries\ResponseException as MGPResponseException;
use MangoPay\Libraries\Exception as MGPException;
$api = new MangoPayApi();
$api->Config->ClientId = 'your-client-id';
$api->Config->ClientPassword = 'your-api-key';
$api->Config->TemporaryFolder = 'tmp/';
try {
$user = $api->Users->Get('210513027');
$payIn = new \MangoPay\PayIn();
$payIn->Tag = "Created using Mangopay PHP SDK";
$payIn->CreditedWalletId = "210514820";
$payIn->PaymentType = "KLARNA";
$payIn->AuthorId = $user->Id;
$payIn->DebitedFunds = new \MangoPay\Money();
$payIn->DebitedFunds->Currency = 'EUR';
$payIn->DebitedFunds->Amount = 1500;
$payIn->Fees = new \MangoPay\Money();
$payIn->Fees->Currency = 'EUR';
$payIn->Fees->Amount = 300;
$payIn->ExecutionDetails = new \MangoPay\PayInExecutionDetailsWeb();
$payIn->ExecutionDetails->ReturnURL = "http://example.com";
$payIn->ExecutionDetails->Culture = 'FR';
$payIn->PaymentDetails = new \MangoPay\PayInPaymentDetailsKlarna();
$payIn->PaymentDetails->Email = $user->Email;
$payIn->PaymentDetails->Phone = '[+33][689854321]';
$payIn->PaymentDetails->Country = $user->Address->Country;
$payIn->PaymentDetails->AdditionalData = "your-additional-data"
$payIn->PaymentDetails->Reference = '8569';
$payIn->ExecutionDetails->Billing = new \MangoPay\Billing();
$payIn->ExecutionDetails->Billing->FirstName = $user->FirstName;
$payIn->ExecutionDetails->Billing->LastName = $user->LastName;
$payIn->ExecutionDetails->Billing->Address = new \MangoPay\Address();
$payIn->ExecutionDetails->Billing->Address->AddressLine1 =$user->Address->AddressLine1;
$payIn->ExecutionDetails->Billing->Address->AddressLine2 =$user->Address->AddressLine2;
$payIn->ExecutionDetails->Billing->Address->Region = $user->Address->Region;
$payIn->ExecutionDetails->Billing->Address->City = $user->Address->City;
$payIn->ExecutionDetails->Billing->Address->PostalCode = $user->Address->PostalCode;
$payIn->ExecutionDetails->Billing->Address->Country = $user->Address->Country;
$payIn->PaymentDetails->Shipping = new \MangoPay\Shipping();
$payIn->PaymentDetails->Shipping->FirstName = $user->FirstName;
$payIn->PaymentDetails->Shipping->LastName = $user->LastName;
$payIn->PaymentDetails->Shipping->Address = new \MangoPay\Address();
$payIn->PaymentDetails->Shipping->Address->AddressLine1 =$user->Address->AddressLine1;
$payIn->PaymentDetails->Shipping->Address->AddressLine2 =$user->Address->AddressLine2;
$payIn->PaymentDetails->Shipping->Address->Region = $user->Address->Region;
$payIn->PaymentDetails->Shipping->Address->City = $user->Address->City;
$payIn->PaymentDetails->Shipping->Address->PostalCode = $user->Address->PostalCode;
$payIn->PaymentDetails->Shipping->Address->Country = $user->Address->Country;
$lineItem1 = new \MangoPay\LineItem();
$lineItem1->Name = 'Running shoes';
$lineItem1->Quantity = 1;
$lineItem1->UnitAmount = 400;
$lineItem1->TaxAmount = 100;
$lineItem1->Description = 'ID of Seller 1';
$lineItem2 = new \MangoPay\LineItem();
$lineItem2->Name = 'Walking shoes';
$lineItem2->Quantity = 2;
$lineItem2->UnitAmount = 400;
$lineItem2->TaxAmount = 100;
$lineItem2->Description = 'ID of Seller 2';
$payIn->PaymentDetails->LineItems = array($lineItem1, $lineItem2);
$response = $api->PayIns->Create($payIn);
print_r($response);
} catch(MGPResponseException $e) {
print_r($e);
} catch(MGPException $e) {
print_r($e);
}
const mangopayInstance = require('mangopay4-nodejs-sdk');
const mangopay = new mangopayInstance({
clientId: "your-client-id",
clientApiKey: "your-api-key",
})
let myPayIn = {
PaymentType: 'KLARNA',
ExecutionType: 'WEB',
AuthorId: '210513027',
Tag: 'Created with Mangopay Node.js SDK',
CreditedUserId: '210513027',
DebitedFunds: {
Currency: 'EUR',
Amount: 400
},
Fees: {
Currency: 'EUR',
Amount: 10
},
LineItems: [
{
Name: "Running shoes",
Quantity: 1,
UnitAmount: 200,
TaxAmount: 0,
Description: "seller1 ID"
},
{
Name: "Running shoes",
Quantity: 1,
UnitAmount: 200,
TaxAmount: 0,
Description: "seller2 ID"
}
],
Country: 'FR',
Phone: '33#607080900',
Email: 'mango@mangopay.com',
CreditedWalletId: '210514820',
ReturnURL: 'http://example.com',
Culture: 'FR',
Billing: {
FirstName: 'Alex',
LastName: 'Smith',
Address: {
AddressLine1: 'Rue des plantes',
AddressLine2: 'The Oasis',
City: 'Paris',
Region: 'IDF',
PostalCode: '75000',
Country: 'FR',
},
},
Shipping: {
FirstName: 'Alex',
LastName: 'Smith',
Address: {
AddressLine1: 'Rue des plantes',
AddressLine2: 'The Oasis',
City: 'Paris',
Region: 'IDF',
PostalCode: '75000',
Country: 'FR',
},
},
AdditionalData: 'your-additional-data',
StatementDescriptor: 'Feb2024',
Reference: 'afd48-879d-48fg'
}
const createKlarnaPayIn = async (payin) => {
return await mangopay.PayIns.create(payin)
.then((response) => {
console.info(response)
return response
})
.catch((err) => {
console.log(err)
return false
})
}
createKlarnaPayIn(myPayIn)
require 'mangopay'
require 'PP'
MangoPay.configure do |client|
client.preproduction = true
client.client_id = 'your-client-id'
client.client_apiKey = 'your-api-key'
client.log_file = File.join(Dir.pwd, 'mangopay.log')
end
let myPayIn = {
PaymentType: 'KLARNA',
ExecutionType: 'WEB',
AuthorId: '210513027',
Tag: 'Created with Mangopay Node.js SDK',
CreditedUserId: '210513027',
DebitedFunds: {
Currency: 'EUR',
Amount: 400
},
Fees: {
Currency: 'EUR',
Amount: 10
},
LineItems: [
{
Name: "running shoes",
Quantity: 1,
UnitAmount: 200,
TaxAmount: 0,
Description: "seller1 ID"
},
{
Name: "running shoes",
Quantity: 1,
UnitAmount: 200,
TaxAmount: 0,
Description: "seller2 ID"
}
],
Country: 'FR',
Phone: '33#607080900',
Email: 'mango@mangopay.com',
CreditedWalletId: '210514820',
ReturnURL: 'http://example.com',
Culture: 'FR',
Billing: {
FirstName: 'Alex',
LastName: 'Smith',
Address: {
AddressLine1: 'Rue des plantes',
AddressLine2: 'The Oasis',
City: 'Paris',
Region: 'IDF',
PostalCode: '75000',
Country: 'FR',
},
},
Shipping: {
FirstName: 'Alex',
LastName: 'Smith',
Address: {
AddressLine1: 'Rue des plantes',
AddressLine2: 'The Oasis',
City: 'Paris',
Region: 'IDF',
PostalCode: '75000',
Country: 'FR',
},
},
StatementDescriptor: 'Feb2024',
Reference: 'afd48-879d-48fg',
AdditionalData: "your-additional-data"
}
const createKlarnaPayIn = async (payin) => {
return await mangopay.PayIns.create(payin)
.then((response) => {
console.info(response)
return response
})
.catch((err) => {
console.log(err)
return false
})
}
pp(createKlarnaPayIn(myPayIn))
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mangopay.MangoPayApi;
import com.mangopay.core.Address;
import com.mangopay.core.Billing;
import com.mangopay.core.LineItem;
import com.mangopay.core.Money;
import com.mangopay.entities.PayIn;
import com.mangopay.entities.User;
import com.mangopay.entities.subentities.PayInExecutionDetailsWeb;
import com.mangopay.entities.subentities.PayInPaymentDetailsKlarna;
import com.mangopay.core.enumerations.PayInExecutionType;
import com.mangopay.core.enumerations.PayInPaymentType;
import com.mangopay.core.enumerations.CountryIso;
import com.mangopay.core.enumerations.CultureCode;
import com.mangopay.core.enumerations.CurrencyIso;
import java.util.Arrays;
import java.util.List;
public class CreateKlarnaPayIn {
public static void main(String[] args) throws Exception {
MangoPayApi mangopay = new MangoPayApi();
mangopay.getConfig().setClientId("your-client-id");
mangopay.getConfig().setClientPassword("your-api-key");
PayIn payin = new PayIn();
User myUser = mangopay.getUserApi().get("user_m_01HT2NFK7Z2BRQNGNHMY30VVTT");
var walletId = "wlt_m_01HTHTXEF4BJCTKMXNWMSZ6KP5";
var additionalData = "{\"customer_account_info\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"app_id\": \"81363501-3540-494a-8627-33bc6112035d\",\"loyalty_level\": \"high\",\"customer_email\": \"customer@email.com\",\"customer_phone\": \"0611223344\",\"customer_ranking\": 2,\"customer_reviews\": 5,\"last_login_time\": \"2023-10-21T19:11:34Z\",\"account_security\": {\"last_verification_method\": \"2FA TOTP\",\"last_verification_time\": \"2023-10-21T19:11:34Z\",\"device_id\": \"772af5a5-2d55-4a5e-bb79-85969f683810\",\"fraud_behavior\": false,\"devices_linked\": 2,\"phone_verified\": true,\"email_verified\": true,\"failed_transactions_attempts\": 0},\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": \"2022-12-22T18:45:44Z\"}],\"marketplace_seller_info\": [{\"sub_merchant_id\": \"615a0e87-4941-45dc-978d-e6efcbd90ba0\",\"sub_merchant_name\": \"Marketbrick Ltd.\",\"sub_merchant_postal_code\": \"75010\",\"product_category\": \"Computers\",\"product_name\": \"Asus Zenbook 14\",\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2020-06-10T12:02:21Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2020-06-10T12:02:21Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"digital_download\": false,\"seller_rating\": 4.5,\"number_of_trades\": 34,\"volume_of_trades\": 4500}],\"payment_history_full\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 10,\"payment_option\": \"card\",\"total_amount_paid_purchases\": 1000.10,\"date_of_first_paid_purchase\": \"2020-06-10T12:12:34Z\",\"date_of_last_paid_purchase\": \"2023-10-26T18:52:38Z\"},{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 14,\"payment_option\": \"non klarna credit\",\"total_amount_paid_purchases\": 2322.10,\"date_of_first_paid_purchase\": \"2021-10-11T20:31:15Z\",\"date_of_last_paid_purchase\": \"2023-09-22T14:59:22Z\"}],\"marketplace_winner_info\": [{\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2022-12-22T18:45:44Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2023-08-14T08:23:34Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"number_of_trades\": 24,\"volume_of_trades\": 3322}],\"other_delivery_address\": [{\"shipping_method\": \"pick-up point\",\"shipping_type\": \"express\",\"first_name\": \"Test\",\"last_name\": \"Person\",\"street_address\": \"Rue La Fayette\",\"street_number\": \"33\",\"postal_code\": \"75009\",\"city\": \"Paris\",\"country\": \"FR\"}]}";
Address address = new Address();
address.setAddressLine1("2795 Edgewood Road");
address.setCity("Little Rock");
address.setRegion("Arkansas");
address.setPostalCode("72212");
address.setCountry(CountryIso.FR);
LineItem lineItem1 = new LineItem(null, null, null, null, null);
lineItem1.setName("Running shoes");
lineItem1.setQuantity(1);
lineItem1.setUnitAmount(200);
lineItem1.setTaxAmount(0);
lineItem1.setDescription("Seller 1 ID");
LineItem lineItem2 = new LineItem(null, null, null, null, null);
lineItem2.setName("Running shoes");
lineItem2.setQuantity(1);
lineItem2.setUnitAmount(200);
lineItem2.setTaxAmount(0);
lineItem2.setDescription("Seller 2 ID");
List<LineItem> lineItems = Arrays.asList(lineItem1, lineItem2);
PayInExecutionDetailsWeb payinExecutionDetails = new PayInExecutionDetailsWeb();
payinExecutionDetails.setReturnUrl("http://www.mangopay.com/docs/please-ignore");
PayInPaymentDetailsKlarna paymentDetails = new PayInPaymentDetailsKlarna();
paymentDetails.setAdditionalData(additionalData);
paymentDetails.setBilling(new Billing());
paymentDetails.getBilling().setFirstName("Alex");
paymentDetails.getBilling().setLastName("Smith");
paymentDetails.getBilling().setAddress(address);
paymentDetails.setCountry(CountryIso.FR);
paymentDetails.setCulture(CultureCode.FR);
paymentDetails.setReference("1234");
paymentDetails.setPhone("[+33][689854321]");
paymentDetails.setEmail(myUser.getEmail());
paymentDetails.setLineItems(lineItems);
payin.setPaymentType(PayInPaymentType.KLARNA);
payin.setExecutionType(PayInExecutionType.WEB);
payin.setCreditedWalletId(walletId);
payin.setExecutionDetails(payinExecutionDetails);
payin.setPaymentDetails(paymentDetails);
payin.setTag("Created with Mangopay Java SDK");
payin.setAuthorId(myUser.getId());
payin.setDebitedFunds(new Money(CurrencyIso.EUR, 400));
payin.setFees(new Money(CurrencyIso.EUR, 100));
PayIn createKlarnaPayin = mangopay.getPayInApi().create(payin);
Gson prettyPrint = new GsonBuilder().setPrettyPrinting().create();
String prettyJson = prettyPrint.toJson(createKlarnaPayin);
System.out.println(prettyJson);
}
}
from pprint import pprint
import mangopay
mangopay.client_id='your-client-id'
mangopay.apikey='your-api-key'
from mangopay.api import APIRequest
handler = APIRequest(sandbox=True)
from mangopay.resources import NaturalUser, KlarnaPayIn
from mangopay.utils import Money, Billing, Shipping, Address, LineItem
natural_user = NaturalUser.get('210513027')
klarna_payin = KlarnaPayIn(
author = natural_user,
credited_wallet_id = '210514820',
debited_funds = Money(amount=1500, currency='EUR'),
fees = Money(amount=300, currency='EUR'),
return_url = 'http://www.mangopay.com/docs/please-ignore',
statement_descriptor = 'Feb2024',
billing = Billing(
first_name = natural_user.first_name,
last_name = natural_user.last_name,
address = Address(
address_line_1 = natural_user.address.address_line_1,
address_line_2 = natural_user.address.address_line_2,
city = natural_user.address.city,
region = natural_user.address.region,
postal_code = natural_user.address.postal_code,
country = natural_user.address.country
)
),
line_items = [
LineItem(
name = 'Running shoes',
quantity=1,
unit_amount=400,
tax_amount=100,
description='ID of Seller 1'),
LineItem(
name = 'Walking shoes',
quantity=2,
unit_amount=400,
tax_amount=100,
description='ID of Seller 2')
],
shipping = Shipping(
first_name = natural_user.first_name,
last_name = natural_user.last_name,
address = Address(
address_line_1 = natural_user.address.address_line_1,
address_line_2 = natural_user.address.address_line_2,
city = natural_user.address.city,
region = natural_user.address.region,
postal_code = natural_user.address.postal_code,
country = natural_user.address.country,
)
),
country = natural_user.address.country,
email = natural_user.email,
phone = '[+33][689854321]',
reference = '2345',
culture = 'FR',
additional_data = 'your-additional-data',
tag = 'Created using the Mangopay Python SDK'
)
create_klarna_payin = klarna_payin.save()
pprint(create_klarna_payin)
using MangoPay.SDK;
using MangoPay.SDK.Core.Enumerations;
using MangoPay.SDK.Entities;
using MangoPay.SDK.Entities.POST;
using Newtonsoft.Json;
class Program
{
static async Task Main(string[] args)
{
MangoPayApi api = new MangoPayApi();
api.Config.ClientId = "your-client-id";
api.Config.ClientPassword = "your-api-key";
var myUser = await api.Users.GetNaturalAsync("210513027");
List<LineItem> LineItems = new List<LineItem>();
var myPayIn = new PayInKlarnaWebPostDTO(
authorId: myUser.Id,
debitedFunds: new Money {
Amount = 1500,
Currency = CurrencyIso.EUR
},
fees: new Money {
Amount = 300,
Currency = CurrencyIso.EUR
},
creditedWalletId: "210514820",
returnUrl: "http://www.mangopay.com/docs/please-ignore",
lineItems: new List<LineItem>{
new LineItem
{
Name = "Running shoes",
Quantity = 1,
UnitAmount = 400,
TaxAmount = 100,
Description = "ID of Seller 1"
},
new LineItem
{
Name = "Walking shoes",
Quantity = 2,
UnitAmount = 400,
TaxAmount = 100,
Description = "ID of Seller 2"
}
},
country: "FR",
phone: "[+33][689854321]",
email: myUser.Email,
additionalData: "{\"customer_account_info\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"app_id\": \"81363501-3540-494a-8627-33bc6112035d\",\"loyalty_level\": \"high\",\"customer_email\": \"customer@email.com\",\"customer_phone\": \"0611223344\",\"customer_ranking\": 2,\"customer_reviews\": 5,\"last_login_time\": \"2023-10-21T19:11:34Z\",\"account_security\": {\"last_verification_method\": \"2FA TOTP\",\"last_verification_time\": \"2023-10-21T19:11:34Z\",\"device_id\": \"772af5a5-2d55-4a5e-bb79-85969f683810\",\"fraud_behavior\": false,\"devices_linked\": 2,\"phone_verified\": true,\"email_verified\": true,\"failed_transactions_attempts\": 0},\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": \"2022-12-22T18:45:44Z\"}],\"marketplace_seller_info\": [{\"sub_merchant_id\": \"615a0e87-4941-45dc-978d-e6efcbd90ba0\",\"sub_merchant_name\": \"Marketbrick Ltd.\",\"sub_merchant_postal_code\": \"75010\",\"product_category\": \"Computers\",\"product_name\": \"Asus Zenbook 14\",\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2020-06-10T12:02:21Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2020-06-10T12:02:21Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"digital_download\": false,\"seller_rating\": 4.5,\"number_of_trades\": 34,\"volume_of_trades\": 4500}],\"payment_history_full\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 10,\"payment_option\": \"card\",\"total_amount_paid_purchases\": 1000.10,\"date_of_first_paid_purchase\": \"2020-06-10T12:12:34Z\",\"date_of_last_paid_purchase\": \"2023-10-26T18:52:38Z\"},{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 14,\"payment_option\": \"non klarna credit\",\"total_amount_paid_purchases\": 2322.10,\"date_of_first_paid_purchase\": \"2021-10-11T20:31:15Z\",\"date_of_last_paid_purchase\": \"2023-09-22T14:59:22Z\"}],\"marketplace_winner_info\": [{\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2022-12-22T18:45:44Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2023-08-14T08:23:34Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"number_of_trades\": 24,\"volume_of_trades\": 3322}],\"other_delivery_address\": [{\"shipping_method\": \"pick-up point\",\"shipping_type\": \"express\",\"first_name\": \"Test\",\"last_name\": \"Person\",\"street_address\": \"Rue La Fayette\",\"street_number\": \"33\",\"postal_code\": \"75009\",\"city\": \"Paris\",\"country\": \"FR\"}]}",
billing: new Billing{
FirstName = myUser.FirstName,
LastName = myUser.LastName,
Address = new Address {
AddressLine1 = myUser.Address.AddressLine1,
AddressLine2 = myUser.Address.AddressLine2,
City = myUser.Address.City,
Region = myUser.Address.Region,
PostalCode = myUser.Address.PostalCode,
Country = myUser.Address.Country
},
},
reference: "2345",
culture: "FR",
tag: "Created using the Mangopay .NET SDK"
);
var createKlarnaPayIn = await api.PayIns.CreateKlarnaWebAsync(myPayIn);
string prettyPrint = JsonConvert.SerializeObject(createKlarnaPayIn, Formatting.Indented);
Console.WriteLine(prettyPrint);
}
}
{
"Id": "wt_5a175522-04c3-4115-88ef-3b1b3446c4c6",
"Tag": "Created using the Mangopay API Postman collection",
"CreationDate": 1706797249,
"AuthorId": "213407540",
"DebitedFunds": {
"Currency": "EUR",
"Amount": 1300
},
"CreditedFunds": {
"Currency": "EUR",
"Amount": 1000
},
"Fees": {
"Currency": "EUR",
"Amount": 300
},
"Status": "CREATED",
"ResultCode": null,
"ResultMessage": null,
"ExecutionDate": null,
"Type": "PAYIN",
"Nature": "REGULAR",
"CreditedWalletId": "213407543",
"CreditedUserId": "213407540",
"PaymentType": "KLARNA",
"ExecutionType": "WEB",
"ReturnURL": "http://www.mangopay.com/docs/please-ignore?transactionId=wt_5a175522-04c3-4115-88ef-3b1b3446c4c6",
"RedirectURL": "https://pay.playground.klarna.com/eu/hpp/payments/2fuacUE",
"StatementDescriptor": "Mangopay",
"Billing": {
"FirstName": "Alex",
"LastName": "Smith",
"Address": {
"AddressLine1": "6 rue de la Cité",
"AddressLine2": "Appartement 3",
"City": "Paris",
"Region": "île-de-france",
"PostalCode": "75003",
"Country": "FR"
}
},
"Shipping": {
"FirstName": "Alex",
"LastName": "Smith",
"Address": {
"AddressLine1": "Rue de la Fourche 26",
"AddressLine2": "Appartement 3",
"City": "Bruxelles",
"Region": "Bruxelles-Capitale",
"PostalCode": "75003",
"Country": "BE"
}
},
"LineItems": [
{
"Name": "Running shoes",
"Quantity": 2,
"UnitAmount": 400,
"TaxAmount": 100,
"Description": "ID of Seller 1",
"Category": "PHYSICAL_GOODS",
"Sku": "example-item-123",
"Discount": 100
},
{
"Name": "Walking shoes",
"Quantity": 1,
"UnitAmount": 400,
"TaxAmount": 100,
"Description": "ID of Seller 2",
"Category": "PHYSICAL_GOODS",
"Sku": "example-item-456",
"Discount": 100
}
],
"Country": "FR",
"Culture": "FR",
"Email": "alex.smith@example.com",
"Phone": "[+33][689854321]",
"AdditionalData": "{\"customer_account_info\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"app_id\": \"81363501-3540-494a-8627-33bc6112035d\",\"loyalty_level\": \"high\",\"customer_email\": \"customer@email.com\",\"customer_phone\": \"0611223344\",\"customer_ranking\": 2,\"customer_reviews\": 5,\"last_login_time\": \"2023-10-21T19:11:34Z\",\"account_security\": {\"last_verification_method\": \"2FA TOTP\",\"last_verification_time\": \"2023-10-21T19:11:34Z\",\"device_id\": \"772af5a5-2d55-4a5e-bb79-85969f683810\",\"fraud_behavior\": false,\"devices_linked\": 2,\"phone_verified\": true,\"email_verified\": true,\"failed_transactions_attempts\": 0},\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": \"2022-12-22T18:45:44Z\"}],\"marketplace_seller_info\": [{\"sub_merchant_id\": \"615a0e87-4941-45dc-978d-e6efcbd90ba0\",\"sub_merchant_name\": \"Marketbrick Ltd.\",\"sub_merchant_postal_code\": \"75010\",\"product_category\": \"Computers\",\"product_name\": \"Asus Zenbook 14\",\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2020-06-10T12:02:21Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2020-06-10T12:02:21Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"digital_download\": false,\"seller_rating\": 4.5,\"number_of_trades\": 34,\"volume_of_trades\": 4500}],\"payment_history_full\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 10,\"payment_option\": \"card\",\"total_amount_paid_purchases\": 1000.10,\"date_of_first_paid_purchase\": \"2020-06-10T12:12:34Z\",\"date_of_last_paid_purchase\": \"2023-10-26T18:52:38Z\"},{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 14,\"payment_option\": \"non klarna credit\",\"total_amount_paid_purchases\": 2322.10,\"date_of_first_paid_purchase\": \"2021-10-11T20:31:15Z\",\"date_of_last_paid_purchase\": \"2023-09-22T14:59:22Z\"}],\"marketplace_winner_info\": [{\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2022-12-22T18:45:44Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2023-08-14T08:23:34Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"number_of_trades\": 24,\"volume_of_trades\": 3322}],\"other_delivery_address\": [{\"shipping_method\": \"pick-up point\",\"shipping_type\": \"express\",\"first_name\": \"Test\",\"last_name\": \"Person\",\"street_address\": \"Rue La Fayette\",\"street_number\": \"33\",\"postal_code\": \"75009\",\"city\": \"Paris\",\"country\": \"FR\"}]}",
"Reference": "1234"
}
Note – Timeout after 3 hoursThe Klarna payment session lasts 3 hours, at which point the pay-in fails automatically (result code 101109) if no action has been taken by the user.
Note – Minimum amount in ProductionIn Production, the minimum accepted
DebitedFunds amount for Klarna is 1 (regardless of currency).Body parameters
Max. length: 255 charactersCustom data that you can add to this object.
For transactions (pay-in, transfer, payout), you can use this parameter to identify corresponding information regarding the user, transaction, or payment methods on your platform.
For transactions (pay-in, transfer, payout), you can use this parameter to identify corresponding information regarding the user, transaction, or payment methods on your platform.
Information about the debited funds. The amount must be equal to the total of all
UnitAmount and TaxAmount of all LineItems.Show properties
Show properties
Allowed values: The three-letter ISO 4217 code (EUR, GBP, etc.) of a supported currency (depends on feature, contract, and activation settings).The currency of the funds.
Information about the fees.
Show properties
Show properties
Allowed values: The three-letter ISO 4217 code (EUR, GBP, etc.) of a supported currency (depends on feature, contract, and activation settings).The currency of the fees.
Max. length: 255 charactersThe URL to which the user is returned after the payment, whether the transaction is successful or not.
Max. length: 10 characters; only alphanumeric and spacesCustom description to appear on the user’s bank statement along with the platform name. Different banks may show more or less information. See the Customizing bank statement references article for details.
Information about the end user billing address.
Show properties
Show properties
Information about the billing address.
Show properties
Show properties
Max. length: 255 charactersThe postal code of the address. The postal code can contain the following characters: alphanumeric, dashes, and spaces.
Information about the end user’s shipping address.
The shipping address
The shipping address
AddressLine1 must be formatted:- FR, UK, US: [Number][StreetName], for example: 33 Cavendish Square
- Rest of EU: [StreetName][Number], for example: De Ruijterkade 7
Caution: Failure to follow this formatting may result in an error.
If no shipping address is sent, Klarna considers it to be the same as the billing address.
Show properties
Show properties
Information about the shipping address.
Show properties
Show properties
Max. length: 255 charactersThe postal code of the address. The postal code can contain the following characters: alphanumeric, dashes, and spaces.
Format: Two-letter country code (ISO 3166-1 alpha-2 format)The country of the address.
Information about the items purchased in the transaction. The pay-in
DebitedFunds.Amount must equal all LineItems objects’ ((UnitAmount + TaxAmount) - Discount).Show properties
Show properties
Possible values:
DIGITAL_GOODS, PHYSICAL_GOODS, DISCOUNT, SHIPPING_FEE, SALES_TAX, GIFT_CARD, STORE_CREDIT, SURCHARGEThe category of the item, allowing line items of different types to be distinguished (for example, buyer protection as DIGITAL_GOODS).Format: Two-letter country code (ISO 3166-1 alpha-2 format)The country of residence of the user.
Format: Two-letter language code (ISO 639-1 alpha-2)The language in which the Klarna payment page is to be displayed.The
Culture must match the Country to show the checkout page in the desired language. If not, or if Culture is not sent, EN is the language by default.Format: International E.164 standard (preceded by plus sign and country code)The user’s mobile phone number. If the phone matches the user’s Klarna account, their checkout experience involves one less step.
Format: Serialized JSON objectThe extra merchant data required by Klarna for the transaction, as described in the Klarna guide.
The unique reference generated for the profiling session, used by the fraud prevention solution to produce recommendations for the transaction using the profiling data.Note: Parameter not returned by the API. Profiling feature available on request – contact Mangopay via the Dashboard for more information.
Responses
200 - Response parameters
200 - Response parameters
Max length: 128 characters (see data formats for details)The unique identifier of the object.
Max. length: 255 charactersCustom data that you can add to this object.
For transactions (pay-in, transfer, payout), you can use this parameter to identify corresponding information regarding the user, transaction, or payment methods on your platform.
For transactions (pay-in, transfer, payout), you can use this parameter to identify corresponding information regarding the user, transaction, or payment methods on your platform.
Information about the debited funds. The amount must be equal to the total of all
UnitAmount and TaxAmount of all LineItems.Show properties
Show properties
Returned values: The three-letter ISO 4217 code (EUR, GBP, etc.) of a supported currency (depends on feature, contract, and activation settings).The currency of the funds.
Information about the credited funds (
CreditedFunds = DebitedFunds - Fees).Show properties
Show properties
Returned values: The three-letter ISO 4217 code (EUR, GBP, etc.) of a supported currency (depends on feature, contract, and activation settings).The currency of the funds.
Information about the fees.
Show properties
Show properties
Returned values: The three-letter ISO 4217 code (EUR, GBP, etc.) of a supported currency (depends on feature, contract, and activation settings).The currency of the fees.
The code indicating the result of the operation. This information is mostly used to handle errors or for filtering purposes.
The date and time at which the status changed to
SUCCEEDED, indicating that the transaction occurred. The statuses CREATED and FAILED return an ExecutionDate of null.Returned values:
REGULAR, REPUDIATION, REFUND, SETTLEMENTThe nature of the transaction, providing more information about the context in which the transaction occurred:REGULAR– Relative to most of the transactions (pay-ins, payouts, and transfers) in a usual workflow.REPUDIATION– Automatic withdrawal of funds from the platform’s repudiation wallet as part of the dispute process (when the user has requested a chargeback).REFUND– Reimbursement of a transaction to the user (pay-in refund), to a wallet (transfer refund), or of a payout (payout refund, only initiated by Mangopay).SETTLEMENT– Transfer made to the repudiation wallet by the platform to settle a lost dispute.
Default value: The unique identifier of the owner of the credited wallet.The unique identifier of the user whose wallet is credited.
Max. length: 255 charactersThe URL to which the user is returned after the payment, whether the transaction is successful or not.
The URL to which to redirect the user to complete the payment.Caution: This variable URL is specific to each payment. You must rely on the returned URL in full (host, path, and queries) and not hardcode any part of it.
Max. length: 10 characters; only alphanumeric and spacesCustom description to appear on the user’s bank statement along with the platform name. Different banks may show more or less information. See the Customizing bank statement references article for details.
Information about the end user billing address.
Show properties
Show properties
Information about the billing address.
Show properties
Show properties
Max. length: 255 charactersThe region of the address. This field is optional except if the
Country is US, CA, or MX.Max. length: 255 charactersThe postal code of the address. The postal code can contain the following characters: alphanumeric, dashes, and spaces.
Format: Two-letter country code (ISO 3166-1 alpha-2 format)The country of the address.
Information about the end user’s shipping address.The shipping address
AddressLine1 must be formatted:- FR, UK, US: [Number][StreetName], for example: 33 Cavendish Square
- Rest of EU: [StreetName][Number], for example: De Ruijterkade 7
Show properties
Show properties
Information about the shipping address.
Show properties
Show properties
Max. length: 255 charactersThe region of the address. This field is optional except if the
Country is US, CA, or MX.Max. length: 255 charactersThe postal code of the address. The postal code can contain the following characters: alphanumeric, dashes, and spaces.
Format: Two-letter country code (ISO 3166-1 alpha-2 format)The country of the address.
Information about the items purchased in the transaction. The pay-in
DebitedFunds.Amount must equal all LineItems objects’ ((UnitAmount + TaxAmount) - Discount).Show properties
Show properties
Possible values:
DIGITAL_GOODS, PHYSICAL_GOODS, DISCOUNT, SHIPPING_FEE, SALES_TAX, GIFT_CARD, STORE_CREDIT, SURCHARGEThe category of the item, allowing line items of different types to be distinguished (for example, buyer protection as DIGITAL_GOODS).Format: Two-letter country code (ISO 3166-1 alpha-2 format)The country of residence of the user.
Format: Two-letter language code (ISO 639-1 alpha-2)The language in which the Klarna payment page is to be displayed.
The
The
Culture must match the Country to show the checkout page in the desired language. If not, or if Culture is not sent, EN is the language by default.Format: International E.164 standard (preceded by plus sign and country code)The user’s mobile phone number. If the phone matches the user’s Klarna account, their checkout experience involves one less step.
Format: Serialized JSON objectThe extra merchant data required by Klarna for the transaction, as described in the Klarna guide.
400 - Billing address country doesn't match Country
400 - Billing address country doesn't match Country
{
"message": "One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error.",
"id": "5c1bd99e-3af9-4ac2-997a-daec27b8a255",
"date": 1710162995,
"type": "param_error",
"errors": {
"billing.Country": "The field should equal Country"
}
}
400 - AdditionalData JSON format error
400 - AdditionalData JSON format error
{
"message": "One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error.",
"id": "34554ec3-e46e-49f2-b29c-12db3e7e1c90",
"date": 1706798154,
"type": "param_error",
"errors": {
"additionalData": "The value is not a valid JSON format"
}
}
{
"Id": "wt_5a175522-04c3-4115-88ef-3b1b3446c4c6",
"Tag": "Created using the Mangopay API Postman collection",
"CreationDate": 1706797249,
"AuthorId": "213407540",
"DebitedFunds": {
"Currency": "EUR",
"Amount": 1300
},
"CreditedFunds": {
"Currency": "EUR",
"Amount": 1000
},
"Fees": {
"Currency": "EUR",
"Amount": 300
},
"Status": "CREATED",
"ResultCode": null,
"ResultMessage": null,
"ExecutionDate": null,
"Type": "PAYIN",
"Nature": "REGULAR",
"CreditedWalletId": "213407543",
"CreditedUserId": "213407540",
"PaymentType": "KLARNA",
"ExecutionType": "WEB",
"ReturnURL": "http://www.mangopay.com/docs/please-ignore?transactionId=wt_5a175522-04c3-4115-88ef-3b1b3446c4c6",
"RedirectURL": "https://pay.playground.klarna.com/eu/hpp/payments/2fuacUE",
"StatementDescriptor": "Mangopay",
"Billing": {
"FirstName": "Alex",
"LastName": "Smith",
"Address": {
"AddressLine1": "6 rue de la Cité",
"AddressLine2": "Appartement 3",
"City": "Paris",
"Region": "île-de-france",
"PostalCode": "75003",
"Country": "FR"
}
},
"Shipping": {
"FirstName": "Alex",
"LastName": "Smith",
"Address": {
"AddressLine1": "Rue de la Fourche 26",
"AddressLine2": "Appartement 3",
"City": "Bruxelles",
"Region": "Bruxelles-Capitale",
"PostalCode": "75003",
"Country": "BE"
}
},
"LineItems": [
{
"Name": "Running shoes",
"Quantity": 2,
"UnitAmount": 400,
"TaxAmount": 100,
"Description": "ID of Seller 1",
"Category": "PHYSICAL_GOODS",
"Sku": "example-item-123",
"Discount": 100
},
{
"Name": "Walking shoes",
"Quantity": 1,
"UnitAmount": 400,
"TaxAmount": 100,
"Description": "ID of Seller 2",
"Category": "PHYSICAL_GOODS",
"Sku": "example-item-456",
"Discount": 100
}
],
"Country": "FR",
"Culture": "FR",
"Email": "alex.smith@example.com",
"Phone": "[+33][689854321]",
"AdditionalData": "{\"customer_account_info\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"app_id\": \"81363501-3540-494a-8627-33bc6112035d\",\"loyalty_level\": \"high\",\"customer_email\": \"customer@email.com\",\"customer_phone\": \"0611223344\",\"customer_ranking\": 2,\"customer_reviews\": 5,\"last_login_time\": \"2023-10-21T19:11:34Z\",\"account_security\": {\"last_verification_method\": \"2FA TOTP\",\"last_verification_time\": \"2023-10-21T19:11:34Z\",\"device_id\": \"772af5a5-2d55-4a5e-bb79-85969f683810\",\"fraud_behavior\": false,\"devices_linked\": 2,\"phone_verified\": true,\"email_verified\": true,\"failed_transactions_attempts\": 0},\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": \"2022-12-22T18:45:44Z\"}],\"marketplace_seller_info\": [{\"sub_merchant_id\": \"615a0e87-4941-45dc-978d-e6efcbd90ba0\",\"sub_merchant_name\": \"Marketbrick Ltd.\",\"sub_merchant_postal_code\": \"75010\",\"product_category\": \"Computers\",\"product_name\": \"Asus Zenbook 14\",\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2020-06-10T12:02:21Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2020-06-10T12:02:21Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"digital_download\": false,\"seller_rating\": 4.5,\"number_of_trades\": 34,\"volume_of_trades\": 4500}],\"payment_history_full\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 10,\"payment_option\": \"card\",\"total_amount_paid_purchases\": 1000.10,\"date_of_first_paid_purchase\": \"2020-06-10T12:12:34Z\",\"date_of_last_paid_purchase\": \"2023-10-26T18:52:38Z\"},{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 14,\"payment_option\": \"non klarna credit\",\"total_amount_paid_purchases\": 2322.10,\"date_of_first_paid_purchase\": \"2021-10-11T20:31:15Z\",\"date_of_last_paid_purchase\": \"2023-09-22T14:59:22Z\"}],\"marketplace_winner_info\": [{\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2022-12-22T18:45:44Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2023-08-14T08:23:34Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"number_of_trades\": 24,\"volume_of_trades\": 3322}],\"other_delivery_address\": [{\"shipping_method\": \"pick-up point\",\"shipping_type\": \"express\",\"first_name\": \"Test\",\"last_name\": \"Person\",\"street_address\": \"Rue La Fayette\",\"street_number\": \"33\",\"postal_code\": \"75009\",\"city\": \"Paris\",\"country\": \"FR\"}]}",
"Reference": "1234"
}
{
"Tag": "Created using the Mangopay API Postman collection",
"AuthorId": "213407540",
"DebitedFunds": {
"Currency": "EUR",
"Amount": 1300
},
"Fees": {
"Currency": "EUR",
"Amount": 300
},
"CreditedWalletId": "213407543",
"ReturnURL": "http://www.mangopay.com/docs/please-ignore",
"StatementDescriptor": "Mangopay",
"Billing": {
"FirstName": "Alex",
"LastName": "Smith",
"Address": {
"AddressLine1": "6 rue de la Cité",
"AddressLine2": "Appartement 3",
"City": "Paris",
"Region": "île-de-france",
"PostalCode": "75003",
"Country": "FR"
}
},
"Shipping": {
"FirstName": "Alex",
"LastName": "Smith",
"Address": {
"AddressLine1": "Rue de la Fourche 26",
"AddressLine2": "Appartement 3",
"City": "Bruxelles",
"Region": "Bruxelles-Capitale",
"PostalCode": "75003",
"Country": "BE"
}
},
"LineItems": [
{
"Name": "Running shoes",
"Quantity": 2,
"UnitAmount": 400,
"TaxAmount": 100,
"Description": "ID of Seller 1",
"Category": "PHYSICAL_GOODS",
"Sku": "example-item-123",
"Discount": 100,
},
{
"Name": "Walking shoes",
"Quantity": 1,
"UnitAmount": 400,
"TaxAmount": 100,
"Description": "ID of Seller 2",
"Category": "PHYSICAL_GOODS",
"Sku": "example-item-456",
"Discount": 100,
}
],
"Country": "FR",
"Culture": "FR",
"Email": "alex.smith@example.com",
"Phone": "[+33][689854321]",
"AdditionalData": "{\"customer_account_info\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"app_id\": \"81363501-3540-494a-8627-33bc6112035d\",\"loyalty_level\": \"high\",\"customer_email\": \"customer@email.com\",\"customer_phone\": \"0611223344\",\"customer_ranking\": 2,\"customer_reviews\": 5,\"last_login_time\": \"2023-10-21T19:11:34Z\",\"account_security\": {\"last_verification_method\": \"2FA TOTP\",\"last_verification_time\": \"2023-10-21T19:11:34Z\",\"device_id\": \"772af5a5-2d55-4a5e-bb79-85969f683810\",\"fraud_behavior\": false,\"devices_linked\": 2,\"phone_verified\": true,\"email_verified\": true,\"failed_transactions_attempts\": 0},\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": \"2022-12-22T18:45:44Z\"}],\"marketplace_seller_info\": [{\"sub_merchant_id\": \"615a0e87-4941-45dc-978d-e6efcbd90ba0\",\"sub_merchant_name\": \"Marketbrick Ltd.\",\"sub_merchant_postal_code\": \"75010\",\"product_category\": \"Computers\",\"product_name\": \"Asus Zenbook 14\",\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2020-06-10T12:02:21Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2020-06-10T12:02:21Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"digital_download\": false,\"seller_rating\": 4.5,\"number_of_trades\": 34,\"volume_of_trades\": 4500}],\"payment_history_full\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 10,\"payment_option\": \"card\",\"total_amount_paid_purchases\": 1000.10,\"date_of_first_paid_purchase\": \"2020-06-10T12:12:34Z\",\"date_of_last_paid_purchase\": \"2023-10-26T18:52:38Z\"},{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 14,\"payment_option\": \"non klarna credit\",\"total_amount_paid_purchases\": 2322.10,\"date_of_first_paid_purchase\": \"2021-10-11T20:31:15Z\",\"date_of_last_paid_purchase\": \"2023-09-22T14:59:22Z\"}],\"marketplace_winner_info\": [{\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2022-12-22T18:45:44Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2023-08-14T08:23:34Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"number_of_trades\": 24,\"volume_of_trades\": 3322}],\"other_delivery_address\": [{\"shipping_method\": \"pick-up point\",\"shipping_type\": \"express\",\"first_name\": \"Test\",\"last_name\": \"Person\",\"street_address\": \"Rue La Fayette\",\"street_number\": \"33\",\"postal_code\": \"75009\",\"city\": \"Paris\",\"country\": \"FR\"}]}",
"Reference": "1234"
}
<?php
require_once 'vendor/autoload.php';
use MangoPay\MangoPayApi;
use MangoPay\Libraries\ResponseException as MGPResponseException;
use MangoPay\Libraries\Exception as MGPException;
$api = new MangoPayApi();
$api->Config->ClientId = 'your-client-id';
$api->Config->ClientPassword = 'your-api-key';
$api->Config->TemporaryFolder = 'tmp/';
try {
$user = $api->Users->Get('210513027');
$payIn = new \MangoPay\PayIn();
$payIn->Tag = "Created using Mangopay PHP SDK";
$payIn->CreditedWalletId = "210514820";
$payIn->PaymentType = "KLARNA";
$payIn->AuthorId = $user->Id;
$payIn->DebitedFunds = new \MangoPay\Money();
$payIn->DebitedFunds->Currency = 'EUR';
$payIn->DebitedFunds->Amount = 1500;
$payIn->Fees = new \MangoPay\Money();
$payIn->Fees->Currency = 'EUR';
$payIn->Fees->Amount = 300;
$payIn->ExecutionDetails = new \MangoPay\PayInExecutionDetailsWeb();
$payIn->ExecutionDetails->ReturnURL = "http://example.com";
$payIn->ExecutionDetails->Culture = 'FR';
$payIn->PaymentDetails = new \MangoPay\PayInPaymentDetailsKlarna();
$payIn->PaymentDetails->Email = $user->Email;
$payIn->PaymentDetails->Phone = '[+33][689854321]';
$payIn->PaymentDetails->Country = $user->Address->Country;
$payIn->PaymentDetails->AdditionalData = "your-additional-data"
$payIn->PaymentDetails->Reference = '8569';
$payIn->ExecutionDetails->Billing = new \MangoPay\Billing();
$payIn->ExecutionDetails->Billing->FirstName = $user->FirstName;
$payIn->ExecutionDetails->Billing->LastName = $user->LastName;
$payIn->ExecutionDetails->Billing->Address = new \MangoPay\Address();
$payIn->ExecutionDetails->Billing->Address->AddressLine1 =$user->Address->AddressLine1;
$payIn->ExecutionDetails->Billing->Address->AddressLine2 =$user->Address->AddressLine2;
$payIn->ExecutionDetails->Billing->Address->Region = $user->Address->Region;
$payIn->ExecutionDetails->Billing->Address->City = $user->Address->City;
$payIn->ExecutionDetails->Billing->Address->PostalCode = $user->Address->PostalCode;
$payIn->ExecutionDetails->Billing->Address->Country = $user->Address->Country;
$payIn->PaymentDetails->Shipping = new \MangoPay\Shipping();
$payIn->PaymentDetails->Shipping->FirstName = $user->FirstName;
$payIn->PaymentDetails->Shipping->LastName = $user->LastName;
$payIn->PaymentDetails->Shipping->Address = new \MangoPay\Address();
$payIn->PaymentDetails->Shipping->Address->AddressLine1 =$user->Address->AddressLine1;
$payIn->PaymentDetails->Shipping->Address->AddressLine2 =$user->Address->AddressLine2;
$payIn->PaymentDetails->Shipping->Address->Region = $user->Address->Region;
$payIn->PaymentDetails->Shipping->Address->City = $user->Address->City;
$payIn->PaymentDetails->Shipping->Address->PostalCode = $user->Address->PostalCode;
$payIn->PaymentDetails->Shipping->Address->Country = $user->Address->Country;
$lineItem1 = new \MangoPay\LineItem();
$lineItem1->Name = 'Running shoes';
$lineItem1->Quantity = 1;
$lineItem1->UnitAmount = 400;
$lineItem1->TaxAmount = 100;
$lineItem1->Description = 'ID of Seller 1';
$lineItem2 = new \MangoPay\LineItem();
$lineItem2->Name = 'Walking shoes';
$lineItem2->Quantity = 2;
$lineItem2->UnitAmount = 400;
$lineItem2->TaxAmount = 100;
$lineItem2->Description = 'ID of Seller 2';
$payIn->PaymentDetails->LineItems = array($lineItem1, $lineItem2);
$response = $api->PayIns->Create($payIn);
print_r($response);
} catch(MGPResponseException $e) {
print_r($e);
} catch(MGPException $e) {
print_r($e);
}
const mangopayInstance = require('mangopay4-nodejs-sdk');
const mangopay = new mangopayInstance({
clientId: "your-client-id",
clientApiKey: "your-api-key",
})
let myPayIn = {
PaymentType: 'KLARNA',
ExecutionType: 'WEB',
AuthorId: '210513027',
Tag: 'Created with Mangopay Node.js SDK',
CreditedUserId: '210513027',
DebitedFunds: {
Currency: 'EUR',
Amount: 400
},
Fees: {
Currency: 'EUR',
Amount: 10
},
LineItems: [
{
Name: "Running shoes",
Quantity: 1,
UnitAmount: 200,
TaxAmount: 0,
Description: "seller1 ID"
},
{
Name: "Running shoes",
Quantity: 1,
UnitAmount: 200,
TaxAmount: 0,
Description: "seller2 ID"
}
],
Country: 'FR',
Phone: '33#607080900',
Email: 'mango@mangopay.com',
CreditedWalletId: '210514820',
ReturnURL: 'http://example.com',
Culture: 'FR',
Billing: {
FirstName: 'Alex',
LastName: 'Smith',
Address: {
AddressLine1: 'Rue des plantes',
AddressLine2: 'The Oasis',
City: 'Paris',
Region: 'IDF',
PostalCode: '75000',
Country: 'FR',
},
},
Shipping: {
FirstName: 'Alex',
LastName: 'Smith',
Address: {
AddressLine1: 'Rue des plantes',
AddressLine2: 'The Oasis',
City: 'Paris',
Region: 'IDF',
PostalCode: '75000',
Country: 'FR',
},
},
AdditionalData: 'your-additional-data',
StatementDescriptor: 'Feb2024',
Reference: 'afd48-879d-48fg'
}
const createKlarnaPayIn = async (payin) => {
return await mangopay.PayIns.create(payin)
.then((response) => {
console.info(response)
return response
})
.catch((err) => {
console.log(err)
return false
})
}
createKlarnaPayIn(myPayIn)
require 'mangopay'
require 'PP'
MangoPay.configure do |client|
client.preproduction = true
client.client_id = 'your-client-id'
client.client_apiKey = 'your-api-key'
client.log_file = File.join(Dir.pwd, 'mangopay.log')
end
let myPayIn = {
PaymentType: 'KLARNA',
ExecutionType: 'WEB',
AuthorId: '210513027',
Tag: 'Created with Mangopay Node.js SDK',
CreditedUserId: '210513027',
DebitedFunds: {
Currency: 'EUR',
Amount: 400
},
Fees: {
Currency: 'EUR',
Amount: 10
},
LineItems: [
{
Name: "running shoes",
Quantity: 1,
UnitAmount: 200,
TaxAmount: 0,
Description: "seller1 ID"
},
{
Name: "running shoes",
Quantity: 1,
UnitAmount: 200,
TaxAmount: 0,
Description: "seller2 ID"
}
],
Country: 'FR',
Phone: '33#607080900',
Email: 'mango@mangopay.com',
CreditedWalletId: '210514820',
ReturnURL: 'http://example.com',
Culture: 'FR',
Billing: {
FirstName: 'Alex',
LastName: 'Smith',
Address: {
AddressLine1: 'Rue des plantes',
AddressLine2: 'The Oasis',
City: 'Paris',
Region: 'IDF',
PostalCode: '75000',
Country: 'FR',
},
},
Shipping: {
FirstName: 'Alex',
LastName: 'Smith',
Address: {
AddressLine1: 'Rue des plantes',
AddressLine2: 'The Oasis',
City: 'Paris',
Region: 'IDF',
PostalCode: '75000',
Country: 'FR',
},
},
StatementDescriptor: 'Feb2024',
Reference: 'afd48-879d-48fg',
AdditionalData: "your-additional-data"
}
const createKlarnaPayIn = async (payin) => {
return await mangopay.PayIns.create(payin)
.then((response) => {
console.info(response)
return response
})
.catch((err) => {
console.log(err)
return false
})
}
pp(createKlarnaPayIn(myPayIn))
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mangopay.MangoPayApi;
import com.mangopay.core.Address;
import com.mangopay.core.Billing;
import com.mangopay.core.LineItem;
import com.mangopay.core.Money;
import com.mangopay.entities.PayIn;
import com.mangopay.entities.User;
import com.mangopay.entities.subentities.PayInExecutionDetailsWeb;
import com.mangopay.entities.subentities.PayInPaymentDetailsKlarna;
import com.mangopay.core.enumerations.PayInExecutionType;
import com.mangopay.core.enumerations.PayInPaymentType;
import com.mangopay.core.enumerations.CountryIso;
import com.mangopay.core.enumerations.CultureCode;
import com.mangopay.core.enumerations.CurrencyIso;
import java.util.Arrays;
import java.util.List;
public class CreateKlarnaPayIn {
public static void main(String[] args) throws Exception {
MangoPayApi mangopay = new MangoPayApi();
mangopay.getConfig().setClientId("your-client-id");
mangopay.getConfig().setClientPassword("your-api-key");
PayIn payin = new PayIn();
User myUser = mangopay.getUserApi().get("user_m_01HT2NFK7Z2BRQNGNHMY30VVTT");
var walletId = "wlt_m_01HTHTXEF4BJCTKMXNWMSZ6KP5";
var additionalData = "{\"customer_account_info\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"app_id\": \"81363501-3540-494a-8627-33bc6112035d\",\"loyalty_level\": \"high\",\"customer_email\": \"customer@email.com\",\"customer_phone\": \"0611223344\",\"customer_ranking\": 2,\"customer_reviews\": 5,\"last_login_time\": \"2023-10-21T19:11:34Z\",\"account_security\": {\"last_verification_method\": \"2FA TOTP\",\"last_verification_time\": \"2023-10-21T19:11:34Z\",\"device_id\": \"772af5a5-2d55-4a5e-bb79-85969f683810\",\"fraud_behavior\": false,\"devices_linked\": 2,\"phone_verified\": true,\"email_verified\": true,\"failed_transactions_attempts\": 0},\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": \"2022-12-22T18:45:44Z\"}],\"marketplace_seller_info\": [{\"sub_merchant_id\": \"615a0e87-4941-45dc-978d-e6efcbd90ba0\",\"sub_merchant_name\": \"Marketbrick Ltd.\",\"sub_merchant_postal_code\": \"75010\",\"product_category\": \"Computers\",\"product_name\": \"Asus Zenbook 14\",\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2020-06-10T12:02:21Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2020-06-10T12:02:21Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"digital_download\": false,\"seller_rating\": 4.5,\"number_of_trades\": 34,\"volume_of_trades\": 4500}],\"payment_history_full\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 10,\"payment_option\": \"card\",\"total_amount_paid_purchases\": 1000.10,\"date_of_first_paid_purchase\": \"2020-06-10T12:12:34Z\",\"date_of_last_paid_purchase\": \"2023-10-26T18:52:38Z\"},{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 14,\"payment_option\": \"non klarna credit\",\"total_amount_paid_purchases\": 2322.10,\"date_of_first_paid_purchase\": \"2021-10-11T20:31:15Z\",\"date_of_last_paid_purchase\": \"2023-09-22T14:59:22Z\"}],\"marketplace_winner_info\": [{\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2022-12-22T18:45:44Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2023-08-14T08:23:34Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"number_of_trades\": 24,\"volume_of_trades\": 3322}],\"other_delivery_address\": [{\"shipping_method\": \"pick-up point\",\"shipping_type\": \"express\",\"first_name\": \"Test\",\"last_name\": \"Person\",\"street_address\": \"Rue La Fayette\",\"street_number\": \"33\",\"postal_code\": \"75009\",\"city\": \"Paris\",\"country\": \"FR\"}]}";
Address address = new Address();
address.setAddressLine1("2795 Edgewood Road");
address.setCity("Little Rock");
address.setRegion("Arkansas");
address.setPostalCode("72212");
address.setCountry(CountryIso.FR);
LineItem lineItem1 = new LineItem(null, null, null, null, null);
lineItem1.setName("Running shoes");
lineItem1.setQuantity(1);
lineItem1.setUnitAmount(200);
lineItem1.setTaxAmount(0);
lineItem1.setDescription("Seller 1 ID");
LineItem lineItem2 = new LineItem(null, null, null, null, null);
lineItem2.setName("Running shoes");
lineItem2.setQuantity(1);
lineItem2.setUnitAmount(200);
lineItem2.setTaxAmount(0);
lineItem2.setDescription("Seller 2 ID");
List<LineItem> lineItems = Arrays.asList(lineItem1, lineItem2);
PayInExecutionDetailsWeb payinExecutionDetails = new PayInExecutionDetailsWeb();
payinExecutionDetails.setReturnUrl("http://www.mangopay.com/docs/please-ignore");
PayInPaymentDetailsKlarna paymentDetails = new PayInPaymentDetailsKlarna();
paymentDetails.setAdditionalData(additionalData);
paymentDetails.setBilling(new Billing());
paymentDetails.getBilling().setFirstName("Alex");
paymentDetails.getBilling().setLastName("Smith");
paymentDetails.getBilling().setAddress(address);
paymentDetails.setCountry(CountryIso.FR);
paymentDetails.setCulture(CultureCode.FR);
paymentDetails.setReference("1234");
paymentDetails.setPhone("[+33][689854321]");
paymentDetails.setEmail(myUser.getEmail());
paymentDetails.setLineItems(lineItems);
payin.setPaymentType(PayInPaymentType.KLARNA);
payin.setExecutionType(PayInExecutionType.WEB);
payin.setCreditedWalletId(walletId);
payin.setExecutionDetails(payinExecutionDetails);
payin.setPaymentDetails(paymentDetails);
payin.setTag("Created with Mangopay Java SDK");
payin.setAuthorId(myUser.getId());
payin.setDebitedFunds(new Money(CurrencyIso.EUR, 400));
payin.setFees(new Money(CurrencyIso.EUR, 100));
PayIn createKlarnaPayin = mangopay.getPayInApi().create(payin);
Gson prettyPrint = new GsonBuilder().setPrettyPrinting().create();
String prettyJson = prettyPrint.toJson(createKlarnaPayin);
System.out.println(prettyJson);
}
}
from pprint import pprint
import mangopay
mangopay.client_id='your-client-id'
mangopay.apikey='your-api-key'
from mangopay.api import APIRequest
handler = APIRequest(sandbox=True)
from mangopay.resources import NaturalUser, KlarnaPayIn
from mangopay.utils import Money, Billing, Shipping, Address, LineItem
natural_user = NaturalUser.get('210513027')
klarna_payin = KlarnaPayIn(
author = natural_user,
credited_wallet_id = '210514820',
debited_funds = Money(amount=1500, currency='EUR'),
fees = Money(amount=300, currency='EUR'),
return_url = 'http://www.mangopay.com/docs/please-ignore',
statement_descriptor = 'Feb2024',
billing = Billing(
first_name = natural_user.first_name,
last_name = natural_user.last_name,
address = Address(
address_line_1 = natural_user.address.address_line_1,
address_line_2 = natural_user.address.address_line_2,
city = natural_user.address.city,
region = natural_user.address.region,
postal_code = natural_user.address.postal_code,
country = natural_user.address.country
)
),
line_items = [
LineItem(
name = 'Running shoes',
quantity=1,
unit_amount=400,
tax_amount=100,
description='ID of Seller 1'),
LineItem(
name = 'Walking shoes',
quantity=2,
unit_amount=400,
tax_amount=100,
description='ID of Seller 2')
],
shipping = Shipping(
first_name = natural_user.first_name,
last_name = natural_user.last_name,
address = Address(
address_line_1 = natural_user.address.address_line_1,
address_line_2 = natural_user.address.address_line_2,
city = natural_user.address.city,
region = natural_user.address.region,
postal_code = natural_user.address.postal_code,
country = natural_user.address.country,
)
),
country = natural_user.address.country,
email = natural_user.email,
phone = '[+33][689854321]',
reference = '2345',
culture = 'FR',
additional_data = 'your-additional-data',
tag = 'Created using the Mangopay Python SDK'
)
create_klarna_payin = klarna_payin.save()
pprint(create_klarna_payin)
using MangoPay.SDK;
using MangoPay.SDK.Core.Enumerations;
using MangoPay.SDK.Entities;
using MangoPay.SDK.Entities.POST;
using Newtonsoft.Json;
class Program
{
static async Task Main(string[] args)
{
MangoPayApi api = new MangoPayApi();
api.Config.ClientId = "your-client-id";
api.Config.ClientPassword = "your-api-key";
var myUser = await api.Users.GetNaturalAsync("210513027");
List<LineItem> LineItems = new List<LineItem>();
var myPayIn = new PayInKlarnaWebPostDTO(
authorId: myUser.Id,
debitedFunds: new Money {
Amount = 1500,
Currency = CurrencyIso.EUR
},
fees: new Money {
Amount = 300,
Currency = CurrencyIso.EUR
},
creditedWalletId: "210514820",
returnUrl: "http://www.mangopay.com/docs/please-ignore",
lineItems: new List<LineItem>{
new LineItem
{
Name = "Running shoes",
Quantity = 1,
UnitAmount = 400,
TaxAmount = 100,
Description = "ID of Seller 1"
},
new LineItem
{
Name = "Walking shoes",
Quantity = 2,
UnitAmount = 400,
TaxAmount = 100,
Description = "ID of Seller 2"
}
},
country: "FR",
phone: "[+33][689854321]",
email: myUser.Email,
additionalData: "{\"customer_account_info\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"app_id\": \"81363501-3540-494a-8627-33bc6112035d\",\"loyalty_level\": \"high\",\"customer_email\": \"customer@email.com\",\"customer_phone\": \"0611223344\",\"customer_ranking\": 2,\"customer_reviews\": 5,\"last_login_time\": \"2023-10-21T19:11:34Z\",\"account_security\": {\"last_verification_method\": \"2FA TOTP\",\"last_verification_time\": \"2023-10-21T19:11:34Z\",\"device_id\": \"772af5a5-2d55-4a5e-bb79-85969f683810\",\"fraud_behavior\": false,\"devices_linked\": 2,\"phone_verified\": true,\"email_verified\": true,\"failed_transactions_attempts\": 0},\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": \"2022-12-22T18:45:44Z\"}],\"marketplace_seller_info\": [{\"sub_merchant_id\": \"615a0e87-4941-45dc-978d-e6efcbd90ba0\",\"sub_merchant_name\": \"Marketbrick Ltd.\",\"sub_merchant_postal_code\": \"75010\",\"product_category\": \"Computers\",\"product_name\": \"Asus Zenbook 14\",\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2020-06-10T12:02:21Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2020-06-10T12:02:21Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"digital_download\": false,\"seller_rating\": 4.5,\"number_of_trades\": 34,\"volume_of_trades\": 4500}],\"payment_history_full\": [{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 10,\"payment_option\": \"card\",\"total_amount_paid_purchases\": 1000.10,\"date_of_first_paid_purchase\": \"2020-06-10T12:12:34Z\",\"date_of_last_paid_purchase\": \"2023-10-26T18:52:38Z\"},{\"unique_account_identifier\": \"382f5a69-c51c-45af-9707-6991eb08f7bf\",\"number_paid_purchases\": 14,\"payment_option\": \"non klarna credit\",\"total_amount_paid_purchases\": 2322.10,\"date_of_first_paid_purchase\": \"2021-10-11T20:31:15Z\",\"date_of_last_paid_purchase\": \"2023-09-22T14:59:22Z\"}],\"marketplace_winner_info\": [{\"account_registration_date\": \"2020-06-10T12:02:21Z\",\"account_last_modified\": {\"password\": \"2022-12-22T18:45:44Z\",\"email\": \"2020-06-10T12:02:21Z\",\"listing\": \"2023-08-14T08:23:34Z\",\"login\": \"2020-06-10T12:02:21Z\",\"address\": \"2020-06-10T12:02:21Z\"},\"number_of_trades\": 24,\"volume_of_trades\": 3322}],\"other_delivery_address\": [{\"shipping_method\": \"pick-up point\",\"shipping_type\": \"express\",\"first_name\": \"Test\",\"last_name\": \"Person\",\"street_address\": \"Rue La Fayette\",\"street_number\": \"33\",\"postal_code\": \"75009\",\"city\": \"Paris\",\"country\": \"FR\"}]}",
billing: new Billing{
FirstName = myUser.FirstName,
LastName = myUser.LastName,
Address = new Address {
AddressLine1 = myUser.Address.AddressLine1,
AddressLine2 = myUser.Address.AddressLine2,
City = myUser.Address.City,
Region = myUser.Address.Region,
PostalCode = myUser.Address.PostalCode,
Country = myUser.Address.Country
},
},
reference: "2345",
culture: "FR",
tag: "Created using the Mangopay .NET SDK"
);
var createKlarnaPayIn = await api.PayIns.CreateKlarnaWebAsync(myPayIn);
string prettyPrint = JsonConvert.SerializeObject(createKlarnaPayIn, Formatting.Indented);
Console.WriteLine(prettyPrint);
}
}
Was this page helpful?