交易后获取客户详细信息 [英] Get customer details after transaction

查看:143
本文介绍了交易后获取客户详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力在Paypal NVP和REST API之间做出选择.

I'm struggling to decide between Paypal NVP and REST APIs.

REST API似乎是更新和更好的,但是我找不到在交易发生后获取客户详细信息的方法.

The REST API seems to be newer and better but I can't find a way to get customer details after a transaction occured.

基本上,我想为定期付款设置一个计费计划,然后通过API获取客户详细信息,这样他们就不必通过我的网站输入这些信息了.

Basically I want to set up a billing plan for recurring payments and then get customer details via API so they do not have to enter them through my website.

Paypal Express结帐似乎是我应该在这里使用的

Paypal Express checkout seems to be what I should use here.

NVP API提供了 GetExpressCheckoutDetails 获取这些详细信息的方法.

The NVP API offers a GetExpressCheckoutDetails method to get these details.

我没有找到与REST API类似的东西.

I didn't find something similar for the REST API.

由于REST API似乎也要通过Express Checkout进行,因此应该有解决方案.

Since the REST API seems to go through Express Checkout as well there should be a solution.

激活帐单协议后如何获取客户详细信息?

How can I get customer details after activating the billing agreement?

推荐答案

一个月前,我遇到了同样的问题,阅读文档后,目前尚无办法使用REST API来完成此任务.如果有办法,则没有记录.

I ran into this same problem a month ago and after reading the docs, there's currently no way to accomplish this with the REST API. If there is a way, it's not documented.

我发现做到这一点的唯一方法是使用NVP API,也可能使用SOAP API. NVP API将为您提供所需的大多数字段,但是如果您存储了交易的自定义字段,它将仅为您提供3个自定义字段,而不是全部(怪异).

The only way I found to do this is with the NVP API and possibly the SOAP API. The NVP API will give you back most of the fields that you want but if you've stored custom fields for a transaction, it will only give you 3 of the custom fields but not all of them (weird).

我没有尝试过NVP方法 GetExpressCheckoutDetails ,但我使用了 GetTransactionDetails 方法.它将退还您的交易详细信息.它返回您必须解析的文本块.每个字段均经过URL编码,并以&"号分隔.这是PHP中的示例:

I haven't tried the NVP method GetExpressCheckoutDetails but I have used the GetTransactionDetails method. It will give you back the transaction details. It returns a text block that you must parse. Each field is URL encoded and separated by an ampersand. Here's an example in PHP:

<?php

// Get cURL resource
$ch = curl_init();

// Set url
curl_setopt($ch, CURLOPT_URL, 'https://api-3t.paypal.com/nvp/');

// Set method
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');

// Set options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// Set headers
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Content-Type: application/x-www-form-urlencoded; charset=utf-8",
    ]
);
// Create body
$body = [
    "VERSION" => "204.0",
    "METHOD" => "GetTransactionDetails",
    "USER" => "nvp_api_username_here",
    "PWD" => "nvp_api_password_here",
    "SIGNATURE" => "nvp_api_signature_here",
    "TRANSACTIONID" => "some_paypal_transaction_id_here",
];
$body = http_build_query($body);

// Set body
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

// Send the request and save response to $resp
$resp = curl_exec($ch);

if(!$resp) {
    die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
} else {
    parse_str($resp, $formated_response);
    print_r($formated_response);
}

// Close request to clear up some resources
curl_close($ch);

以下是格式化的返回正文:

Here's the formatted return body:

Array
(
    [RECEIVERBUSINESS] => paypal_account_owner_email_address_here@test.com
    [RECEIVEREMAIL] => paypal_account_owner_email_address_here@test.com
    [RECEIVERID] => 1111111111111
    [EMAIL] => buyers_email_address_here@test.com
    [PAYERID] => 55551
    [PAYERSTATUS] => verified
    [COUNTRYCODE] => US
    [BUSINESS] => buyers_business_name_here
    [ADDRESSOWNER] => PayPal
    [ADDRESSSTATUS] => None
    [SALESTAX] => 0.00
    [SHIPAMOUNT] => 0.00
    [SHIPHANDLEAMOUNT] => 0.00
    [SHIPDISCOUNT] => 0.00
    [INSURANCEAMOUNT] => 0.00
    [GIFTRECEIPT] => 0
    [TIMESTAMP] => 2016-08-02T17:04:58Z
    [CORRELATIONID] => 55552
    [ACK] => Success
    [VERSION] => 204.0
    [BUILD] => 22386173
    [FIRSTNAME] => Foo
    [LASTNAME] => Bar
    [TRANSACTIONID] => 55553
    [TRANSACTIONTYPE] => webaccept
    [PAYMENTTYPE] => instant
    [ORDERTIME] => 2016-08-01T20:49:28Z
    [AMT] => 1.00
    [TAXAMT] => 0.00
    [CURRENCYCODE] => USD
    [PAYMENTSTATUS] => Completed
    [PENDINGREASON] => None
    [REASONCODE] => None
    [SHIPPINGMETHOD] => Default
    [PROTECTIONELIGIBILITY] => Ineligible
    [PROTECTIONELIGIBILITYTYPE] => None
    [L_QTY0] => 0
    [L_TAXAMT0] => 0.00
    [L_SHIPPINGAMT0] => 0.00
    [L_HANDLINGAMT0] => 0.00
    [L_CURRENCYCODE0] => USD
    [L_OPTIONSNAME0] => first_custom_field_label_here
    [L_OPTIONSVALUE0] => first_custom_field_value_here
    [L_OPTIONSNAME1] => second_custom_field_label_here
    [L_OPTIONSVALUE1] => second_custom_field_value_here
    [L_OPTIONS1NAME0] => second_custom_field_label_here_duplicate
    [L_OPTIONS1VALUE0] => second_custom_field_value_here_duplicate
    [L_TAXABLE0] => false
    [L_TAXRATE0] => 0.0
    [L_AMT0] => 1.00
    [INSURANCEOPTIONSELECTED] => 0
    [SHIPPINGOPTIONISDEFAULT] => 0
)

警告:

仅在将自定义字段存储在PayPal交易中时适用.

This only applies if you're storing custom fields in a PayPal transaction.

PayPal的NVP API最多只能为一个事务返回3个自定义字段,即使您在一个事务中最多可以存储7个自定义字段也是如此.更疯狂的是,它返回的自定义字段之一是 second 自定义字段的副本.至少当我尝试从事务中检索自定义字段时就是这种情况.

PayPal's NVP API only returns up to 3 custom fields for a transaction, even though you can store up to 7 custom fields in a transaction. Even crazier, one of the custom fields it returns is a duplicate of the second custom field. At least that's the case when I try to retrieve a custom fields from a transaction.

这篇关于交易后获取客户详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆