1

在过去的 2 天里,我已经阅读并测试了如何将 paypal website pro 集成到我当前的网站。

我正在使用可下载的贝宝最新 SDK:https ://www.x.com/developers/paypal/documentation-tools/paypal-sdk-index

到目前为止,我已经设法添加了运输/抄送详细信息、项目详细信息、税务详细信息和其他所有内容。我唯一的问题是如何添加优惠券。我到处寻找一种方法来做到这一点,但我找不到它。

我正在尝试整合直接付款。和快速退房 - 现在我正在处理直接付款

这是到目前为止我得到的代码,其中大部分位于他们的示例文件中。

$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];

$address = new AddressType();
$address->Name = "$firstName $lastName";
$address->Street1 = $_POST['address1'];
$address->Street2 = $_POST['address2'];
$address->CityName = $_POST['city'];
$address->StateOrProvince = $_POST['state'];
$address->PostalCode = $_POST['zip'];
$address->Country = $_POST['country'];
$address->Phone = $_POST['phone'];

$shippingTotal = new BasicAmountType($currencyCode, 25);
$handlingTotal = new BasicAmountType($currencyCode, 0);
$insuranceTotal = new BasicAmountType($currencyCode, 0);

$paymentDetails = new PaymentDetailsType();
$itemTotalValue = 0;
$taxTotalValue = 0;

$itemTotalValue += 15 * 2; 
$taxTotalValue += 0 * 2;
$itemDetails = new PaymentDetailsItemType();
$itemDetails->Name = 'First Item';
$itemDetails->Amount = new BasicAmountType($currencyCode, 15);
$itemDetails->Quantity = 2;
$itemDetails->ItemCategory = 'Digital';
$itemDetails->Tax = new BasicAmountType($currencyCode, 0);  

$paymentDetails->PaymentDetailsItem[0] = $itemDetails;  
//}

$orderTotalValue = $shippingTotal->value + $handlingTotal->value +
$insuranceTotal->value +
$itemTotalValue + $taxTotalValue;

$paymentDetails->ShipToAddress = $address;
$paymentDetails->ItemTotal = new BasicAmountType($currencyCode, $itemTotalValue);
$paymentDetails->OrderTotal = new BasicAmountType($currencyCode, $orderTotalValue);
$paymentDetails->TaxTotal = new BasicAmountType($currencyCode, $taxTotalValue);
$paymentDetails->PaymentAction = $_REQUEST['paymentType'];

$paymentDetails->HandlingTotal = $handlingTotal;
$paymentDetails->InsuranceTotal = $insuranceTotal;
$paymentDetails->ShippingTotal = $shippingTotal;

if(isset($_REQUEST['notifyURL']))
{
$paymentDetails->NotifyURL = $_REQUEST['notifyURL'];
}

我已经挖掘了他们的课程并找到了一个课程名称:OfferCouponInfoType

这似乎做了我想要实现的目标,但是我不知道如何使用它。

4

0 回答 0