如何通过Suitetalk添加CustomerCreditCardsList/CustomerCreditCards
How to add CustomerCreditCardsList/CustomerCreditCards through Suitetalk
我在使用 Sandbox 中的 Suitetalk 时遇到问题,任何使用信用卡添加或更新客户记录的尝试都成功 returns,但没有在系统中创建卡。
尝试将现有的卡记录附加到帐户也不起作用。
但是我可以更新现有的卡没问题。
有什么指点吗?
$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>
这是我用来更新客户 ID:434 并添加新信用卡记录的 XML 正文请求。
<update xsi:type='platformMsgs:UpdateRequest'>
<record xsi:type='listRel:Customer' internalId='434'>
<creditCardsList replaceAll='false' xsi:type='listRel:CustomerCreditCardsList'>
<creditCards xsi:type='listRel:CustomerCreditCards'>
<ccNumber xsi:type='xsd:string'>****************</ccNumber>
<ccExpireDate xsi:type='xsd:dateTime'>2021-04-03T05:54:29.245Z</ccExpireDate>
<paymentMethod xsi:type='platformCore:RecordRef' internalId='5'/>
</creditCards>
</creditCardsList>
</record>
</update>
问题是 $customer->CreditCardsList
应该是 $customer->creditCardsList
我显然是个白痴。
我在使用 Sandbox 中的 Suitetalk 时遇到问题,任何使用信用卡添加或更新客户记录的尝试都成功 returns,但没有在系统中创建卡。
尝试将现有的卡记录附加到帐户也不起作用。
但是我可以更新现有的卡没问题。
有什么指点吗?
$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>
这是我用来更新客户 ID:434 并添加新信用卡记录的 XML 正文请求。
<update xsi:type='platformMsgs:UpdateRequest'>
<record xsi:type='listRel:Customer' internalId='434'>
<creditCardsList replaceAll='false' xsi:type='listRel:CustomerCreditCardsList'>
<creditCards xsi:type='listRel:CustomerCreditCards'>
<ccNumber xsi:type='xsd:string'>****************</ccNumber>
<ccExpireDate xsi:type='xsd:dateTime'>2021-04-03T05:54:29.245Z</ccExpireDate>
<paymentMethod xsi:type='platformCore:RecordRef' internalId='5'/>
</creditCards>
</creditCardsList>
</record>
</update>
问题是 $customer->CreditCardsList
应该是 $customer->creditCardsList
我显然是个白痴。