简体   繁体   English

如何将Paypal自适应付款与Cake php 1.3版本集成在一起?

[英]How do I integrate paypal adaptive payment with cake php 1.3 version?

I have a application in Cakephp 1.3 where I need to integrate latest paypal adaptive payment system. 我在Cakephp 1.3中有一个应用程序,需要集成最新的Paypal自适应支付系统。 I get code sample from paypal web site for adaptive payment. 我从贝宝网站上获得了用于自适应支付的代码示例。 I get code here https://www.x.com/developers/paypal/products/adaptive-payments after login. 登录后,我在这里获得代码https://www.x.com/developers/paypal/products/adaptive-payments It provide me a rest API SDK where I get code for pay with credit card. 它为我提供了一个休息的API SDK,在这里我可以使用信用卡获取付款代码。

require __DIR__ . '/../bootstrap.php'; 
use PayPal\Api\Address; 
use PayPal\Api\Amount; 
use PayPal\Api\CreditCard; 
use PayPal\Api\Payer; 
use PayPal\Api\Payment; 
use PayPal\Api\FundingInstrument; 
use PayPal\Api\Transaction;

$addr = new Address(); 
$addr->setLine1("3909 Witmer Road"); 
$addr->setLine2("Niagara Falls"); 
$addr->setCity("Niagara Falls"); 
$addr->setState("NY"); 
$addr->setPostal_code("14305"); 
$addr->setCountry_code("US"); 
$addr->setPhone("716-298-1822");

$card = new CreditCard(); 
$card->setType("visa"); 
$card->setNumber("4417119669820331"); 
$card->setExpire_month("11"); 
$card->setExpire_year("2019"); 
$card->setCvv2("012"); 
$card->setFirst_name("Joe"); 
$card->setLast_name("Shopper"); 
$card->setBilling_address($addr);

$fi = new FundingInstrument(); 
$fi->setCredit_card($card);

$payer = new Payer(); 
    $payer->setPayment_method("credit_card");
$payer->setFunding_instruments(array($fi));

$amount = new Amount(); 
$amount->setCurrency("USD"); 
$amount->setTotal("1.00");

$transaction = new Transaction(); 
$transaction->setAmount($amount); 
$transaction->setDescription("This is the payment description.");

$payment = new Payment(); 
$payment->setIntent("sale"); 
$payment->setPayer($payer); 
$payment->setTransactions(array($transaction));

try { 
  $payment->create($apiContext); 
} 
catch (\PPConnectionException $ex) 
{ echo "Exception: " . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); 
exit(1); }

Is there any other easy way do implement adaptive payment with paypal in Cakephp? 还有其他简单的方法可以在Cakephp中使用Paypal实施自适应支付吗?

Is the code sample you provided from the REST SDK? 您是否从REST SDK提供了代码示例? You shouldn't be using that if you're trying to use Adaptive Payments. 如果您要使用自适应支付,则不应使用该功能。 Adaptive Payments doesn't have a direct credit card payment option and that is what the code sample you provided is trying to do. Adaptive Payments没有直接的信用卡付款选项,这就是您提供的代码示例正在尝试执行的操作。

Here is a direct link to the PHP SDK for Adaptive Payments: https://github.com/paypal/adaptivepayments-sdk-php 这是用于自适应支付的PHP SDK的直接链接: https : //github.com/paypal/adaptivepayments-sdk-php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM