我们使用PayPal PHP SDK创建“定期付款资料”,但每个资料都缺少沙盒帐户中“历史记录”下的“买家信息”(姓名和电子邮件)。
我们如何在请求中添加买家的姓名和电子邮件地址?
$firstName = $_POST[ 'firstName' ];
$lastName = $_POST[ 'lastName' ];
$email = $_POST[ 'email' ];
$installment_amount = ...;
$shippingAddress = new AddressType();
$shippingAddress->Name = $firstName . ' ' . $lastName;
$shippingAddress->Street1 = $_POST[ 'address1' ];
$shippingAddress->Street2 = $_POST[ 'address2' ];
$shippingAddress->CityName = $_POST[ 'city' ];
$shippingAddress->StateOrProvince = $_POST[ 'state' ];
$shippingAddress->PostalCode = $_POST[ 'zip' ];
$shippingAddress->Country = $_POST[ 'country' ];
$shippingAddress->Phone = $_POST[ 'phone' ];
$RPProfileDetails = new RecurringPaymentsProfileDetailsType();
$RPProfileDetails->SubscriberName = $firstName . ' ' . $lastName;
$RPProfileDetails->BillingStartDate = date( DATE_ATOM );
$RPProfileDetails->SubscriberShippingAddress = $shippingAddress;
$activationDetails = new ActivationDetailsType();
$activationDetails->InitialAmount = new BasicAmountType( 'USD', $installment_amount );
$activationDetails->FailedInitialAmountAction = 'CancelOnFailure';
$paymentBillingPeriod = new BillingPeriodDetailsType();
$paymentBillingPeriod->BillingFrequency = 1;
$paymentBillingPeriod->BillingPeriod = 'Day';
$paymentBillingPeriod->TotalBillingCycles = 2;
$paymentBillingPeriod->Amount = new BasicAmountType( 'USD', $installment_amount );
$scheduleDetails = new ScheduleDetailsType();
$scheduleDetails->Description = ...;
$scheduleDetails->ActivationDetails = $activationDetails;
$scheduleDetails->PaymentPeriod = $paymentBillingPeriod;
$scheduleDetails->MaxFailedPayments = 3;
$scheduleDetails->AutoBillOutstandingAmount = 'AddToNextBilling';
$createRPProfileRequestDetail = new CreateRecurringPaymentsProfileRequestDetailsType();
$cardDetails = new CreditCardDetailsType();
$cardDetails->CreditCardNumber = $_POST[ 'creditCardNumber' ];
$cardDetails->CreditCardType = $_POST[ 'creditCardType' ];
$cardDetails->ExpMonth = $_POST[ 'expDateMonth' ];
$cardDetails->ExpYear = $_POST[ 'expDateYear' ];
$cardDetails->CVV2 = $_POST[ 'cvv2Number' ];
$createRPProfileRequestDetail->CreditCard = $cardDetails;
$createRPProfileRequestDetail->ScheduleDetails = $scheduleDetails;
$createRPProfileRequestDetail->RecurringPaymentsProfileDetails = $RPProfileDetails;
$createRPProfileRequest = new CreateRecurringPaymentsProfileRequestType();
$createRPProfileRequest->CreateRecurringPaymentsProfileRequestDetails = $createRPProfileRequestDetail;
$createRPProfileReq = new CreateRecurringPaymentsProfileReq();
$createRPProfileReq->CreateRecurringPaymentsProfileRequest = $createRPProfileRequest;
$paypalService = new PayPalAPIInterfaceServiceService( ... );
try {
$createRPProfileResponse = $paypalService->CreateRecurringPaymentsProfile( $createRPProfileReq );
} catch ( Exception $exception ) {
...
}
答案 0 :(得分:0)
只要您在“个人资料详细信息”中传递送货信息,就应该将其传递到Sandbox中的交易信息中。结算地址未存储在PayPal交易中
您的代码看起来应该正确传递信息。以防万一,从GitHub查看下面的示例代码。我没有粘贴所有代码。
Merchant SDK php Sample for Recurring Billing
$shippingAddress = new AddressType();
$shippingAddress->Name = $_REQUEST['shippingName'];
$shippingAddress->Street1 = $_REQUEST['shippingStreet1'];
$shippingAddress->Street2 = $_REQUEST['shippingStreet2'];
$shippingAddress->CityName = $_REQUEST['shippingCity'];
$shippingAddress->StateOrProvince = $_REQUEST['shippingState'];
$shippingAddress->PostalCode = $_REQUEST['shippingPostalCode'];
$shippingAddress->Country = $_REQUEST['shippingCountry'];
$shippingAddress->Phone = $_REQUEST['shippingPhone'];
$RPProfileDetails = new RecurringPaymentsProfileDetailsType();
$RPProfileDetails->SubscriberName = $_REQUEST['subscriberName'];
$RPProfileDetails->BillingStartDate = $_REQUEST['billingStartDate'];
$RPProfileDetails->SubscriberShippingAddress = $shippingAddress;
$activationDetails = new ActivationDetailsType();