我在 Sandbox 中遇到 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>