我是Paypal新手。我到现在为止尝试的是
$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
'My Client ID',
'My ClientSecret'
)
);
$addr = new Address();
$addr->setLine1("3909 Witmer Road")
->setLine2("Niagara Falls")
->setCity("Niagara Falls")
->setState("NY")
->setPostalCode("14305")
->setCountryCode("US")
->setPhone("716-298-1822");
$$payer_info= new PayerInfo();
$$payer_info->setBillingAddress($addr);
$payer = new Payer();
$payer->setPaymentMethod("paypal")
->setPayerInfo($payer_info);
$itemList = new ItemList();
$itemList->setItems(array($item1))
//->setShippingAddress($shipToAddress1);
$details = new Details();
$details->setShipping(0)
->setTax(0)
->setSubtotal($formattedAmount);
$amount = new Amount();
$amount->setCurrency('USD');
$amount->setTotal($formattedAmount);
$amount->setDetails($details);
$transaction = new Transaction();
$transaction->setAmount($amount)
->setItemList($itemList)
->setDescription("Payment description")
->setInvoiceNumber(uniqid());
//$baseUrl = getBaseUrl();
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl("My return url")
->setCancelUrl("My cancel url");
$payment = new Payment();
$payment->setIntent("authorize")
->setPayer($payer)
->setRedirectUrls($redirectUrls)
->setTransactions(array($transaction));
$request = clone $payment;
try {
$payment->create($apiContext);
} catch (\PayPal\Exception\PayPalConnectionException $ex) {
echo "<pre>";
print_r(json_decode($ex->getData()));
exit(1);
}
$approvalUrl = $payment->getApprovalLink();
return $payment;
我希望用户在Paypal系统中选择Paypal或其他(ie.visa,mastercard)。一切似乎都很好。但问题是: -
a。如果用户选择其他支付网关,我不能使用我在$ addr中传递的地址的每个污染用户表单。
b。如果用户选择Paypal登录,请覆盖从我的网页传递的Paypal帐单邮寄地址。
我的问题是: -
1.我如何预先污染用户表格?
2.我不确定是否可以覆盖Paypal帐单地址。如果可能,我该如何实现?
3.如果不是,你能帮助我理解更好的解决方案吗?
提前致谢。