paypal IPN and PDT 2

当支付模式为快速支付(按钮)时,IPN 和PDT都会起作用, 当以Rest Api方式创建支付时, PDT是无效的,它应该是针对网站的,IPN依然起作用。调用Rest Api 付款的步骤是这样的:

1. 注册paypal账号, 升级为高级或者企业账号;

2. 登录开发者中心后台,注册app;

3. 获取Client ID, Secret;

4. 设置ipn通知地址(profile里面设置);

5. 获取paypal SDK, 在sandbox环境测试, 支付返回的url是在调用代码里面设置的;

POST /v1/payments/payment

POST /v1/payments/payment/<Payment-Id>/execute

主要是这两个APi

6. 替换代码sandbox为正式url,上线。

需要注意的问题:

1.如果卖家退款, 资金会立刻结算,并向paypal支付一定的手续费,程序会收到ipn通知;

2.如果买家提出争议,争议类型是未经授权的交易时,资金会立刻冻结,程序会收到ipn通知;

3.如果买家提出争议,争议类型不是未经授权的交易时,资金会立刻冻结,程序不会收到ipn通知;

4. 买家和卖家的唯一交易号是完全不一致的;

5.买家和卖家的发票号(账单号)是一致的;

6.支付返回的url所在的程序,收到的数据不可信, 可以把一切本地的逻辑放在处理ipn的程序里面进行。ipn消息不是实时的,差不多秒级的延迟。

用户支付完成时,返回的url会收到如下请求数据:

‘success‘ => ‘true‘,

‘paymentId‘ => ‘PAY-1BV5911839643144YKSCUA7Q‘,

‘token‘ => ‘EC-8684120785130974D‘,

‘PayerID‘ => ‘JARYJK2TES6C6‘,

调用execute接口返回:

{
    "id": "PAY-1BV5911839643144YKSCUA7Q",
    "create_time": "2014-12-08T06:09:02Z",
    "update_time": "2014-12-08T06:10:51Z",
    "state": "approved",
    "intent": "sale",
    "payer": {
        "payment_method": "paypal",
        "payer_info": {
            "email": "[email protected]",
            "first_name": "Test",
            "last_name": "Buyer",
            "payer_id": "JARYJK2TES6C6",
            "shipping_address": {
                "line1": "NO 1 Nan Jin Road",
                "city": "Shanghai",
                "state": "Shanghai",
                "postal_code": "200000",
                "country_code": "CN",
                "recipient_name": "Buyer Test"
            }
        }
    },
    "transactions": [
        {
            "amount": {
                "total": "20.00",
                "currency": "USD",
                "details": {
                    "subtotal": "17.50",
                    "tax": "1.30",
                    "shipping": "1.20"
                }
            },
            "description": "Payment description",
            "item_list": {
                "items": [
                    {
                        "name": "Ground Coffee 40 oz",
                        "price": "7.50",
                        "currency": "USD",
                        "quantity": "1"
                    },
                    {
                        "name": "Granola bars",
                        "price": "2.00",
                        "currency": "USD",
                        "quantity": "5"
                    }
                ],
                "shipping_address": {
                    "recipient_name": "Buyer Test",
                    "line1": "NO 1 Nan Jin Road",
                    "city": "Shanghai",
                    "state": "Shanghai",
                    "postal_code": "200000",
                    "country_code": "CN"
                }
            },
            "related_resources": [
                {
                    "sale": {
                        "id": "74V52932AB811673C",
                        "create_time": "2014-12-08T06:09:02Z",
                        "update_time": "2014-12-08T06:10:51Z",
                        "amount": {
                            "total": "20.00",
                            "currency": "USD"
                        },
                        "payment_mode": "INSTANT_TRANSFER",
                        "state": "completed",
                        "protection_eligibility": "ELIGIBLE",
                        "protection_eligibility_type": "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE",
                        "parent_payment": "PAY-1BV5911839643144YKSCUA7Q",
                        "links": [
                            {
                                "href": "https://api.sandbox.paypal.com/v1/payments/sale/74V52932AB811673C",
                                "rel": "self",
                                "method": "GET"
                            },
                            {
                                "href": "https://api.sandbox.paypal.com/v1/payments/sale/74V52932AB811673C/refund",
                                "rel": "refund",
                                "method": "POST"
                            },
                            {
                                "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-1BV5911839643144YKSCUA7Q",
                                "rel": "parent_payment",
                                "method": "GET"
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "links": [
        {
            "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-1BV5911839643144YKSCUA7Q",
            "rel": "self",
            "method": "GET"
        }
    ]
}

同时服务器会收到ipn消息, 类似:

array (
  'act' => 'ipn',
  'mc_gross' => '20.00',
  'invoice' => '548531d624f59',
  'protection_eligibility' => 'Eligible',
  'address_status' => 'unconfirmed',
  'item_number1' => '',
  'tax' => '1.30',
  'item_number2' => '',
  'payer_id' => 'JARYJK2TES6C6',
  'address_street' => 'NO 1 Nan Jin Road',
  'payment_date' => '21:04:35 Dec 07, 2014 PST',
  'payment_status' => 'Completed',
  'charset' => 'gb2312',
  'address_zip' => '200000',
  'mc_shipping' => '1.20',
  'mc_handling' => '0.00',
  'first_name' => 'Test',
  'mc_fee' => '0.98',
  'address_country_code' => 'CN',
  'address_name' => 'Buyer Test',
  'notify_version' => '3.8',
  'custom' => '',
  'payer_status' => 'unverified',
  'address_country' => 'China',
  'num_cart_items' => '2',
  'mc_handling1' => '0.00',
  'mc_handling2' => '0.00',
  'address_city' => 'Shanghai',
  'verify_sign' => 'AomRS5l2W2xlt2An.GaSrAzpCl-NACIvh3Pz0HtrSBZzfcIeqDPGrXSk',
  'payer_email' => '[email protected]',
  'mc_shipping1' => '0.00',
  'mc_shipping2' => '0.00',
  'tax1' => '0.00',
  'tax2' => '0.00',
  'txn_id' => '5CS19517SJ894934R',
  'payment_type' => 'instant',
  'last_name' => 'Buyer',
  'address_state' => 'Shanghai',
  'item_name1' => 'Ground Coffee 40 oz',
  'receiver_email' => '[email protected]',
  'item_name2' => 'Granola bars',
  'payment_fee' => '0.98',
  'quantity1' => '1',
  'quantity2' => '5',
  'receiver_id' => '937CP9PSMDS2A',
  'txn_type' => 'cart',
  'mc_gross_1' => '7.50',
  'mc_currency' => 'USD',
  'mc_gross_2' => '10.00',
  'residence_country' => 'CN',
  'test_ipn' => '1',
  'transaction_subject' => '',
  'payment_gross' => '20.00',
  'ipn_track_id' => 'a9059421a1dd7',
)
2014-12-08 13:04:35

卖家退款收到的ipn:

array (
  'act' => 'ipn',
  'mc_gross' => '-55.90',
  'protection_eligibility' => 'Eligible',
  'payer_id' => 'JARYJK2TES6C6',
  'address_street' => 'NO 1 Nan Jin Road',
  'payment_date' => '18:17:29 Dec 07, 2014 PST',
  'payment_status' => 'Refunded',
  'charset' => 'gb2312',
  'address_zip' => '200000',
  'first_name' => 'Test',
  'mc_fee' => '-1.90',
  'address_country_code' => 'CN',
  'address_name' => 'Buyer Test',
  'notify_version' => '3.8',
  'reason_code' => 'refund',
  'custom' => '',
  'business' => '[email protected]',
  'address_country' => 'China',
  'address_city' => 'Shanghai',
  'verify_sign' => 'AIkKNboJiyuxWLOHUlzTd3lpqCSxA1j2G80g.Gf68usTx7dykHwVOx4g',
  'payer_email' => '[email protected]',
  'parent_txn_id' => '78V79646KB938951Y',
  'txn_id' => '03C86087BS569332H',
  'payment_type' => 'instant',
  'btn_id' => '3042078',
  'last_name' => 'Buyer',
  'address_state' => 'Shanghai',
  'receiver_email' => '[email protected]',
  'payment_fee' => '-1.90',
  'shipping_discount' => '0.00',
  'receiver_id' => '2XP27KEMUVN8A',
  'insurance_amount' => '0.00',
  'item_name' => 'sandbox_item111',
  'discount' => '0.00',
  'mc_currency' => 'USD',
  'item_number' => '',
  'residence_country' => 'CN',
  'test_ipn' => '1',
  'handling_amount' => '0.00',
  'shipping_method' => 'Default',
  'transaction_subject' => '',
  'payment_gross' => '-55.90',
  'shipping' => '10.00',
  'ipn_track_id' => '2d16876d72c70',
)
2014-12-08 10:17:27

资金冻结时候收到的ipn:

array (
  'act' => 'ipn',
  'mc_gross' => '-19.02',
  'invoice' => '548541570184f',
  'protection_eligibility' => 'Eligible',
  'item_number1' => '',
  'item_number2' => '',
  'payer_id' => 'JARYJK2TES6C6',
  'address_street' => 'NO 1 Nan Jin Road',
  'payment_date' => '22:23:36 Dec 07, 2014 PST',
  'payment_status' => 'Reversed',
  'charset' => 'gb2312',
  'address_zip' => '200000',
  'mc_shipping' => '1.20',
  'mc_handling' => '0.00',
  'first_name' => 'Test',
  'mc_fee' => '-0.98',
  'address_country_code' => 'CN',
  'address_name' => 'Buyer Test',
  'notify_version' => '3.8',
  'reason_code' => 'unauthorized_claim',
  'custom' => '',
  'address_country' => 'China',
  'mc_handling1' => '0.00',
  'mc_handling2' => '0.00',
  'address_city' => 'Shanghai',
  'verify_sign' => 'A.7n6Acd75CB8FdbeZyRGF.BoVPlArI2BzuxGNUFbCI-qvgcHJe4LgLp',
  'payer_email' => '[email protected]',
  'mc_shipping1' => '0.00',
  'mc_shipping2' => '0.00',
  'tax1' => '0.00',
  'tax2' => '0.00',
  'parent_txn_id' => '74V52932AB811673C',
  'memo' => '14.13',
  'txn_id' => '2Y80904055783821A',
  'payment_type' => 'instant',
  'last_name' => 'Buyer',
  'address_state' => 'Shanghai',
  'item_name1' => 'Ground Coffee 40 oz',
  'receiver_email' => '[email protected]',
  'item_name2' => 'Granola bars',
  'payment_fee' => '-0.98',
  'quantity1' => '1',
  'quantity2' => '5',
  'receiver_id' => '937CP9PSMDS2A',
  'mc_gross_1' => '7.50',
  'mc_currency' => 'USD',
  'mc_gross_2' => '10.00',
  'residence_country' => 'CN',
  'test_ipn' => '1',
  'transaction_subject' => '',
  'payment_gross' => '-19.02',
  'ipn_track_id' => '5df4cee26f6d3',
)
2014-12-08 14:23:33
时间: 2024-11-13 03:25:10

paypal IPN and PDT 2的相关文章

解决Opencart paypal ipn 返回 INVALID

系统出现个别订单状态是Pending,但Paypal已经收到钱,按照下面步骤逐一排查 1.打开Paypal的设置,修改Debug Mode为Enabled 2.后台System > Tools >Error Logs,查看日志,发现出现问题的订单返回PP_STANDARD :: IPN RESPONSE: INVALID 3.通过在Paypal官网查询,发现以下文字: To ensure that symbols and special characters in the date or ot

paypal IPN 接口小结

1.sandbox下payment status为pending,pending reason为payment review 解决办法: 这个原因是买方或卖房开启了付款审核,将付款审核关闭,payment status就会变成Completed 在http://developer.paypal.com/ 登陆 在Dashboard页面的左侧菜单中点击Sandbox的Accounts 编辑买方或者卖方的个人设置Profile 选择settings,把payment review的设置改成off 2

PayPal的Restful-API方式退款、WEB支付、回调

记录之用. 1.移动App中想要接入PayPal支付,婉转的采用PayPal的一种最简便的方式(网页版).    <h1>PayPal支付</h1>       <div class="orderinfo">   <ul> <li><label>商品名称:</label>流量支付</li> <li><label>订单编号:</label>{$out_tra

网站建立(杂)

1 服务器 转:http://zhidao.baidu.com/link?url=1rHCzSsc-TBQoIT64fx-qhtE8zGQ0eL01VopRoD00I6wdyizMRLiya0gEBIbXIdB_tGbfHBhUk-I5tAUBnoYJ_1igmTW_2miy5-UWrFpOSW(1)ApacheApache是世界使用排名第一的Web服务器软件.它可以运行在几乎所有广泛使用的计算机平台上.Apache源于NCSAhttpd服务器,经过多次修改,成为世界上最流行的Web服务器软件之

国内外主要的PHP开源CMS系统分析

国内PHP开源CMS内容管理系统从程序框架,模版加载到程序功能上都有很大的进步,大部分都采用了自定义模块,自定义模型的方式,同时提供各个CMS都提供不同的特色功能,CMS内容管理系统一直影响着互联网的发展.  CMS介绍CMS是Content Management System的缩写,意为“内容管理系统”.CMS具有许多基于模板的优秀设计,可以加快网站开发的速度和减少开发的成本.CMS的功能并不只限于文本处理,它也可以处理图片.Flash动画.声像流.图像甚至电子邮件档案.CMS其实是一个很广泛

国内外php主流开源cms、商城、点评、SNS、DIGG、RSS、分类信息、Wiki汇总

网上商城源代码 源码之家- www.mycodes.net 酷网动力 www.aspcool.com 源码联盟 www.aspsun.com 源码天下 www.pccode.net http://blog.chinaunix.net/space.php?uid=20787846&do=blog&id=1842324      2009年快完了,今年国内PHP开源CMS内容管理系统从程序框架,模版加载到程序功能上都有很大的进步,大部分都采用了自定义模块,自定义模型的方式,同时提供各个CMS都

paypal 的IPN通知调用出错

一直报错: 当本地curl需要访问https时,出现SSL certificate: unable to get local issuer certificate错误信息 解决办法: 到http://curl.haxx.se/ca/cacert.pem下载pem文件,并将文件拷贝到D:\phpStudy\PHPTutorial\cacert.pem 在php.ini增加curl.cainfo = "D:\phpStudy\PHPTutorial\cacert.pem" 原文地址:htt

java实现网站paypal支付功能并且异步修改订单的状态

java实现网站paypal支付功能并且异步修改订单的状态:步骤如下 第一步:去paypal的官网https://www.paypal.com注册一个个人账号,在创建沙箱测试账号时需要用到 第二步:paypal提供了模拟的测试环境,我们需要在https://www.sandbox.paypal.com/去创建一个虚拟卖家账号和买家账号 (必须用第一步注册的真实账号才能登录进去,沙箱账号是登录不进去的) 第三步:登录成功后创建卖家.买家账号,如果不知道在哪创建账号可以直接点击这个链接https:/

paypal接口对接注意事项

在paypal对接过程中,会存在return_url和notify两种 分别用pdt和ipn实现 但是对于paypal,大家请注意,真实环境和沙盒测试环境的区别 你可以到www.paypal.com注册一个账号,然后在developer.paypal.com下面登陆,会发现生成了一个测试的商家账号和一个测试的买家账号,这两个账号是准备着方便你进行对接调试的. 但是大家不要忘了,要想测试通过,还得在www.sandbox.paypal.com用商家测试账号登陆(记住一定要是商家测试账号,不是买家测