У меня проблемы с Suitetalk в Песочнице, когда любая попытка добавить или обновить запись клиента с помощью кредитной карты возвращает успех, но не создает карту в системе.
Попытка присоединить существующую картузапись в учетную запись также не работает.
НО Я не могу обновить существующую карту без проблем.
Любые указатели?
$id,
$ccNumber,
$ccExpireDate,
$ccName
) {
$issuer = substr($ccNumber, 0, 1);
$paymentMethod = 0;
switch ($issuer) {
case 3:
$paymentMethod = PAYMENT_AMEX;
break;
case 4:
$paymentMethod = PAYMENT_VISA;
break;
case 5:
$paymentMethod = PAYMENT_MASTERCARD;
break;
case 6:
$paymentMethod = PAYMENT_DISCOVER;
break;
default:
throw new Exception("Invalid Credit Card Number provided.");
}
$customer = new Customer();
$customer->internalId = $id;
$customer->CreditCardsList = new CustomerCreditCardsList();
$customer->CreditCardsList->creditCards = new CustomerCreditCards;
$customer->CreditCardsList->creditCards->ccNumber = $ccNumber;
$customer->CreditCardsList->creditCards->ccExpireDate = Carbon::create(
$ccExpireDate
)->toIso8601String();
$customer->CreditCardsList->creditCards->ccName = $ccName;
$customer->CreditCardsList->creditCards->validfrom = Carbon::now()
->subYear()
->toIso8601String();
$customer->CreditCardsList->creditCards->paymentMethod = new RecordRef();
$customer->CreditCardsList->creditCards->paymentMethod->internalId
= $paymentMethod;
$customer->CreditCardsList->creditCards->ccDefault = true;
$customer->CreditCardsList->replaceAll = true;
$paymentType = new SelectCustomFieldRef();
$paymentType->value = new ListOrRecordRef();
$paymentType->value->internalId = 5; // Direct Debit: 1, CC: 5
$paymentType->scriptId = 'custentity_kl_member_member_payment_type';
$customer->customFieldList = new CustomFieldList();
$customer->customFieldList->customField = array($paymentType);
$this->putData($id, "customer", $customer);
}
public function putData($id, string $type, $record)
{
$request = new UpdateRequest();
$request->baseRef = new RecordRef();
$request->baseRef->internalId = $id;
$request->baseRef->type = $type;
$request->record = $record;
$updateResponse = $this->service->update($request);
echo json_encode(
$updateResponse,
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
);
if (!$updateResponse->writeResponse->status->isSuccess) {
return false;
} else {
return true;
}
}
Код добавления работает в основном так же, за исключением того, что к нему присоединена вся запись клиента.
Это объект внутри записи, отправляемой в SOAP:
Array
(
[0] => NetSuite\Classes\UpdateRequest Object
(
[record] => NetSuite\Classes\Customer Object
(
[customFieldList] => NetSuite\Classes\CustomFieldList Object
(
[customField] => Array
(
[0] => NetSuite\Classes\SelectCustomFieldRef Object
(
[value] => NetSuite\Classes\ListOrRecordRef Object
(
[name] =>
[internalId] => 5
[externalId] =>
[typeId] =>
)
[internalId] =>
[scriptId] => custentity_kl_member_member_payment_type
)
)
)
[internalId] => 327516
[externalId] =>
[nullFieldList] =>
[CreditCardsList] => NetSuite\Classes\CustomerCreditCardsList Object
(
[creditCards] => NetSuite\Classes\CustomerCreditCards Object
(
[internalId] =>
[ccNumber] => 4012888888881881
[ccExpireDate] => 2019-12-09T00:00:00+00:00
[ccName] => Bill Gates
[paymentMethod] => NetSuite\Classes\RecordRef Object
(
[internalId] => 5
[externalId] =>
[type] =>
[name] =>
)
[cardState] =>
[stateFrom] =>
[debitcardIssueNo] =>
[ccMemo] =>
[validfrom] => 2018-04-03T07:01:58+00:00
[ccDefault] => 1
)
[replaceAll] => 1
)
)
[baseRef] => NetSuite\Classes\RecordRef Object
(
[internalId] => 327516
[externalId] =>
[type] => customer
[name] =>
)
)
)
И все же этосгенерированное SOAP:
<SOAP-ENV:Body>
<ns3:update>
<ns3:record internalId="327516" xsi:type="ns2:Customer">
<ns2:customFieldList>
<ns1:customField scriptId="custentity_kl_member_member_payment_type" xsi:type="ns1:SelectCustomFieldRef">
<ns1:value internalId="5" />
</ns1:customField>
</ns2:customFieldList>
</ns3:record>
</ns3:update>
</SOAP-ENV:Body>