0

下面的代码是我们用来尝试为用户创建新订阅的代码。如果用户不存在,我们createAccount在运行之前使用创建它们createSubscription

public function createAccount($recurlyId, $email, $firstName, $lastName)
{
    if ($this->getAccount($recurlyId) === null)
    {
        $account = new Recurly_Account($recurlyId);
        $account->email = $email;
        $account->first_name = $firstName;
        $account->last_name = $lastName;
        $account->create();
    }
}

public function createSubscription($recurlyId, $planCode, CardBillingInformation $billingInfo, $startDate = null)
{
    if (($account = $this->getAccount($recurlyId)) === null) throw new CHttpException(400, 'You are trying to create a subscription for an account that doesn\'t exist');

    $account->billing_info = new Recurly_BillingInfo();
    $account->billing_info->number = $billingInfo->number;
    $account->billing_info->year = (int) $billingInfo->year;
    $account->billing_info->month = (int) $billingInfo->month;
    $account->billing_info->address1 = $billingInfo->address1;
    $account->billing_info->city = $billingInfo->city;
    $account->billing_info->country = $billingInfo->country;
    $account->billing_info->zip = $billingInfo->zip;

    $subscription = new Recurly_Subscription();
    $subscription->plan_code = $planCode;
    $subscription->currency = 'GBP';
    $subscription->account = $account;
    if ($startDate !== null) $subscription->starts_at = $startDate;

    $subscription->create();
}

这是我们从 recurly 收到的回复(我已经更改了任何个人身份信息,但我们使用的帐户详细信息有效的详细信息:

<?xml version="1.0" encoding="UTF-8"?>
<errors>
    <transaction_error>
        <error_code>invalid_data</error_code>
        <error_category>hard</error_category>
        <merchant_message>The payment gateway declined the transaction due to invalid data. Please check the response details for more information.</merchant_message>
        <customer_message>The transaction was declined due to invalid data.</customer_message>
    </transaction_error>
    <error field="subscription.account.base" symbol="invalid_data">The transaction was declined due to invalid data.</error>
    <transaction href="https://SOMEACCOUNT.recurly.com/v2/transactions/254720b963dcb40226e8064229a1ce24" type="credit_card">
    <account href="https://SOMEACCOUNT.recurly.com/v2/accounts/3368d152-2a8b-11e3-a3de-22000a24db56"/>
    <subscription href="https://SOMEACCOUNT.recurly.com/v2/subscriptions/254720b91850041f76a17d42f0a66b54"/>
    <uuid>254720b963dcb40226e8064229a1ce24</uuid>
    <action>purchase</action>
    <amount_in_cents type="integer">1800</amount_in_cents>
    <tax_in_cents type="integer">300</tax_in_cents>
    <currency>GBP</currency>
    <status>declined</status>
    <payment_method>credit_card</payment_method>
    <reference nil="nil"/>
    <source>subscription</source>
    <recurring type="boolean">false</recurring>
    <test type="boolean">false</test>
    <voidable type="boolean">false</voidable>
    <refundable type="boolean">false</refundable>
    <transaction_error>
        <error_code>invalid_data</error_code>
        <error_category>hard</error_category>
        <merchant_message>The payment gateway declined the transaction due to invalid data. Please check the response details for more information.</merchant_message>
        <customer_message>The transaction was declined due to invalid data.</customer_message>
    </transaction_error>
    <cvv_result code="" nil="nil"/>
    <avs_result code="" nil="nil"/>
    <avs_result_street nil="nil"/>
    <avs_result_postal nil="nil"/>
    <created_at type="datetime">2014-01-28T10:11:57Z</created_at>
    <details>
        <account>
            <account_code>3368d152-2a8b-11e3-a3de-22000a24db56</account_code>
            <first_name>An</first_name>
            <last_name>Other</last_name>
            <company/>
            <email>a_user9@hotmail.com</email>
            <billing_info type="credit_card">
                <first_name>An</first_name>
                <last_name>Other</last_name>
                <address1>123 Fake St</address1>
                <address2 nil="nil"/>
                <city>Townsville</city>
                <state nil="nil"/>
                <zip>TV23 6EU</zip>
                <country>GB</country>
                <phone nil="nil"/>
                <vat_number/>
                <card_type>Visa</card_type>
                <year type="integer">2014</year>
                <month type="integer">9</month>
                <first_six>xxxxxx</first_six>
                <last_four>xxxx</last_four>
            </billing_info>
        </account>
    </details>
</transaction>
</errors>

我们真的很困惑,并且反复提供的错误消息非常不具体和模糊。任何帮助表示赞赏。

4

1 回答 1

2

返回的错误消息实际上是直接来自您的支付网关,而不是 Recurly 本身。查看交易数据应该可以提供更多关于拒绝原因的信息。

如果您可以联系Recurly Support并提供交易详细信息,我们可以仔细查看,看看我们是否可以推断出比网关提供的更多的数据!

于 2014-01-29T17:19:46.710 回答