我正在嘗試使用 MangoPay 注冊信用卡。
在我的服務檔案中,我創建了一個公共函式來注冊卡,使用 package mangopay/php-sdk-v2。
// ApiUser.php
public function Registration($UserId)
{
$CardRegistration = new \MangoPay\CardRegistration();
$CardRegistration->UserId = $UserId;
$CardRegistration->Currency = "EUR";
$CardRegistration->CardType = "CB_VISA_MASTERCARD";
$Result = $this->mangoPayApi->CardRegistrations->Create($CardRegistration);
$this->registration = $Result;
return $Result;
}
其結果將是一個物件,位于三個主要鍵中AccessKey:PreRegistrationData和CardRegistrationURL。
{
[...]
"AccessKey": "1X0m87dmM2LiwFgxPLBJ",
"PreregistrationData": "YkgVxL1yNY4ZOfKtqEew_ZzBSGg0ie3ghohlFhb-37oidM_c0HMmR9H0WvKWb8pa2ddFLVXdicolcUIkv_kKEA",
"CardRegistrationURL": "https://homologation-webpayment.payline.com/webpayment/getToken",
[...]
}
在嘗試使用 PostMan 時,我只需將 URL 放在CardRegistrationURLand 中,在其中body添加:datawith the PreRegistrationData,accessKeyRefwith AccessKeyand cardNumber,cardExpirationDateand cardCvx(the Content-Typeis x-www-urlencoded)
單擊Send按鈕后,它的回應將是一個以 開頭的長字串data=。
有了這個字串,我終于可以更新CardRegistration物件并在 MangoPay 上為用戶提供信用卡。
問題是,在編碼時,我找不到一種方法來獲得CardRegistrationURL.
我嘗試POST使用該http-client包一段時間,但給出的回應是一個物件。我檢查了它是否存在于物件中,但事實并非如此。
我也試過檢查這個:https ://github.com/Mangopay/mangopay2-php-sdk/blob/master/demos/paymentDirect/payment.php并試圖模仿它,但沒有成功。
uj5u.com熱心網友回復:
警告:您不必在服務器端收集卡片詳細資訊,您必須創建這樣的 HTML 表單
<form action="CardRegistrationURL here">
// inputs for cardNumber, expiration date ...
// You can add an input to redirect your user after card registration, ex:
// <input name="returnUrl" value="https://youwebsite.com">
</form>
您的用戶將被重定向到 MangoPay 服務器,然后回傳您的網站。當用戶回傳您的網站時,使用請求資料更新卡注冊并執行相關操作。
檔案不是很清楚,請不要猶豫,詢問 MangoPay 支持。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/461390.html
