Периодический возврат неверных данных для создания новой подписки

Приведенный ниже код — это то, что мы используем, чтобы попытаться создать новую подписку для пользователя. Если пользователь еще не существует, мы создаем его с помощью 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>[email protected]</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>

Мы действительно в тупике, и сообщение об ошибке, которое постоянно выдает, невероятно неконкретно и расплывчато. Любая помощь приветствуется.


person Tom Busby    schedule 28.01.2014    source источник


Ответы (1)


Возвращаемое сообщение об ошибке на самом деле исходит непосредственно от вашего платежного шлюза, а не от самого Recurly. Просмотр данных о транзакции должен предоставить немного больше информации о причине отклонения.

Если вы можете связаться с поддержкой Recurly и сообщить подробности транзакции, мы сможем более внимательно изучить и посмотреть, сможем ли мы вывести больше данных, чем шлюз обеспечивает!

person Rachel Quick    schedule 29.01.2014