我正在尝试为全球支付网关创建定期付款。但在错误之下-
所选网关不支持此事务类型。
$config = new ServicesConfig();
$config->merchantId = "merchantId";
$config->accountId = "accountId";
$config->sharedSecret = "sharedSecret";
$config->serviceUrl = "https://pay.sandbox.realexpayments.com/pay";
$config->hostedPaymentConfig = new HostedPaymentConfig();
$config->hostedPaymentConfig->version = HppVersion::VERSION_2;
if ($recurring){
$config->hostedPaymentConfig->cardStorageEnabled = "1";
}
$service = new HostedService(
$config
);
$hostedPaymentData = new HostedPaymentData();
$hostedPaymentData->offerToSaveCard = true;
$hostedPaymentData->customerExists = false;
echo $service->Authorize($amount)
->withCurrency($currency_code)
->withRecurringInfo(RecurringType::FIXED, RecurringSequence::FIRST)
->withOrderId($order_id)
->withHostedPaymentData($hostedPaymentData)
->serialize();
在服务器端,我从带有客户id和支付id的支付网关获得post响应。
$parsedResponse = $service->parseResponse(json_encode($_POST));
$responseValues = $parsedResponse->responseValues;
$schedule = createSchedule($responseValues);
function createSchedule($responseValues)
{
$schedule = new Schedule();
$customerKey = $responseValues['SAVED_PAYER_REF'];
$paymentMethodKey = $responseValues['SAVED_PMT_REF'];
$orderId = $responseValues['ORDER_ID'];
$amount = $responseValues['AMOUNT'];
$schedule->id = getIdentifier('CreditV');
$schedule->customerKey = $customerKey;
$schedule->paymentKey = $paymentMethodKey;
$schedule->amount = $amount;
$schedule->currency = 'EUR';
$schedule->startDate = date('mdY');
$schedule->paymentSchedule = PaymentSchedule::DYNAMIC;
$schedule->frequency = ScheduleFrequency::WEEKLY;
$schedule->numberOfPayments = 4;
$schedule->description = 'Test';
$schedule->poNumber = $orderId;
$schedule->reprocessingCount = 1;
$schedule->emailReceipt = 'Never';
$schedule->status = 'Active';
$response = $schedule->create();
return $response;
}
function getIdentifier($id)
{
$identifierBase = '%s-%s' . substr(str_shuffle('abcdefghijklmnopqrstuvwxyz'), 0, 10);
return sprintf($identifierBase, date('Ymd'), $id);
}