1 回答
TA贡献1834条经验 获得超8个赞
因此,通过阅读文档,您似乎需要执行以下操作:
<?php
use GlobalPayments\Api\ServicesConfig;
use GlobalPayments\Api\ServicesContainer;
use GlobalPayments\Api\Entities\Address;
use GlobalPayments\Api\PaymentMethods\CreditCardData;
use GlobalPayments\Api\Entities\Exceptions\ApiException;
public function heartlandPost()
{
$config = new ServicesConfig();
$config->secretApiKey = "skapi_cert_***";
$config->developerId = "000000";
$config->versionNumber = "0000";
$config->serviceUrl = "https://cert.api2.heartlandportico.com";
ServicesContainer::configure($config);
$card = new CreditCardData();
$card->token = $request->input('payment_token');
$address = new Address();
$address->postalCode = $request->input('postal_code');
try {
$response = $card->charge(10)
->withCurrency("USD")
->withAddress($address)
->execute();
} catch (ApiException $e) {
// handle error
}
// return your response to the client
}
您需要更新配置以匹配您自己的密钥和诸如此类的东西,而且我不确定您如何将金额/邮政编码传递到您的后端,因此请确保您也这样做。
- 1 回答
- 0 关注
- 111 浏览
添加回答
举报