php mollie支付定期账单
我的代码是:php mollie支付定期账单,php,payment,recurring-billing,mollie,Php,Payment,Recurring Billing,Mollie,我的代码是: $customer = $mollie->customers->create([ "name" => $name, "email" => $email, ]); $customer->createSubscription([ "amount" => [ "currency" => 'USD', "value" =>
$customer = $mollie->customers->create([
"name" => $name,
"email" => $email,
]);
$customer->createSubscription([
"amount" => [
"currency" => 'USD',
"value" => 20.00,
],
"interval" => '2months',
"times" => 3,
"description" => $someDescription,
"webhookUrl" => $webhook,
"method" => NULL,
]);
$payment = $customer->createPayment([
"amount" => [
"currency" => 'USD',
"value" => 20.00,
],
"description" => $someDescription,
"redirectUrl" => $siteUrl,
"webhookUrl" => $webhook,
"metadata" => [
"order_id" => $orderId,
],
"sequenceType" => \Mollie\Api\Types\SequenceType::SEQUENCETYPE_FIRST,
]);
结果是:
致命错误:未捕获异常“Mollie\Api\Exceptions\ApiException”
执行API调用时出现消息“错误”(422:不可处理实体):否
为客户找到合适的授权书。字段:customerId
是我遗漏的内容吗???您遗漏了先前创建的客户的客户ID
$payment = $customer->createPayment([
"customerId" => $customer->id, /* see #3 in documentation */
"amount" => [
"currency" => 'USD',
"value" => 20.00,
],
"description" => $someDescription,
"redirectUrl" => $siteUrl,
"webhookUrl" => $webhook,
"metadata" => [
"order_id" => $orderId,
],
"sequenceType" => \Mollie\Api\Types\SequenceType::SEQUENCETYPE_FIRST,
]);
我找到了我自己问题的答案: 要为用户添加订阅,必须先添加付款,然后再添加订阅
$customer = $mollie->customers->create([
"name" => $fullName,
"email" => $email,
]);
$payment = $customer->createPayment([
"amount" => [
"currency" => $currency,
"value" => $amount,
],
"description" => $description,
"redirectUrl" => $siteUrl,
"webhookUrl" => $webhook,
"metadata" => [
"order_id" => $orderId,
],
"sequenceType" => \Mollie\Api\Types\SequenceType::SEQUENCETYPE_FIRST,
]);
$customer->createSubscription([
"amount" => [
"currency" => $currency,
"value" => $amount,
],
"times" => $recurringLimit,
"interval" => $interval,
"description" => $description,
"webhookUrl" => $webhook,
"method" => NULL,
]);
在创建订阅之前,您必须创建委托书
($customer->create委托书)
您尚未存储要创建此费用和订阅的客户ID,$customer->ID
应持有该客户ID。有关引用客户的信息,请参见上的#3。在$customer->createSubscription([])之后触发该错误;当我将customerId放入createSubscription()中时,我得到:致命错误:未捕获异常“Mollie\Api\Exceptions\ApiException”,消息是“执行Api调用时出错(422:不可处理实体):此Api调用不存在主体参数“customerId”。你是说“时代”吗?。字段:customerId。订阅需要在webhook中