Paypal Plus 成功数据
Paypal Plus success data
我在 angular 项目中使用 Paypal Plus。一切正常。
如何确认支付成功?我必须将哪些数据保存在我的数据库中。总之我在等待哪些数据成功?
<div id="payments-container"></div>
export class PaypalComponent implements OnInit {
paypalConfig = {
env: 'sandbox',
client: {
sandbox: 'ATvgtyEZznsHf...',
production: '<insert production client id>'
},
style: {
layout: 'vertical',
label: 'pay',
size: 'responsive',
shape: 'rect',
color: 'gold'
},
commit: true,
payment: (data, actions) => {
return actions.payment.create({
payment: {
transactions: [{
amount: {
total: 10.5,
currency: "EUR",
}
}]
}
});
},
onAuthorize: (data, actions) => {
return actions.payment.execute().then((response) => {
console.log('response', response);
console.log('data', data);
console.log('actions', actions);
});
},
onCancel: (data, actions) => {
console.log('Canceled!');
}
};
ngOnInit() {
paypal.Button.render(this.paypalConfig, '#payments-container');
}
}
来自docs:
A successful response returns confirmation of the transaction, with the approved state and a transaction ID. See the complete list of response values in the Payments API Reference.
具体看一下response docs:
id string
The ID of the payment. Read only.
intent enum
The payment intent. Value is: sale. Makes an immediate
payment. authorize. Authorizes a payment for capture later. order.
Creates an order. Possible values: sale, authorize, order.
payer object
The source of the funds for this payment. Payment method
is PayPal Wallet payment or bank direct debit.
application_context object
Use the application context resource to customize payment flow
experience for your buyers.
transactions array (contains the transaction object)
An array of payment-related
transactions. A transaction defines what the payment is for and who
fulfills the payment. For update and execute payment calls, the
transactions object accepts the amount object only.
state enum
The state of the payment,
authorization, or order transaction. Value is:
created. The
transaction was successfully created.
approved. The customer approved
the transaction. The state changes from created to approved on
generation of the sale_id for sale transactions, authorization_id for
authorization transactions, or order_id for order transactions.
failed. The transaction request failed. Read only.
Possible values: created, approved, failed.
experience_profile_id string
The PayPal-generated ID for the
merchant's payment experience profile. For information, see create web
experience profile. note_to_payer string A free-form field that
clients can use to send a note to the payer. Maximum length: 165.
redirect_urls object
A set of redirect URLs that you provide for
PayPal-based payments.
failure_reason enum
The reason code for a
payment failure. Read only.
Possible values: UNABLE_TO_COMPLETE_TRANSACTION,
INVALID_PAYMENT_METHOD, PAYER_CANNOT_PAY, CANNOT_PAY_THIS_PAYEE,
REDIRECT_REQUIRED, PAYEE_FILTER_RESTRICTIONS.
create_time string
The date and time when the payment was created, in
Internet date and time format. Read only.
update_time string
The date and time when the payment was updated, in
Internet date and time format. Read only.
links array (contains the link_description object)
An array of request-related HATEOAS links. Read only.
您肯定会希望 state
成为 approved
。
根据您的审计需要,您可能希望保存任何或所有其他字段。 ID、意图、付款人、交易和至少 failure_reason 都可能值得考虑。
我在 angular 项目中使用 Paypal Plus。一切正常。
如何确认支付成功?我必须将哪些数据保存在我的数据库中。总之我在等待哪些数据成功?
<div id="payments-container"></div>
export class PaypalComponent implements OnInit {
paypalConfig = {
env: 'sandbox',
client: {
sandbox: 'ATvgtyEZznsHf...',
production: '<insert production client id>'
},
style: {
layout: 'vertical',
label: 'pay',
size: 'responsive',
shape: 'rect',
color: 'gold'
},
commit: true,
payment: (data, actions) => {
return actions.payment.create({
payment: {
transactions: [{
amount: {
total: 10.5,
currency: "EUR",
}
}]
}
});
},
onAuthorize: (data, actions) => {
return actions.payment.execute().then((response) => {
console.log('response', response);
console.log('data', data);
console.log('actions', actions);
});
},
onCancel: (data, actions) => {
console.log('Canceled!');
}
};
ngOnInit() {
paypal.Button.render(this.paypalConfig, '#payments-container');
}
}
来自docs:
A successful response returns confirmation of the transaction, with the approved state and a transaction ID. See the complete list of response values in the Payments API Reference.
具体看一下response docs:
id string
The ID of the payment. Read only.
intent enum
The payment intent. Value is: sale. Makes an immediate payment. authorize. Authorizes a payment for capture later. order. Creates an order. Possible values: sale, authorize, order.
payer object
The source of the funds for this payment. Payment method is PayPal Wallet payment or bank direct debit.
application_context object
Use the application context resource to customize payment flow experience for your buyers.
transactions array (contains the transaction object)
An array of payment-related transactions. A transaction defines what the payment is for and who fulfills the payment. For update and execute payment calls, the transactions object accepts the amount object only.
state enum
The state of the payment, authorization, or order transaction. Value is:
created. The transaction was successfully created.
approved. The customer approved the transaction. The state changes from created to approved on generation of the sale_id for sale transactions, authorization_id for authorization transactions, or order_id for order transactions.
failed. The transaction request failed. Read only.
Possible values: created, approved, failed.
experience_profile_id string
The PayPal-generated ID for the merchant's payment experience profile. For information, see create web experience profile. note_to_payer string A free-form field that clients can use to send a note to the payer. Maximum length: 165.
redirect_urls object
A set of redirect URLs that you provide for PayPal-based payments.
failure_reason enum
The reason code for a payment failure. Read only.
Possible values: UNABLE_TO_COMPLETE_TRANSACTION, INVALID_PAYMENT_METHOD, PAYER_CANNOT_PAY, CANNOT_PAY_THIS_PAYEE, REDIRECT_REQUIRED, PAYEE_FILTER_RESTRICTIONS.
create_time string
The date and time when the payment was created, in Internet date and time format. Read only.
update_time string
The date and time when the payment was updated, in Internet date and time format. Read only.
links array (contains the link_description object)
An array of request-related HATEOAS links. Read only.
您肯定会希望 state
成为 approved
。
根据您的审计需要,您可能希望保存任何或所有其他字段。 ID、意图、付款人、交易和至少 failure_reason 都可能值得考虑。