התממשקות עם קרדיט כארד API
-
אני מנסה להתממשק ל קרדיט כארד, עד היום עבדתי בצורה שונה עם טרנזילה נדרים יעד שריג, אייפרם של כתובת פשוטה עם פרמטרים.
לקרדיט כארד זה עובד בצורה שונה, אשמח לעזרה איך זה אמור לעבוד, זה כנראה אמור להחזיר לי את כתובת דף התשלום הייחודית. איך אני מקבל את זה.,
תודהזה הדוגמא ששלחו לי
var qs = require("querystring"); var http = require("https"); var options = { "method": "POST", "hostname": [ "cguat2", "creditguard", "co", "il" ], "path": [ "xpo", "Relay" ], "headers": { "Content-Type": "application/x-www-form-urlencoded", "cache-control": "no-cache", "Postman-Token": "7fa351ab54d-4a63f-48137-be86-45a502144729" } }; var req = http.request(options, function (res) { var chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); }); req.write(qs.stringify({ user: 'hsad3esdad', password: 'PAS33SWORD', int_in: '<ashrait><request><version>2000</version><language>HEB</language><dateTime/><requestId/><command>doDeal</command><doDeal><terminalNumber>8802346</terminalNumber><cardNo>CGMPI</cardNo><total>300</total><id>123456789</id><paymentPageData><useId></useId></paymentPageData>\n<transactionType>Debit</transactionType><email>shaie@tuttnauerhd2323.com</email><creditType>RegularCredit</creditType><currency>ILS</currency><transactionCode>Phone</transactionCode><validation>TxnSetup</validation><mid>11412</mid><uniqueid>0.6457763203173892</uniqueid><mpiValidation>Token</mpiValidation><keepCD>1</keepCD>\n<successUrl></successUrl><errorUrl></errorUrl><cancelUrl>https://google.com</cancelUrl></doDeal></request></ashrait>', undefined: undefined })); req.end();
-
@אבי-203 אולי אני אמור להמיר את זה לספריית velo אשמח להכוונה
export function sendWithService1() { const url = "https://server_name/xpo/services/Relay"; var options = { "method": "POST", "hostname": [ "cguat2", "creditguard", "co", "il" ], "path": [ "xpo", "Relay" ], "headers": { "Content-Type": "application/x-www-form-urlencoded", "cache-control": "no-cache", "Postman-Token": "7fa51adebd-4aed6f-48ed17-beed86-45a502144729" } }; const data = JSON.stringify({ user: 'hwadsdaed', password: 'PAaSSdWOsRD', int_in: '<ashrait><request><version>2000</version><language>HEB</language><dateTime/><requestId/><command>doDeal</command><doDeal><terminalNumber>8802346</terminalNumber><cardNo>CGMPI</cardNo><total>300</total><id>123456789</id><paymentPageData><useId></useId></paymentPageData>\n<transactionType>Debit</transactionType><email>shaie@tuttnauerhd2323.com</email><creditType>RegularCredit</creditType><currency>ILS</currency><transactionCode>Phone</transactionCode><validation>TxnSetup</validation><mid>11412</mid><uniqueid>0.6457763203173892</uniqueid><mpiValidation>Token</mpiValidation><keepCD>1</keepCD>\n<successUrl></successUrl><errorUrl></errorUrl><cancelUrl>https://google.com</cancelUrl></doDeal></request></ashrait>', undefined: undefined }); const request = { "options" : options, "body": data }; return fetch(url, request) .then(response => response.text()) }
-
@אבי-203 אמר בהתממשקות עם קרדיט כארד API:
קרדיט כארד
צ"ל קרדיט גארד. (לקח לי זמן להבין למה התכוונת).
ספריית velo
גם לקח לי זמן להבין מה זה velo טוב, הבנתי עכשיו, שינו את השם של Corvid ל-velo (יותר מדי הזכיר Covid... )
בוא נעשה פה קצת סדר.
דוגמת הקוד ששלחו לך מיועד עבור nodejs. הדוגמה עצמה מגיע ישר מהייצוא האוטומטי של postman וממש לא שימושי... (מה צפית מחברה ישראלית...)נתרגם את זה למשהו נורמלי שאולי יעבוד לך:
import FormData from 'form-data'; import { fetch } from 'wix-fetch'; const form = new FormData(); form.append('user', 'hsad3esdad'); form.append('password', 'PAS33SWORD'); form.append('int_in', ` <?xml version="1.0"?> <ashrait> <request> <version>2000</version> <language>HEB</language> <dateTime/> <requestId/> <command>doDeal</command> <doDeal> <terminalNumber>8802346</terminalNumber> <cardNo>CGMPI</cardNo> <total>300</total> <id>123456789</id> <paymentPageData> <useId/> </paymentPageData> <transactionType>Debit</transactionType> <email>shaie@tuttnauerhd2323.com</email> <creditType>RegularCredit</creditType> <currency>ILS</currency> <transactionCode>Phone</transactionCode> <validation>TxnSetup</validation> <mid>11412</mid> <uniqueid>0.6457763203173892</uniqueid> <mpiValidation>Token</mpiValidation> <keepCD>1</keepCD> <successUrl/> <errorUrl/> <cancelUrl>https://google.com</cancelUrl> </doDeal> </request> </ashrait> `); const res = await fetch('https://cguat2.creditguard.co.il/xpo/Relay', { method: 'post', headers: { 'Content-Type': 'application/x-www-form-urlencoded', body: form } });
משהו כזה. יכול להיות שעשיתי פה טעויות, אני לא משתמש ב-WIX.
-
@yossiz נראה לי שזה עובד!
החזיר לי את התשובה הזו:
אני מבין שבתוך זה אמור להיות כתובת האייפרם של התשלום.
או שבכלל זה שגיאה, בכל אופן זה נראה שכן היתה תקשורת נכונה. לא?url https://cguat2.creditguard.co.il/xpo/Relay status 500 statusText Internal Server Error headers {"_headers":{"content-type":["text/html;charset=utf-8"],"content-language":["en"],"content-length":["1216"],"date":["Wed, 17 Feb 2021 20:56:50 GMT"],"connection":["close"],"set-cookie":["TS011c0af0=01c4b5d6b1dc7844df056184f5ba0a54c4114fc647cf6b7206b9bc6ef428fa22603e1359086d560da3fb1c0d34199ecb419f43f3a0; Path=/; Domain=.cguat2.creditguard.co.il; Secure; HTTPOnly"]}} ok false body {"_readableState":{"objectMode":false,"highWaterMark":16384,"buffer":{"head":{"data":{"type":"Buffer","data":[60,33,68,79,67,84,89,80,69,32,104,116,109,108,62,60,104,116,109,108,62,60,104,101,97,100,62,60,116,105,116,108,101,62,65,112,97,99,104,101,32,84,111,109,99,97,116,47,56,46,48,46,57,32,45,32,69,114,114,111,114,32,114,101,112,111,114,116,60,47,116,105,116,108,101,62,60,115,116,121,108,101,32,116,121,112,101,61,34,116,101,120,116,47,99,115,115,34,62,72,49,32,123,102,111,110,116,45,102,97,109,105,108,121,58,84,97,104,111,109,97,44,65,114,105,97,108,44,115,97,110,115,45,115,101,114,105,102,59,99,111,108,111,114,58,119,104,105,116,101,59,98,97,99,107,103,114,111,117,110,100,45,99,111,108,111,114,58,35,53,50,53,68,55,54,59,102,111,110,116,45,115,105,122,101,58,50,50,112,120,59,125,32,72,50,32,123,102,111,110,116,45,102,97,109,105,108,121,58,84,97,104,111,109,97,44,65,114,105,97,108,44,115,97,110,115,45,115,101,114,105,102,59,99,111,108,111,114,58,119,104,105,116,101,59,98,97,99,107,103,114,111,117,110,100,45,99,111,108,111,114,58,35,53,50,53,68,55,54,59,102,111,110,116,45,115,105,122,101,58,49,54,112,120,59,125,32,72,51,32,123,102,111,110,116,45,102,97,109,105,108,121,58,84,97,104,111,109,97,44,65,114,105,97,108,44,115,97,110,115,45,115,101,114,105,102,59,99,111,108,111,114,58,119,104,105,116,101,59,98,97,99,107,103,114,111,117,110,100,45,99,111,108,111,114,58,35,53,50,53,68,55,54,59,102,111,110,116,45,115,105,122,101,58,49,52,112,120,59,125,32,66,79,68,89,32,123,102,111,110,116,45,102,97,109,105,108,121,58,84,97,104,111,109,97,44,65,114,105,97,108,44,115,97,110,115,45,115,101,114,105,102,59,99,111,108,111,114,58,98,108,97,99,107,59,98,97,99,107,103,114,111,117,110,100,45,99,111,108,111,114,58,119,104,105,116,101,59,125,32,66,32,123,102,111,110,116,45,102,97,109,105,108,121,58,84,97,104,111,109,97,44,65,114,105,97,108,44,115,97,110,115,45,115,101,114,105,102,59,99,111,108,111,114,58,119,104,105,116,101,59,98,97,99,107,103,114,111,117,110,100,45,99,111,108,111,114,58,35,53,50,53,68,55,54,59,125,32,80,32,123,102,111,110,116,45,102,97,109,105,108,121,58,84,97,104,111,109,97,44,65,114,105,97,108,44,115,97,110,115,45,115,101,114,105,102,59,98,97,99,107,103,114,111,117,110,100,58,119,104,105,116,101,59,99,111,108,111,114,58,98,108,97,99,107,59,102,111,110,116,45,115,105,122,101,58,49,50,112,120,59,125,65,32,123,99,111,108,111,114,32,58,32,98,108,97,99,107,59,125,65,46,110,97,109,101,32,123,99,111,108,111,114,32,58,32,98,108,97,99,107,59,125,46,108,105,110,101,32,123,104,101,105,103,104,116,58,32,49,112,120,59,32,98,97,99,107,103,114,111,117,110,100,45,99,111,108,111,114,58,32,35,53,50,53,68,55,54,59,32,98,111,114,100,101,114,58,32,110,111,110,101,59,125,60,47,115,116,121,108,101,62,32,60,47,104,101,97,100,62,60,98,111,100,121,62,60,104,49,62,72,84,84,80,32,83,116,97,116,117,115,32,53,48,48,32,45,32,60,47,104,49,62,60,100,105,118,32,99,108,97,115,115,61,34,108,105,110,101,34,62,60,47,100,105,118,62,60,112,62,60,98,62,116,121,112,101,60,47,98,62,32,69,120,99,101,112,116,105,111,110,32,114,101,112,111,114,116,60,47,112,62,60,112,62,60,98,62,109,101,115,115,97,103,101,60,47,98,62,32,60,117,62,60,47,117,62,60,47,112,62,60,112,62,60,98,62,100,101,115,99,114,105,112,116,105,111,110,60,47,98,62,32,60,117,62,84,104,101,32,115,101,114,118,101,114,32,101,110,99,111,117,110,116,101,114,101,100,32,97,110,32,105,110,116,101,114,110,97,108,32,101,114,114,111,114,32,116,104,97,116,32,112,114,101,118,101,110,116,101,100,32,105,116,32,102,114,111,109,32,102,117,108,102,105,108,108,105,110,103,32,116,104,105,115,32,114,101,113,117,101,115,116,46,60,47,117,62,60,47,112,62,60,112,62,60,98,62,101,120,99,101,112,116,105,111,110,60,47,98,62,60,47,112,62,60,112,114,101,62,106,97,118,97,46,108,97,110,103,46,78,117,108,108,80,111,105,110,116,101,114,69,120,99,101,112,116,105,111,110,10,60,47,112,114,101,62,60,112,62,60,98,62,110,111,116,101,60,47,98,62,32,60,117,62,84,104,101,32,102,117,108,108,32,115,116,97,99,107,32,116,114,97,99,101,32,111,102,32,116,104,101,32,114,111,111,116,32,99,97,117,115,101,32,105,115,32,97,118,97,105,108,97,98,108,101,32,105,110,32,116,104,101,32,65,112,97,99,104,101,32,84,111,109,99,97,116,47,56,46,48,46,57,32,108,111,103,115,46,60,47,117,62,60,47,112,62,60,104,114,32,99,108,97,115,115,61,34,108,105,110,101,34,62,60,104,51,62,65,112,97,99,104,101,32,84,111,109,99,97,116,47,56,46,48,46,57,60,47,104,51,62,60,47,98,111,100,121,62,60,47,104,116,109,108,62]},"next":null},"tail":{"data":{"type":"Buffer","data":[60,33,68,79,67,84,89,80,69,32,104,116,109,108,62,60,104,116,109,108,62,60,104,101,97,100,62,60,116,105,116,108,101,62,65,112,97,99,104,101,32,84,111,109,99,97,116,47,56,46,48,46,57,32,45,32,69,114,114,111,114,32,114,101,112,111,114,116,60,47,116,105,116,108,101,62,60,115,116,121,108,101,32,116,121,112,101,61,34,116,101,120,116,47,99,115,115,34,62,72,49,32,123,102,111,110,116,45,102,97,109,105,108,121,58,84,97,104,111,109,97,44,65,114,105,97,108,44,115,97,110,115,45,115,101,114,105,102,59,99,111,108,111,114,58,119,104,105,116,101,59,98,97,99,107,103,114,111,117,110,100,45,99,111,108,111,114,58,35,53,50,53,68,55,54,59,102,111,110,116,45,115,105,122,101,58,50,50,112,120,59,125,32,72,50,32,123,102,111,110,116,45,102,97,109,105,108,121,58,84,97,104,111,109,97,44,65,114,105,97,108,44,115,97,110,115,45,115,101,114,105,102,59,99,111,108,111,114,58,119,104,105,116,101,59,98,97,99,107,103,114,111,117,110,100,45,99,111,108,111,114,58,35,53,50,53,68,55,54,59,102,111,110,116,45,115,105,122,101,58,49,54,112,120,59,125,32,72,51,32,123,102,111,110,116,45,102,97,109,105,108,121,58,84,97,104,111,109,97,44,65,114,105,97,108,44,115,97,110,115,45,115,101,114,105,102,59,99,111,108,111,114,58,119,104,105,116,101,59,98,97,99,107,103,114,111,117,110,100,45,99,111,108,111,114,58,35,53,50,53,68,55,54,59,102,111,110,116,45,115,105,122,101,58,49,52,112,120,59,125,32,66,79,68,89,32,123,102,111,110,116,45,102,97,109,105,108,121,58,84,97,104,111,109,97,44,65,114,105,97,108,44,115,97,110,115,45,115,101,114,105,102,59,99,111,108,111,114,58,98,108,97,99,107,59,98,97,99,107,103,114,111,117,110,100,45,99,111,108,111,114,58,119,104,105,116,101,59,125,32,66,32,123,102,111,110,116,45,102,97,109,105,108,121,58,84,97,104,111,109,97,44,65,114,105,97,108,44,115,97,110,115,45,115,101,114,105,102,59,99,111,108,111,114,58,119,104,105,116,101,59,98,97,99,107,103,114,111,117,110,100,45,99,111,108,111,114,58,35,53,50,53,68,55,54,59,125,32,80,32,123,102,111,110,116,45,102,97,109,105,108,121,58,84,97,104,111,109,97,44,65,114,105,97,108,44,115,97,110,115,45,115,101,114,105,102,59,98,97,99,107,103,114,111,117,110,100,58,119,104,105,116,101,59,99,111,108,111,114,58,98,108,97,99,107,59,102,111,110,116,45,115,105,122,101,58,49,50,112,120,59,125,65,32,123,99,111,108,111,114,32,58,32,98,108,97,99,107,59,125,65,46,110,97,109,101,32,123,99,111,108,111,114,32,58,32,98,108,97,99,107,59,125,46,108,105,110,101,32,123,104,101,105,103,104,116,58,32,49,112,120,59,32,98,97,99,107,103,114,111,117,110,100,45,99,111,108,111,114,58,32,35,53,50,53,68,55,54,59,32,98,111,114,100,101,114,58,32,110,111,110,101,59,125,60,47,115,116,121,108,101,62,32,60,47,104,101,97,100,62,60,98,111,100,121,62,60,104,49,62,72,84,84,80,32,83,116,97,116,117,115,32,53,48,48,32,45,32,60,47,104,49,62,60,100,105,118,32,99,108,97,115,115,61,34,108,105,110,101,34,62,60,47,100,105,118,62,60,112,62,60,98,62,116,121,112,101,60,47,98,62,32,69,120,99,101,112,116,105,111,110,32,114,101,112,111,114,116,60,47,112,62,60,112,62,60,98,62,109,101,115,115,97,103,101,60,47,98,62,32,60,117,62,60,47,117,62,60,47,112,62,60,112,62,60,98,62,100,101,115,99,114,105,112,116,105,111,110,60,47,98,62,32,60,117,62,84,104,101,32,115,101,114,118,101,114,32,101,110,99,111,117,110,116,101,114,101,100,32,97,110,32,105,110,116,101,114,110,97,108,32,101,114,114,111,114,32,116,104,97,116,32,112,114,101,118,101,110,116,101,100,32,105,116,32,102,114,111,109,32,102,117,108,102,105,108,108,105,110,103,32,116,104,105,115,32,114,101,113,117,101,115,116,46,60,47,117,62,60,47,112,62,60,112,62,60,98,62,101,120,99,101,112,116,105,111,110,60,47,98,62,60,47,112,62,60,112,114,101,62,106,97,118,97,46,108,97,110,103,46,78,117,108,108,80,111,105,110,116,101,114,69,120,99,101,112,116,105,111,110,10,60,47,112,114,101,62,60,112,62,60,98,62,110,111,116,101,60,47,98,62,32,60,117,62,84,104,101,32,102,117,108,108,32,115,116,97,99,107,32,116,114,97,99,101,32,111,102,32,116,104,101,32,114,111,111,116,32,99,97,117,115,101,32,105,115,32,97,118,97,105,108,97,98,108,101,32,105,110,32,116,104,101,32,65,112,97,99,104,101,32,84,111,109,99,97,116,47,56,46,48,46,57,32,108,111,103,115,46,60,47,117,62,60,47,112,62,60,104,114,32,99,108,97,115,115,61,34,108,105,110,101,34,62,60,104,51,62,65,112,97,99,104,101,32,84,111,109,99,97,116,47,56,46,48,46,57,60,47,104,51,62,60,47,98,111,100,121,62,60,47,104,116,109,108,62]},"next":null},"length":1},"length":1216,"pipes":null,"pipesCount":0,"flowing":null,"ended":true,"endEmitted":false,"reading":false,"sync":false,"needReadable":false,"emittedReadable":false,"readableListening":false,"resumeScheduled":false,"paused":true,"emitClose":true,"autoDestroy":false,"destroyed":false,"defaultEncoding":"utf8","awaitDrain":0,"readingMore":false,"decoder":null,"encoding":null},"readable":true,"_events":{},"_eventsCount":1,"_writableState":{"objectMode":false,"highWaterMark":16384,"finalCalled":false,"needDrain":false,"ending":true,"ended":true,"finished":true,"destroyed":false,"decodeStrings":true,"defaultEncoding":"utf8","length":0,"writing":false,"corked":0,"sync":false,"bufferProcessing":false,"writecb":null,"writelen":0,"bufferedRequest":null,"lastBufferedRequest":null,"pendingcb":0,"prefinished":true,"errorEmitted":false,"emitClose":true,"autoDestroy":false,"bufferedRequestCount":0,"corkedRequestsFree":{"next":null,"entry":null}},"writable":false,"allowHalfOpen":true,"_transformState":{"needTransform":false,"transforming":false,"writecb":null,"writechunk":null,"writeencoding":"buffer"}} bodyUsed false size 0 timeout 0 _raw [] _abort false
-
@אבי-203 אוקיי, יש שתי בעיות בקוד שלי:
א. השתמשתי ב-form-data
שמייצר פורמט multipart/form-data במקום application/x-www-form-urlencoded (העתקתי מפוסט בפורום של WIX... )
ב. בטעות שמתי את ה-body בתוך ה-headersגם, לא ידעתי שאפשר להשתמש בנוד בבקאנד של WIX. עכשיו אני יודע שאפשר. בעיקרון הקוד שהם הביאו היה אמור לעבוד בהעתקה ישירה.
משום מה זה עדיין לא עובד... וגם הוא לגמרי לא קריא...
(גם לא ידעתי ש-querystring
מובנה בנוד)הנה קוד מתוקן שניסיתי ב-WIX וזה עובד:
import qs from 'querystring'; import { fetch } from 'wix-fetch'; export async function test() { const body = qs.stringify({ user: 'hsad3esdad', password: 'PAS33SWORD', int_in: ` <?xml version="1.0"?> <ashrait> <request> <version>2000</version> <language>HEB</language> <dateTime/> <requestId/> <command>doDeal</command> <doDeal> <terminalNumber>8802346</terminalNumber> <cardNo>CGMPI</cardNo> <total>300</total> <id>123456789</id> <paymentPageData> <useId/> </paymentPageData> <transactionType>Debit</transactionType> <email>shaie@tuttnauerhd2323.com</email> <creditType>RegularCredit</creditType> <currency>ILS</currency> <transactionCode>Phone</transactionCode> <validation>TxnSetup</validation> <mid>11412</mid> <uniqueid>0.6457763203173892</uniqueid> <mpiValidation>Token</mpiValidation> <keepCD>1</keepCD> <successUrl/> <errorUrl/> <cancelUrl>https://google.com</cancelUrl> </doDeal> </request> </ashrait> `}); const res = await fetch('https://cguat2.creditguard.co.il/xpo/Relay', { method: 'post', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, body }); console.log(await res.text()); }
בהצלחה!!