Skip to content

Commit

Permalink
Merge pull request #415 from Mangopay/feature/new-params
Browse files Browse the repository at this point in the history
added new params
  • Loading branch information
iulian03 authored Jul 15, 2024
2 parents b4bbf77 + df87846 commit 2892420
Show file tree
Hide file tree
Showing 15 changed files with 242 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/apiMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ module.exports = {
"payins_klarna-web_create": ["/${apiVersion}/${clientId}/payins/payment-methods/klarna", "POST"],
"payins_ideal-web_create": ["/${apiVersion}/${clientId}/payins/payment-methods/ideal", "POST"],
"payins_giropay-web_create": ["/${apiVersion}/${clientId}/payins/payment-methods/giropay", "POST"],
"payins_bcmc-web_create": ["/${apiVersion}/${clientId}/payins/payment-methods/bancontact", "POST"],

"add_tracking_info": ["/${apiVersion}/${clientId}/payins/${payInId}/trackings", "PUT"],

"payment_method_metadata_get": ["/${apiVersion}/${clientId}/payment-methods/metadata", "POST"],
Expand Down
13 changes: 13 additions & 0 deletions lib/models/PayInPaymentDetailsBancontact.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var PayInPaymentDetails = require('./PayInPaymentDetails');

var PayInPaymentDetailsBancontact = PayInPaymentDetails.extend({
defaults: {
/**
* Custom description to show on the user's bank statement.
* It can be up to 10 char alpha-numeric and space.
*/
StatementDescriptor: null
}
});

module.exports = PayInPaymentDetailsBancontact;
1 change: 1 addition & 0 deletions lib/models/PayInPaymentType.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
GooglePay: 'GOOGLE_PAY',
Payconiq: 'PAYCONIQ',
Mbway: 'MBWAY',
Bancontact: 'BCMC',
Multibanco: 'MULTIBANCO',
Satispay: 'SATISPAY',
Blik: 'BLIK',
Expand Down
1 change: 1 addition & 0 deletions lib/models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ module.exports = {
PayInPaymentDetailsGooglePay: require('./PayInPaymentDetailsGooglePay'),
PayInPaymentDetailsPayPal: require('./PayInPaymentDetailsPayPal'),
PayInPaymentDetailsPreAuthorized: require('./PayInPaymentDetailsPreAuthorized'),
PayInPaymentDetailsBancontact: require('./PayInPaymentDetailsBancontact'),
PayInPaymentType: require('./PayInPaymentType'),
PayInRecurringRegistration: require('./PayInRecurringRegistration'),
PayInTemplateURLOptions: require('./PayInTemplateURLOptions'),
Expand Down
2 changes: 2 additions & 0 deletions lib/services/PayIns.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var PayInExecutionDetailsBankingAlias = require('../models/PayInExecutionDetails
var PayInPaymentDetailsApplePay = require('../models/PayInPaymentDetailsApplePay');
var PayInPaymentDetailsGooglePay = require('../models/PayInPaymentDetailsGooglePay');
var PayInPaymentDetailsMbway = require('../models/PayInPaymentDetailsMbway');
var PayInPaymentDetailsBancontact = require('../models/PayInPaymentDetailsBancontact');
var Refund = require('../models/Refund');
var PayInRecurringRegistration = require('../models/PayInRecurringRegistration');
var PayInPaymentDetailsPayconiq = require('../models/PayInPaymentDetailsPayconiq');
Expand Down Expand Up @@ -292,6 +293,7 @@ var PayIns = Service.extend({
if (payIn.PaymentDetails instanceof PayInPaymentDetailsGooglePay) return 'googlepay';
if (payIn.PaymentDetails instanceof PayInPaymentDetailsPayconiq) return 'payconiq';
if (payIn.PaymentDetails instanceof PayInPaymentDetailsMbway) return 'mbway';
if (payIn.PaymentDetails instanceof PayInPaymentDetailsBancontact) return 'bcmc';
if (payIn.PaymentDetails instanceof PayInPaymentDetailsMultibanco) return 'multibanco';
if (payIn.PaymentDetails instanceof PayInPaymentDetailsSatispay) return 'satispay';
if (payIn.PaymentDetails instanceof PayInPaymentDetailsBlik) return 'blik';
Expand Down
31 changes: 31 additions & 0 deletions test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,37 @@ module.exports = {
});
},

getNewPayInBancontactWeb: function(api, user, callback) {
var wallet = {
Owners: [user.Id],
Currency: 'EUR',
Description: 'WALLET IN EUR'
};

api.Wallets.create(wallet).then(function(){
var payIn = {
AuthorId: user.Id,
CreditedWalletId: wallet.Id,
DebitedFunds: {
Amount: 500,
Currency: 'EUR'
},
Fees: {
Amount: 0,
Currency: 'EUR'
},
ReturnURL: "http://mangopay.com",
PaymentType: 'BCMC',
ExecutionType: 'WEB',
Culture: 'FR',
StatementDescriptor: "test",
Recurring: true,
Tag: "test tag"
};
api.PayIns.create(payIn, callback);
});
},

getNewPayInPayPalWeb: function(api, user, callback) {
var wallet = {
Owners: [user.Id],
Expand Down
40 changes: 40 additions & 0 deletions test/services/PayIns.js
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,46 @@ describe('PayIns', function () {
});
});

describe('Bancontact Web', function () {
var payIn;

before(function (done) {
helpers.getNewPayInBancontactWeb(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('BCMC');
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.Recurring).not.to.be.null;
});
});

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('BCMC');
expect(getPayIn.ExecutionType).to.equal('WEB');
expect(getPayIn.Phone).not.to.be.null;
});
});
});

describe('PayPal Web V2', function () {
var payIn;

Expand Down
1 change: 1 addition & 0 deletions typings/enums.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export namespace enums {
Klarna: "KLARNA";
Ideal: "IDEAL";
Giropay: "GIROPAY";
Bancontact: "BCMC";
}

interface IMandateStatus {
Expand Down
1 change: 1 addition & 0 deletions typings/models/card.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export namespace card {
interface UpdateCard {
Id: string;
Active?: false;
CardHolderName?: string;
}

interface CardInfoData {
Expand Down
11 changes: 10 additions & 1 deletion typings/models/cardPreauthorization.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export namespace cardPreAuthorization {
type PreAuthorizationStatus = "CREATED" | "SUCCEEDED" | "FAILED";

type CreateCardPreAuthorization = PickPartialRequired<CardPreAuthorizationData,
"Tag" | "Billing" | "SecureMode" | "Culture" | "StatementDescriptor" | "Shipping", "AuthorId" | "DebitedFunds" | "CardId" | "SecureModeReturnURL" | "IpAddress" | "BrowserInfo">;
"Tag" | "Billing" | "SecureMode" | "Culture" | "StatementDescriptor" | "Shipping" | "PaymentCategory", "AuthorId" | "DebitedFunds" | "CardId" | "SecureModeReturnURL" | "IpAddress" | "BrowserInfo">;

type UpdateCardPreAuthorization = PickPartialRequired<CardPreAuthorizationData,
"Tag",
Expand Down Expand Up @@ -144,5 +144,14 @@ export namespace cardPreAuthorization {
Shipping: ShippingData;

CardInfo: CardInfoData;

/**
* The channel through which the user provided their card details, used to indicate mail-order and telephone-order (MOTO) payments:
*
* ECommerce – Payment received online.
*
* TelephoneOrder – Payment received via mail order or telephone order (MOTO).
*/
PaymentCategory: string;
}
}
18 changes: 18 additions & 0 deletions typings/models/cardValidation.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ export namespace cardValidation {
* The explanation of the result code.
*/
ResultMessage: string;

/**
* The channel through which the user provided their card details, used to indicate mail-order and telephone-order (MOTO) payments:
*
* ECommerce – Payment received online.
*
* TelephoneOrder – Payment received via mail order or telephone order (MOTO).
*/
PaymentCategory: string;
}

interface CreateCardValidation {
Expand Down Expand Up @@ -103,5 +112,14 @@ export namespace cardValidation {
* Custom data that you can add to this object.
*/
Tag?: string;

/**
* The channel through which the user provided their card details, used to indicate mail-order and telephone-order (MOTO) payments:
*
* ECommerce – Payment received online.
*
* TelephoneOrder – Payment received via mail order or telephone order (MOTO).
*/
PaymentCategory?: string;
}
}
108 changes: 108 additions & 0 deletions typings/models/payIn.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export namespace payIn {
| PayconiqWebPayInData
| DirectDebitDirectPayInData
| MbwayWebPayInData
| BancontactWebPayInData
| MultibancoWebPayInData
| SatispayWebPayInData
| BlikWebPayInData
Expand Down Expand Up @@ -316,6 +317,15 @@ export namespace payIn {
* Information about the card
*/
CardInfo: CardInfoData;

/**
* The channel through which the user provided their card details, used to indicate mail-order and telephone-order (MOTO) payments:
*
* ECommerce – Payment received online.
*
* TelephoneOrder – Payment received via mail order or telephone order (MOTO).
*/
PaymentCategory: string;
}

interface MbwayWebPayInData extends BasePayInData {
Expand All @@ -336,6 +346,43 @@ export namespace payIn {
Phone: string;
}

interface BancontactWebPayInData extends BasePayInData {
ExecutionType: "WEB";

PaymentType: "BCMC";

/**
* The URL to which the user is redirected to complete the payment
*/
RedirectURL: string;

/**
* The URL where users are automatically redirected after the payment is validated
*/
ReturnURL: string;

/**
* The URL where you should redirect your client in a mobile app experience
*/
DeepLinkURL: string;

/**
* A custom description to appear on the user's bank statement. It can be up to 10 characters long, and can only include alphanumeric
* characters or spaces. See here for important info. Note that each bank handles this information differently, some show less or no information.
*/
StatementDescriptor: string;

/**
* The language to use for the payment page - needs to be the ISO code of the language
*/
Culture: CountryISO;

/**
* Whether the Bancontact pay-ins are being made to be re-used in a recurring payment flow
*/
Recurring: boolean;
}

interface PayPalWebPayInData extends BasePayInData {
ExecutionType: "WEB";

Expand Down Expand Up @@ -546,6 +593,15 @@ export namespace payIn {
* Custom data that you can add to this item
*/
Tag?: string;

/**
* The channel through which the user provided their card details, used to indicate mail-order and telephone-order (MOTO) payments:
*
* ECommerce – Payment received online.
*
* TelephoneOrder – Payment received via mail order or telephone order (MOTO).
*/
PaymentCategory?: string;
}

interface CreateMbwayWebPayIn {
Expand Down Expand Up @@ -591,6 +647,58 @@ export namespace payIn {
Tag?: string;
}

interface CreateBancontactWebPayIn {
ExecutionType: "WEB";

PaymentType: "BCMC";

/**
* A user's ID
*/
AuthorId: string;

/**
* The ID of the wallet where money will be credited
*/
CreditedWalletId: string;

/**
* Information about the funds that are being debited
*/
DebitedFunds: MoneyData;

/**
* Information about the fees that were taken by the client for this transaction (and were hence transferred to the Client's platform wallet)
*/
Fees: MoneyData;

/**
* The URL where users are automatically redirected after the payment is validated
*/
ReturnURL: string;

/**
* The language to use for the payment page - needs to be the ISO code of the language
*/
Culture?: CountryISO;

/**
* Whether the Bancontact pay-ins are being made to be re-used in a recurring payment flow
*/
Recurring?: boolean;

/**
* A custom description to appear on the user's bank statement. It can be up to 10 characters long, and can only include alphanumeric characters or spaces.
* See here for important info. Note that each bank handles this information differently, some show less or no information.
*/
StatementDescriptor?: string;

/**
* Custom data that you can add to this item
*/
Tag?: string;
}

interface CreatePayPalWebPayIn {
ExecutionType: "WEB";

Expand Down
10 changes: 10 additions & 0 deletions typings/models/refund.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export namespace refund {
* Contains info about the reason for refund
*/
RefundReason: RefundReason;

/**
* Custom description to appear on the user’s bank statement along with the platform name
*/
StatementDescriptor: string;
}

interface CreatePayInRefund {
Expand All @@ -46,6 +51,11 @@ export namespace refund {
DebitedFunds?: MoneyData;

Fees?: MoneyData;

/**
* Custom description to appear on the user’s bank statement along with the platform name
*/
StatementDescriptor?: string;
}

interface CreateTransferRefund {
Expand Down
4 changes: 3 additions & 1 deletion typings/services/PayIns.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export class PayIns {
MethodOverload<payIn.CreateGooglePayDirectPayIn, payIn.GooglePayDirectPayInData> &
MethodOverload<payIn.CreateKlarnaWebPayIn, payIn.KlarnaWebPayInData> &
MethodOverload<payIn.CreateIdealWebPayIn, payIn.IdealWebPayInData> &
MethodOverload<payIn.CreateGiropayWebPayIn, payIn.GiropayWebPayInData>;
MethodOverload<payIn.CreateGiropayWebPayIn, payIn.GiropayWebPayInData> &
MethodOverload<payIn.CreateBancontactWebPayIn, payIn.BancontactWebPayInData>;


/**
* Get pay-in
Expand Down
1 change: 1 addition & 0 deletions typings/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export type ApiMethod =
| "transactions_get_for_bank_account"
| "idempotency_response_get"
| "payins_mbway-web_create"
| "payins_bcmc-web_create"
| "payins_paypal-web_create_v2"
| "payins_multibanco-web_create"
| "payins_satispay-web_create"
Expand Down

0 comments on commit 2892420

Please sign in to comment.