Closed miguelx97 closed 3 years ago
Hi @miguelx97
Please see here: https://github.com/Mangopay/mangopay2-nodejs-sdk/blob/master/test/services/CardRegistrations.js#L53
We have a test which covers your issue.
Thanks, SoloJr
I can see how it works in javascript vanila, but it's not working for me in nodejs SDK.
I'm trying to do everything like your test, but it's still not working, this is my code:
async cardRegistration() {
try{
const card:MangoPay.cardRegistration.CreateCardRegistration = {
UserId:'107964693'
, Currency:'EUR'
, CardType:'CB_VISA_MASTERCARD'
}
const registrateCard:MangoPay.cardRegistration.CardRegistrationData = await this.mangopayApi.CardRegistrations.create(card)
console.log('CREATE_CARD_REGISTRATION: ', registrateCard);
let resgistrationCardRes = await axios({
method: 'post',
url: registrateCard.CardRegistrationURL,
data: qs.stringify({
accessKeyRef: registrateCard.AccessKey
, data: registrateCard.PreregistrationData
, cardNumber: '4970101122334422'
, cardExpirationDate: '1224'
, cardCvx: '123'
}),
headers: {
'content-type': 'application/x-www-form-urlencoded;charset=utf-8'
}
})
console.log('REGISTRATION_CARD.DATA', resgistrationCardRes.data); //data=VLRcH36ssIXrewmo23k3Cx04UD...
const token:string = resgistrationCardRes.data;
const updateCard:MangoPay.cardRegistration.UpdateCardRegistration = {
RegistrationData: token
}
const resUpdatedCard = await this.mangopayApi.CardRegistrations.update(updateCard);
console.log(resUpdatedCard);
}
catch(e){
console.error(e);
}
}
This is my console response:
CREATE_CARD_REGISTRATION: child {
Id: '108673346',
Tag: null,
CreationDate: 1620825402,
UserId: '107964693',
AccessKey: '1X0m87dmM2LiwFgxPLBJ',
PreregistrationData:
'S2mSVl8PLRVHgaMNATInMtElLo_-ohILlFn0aw5MR6oMOeM2yvC2d2AN8oSVppSa2ddFLVXdicolcUIkv_kKEA',
RegistrationData: null,
CardId: null,
CardType: 'CB_VISA_MASTERCARD',
CardRegistrationURL:
'https://homologation-webpayment.payline.com/webpayment/getToken',
ResultCode: null,
ResultMessage: null,
Currency: 'EUR',
Status: 'CREATED' }
REGISTRATION_CARD.DATA data=WlFlNrFOZLxXvGO11QriKxSWCtvk1ijJKEoY2ZqoN72eud_cclHYKUo9fEDc1upnLZ1ZBU-HUC9ZScK_Ev-_mBoWS-qc2_pek9bgV2k7jnYXuXBooHaLnj0E6IyZ4XoeNx0xgKTVnyDj15oG8jR88g
The ressource does not exist { Message: 'The ressource does not exist',
Type: 'ressource_not_found',
Id: '570b64d0-3e8f-460d-8f9b-7561491d767e#1620825402',
Date: 1620825403,
errors:
{ RessourceNotFound:
'Cannot found the ressource CardRegistration with the id=undefined ' } }
{ Message: 'The ressource does not exist',
Type: 'ressource_not_found',
Id: '570b64d0-3e8f-460d-8f9b-7561491d767e#1620825402',
Date: 1620825403,
errors:
{ RessourceNotFound:
'Cannot found the ressource CardRegistration with the id=undefined ' } }
It always says that CardRegistration Id is undefined, but that Id should be in the token.
Could you help me with this issue?
Thank you so much.
Hello @miguelx97,
As you can see in the documentation, the ID is not in the token.
In const resUpdatedCard = await this.mangopayApi.CardRegistrations.update(updateCard);
, updateCard
should be the full CardRegistration
object and not only the token.
Let me know if it's solve the problem.
Hello @fredericdelordm, thank you for your response. With your help I just resolved the error.
The misunderstanding was because I thought that the parameter for this.mangopayApi.CardRegistrations.update
should be a MangoPay.cardRegistration.UpdateCardRegistration
object, but that's wrong. I only had to edit MangoPay.cardRegistration.CardRegistrationData
object that I used before and use it as the parameter.
Example that works:
const card:MangoPay.cardRegistration.CreateCardRegistration = {
UserId:'107964693' //CHANGE THIS VALUE FOR THE ID OF AN USER THAN EXIST FOR YOU
, Currency:'EUR'
, CardType:'CB_VISA_MASTERCARD'
}
const registrateCard:MangoPay.cardRegistration.CardRegistrationData = await this.mangopayApi.CardRegistrations.create(card)
console.log('CREATE_CARD_REGISTRATION: ', registrateCard);
let resgistrationCardRes = await axios({
method: 'post',
url: registrateCard.CardRegistrationURL,
data: qs.stringify({
accessKeyRef: registrateCard.AccessKey
, data: registrateCard.PreregistrationData
, cardNumber: '4970101122334422'
, cardExpirationDate: '1224'
, cardCvx: '123'
}),
headers: {
'content-type': 'application/x-www-form-urlencoded;charset=utf-8'
}
})
console.log('REGISTRATION_CARD.DATA', resgistrationCardRes.data); //data=VLRcH36ssIXrewmo23k3Cx04UD...
const token:string = resgistrationCardRes.data;
registrateCard.RegistrationData = token;
const resUpdatedCard = await this.mangopayApi.CardRegistrations.update(registrateCard);
console.log(resUpdatedCard);
Hello, I'm getting this error when I try to add a new card. Id is undefined, but I can't find the way to send the Id in the function.
The response is:
¿What could we do?
Thank you