mangopay2-nodejs-sdk
Version:
Mangopay Node.js SDK
1,217 lines (1,098 loc) • 102 kB
JavaScript
var expect = require('chai').expect;
var helpers = require('../helpers');
var mangopay = require('../../index');
var api = global.api = new mangopay({
clientId: 'sdk-unit-tests',
clientApiKey: 'cqFfFrWfCcb7UadHNxx2C9Lo6Djw8ZduLi7J9USTmu8bhxxpju'
});
describe('PayIns', function () {
var payIn;
var john = helpers.data.getUserNatural();
before(function (done) {
api.Users.create(john, function () {
done();
});
});
describe('Card Web', function () {
before(function (done) {
helpers.getNewPayInCardWeb(api, john, function (data, response) {
payIn = data;
done();
});
});
describe('Create', function () {
it('should create the PayIn', function () {
expect(payIn.Id).not.to.be.undefined;
expect(payIn.PaymentType).to.equal('CARD');
expect(payIn.ExecutionType).to.equal('WEB');
});
});
describe('Get', function () {
var getPayIn;
before(function (done) {
api.PayIns.get(payIn.Id, function (data, response) {
getPayIn = data;
done()
});
});
it('should get the PayIn', function () {
expect(getPayIn.Id).not.to.be.undefined;
expect(getPayIn.PaymentType).to.equal('CARD');
expect(getPayIn.ExecutionType).to.equal('WEB');
expect(getPayIn.Status).to.equal('CREATED');
expect(getPayIn.ExecutionDate).to.be.null;
expect(getPayIn.RedirectURL).not.to.be.undefined;
expect(getPayIn.ReturnURL).not.to.be.undefined;
});
});
describe.skip('Get extended details', function () {
console.warn('Cannot be tested because a Succeeded Card Web PayIn cannot be generated from the tests');
var extendedDetails;
before(function (done) {
api.PayIns.getCardWebPayInExtendedDetails(payIn.Id, function (data, response) {
extendedDetails = data;
done();
});
});
it('should get the PayIn', function () {
expect(extendedDetails.Id).not.to.be.undefined;
expect(extendedDetails.PaymentType).to.equal('CARD');
expect(extendedDetails.ExecutionType).to.equal('WEB');
});
});
});
describe('Card Direct', function () {
var payIn;
before(function (done) {
helpers.getNewPayInCardDirect(api, john, function (data, response) {
payIn = data;
done();
});
});
describe('Create', function () {
it('should create the PayIn', function () {
expect(payIn.Id).not.to.be.undefined;
expect(payIn.PaymentType).to.equal('CARD');
expect(payIn.ExecutionType).to.equal('DIRECT');
expect(payIn.AuthorId).to.equal(john.Id);
expect(payIn.Status).to.equal('SUCCEEDED');
expect(payIn.Type).to.equal('PAYIN');
expect(payIn.SecurityInfo.AVSResult).to.equal('NO_CHECK');
expect(payIn.CardInfo).not.to.be.undefined;
});
});
describe('Get', function () {
var getPayIn;
before(function (done) {
api.PayIns.get(payIn.Id, function (data, response) {
getPayIn = data;
done()
});
});
it('should get the PayIn', function () {
expect(getPayIn.Id).to.equal(payIn.Id);
expect(getPayIn.PaymentType).to.equal('CARD');
expect(getPayIn.ExecutionType).to.equal('DIRECT');
expect(getPayIn.CardId).not.to.be.null;
});
});
describe('Create Refund', function () {
var refund;
before(function (done) {
helpers.getNewRefundForPayIn(api, john, payIn, function (data, response) {
refund = data;
done();
});
});
it('should succeed', function () {
expect(refund.DebitedFunds).to.eql(payIn.DebitedFunds);
expect(refund.Type).to.equal('PAYOUT');
expect(refund.Nature).to.equal('REFUND');
});
});
describe('Create Partial Refund', function () {
var refund;
before(function (done) {
helpers.getPartialRefundForPayIn(api, john, payIn, function (data, response) {
refund = data;
done();
});
});
it('should succeed', function () {
expect(refund.Id).to.not.be.null;
expect(refund.Type).to.equal('PAYOUT');
expect(refund.Nature).to.equal('REFUND');
});
});
});
describe('PreAuthorizedDirect', function () {
var preAuthorization, payIn, wallet;
var transactionsData;
before(function (done) {
helpers.getUserCardPreAuthorization(api, john, function (data, response) {
preAuthorization = data;
wallet = {
Owners: [john.Id],
Currency: 'EUR',
Description: 'WALLET IN EUR'
};
api.Wallets.create(wallet).then(function () {
payIn = {
CreditedWalletId: wallet.Id,
AuthorId: john.Id,
DebitedFunds: {
Amount: 1000,
Currency: 'EUR'
},
Fees: {
Amount: 0,
Currency: 'EUR'
},
CardId: preAuthorization.CardId,
SecureModeReturnURL: 'http://test.com',
PaymentType: 'PREAUTHORIZED',
ExecutionType: 'DIRECT',
PreauthorizationId: preAuthorization.Id
};
api.PayIns.create(payIn, async function (data, response) {
// wait 2 seconds for the transactions to be created by the API
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
await delay(2000);
done();
});
});
});
});
it('should succeed', function () {
expect(payIn.Id).not.to.be.undefined;
expect(payIn.data.AuthorId).to.equal(john.Id);
expect(payIn.data.PaymentType).to.equal('PREAUTHORIZED');
expect(payIn.data.ExecutionType).to.equal('DIRECT');
expect(payIn.data.CardId).not.to.be.null;
expect(payIn.data.Type).to.equal('PAYIN');
expect(payIn.data.Status).to.equal('SUCCEEDED');
});
before(function(done){
api.CardPreAuthorizations.getTransactions(preAuthorization.Id, function(data, response){
transactionsData = data;
done();
});
});
it('should get transactions', function () {
expect(transactionsData[0].Status).to.not.equal('FAILED');
});
});
describe('BankWireDirect', function () {
var payIn, wallet;
before(function (done) {
wallet = {
Owners: [john.Id],
Currency: 'EUR',
Description: 'WALLET IN EUR'
};
api.Wallets.create(wallet).then(function () {
done();
});
});
describe('Create', function () {
before(function (done) {
payIn = {
CreditedWalletId: wallet.Id,
AuthorId: john.Id,
DeclaredDebitedFunds: {
Amount: 10000,
Currency: 'EUR'
},
DeclaredFees: {
Amount: 0,
Currency: 'EUR'
},
PaymentType: 'BANK_WIRE',
ExecutionType: 'DIRECT'
};
api.PayIns.create(payIn, function (data, response) {
done();
});
});
it('should succeed', function () {
expect(payIn.Id).not.to.be.undefined;
expect(payIn.data.AuthorId).to.equal(john.Id);
expect(payIn.data.PaymentType).to.equal('BANK_WIRE');
expect(payIn.data.ExecutionType).to.equal('DIRECT');
expect(payIn.data.Type).to.equal('PAYIN');
expect(payIn.data.Status).to.equal('CREATED');
});
});
describe('Get', function () {
var getPayIn;
before(function (done) {
api.PayIns.get(payIn.Id, function (data, response) {
getPayIn = data;
done();
});
});
it('should succeed', function () {
expect(getPayIn.Id).to.equal(payIn.Id);
expect(getPayIn.BankAccount.Type).to.equal('IBAN');
expect(getPayIn.AuthorId).to.equal(john.Id);
expect(getPayIn.ExecutionType).to.equal('DIRECT');
expect(getPayIn.Type).to.equal('PAYIN');
expect(getPayIn.Status).to.equal('CREATED');
});
});
});
describe('DirectDebitWeb', function () {
var payIn, wallet;
before(function (done) {
wallet = {
Owners: [john.Id],
Currency: 'EUR',
Description: 'WALLET IN EUR'
};
api.Wallets.create(wallet).then(function () {
done();
});
});
describe('Create', function () {
before(function (done) {
payIn = {
CreditedWalletId: wallet.Id,
AuthorId: john.Id,
DebitedFunds: {
Amount: 10000,
Currency: 'EUR'
},
Fees: {
Amount: 100,
Currency: 'EUR'
},
PaymentType: 'DIRECT_DEBIT',
ExecutionType: 'WEB',
DirectDebitType: 'GIROPAY',
ReturnURL: 'http://www.mysite.com/returnURL/',
Culture: 'FR',
PAYLINE: 'https://www.maysite.com/payline_template/'
};
api.PayIns.create(payIn, function (data, response) {
done();
});
});
it('should succeed', function () {
expect(payIn.Id).not.to.be.undefined;
expect(payIn.data.AuthorId).to.equal(john.Id);
expect(payIn.data.PaymentType).to.equal('DIRECT_DEBIT');
expect(payIn.data.ExecutionType).to.equal('WEB');
expect(payIn.data.CardId).not.to.be.null;
expect(payIn.data.Type).to.equal('PAYIN');
expect(payIn.data.Status).to.equal('CREATED');
});
});
});
describe('PayPalWeb', function () {
var payIn, wallet;
before(function (done) {
wallet = {
Owners: [john.Id],
Currency: 'EUR',
Description: 'WALLET IN EUR'
};
api.Wallets.create(wallet).then(function () {
done();
});
});
describe('Create', function () {
var shippingAddress = {
RecipientName: "Mangopay Test",
Address: {
"AddressLine1": "4101 Reservoir Rd NW",
"AddressLine2": "",
"City": "Washington",
"Region": "District of Columbia",
"PostalCode": "20007",
"Country": "US"
}
};
before(function (done) {
payIn = {
CreditedWalletId: wallet.Id,
AuthorId: john.Id,
CreditedUserId: john.Id,
DebitedFunds: {
Amount: 10000,
Currency: 'EUR'
},
Fees: {
Amount: 100,
Currency: 'EUR'
},
PaymentType: 'PAYPAL',
ExecutionType: 'WEB',
ReturnURL: 'http://www.mysite.com/returnURL/',
ShippingAddress: shippingAddress
};
api.PayIns.create(payIn, function (data, response) {
done();
});
});
it('should be created', function () {
expect(payIn.Id).not.to.be.undefined;
expect(payIn.data.AuthorId).to.equal(john.Id);
expect(payIn.data.PaymentType).to.equal('PAYPAL');
expect(payIn.data.ExecutionType).to.equal('WEB');
expect(payIn.data.CardId).not.to.be.null;
expect(payIn.data.Type).to.equal('PAYIN');
expect(payIn.data.Status).to.equal('CREATED');
});
describe('Get', function () {
var getPayIn;
before(function (done) {
api.PayIns.get(payIn.Id, function (data, response) {
getPayIn = data;
done();
});
});
it('should be retrieved', function () {
expect(getPayIn.Id).not.to.be.undefined;
expect(getPayIn.Id).to.equal(payIn.Id);
expect(getPayIn.ShippingAddress).not.to.be.undefined;
expect(getPayIn.ShippingAddress).to.deep.equal(shippingAddress);
});
});
});
describe.skip("Get with Email", function () {
console.warn("Cannot be tested. PayIn ID expired.");
var payInId = "54088959";
var accountEmail = "paypal-buyer-user@mangopay.com";
var payinWithEmail;
before(function (done) {
api.PayIns.get(payInId, function (data, response) {
payinWithEmail = data;
done();
});
});
it("should contain buyer's email", function () {
expect(payinWithEmail).not.to.be.undefined;
expect(payinWithEmail.Id).to.equal(payInId);
expect(payinWithEmail.PaypalBuyerAccountEmail).not.to.be.undefined;
expect(payinWithEmail.PaypalBuyerAccountEmail).to.equal(accountEmail);
});
});
});
// describe('ApplePay', function () {
// var applePayPayIn, wallet;
// before(function (done) {
// wallet = {
// Owners: [john.Id],
// Currency: 'EUR',
// Description: 'WALLET IN EUR'
// };
// api.Wallets.create(wallet).then(function () {
// done();
// });
// });
// describe('Create', function () {
// var paymentData = {
// TransactionId: '061EB32181A2D9CA42AD16031B476EEBAA62A9A095AD660E2759FBA52B51A61',
// Network: 'VISA',
// TokenData: "{\"version\":\"EC_v1\",\"data\":\"w4HMBVqNC9ghPP4zncTA\/0oQAsduERfsx78oxgniynNjZLANTL6+0koEtkQnW\/K38Zew8qV1GLp+fLHo+qCBpiKCIwlz3eoFBTbZU+8pYcjaeIYBX9SOxcwxXsNGrGLk+k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bvGeC5CU2RS5KBEG+15HH9tz\/sg3qmQ14CID4F4ZJwAz+tXAUcAIzoMpYSnM8YBlnGJSTSp+LhspenAAAAAAAA\",\"header\":{\"ephemeralPublicKey\":\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE0rs3wRpirXjPbFDQfPRdfEzRIZDWm0qn7Y0HB0PNzV1DDKfpYrnhRb4GEhBF\/oEXBOe452PxbCnN1qAlqcSUWw==\",\"publicKeyHash\":\"saPRAqS7TZ4bAYwzBj8ezDDC55ZolyH1FL+Xc8fd93o=\",\"transactionId\":\"b061eb32181a2d9ca42ad16031b476eebaa62a9a095ad660e2759fba52b51a61\"}}"
// };
// before(function (done) {
// applePayPayIn = {
// CreditedWalletId: wallet.Id,
// AuthorId: john.Id,
// CreditedUserId: john.Id,
// DebitedFunds: {
// Amount: 199,
// Currency: 'EUR'
// },
// Fees: {
// Amount: 1,
// Currency: 'EUR'
// },
// PaymentType: 'APPLEPAY',
// ExecutionType: 'DIRECT',
// PaymentData: paymentData,
// Tag: "Create an ApplePay card direct Payin",
// StatementDescriptor: "php"
// };
// api.PayIns.create(applePayPayIn, function (data, response) {
// done();
// });
// });
// it('should be created', function () {
// expect(applePayPayIn.Id).not.to.be.undefined;
// expect(applePayPayIn.data.AuthorId).to.equal(john.Id);
// expect(applePayPayIn.data.PaymentType).to.equal('APPLEPAY');
// expect(applePayPayIn.data.ExecutionType).to.equal('DIRECT');
// expect(applePayPayIn.data.Type).to.equal('PAYIN');
// expect(applePayPayIn.data.Status).to.equal('SUCCEEDED');
// });
// });
// });
describe.skip('GooglePay', function () {
var googlePayIn, wallet;
before(function (done) {
wallet = {
Owners: [john.Id],
Currency: 'EUR',
Description: 'WALLET IN EUR'
};
api.Wallets.create(wallet).then(function () {
done();
});
});
describe('Create', function () {
var paymentData = {
TransactionId: 'placeholder',
Network: 'placeholder',
TokenData: "placeholder"
};
before(function (done) {
googlePayIn = {
CreditedWalletId: wallet.Id,
AuthorId: john.Id,
CreditedUserId: john.Id,
DebitedFunds: {
Amount: 199,
Currency: 'EUR'
},
Fees: {
Amount: 1,
Currency: 'EUR'
},
PaymentType: 'GOOGLEPAY',
ExecutionType: 'DIRECT',
PaymentData: paymentData,
Tag: "Create an GooglePay card direct Payin",
StatementDescriptor: "php"
};
api.PayIns.create(googlePayIn, function (data, response) {
done();
});
});
it('should be created', function () {
expect(googlePayIn.Id).not.to.be.undefined;
expect(googlePayIn.data.AuthorId).to.equal(john.Id);
expect(googlePayIn.data.PaymentType).to.equal('GOOGLEPAY');
expect(googlePayIn.data.ExecutionType).to.equal('DIRECT');
expect(googlePayIn.data.Type).to.equal('PAYIN');
expect(googlePayIn.data.Status).to.equal('SUCCEEDED');
});
});
});
describe('Get Refunds', function () {
var getRefunds;
before(function (done) {
api.PayIns.getRefunds(payIn.Id, function (data, response) {
getRefunds = data;
done();
});
});
it('should be retrieved', function () {
expect(getRefunds).not.to.be.undefined;
expect(getRefunds).to.be.an('array');
});
});
describe('ExetrnalInstructionIBAN', function () {
describe('Get', function () {
var getPayIn;
before(function (done) {
api.PayIns.get("payin_m_01JFA5CSPT3QBECGYDX6AKQ3QD", function (data, response) {
getPayIn = data;
done()
});
});
it('should get the PayIn', function () {
expect(getPayIn.PaymentType).to.equal('BANK_WIRE');
expect(getPayIn.ExecutionType).to.equal('EXTERNAL_INSTRUCTION');
expect(getPayIn.DebitedBankAccount.Type).to.equal('IBAN');
expect(getPayIn.DebitedBankAccount.IBAN).not.to.be.null;
expect(getPayIn.DebitedBankAccount.AccountNumber).to.be.null;
});
});
});
/*
describe('ExetrnalInstructionAccountNumber', function () {
describe('Get', function () {
var getPayIn;
before(function (done) {
api.PayIns.get("74981216", function (data, response) {
getPayIn = data;
done()
});
});
it('should get the PayIn', function () {
expect(getPayIn.PaymentType).to.equal('BANK_WIRE');
expect(getPayIn.ExecutionType).to.equal('EXTERNAL_INSTRUCTION');
expect(getPayIn.DebitedBankAccount.Type).to.equal('OTHER');
expect(getPayIn.DebitedBankAccount.IBAN).to.be.null;
expect(getPayIn.DebitedBankAccount.AccountNumber).not.to.be.null;
});
});
});
*/
describe('Recurring Payments', function() {
var cardId;
var walletId;
var createdPayPalCit;
before('Create a wallet with money and a card', function(done){
wallet = {
Owners: [john.Id],
Currency: 'EUR',
Description: 'WALLET IN EUR'
};
cardRegistration = {
UserId: john.Id,
Currency: 'EUR'
};
api.Wallets.create(wallet).then(function(){
api.CardRegistrations.create(cardRegistration, function() {
helpers.getPaylineCorrectRegistartionData(cardRegistration, function(data, response){
cardRegistration.RegistrationData = data;
api.CardRegistrations.update(cardRegistration).then(function(data){
updatedCardRegistration = data;
cardId = updatedCardRegistration.CardId;
walletId = wallet.Id;
api.Cards.get(cardRegistration.CardId, function(data, response) {
card = data;
api.PayIns.create({
CreditedWalletId: wallet.Id,
AuthorId: john.Id,
DebitedFunds: {
Amount: 100,
Currency: 'EUR'
},
Fees: {
Amount: 0,
Currency: 'EUR'
},
CardId: card.Id,
SecureMode: 'DEFAULT',
SecureModeReturnURL: 'https://test.com',
PaymentType: 'CARD',
ExecutionType: 'DIRECT',
BrowserInfo: {
AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
JavaEnabled: true,
Language: "FR-FR",
ColorDepth: 4,
ScreenHeight: 1800,
ScreenWidth: 400,
JavascriptEnabled: true,
TimeZoneOffset: "+60",
UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
},
IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C"
}, function(data, response) {
done();
});
});
});
});
});
});
});
describe('Create a Recurring Payment', function() {
var recurring;
before(function(done){
recurringPayin = {
AuthorId: john.Id,
CardId: cardId,
CreditedUserId: john.Id,
CreditedWalletId: walletId,
FirstTransactionDebitedFunds: {
Amount: 10,
Currency: 'EUR'
},
FirstTransactionFees: {
Amount: 1,
Currency: 'EUR'
},
Billing: {
FirstName: 'Joe',
LastName: 'Blogs',
Address: {
AddressLine1: '1 MangoPay Street',
AddressLine2: 'The Loop',
City: 'Paris',
Region: 'Ile de France',
PostalCode: '75001',
Country: 'FR'
}
},
Shipping: {
FirstName: 'Joe',
LastName: 'Blogs',
Address: {
AddressLine1: '1 MangoPay Street',
AddressLine2: 'The Loop',
City: 'Paris',
Region: 'Ile de France',
PostalCode: '75001',
Country: 'FR'
}
},
FreeCycles: 0
};
api.PayIns.createRecurringPayment(recurringPayin, function(data, response){
recurring = data;
}).then(function(){
cit = {
RecurringPayinRegistrationId: recurring.Id,
BrowserInfo: {
AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
JavaEnabled: true,
Language: "FR-FR",
ColorDepth: 4,
ScreenHeight: 1800,
ScreenWidth: 400,
JavascriptEnabled: true,
TimeZoneOffset: "+60",
UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
},
IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C",
SecureModeReturnURL: "http://www.my-site.com/returnurl",
StatementDescriptor: "lorem",
Tag: "custom meta",
DebitedFunds: {
Amount: 10,
Currency: 'EUR'
},
Fees: {
Amount: 1,
Currency: 'EUR'
},
};
api.PayIns.createRecurringPayInRegistrationCIT(cit, function(data, response){
createCit = data;
done();
})
})
})
it('should be created', function() {
expect(recurring).to.not.be.null;
expect(recurring.FreeCycles).to.not.be.null;
expect(createCit).to.not.be.null;
})
})
describe('Create a PayPal Recurring Payment CIT', function() {
var recurring;
before(function(done){
var recurringPayinRegistration = {
AuthorId: john.Id,
CreditedWalletId: walletId,
FirstTransactionDebitedFunds: {
Amount: 1000,
Currency: 'EUR'
},
FirstTransactionFees: {
Amount: 1,
Currency: 'EUR'
},
Billing: {
FirstName: 'Joe',
LastName: 'Blogs',
Address: {
AddressLine1: '1 MangoPay Street',
AddressLine2: 'The Loop',
City: 'Paris',
Region: 'Ile de France',
PostalCode: '75001',
Country: 'FR'
}
},
Shipping: {
FirstName: 'Joe',
LastName: 'Blogs',
Address: {
AddressLine1: '1 MangoPay Street',
AddressLine2: 'The Loop',
City: 'Paris',
Region: 'Ile de France',
PostalCode: '75001',
Country: 'FR'
}
},
PaymentType: 'PAYPAL'
};
api.PayIns.createRecurringPayment(recurringPayinRegistration, function(data, response){
recurringPayinRegistration = data;
}).then(function(){
var cit = {
RecurringPayinRegistrationId: recurringPayinRegistration.Id,
StatementDescriptor: "lorem",
Tag: "custom meta",
LineItems: [
{
Name: "running shoes",
Quantity: 1,
UnitAmount: 1000,
TaxAmount: 0,
Description: "seller1 ID"
}
],
ReturnURL: 'http://example.com',
CancelURL: 'http://example.net',
ShippingPreference: 'SET_PROVIDED_ADDRESS',
Reference: 'abcd-efgh-ijkl'
};
api.PayIns.createRecurringPayPalPayInCIT(cit, function(data){
createdPayPalCit = data;
done();
});
});
});
it('should be created', function() {
expect(createdPayPalCit).to.not.be.null;
// expect(createdPayPalCit.Status).to.eq('CREATED');
expect(createdPayPalCit.PaymentType).to.eq('PAYPAL');
expect(createdPayPalCit.ExecutionType).to.eq('WEB');
});
});
describe('Create a Recurring Payment Check Card Info', function() {
var recurring;
before(function(done){
recurringPayin = {
AuthorId: john.Id,
CardId: cardId,
CreditedUserId: john.Id,
CreditedWalletId: walletId,
FirstTransactionDebitedFunds: {
Amount: 10,
Currency: 'EUR'
},
FirstTransactionFees: {
Amount: 1,
Currency: 'EUR'
},
Billing: {
FirstName: 'Joe',
LastName: 'Blogs',
Address: {
AddressLine1: '1 MangoPay Street',
AddressLine2: 'The Loop',
City: 'Paris',
Region: 'Ile de France',
PostalCode: '75001',
Country: 'FR'
}
},
Shipping: {
FirstName: 'Joe',
LastName: 'Blogs',
Address: {
AddressLine1: '1 MangoPay Street',
AddressLine2: 'The Loop',
City: 'Paris',
Region: 'Ile de France',
PostalCode: '75001',
Country: 'FR'
}
},
FreeCycles: 0
};
api.PayIns.createRecurringPayment(recurringPayin, function(data, response){
recurring = data;
}).then(function(){
cit = {
RecurringPayinRegistrationId: recurring.Id,
BrowserInfo: {
AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
JavaEnabled: true,
Language: "FR-FR",
ColorDepth: 4,
ScreenHeight: 1800,
ScreenWidth: 400,
JavascriptEnabled: true,
TimeZoneOffset: "+60",
UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
},
IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C",
SecureModeReturnURL: "http://www.my-site.com/returnurl",
StatementDescriptor: "lorem",
Tag: "custom meta",
DebitedFunds: {
Amount: 10,
Currency: 'EUR'
},
Fees: {
Amount: 1,
Currency: 'EUR'
},
};
api.PayIns.createRecurringPayInRegistrationCIT(cit, function(data, response){
createCit = data;
done();
});
});
});
it('should be created', function() {
expect(createCit.CardInfo).to.not.be.null;
// expect(createCit.CardInfo.Type).to.not.be.null;
// expect(createCit.CardInfo.Brand).to.not.be.null;
// expect(createCit.CardInfo.IssuingBank).to.not.be.null;
// expect(createCit.CardInfo.BIN).to.not.be.null;
});
});
describe('Get Recurring Payment', function () {
var recurring;
before(function(done){
recurringPayin = {
AuthorId: john.Id,
CardId: cardId,
CreditedUserId: john.Id,
CreditedWalletId: walletId,
FirstTransactionDebitedFunds: {
Amount: 10,
Currency: 'EUR'
},
FirstTransactionFees: {
Amount: 1,
Currency: 'EUR'
},
Billing: {
FirstName: 'Joe',
LastName: 'Blogs',
Address: {
AddressLine1: '1 MangoPay Street',
AddressLine2: 'The Loop',
City: 'Paris',
Region: 'Ile de France',
PostalCode: '75001',
Country: 'FR'
}
},
Shipping: {
FirstName: 'Joe',
LastName: 'Blogs',
Address: {
AddressLine1: '1 MangoPay Street',
AddressLine2: 'The Loop',
City: 'Paris',
Region: 'Ile de France',
PostalCode: '75001',
Country: 'FR'
}
},
FreeCycles: 0
};
api.PayIns.createRecurringPayment(recurringPayin, function(data, response){
recurring = data;
}).then(function(){
api.PayIns.getRecurringPayin(recurring.Id, function (data, response) {
getRecurring = data;
done();
});
});
});
it('should get the RecurringPayin', function () {
expect(getRecurring.Id).not.to.be.undefined;
expect(getRecurring.Status).not.to.be.undefined;
expect(getRecurring.FreeCycles).not.to.be.undefined;
});
});
describe('Update Recurring Payment', function () {
var recurring, updateRec;
before(function(done){
recurringPayin = {
AuthorId: john.Id,
CardId: cardId,
CreditedUserId: john.Id,
CreditedWalletId: walletId,
FirstTransactionDebitedFunds: {
Amount: 10,
Currency: 'EUR'
},
FirstTransactionFees: {
Amount: 1,
Currency: 'EUR'
},
Billing: {
FirstName: 'Joe',
LastName: 'Blogs',
Address: {
AddressLine1: '1 MangoPay Street',
AddressLine2: 'The Loop',
City: 'Paris',
Region: 'Ile de France',
PostalCode: '75001',
Country: 'FR'
}
},
Shipping: {
FirstName: 'Joe',
LastName: 'Blogs',
Address: {
AddressLine1: '1 MangoPay Street',
AddressLine2: 'The Loop',
City: 'Paris',
Region: 'Ile de France',
PostalCode: '75001',
Country: 'FR'
}
}
};
api.PayIns.createRecurringPayment(recurringPayin, function (data, response) {
recurring = data;
}).then(function () {
updateObj = {
Billing: {
FirstName: 'TEST',
LastName: 'TEST',
Address: {
AddressLine1: '1 MangoPay Street',
AddressLine2: 'The Loop',
City: 'Paris',
Region: 'Ile de France',
PostalCode: '75001',
Country: 'FR'
}
},
Shipping: {
FirstName: 'TEST',
LastName: 'TEST',
Address: {
AddressLine1: '1 MangoPay Street',
AddressLine2: 'The Loop',
City: 'Paris',
Region: 'Ile de France',
PostalCode: '75001',
Country: 'FR'
}
},
Status: "ENDED"
};
api.PayIns.updateRecurringPayin(recurring.Id, updateObj, function (data, response) {
updateRec = data;
done();
});
});
});
it('should get the updated RecurringPayin', function () {
expect(updateRec.Id).not.to.be.undefined;
expect(updateRec.Status).not.to.be.undefined;
expect(updateRec.Status).to.equal("ENDED");
});
});
});
describe('Payconiq Web', function () {
var payIn, wallet;
before(function (done) {
wallet = {
Owners: [john.Id],
Currency: 'EUR',
Description: 'WALLET IN EUR'
};
api.Wallets.create(wallet).then(function () {
payIn = {
Tag: 'custom meta',
CreditedWalletId: wallet.Id,
AuthorId: john.Id,
DebitedFunds: {
Amount: 1000,
Currency: 'EUR'
},
Fees: {
Amount: 0,
Currency: 'EUR'
},
PaymentType: 'PAYCONIQ',
ExecutionType: 'WEB',
ReturnURL: 'http://www.my-site.com/returnURL',
Country: 'BE'
};
api.PayIns.create(payIn, function (data, response) {
payIn = data;
done();
});
});
});
describe('Create', function () {
it('should create the PayIn', function () {
expect(payIn.Id).not.to.be.undefined;
expect(payIn.PaymentType).to.equal('PAYCONIQ');
expect(payIn.ExecutionType).to.equal('WEB');
expect(payIn.Status).to.equal('CREATED');
expect(payIn.RedirectURL).not.to.be.undefined;
expect(payIn.DeepLinkURL).not.to.be.undefined;
});
});
describe('Get', function () {
var getPayIn;
before(function (done) {
api.PayIns.get(payIn.Id, function (data, response) {
getPayIn = data;
done()
});
});
it('should get the PayIn', function () {
expect(getPayIn.Id).not.to.be.undefined;
expect(getPayIn.PaymentType).to.equal('PAYCONIQ');
expect(getPayIn.ExecutionType).to.equal('WEB');
expect(getPayIn.Status).to.equal('CREATED');
expect(payIn.RedirectURL).not.to.be.undefined;
expect(payIn.DeepLinkURL).not.to.be.undefined;
});
});
});
describe('Payconiq Web V2', function () {
var payIn, wallet;
before(function (done) {
wallet = {
Owners: [john.Id],
Currency: 'EUR',
Description: 'WALLET IN EUR'
};
api.Wallets.create(wallet).then(function () {
payIn = {
Tag: 'custom meta',
CreditedWalletId: wallet.Id,
AuthorId: john.Id,
DebitedFunds: {
Amount: 100,
Currency: 'EUR'
},
Fees: {
Amount: 0,
Currency: 'EUR'
},
PaymentType: 'PAYCONIQ',
ExecutionType: 'WEB',
ReturnURL: 'http://www.my-site.com/returnURL',
Country: 'BE'
};
api.PayIns.createPayconiq(payIn, function (data, response) {
payIn = data;
done();
});
});
});
describe('Create', function () {
it('should create the PayIn', function () {
expect(payIn.Id).not.to.be.undefined;
expect(payIn.PaymentType).to.equal('PAYCONIQ');
expect(payIn.ExecutionType).to.equal('WEB');
expect(payIn.Status).to.equal('CREATED');
expect(payIn.RedirectURL).not.to.be.undefined;
expect(payIn.DeepLinkURL).not.to.be.undefined;
expect(payIn.QRCodeURL).not.to.be.undefined;
});
});
});
describe('Mbway Web', function () {
var payIn;
before(function (done) {
helpers.getNewPayInMbwayWeb(api, john, function (data, response) {
payIn = data;
done();
});
});
describe('Create', function () {
it('should create the PayIn', function () {
expect(payIn.Id).not.to.be.undefined;
expect(payIn.PaymentType).to.equal('MBWAY');
expect(payIn.ExecutionType).to.equal('WEB');
expect(payIn.AuthorId).to.equal(john.Id);
expect(payIn.Status).to.equal('CREATED');
expect(payIn.Type).to.equal('PAYIN');
expect(payIn.Ph